Wt examples
3.3.2
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
koen
project
wt
public-git
wt
examples
dragdrop
DragExample.C
Go to the documentation of this file.
1
#include "
DragExample.h
"
2
#include "
Character.h
"
3
#include <Wt/WEnvironment>
4
#include <Wt/WImage>
5
#include <Wt/WApplication>
6
7
using namespace
Wt;
8
13
19
WImage
*
createDragImage
(
const
char
*url,
const
char
*smallurl,
20
const
char
*mimeType,
21
WContainerWidget
*p)
22
{
23
WImage
*result =
new
WImage
(url, p);
24
WImage
*dragImage =
new
WImage
(smallurl, p);
25
dragImage->
setMargin
(-15,
Left
|
Top
);
26
27
/*
28
* Set the image to be draggable, showing the other image (dragImage)
29
* to be used as the widget that is visually dragged.
30
*/
31
result->setDraggable(mimeType, dragImage,
true
);
32
33
return
result;
34
}
35
36
DragExample::DragExample
(
WContainerWidget
*parent):
37
WContainerWidget
(parent)
38
{
39
new
WText
(
"<p>Help these people with their decision by dragging one of "
40
"the pills.</p>"
,
this
);
41
42
if
(!wApp->environment().javaScript()) {
43
new
WText
(
"<i>This examples requires that javascript support is "
44
"enabled.</i>"
,
this
);
45
}
46
47
WContainerWidget
*pills =
new
WContainerWidget
(
this
);
48
pills->setContentAlignment(
AlignCenter
);
49
50
createDragImage
(
"icons/blue-pill.jpg"
,
51
"icons/blue-pill-small.png"
,
52
"blue-pill"
, pills);
53
createDragImage
(
"icons/red-pill.jpg"
,
54
"icons/red-pill-small.png"
,
55
"red-pill"
, pills);
56
57
WContainerWidget
*dropSites =
new
WContainerWidget
(
this
);
58
59
new
Character
(
"Neo"
, dropSites);
60
new
Character
(
"Morpheus"
, dropSites);
61
new
Character
(
"Trinity"
, dropSites);
62
63
}
64
Generated on Wed Mar 12 2014 for
the C++ Web Toolkit (Wt)
by
1.8.4