summaryrefslogtreecommitdiff
path: root/test/dnd-test.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2008-09-10 23:56:49 +0000
committerMatthias Melcher <fltk@matthiasm.com>2008-09-10 23:56:49 +0000
commitb6bde2e4569aa617c8a6af64947c688c624ed7f8 (patch)
tree010d15843eb7d4faf7cd1b0cd44d5b9c00462a83 /test/dnd-test.cxx
parentdfb50e85292687561927610e689eb5ab30d0ba26 (diff)
Merging the UTF8 patch, consisting of O'ksi'd s original 1.1.6 patch and additions by Ian. PLEASE BE AWARE that the patch in its current incarnation is a regression in many aspects and further work is required before we can announce Unicode support.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6212 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/dnd-test.cxx')
-rw-r--r--test/dnd-test.cxx75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/dnd-test.cxx b/test/dnd-test.cxx
new file mode 100644
index 000000000..f19873300
--- /dev/null
+++ b/test/dnd-test.cxx
@@ -0,0 +1,75 @@
+/* Drag and Drop test demo. */
+#include <stdio.h>
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Box.H>
+
+static Fl_Window *win_a;
+static Fl_Window *win_b;
+
+class Sender : public Fl_Box {
+public:
+ Sender(int x,int y,int w,int h) : Fl_Box(x,y,w,h) { }
+
+ int handle(int event) {
+ int ret = Fl_Box::handle(event);
+ switch ( event ) {
+ case FL_PUSH:
+ Fl::copy("message",7,0);
+ Fl::dnd();
+ return(1);
+ }
+ return(ret);
+ }
+};
+
+class Receiver : public Fl_Box {
+public:
+ Receiver(int x,int y,int w,int h) : Fl_Box(x,y,w,h) { }
+
+ int handle(int event) {
+ int ret = Fl_Box::handle(event);
+ switch ( event ) {
+ case FL_DND_ENTER:
+ case FL_DND_DRAG:
+ case FL_DND_RELEASE:
+ return(1);
+ case FL_PASTE:
+ label(Fl::event_text());
+ fprintf(stderr, "PASTE: %s\n", Fl::event_text());
+ fflush(stderr);
+ return(1);
+ }
+ return(ret);
+ }
+};
+//
+// Demonstrate DND (drag+drop) from red sender to green receiver
+//
+
+static Sender *Tx;
+static Receiver *Rx;
+
+int main(int argc, char **argv) {
+ win_a = new Fl_Window(40, 40, 200,100);
+ win_a->begin();
+ Tx = new Sender(5,5,90,90);
+ Tx->box(FL_UP_BOX);
+ Tx->label("Drag from here");
+ Tx->align(FL_ALIGN_WRAP);
+ Tx->color(FL_RED);
+ win_a->end();
+ win_a->show(argc, argv);
+
+ win_b = new Fl_Window (350, 40, 200,100,"Receiver");
+ win_b->begin();
+ Rx = new Receiver(105,5,90,90);
+ Rx->box(FL_FLAT_BOX);
+ Rx->label("to here");
+ Rx->color(FL_GREEN);
+ win_b->end();
+ win_b->show();
+
+ return Fl::run();
+}
+/* End of File */