Wt examples  3.3.0
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,
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 }
34 
36  WContainerWidget(parent)
37 {
38  new WText("<p>Help these people with their decision by dragging one of "
39  "the pills.</p>", this);
40 
41  if (!wApp->environment().javaScript()) {
42  new WText("<i>This examples requires that javascript support is "
43  "enabled.</i>", this);
44  }
45 
46  WContainerWidget *pills = new WContainerWidget(this);
47  pills->setContentAlignment(AlignCenter);
48 
49  createDragImage("icons/blue-pill.jpg",
50  "icons/blue-pill-small.png",
51  "blue-pill", pills);
52  createDragImage("icons/red-pill.jpg",
53  "icons/red-pill-small.png",
54  "red-pill", pills);
55 
56  WContainerWidget *dropSites = new WContainerWidget(this);
57 
58  new Character("Neo", dropSites);
59  new Character("Morpheus", dropSites);
60  new Character("Trinity", dropSites);
61 
62 }
63 

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