00001 #include <WApplication>
00002 #include <WEnvironment>
00003 #include <WContainerWidget>
00004 #include <WImage>
00005
00006 #include "Character.h"
00007
00008 using namespace Wt;
00009
00014
00020 WImage *createDragImage(const char *url, const char *smallurl,
00021 const char *mimeType,
00022 WContainerWidget *p)
00023 {
00024 WImage *result = new WImage(url, p);
00025 WImage *dragImage = new WImage(smallurl, p);
00026
00027
00028
00029
00030
00031 result->setDraggable(mimeType, dragImage, true);
00032
00033 return result;
00034 }
00035
00036 WApplication *createApplication(const WEnvironment& env)
00037 {
00038 WApplication *app = new WApplication(env);
00039 app->setTitle(L"Drag & drop");
00040 new WText("<h1>Wt Drag & drop example.</h1>", app->root());
00041
00042 new WText("<p>Help these people with their decision by dragging one of "
00043 "the pills.</p>", app->root());
00044
00045 if (!env.javaScript()) {
00046 new WText("<i>This examples requires that javascript support is "
00047 "enabled.</i>", app->root());
00048 }
00049
00050 WContainerWidget *pills = new WContainerWidget(app->root());
00051 pills->setContentAlignment(WWidget::AlignCenter);
00052
00053 createDragImage("icons/blue-pill.jpg",
00054 "icons/blue-pill-small.png",
00055 "blue-pill", pills);
00056 createDragImage("icons/red-pill.jpg",
00057 "icons/red-pill-small.png",
00058 "red-pill", pills);
00059
00060 WContainerWidget *dropSites = new WContainerWidget(app->root());
00061
00062 new Character(L"Neo", dropSites);
00063 new Character(L"Morpheus", dropSites);
00064 new Character(L"Trinity", dropSites);
00065
00066 app->useStyleSheet("dragdrop.css");
00067
00068 return app;
00069 }
00070
00071 int main(int argc, char **argv)
00072 {
00073 return WRun(argc, argv, &createApplication);
00074 }
00075