Wt examples  3.3.5
/usr/src/RPM/BUILD/wt-3.3.5-rc2/examples/dragdrop/DragExample.C
Go to the documentation of this file.
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   dragImage->setMargin(-15, Left | Top);
00026 
00027   /*
00028    * Set the image to be draggable, showing the other image (dragImage)
00029    * to be used as the widget that is visually dragged.
00030    */
00031   result->setDraggable(mimeType, dragImage, true);
00032 
00033   return result;
00034 }
00035 
00036 DragExample::DragExample(WContainerWidget *parent):
00037   WContainerWidget(parent)
00038 {
00039   new WText("<p>Help these people with their decision by dragging one of "
00040             "the pills.</p>", this);
00041 
00042   if (!wApp->environment().javaScript()) {
00043     new WText("<i>This examples requires that javascript support is "
00044               "enabled.</i>", this);
00045   }
00046 
00047   WContainerWidget *pills = new WContainerWidget(this);
00048   pills->setContentAlignment(AlignCenter);
00049 
00050   createDragImage("icons/blue-pill.jpg",
00051                   "icons/blue-pill-small.png",
00052                   "blue-pill", pills);
00053   createDragImage("icons/red-pill.jpg",
00054                   "icons/red-pill-small.png",
00055                   "red-pill", pills);
00056 
00057   WContainerWidget *dropSites = new WContainerWidget(this);
00058 
00059   new Character("Neo", dropSites);
00060   new Character("Morpheus", dropSites);
00061   new Character("Trinity", dropSites);
00062 
00063 }
00064 

Generated on Tue Mar 22 2016 for the C++ Web Toolkit (Wt) by doxygen 1.7.6.1