Wt examples  3.3.0
Classes | Functions
Drag and Drop example

Classes

class  Character
 A Matrix character that takes red and/or blue pills. More...
 

Functions

WImagecreateDragImage (const char *url, const char *smallurl, const char *mimeType, WContainerWidget *p)
 Create an image which can be dragged. More...
 
 DragExample::DragExample (Wt::WContainerWidget *parent)
 

Detailed Description

Function Documentation

WImage* createDragImage ( const char *  url,
const char *  smallurl,
const char *  mimeType,
WContainerWidget p 
)

Create an image which can be dragged.

The image to be displayed when dragging is given by smallurl, and configured with the given mime type

Definition at line 19 of file DragExample.C.

22 {
23  WImage *result = new WImage(url, p);
24  WImage *dragImage = new WImage(smallurl, p);
25 
26  /*
27  * Set the image to be draggable, showing the other image (dragImage)
28  * to be used as the widget that is visually dragged.
29  */
30  result->setDraggable(mimeType, dragImage, true);
31 
32  return result;
33 }
DragExample::DragExample ( Wt::WContainerWidget parent)

Definition at line 35 of file DragExample.C.

36  :
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 
}

Generated on Fri May 31 2013 for the C++ Web Toolkit (Wt) by doxygen 1.8.3.1