Wt examples
3.2.3
|
00001 #include "DragExample.h" 00002 #include "Character.h" 00003 #include <Wt/WEnvironment> 00004 #include <Wt/WImage> 00005 #include <Wt/WApplication> 00006 00007 using namespace Wt; 00008 00013 00019 WImage *createDragImage(const char *url, const char *smallurl, 00020 const char *mimeType, 00021 WContainerWidget *p) 00022 { 00023 WImage *result = new WImage(url, p); 00024 WImage *dragImage = new WImage(smallurl, p); 00025 00026 /* 00027 * Set the image to be draggable, showing the other image (dragImage) 00028 * to be used as the widget that is visually dragged. 00029 */ 00030 result->setDraggable(mimeType, dragImage, true); 00031 00032 return result; 00033 } 00034 00035 DragExample::DragExample(WContainerWidget *parent): 00036 WContainerWidget(parent) 00037 { 00038 new WText("<p>Help these people with their decision by dragging one of " 00039 "the pills.</p>", this); 00040 00041 if (!wApp->environment().javaScript()) { 00042 new WText("<i>This examples requires that javascript support is " 00043 "enabled.</i>", this); 00044 } 00045 00046 WContainerWidget *pills = new WContainerWidget(this); 00047 pills->setContentAlignment(AlignCenter); 00048 00049 createDragImage("icons/blue-pill.jpg", 00050 "icons/blue-pill-small.png", 00051 "blue-pill", pills); 00052 createDragImage("icons/red-pill.jpg", 00053 "icons/red-pill-small.png", 00054 "red-pill", pills); 00055 00056 WContainerWidget *dropSites = new WContainerWidget(this); 00057 00058 new Character("Neo", dropSites); 00059 new Character("Morpheus", dropSites); 00060 new Character("Trinity", dropSites); 00061 00062 } 00063