summaryrefslogtreecommitdiff
path: root/src/Fl_Input.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2002-02-24 17:52:18 +0000
committerMatthias Melcher <fltk@matthiasm.com>2002-02-24 17:52:18 +0000
commit4603756ed1284dfc9d71a556976f4f5b898abd24 (patch)
tree4a6305d9017b0dc0c34ae97b3ed44f3266a1c1be /src/Fl_Input.cxx
parent0372675ee12e54acd993f6d25a9489c1373caf75 (diff)
- added Win32 native drag'n'drop code
- added dnd support for Fl_Group (not tested with X!) - added dnd support for Fl_Input (not tested with X!) - no Mac implementation yet! Go ahead: drag text or a file from the explorer into a text widget! Tadaa! git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1971 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Input.cxx')
-rw-r--r--src/Fl_Input.cxx84
1 files changed, 81 insertions, 3 deletions
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx
index b7a322ec8..e5a57f3ef 100644
--- a/src/Fl_Input.cxx
+++ b/src/Fl_Input.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input.cxx,v 1.10.2.15.2.5 2002/01/01 15:11:30 easysw Exp $"
+// "$Id: Fl_Input.cxx,v 1.10.2.15.2.6 2002/02/24 17:52:17 matthiaswm Exp $"
//
// Input widget for the Fast Light Tool Kit (FLTK).
//
@@ -34,6 +34,8 @@
#include <FL/fl_draw.H>
#include <string.h>
+#define DND_OUT 1
+
void Fl_Input::draw() {
if (type() == FL_HIDDEN_INPUT) return;
Fl_Boxtype b = box();
@@ -211,7 +213,8 @@ int Fl_Input::handle_key() {
}
int Fl_Input::handle(int event) {
-
+ static int dnd_save_position, dnd_save_mark, drag_start = -1, newpos;
+ static Fl_Widget *dnd_save_focus;
switch (event) {
case FL_FOCUS:
switch (Fl::event_key()) {
@@ -248,12 +251,45 @@ int Fl_Input::handle(int event) {
} else return handle_key();
case FL_PUSH:
+#if DND_OUT
+ {
+ int oldpos = position(), oldmark = mark();
+ Fl_Boxtype b = box();
+ Fl_Input_::handle_mouse(
+ x()+Fl::box_dx(b)+3, y()+Fl::box_dy(b),
+ w()-Fl::box_dw(b)-6, h()-Fl::box_dh(b), 0);
+ newpos = position();
+ position( oldpos, oldmark );
+ if (Fl::focus()==this && !Fl::event_state(FL_SHIFT) && type()!=FL_SECRET_INPUT &&
+ (newpos >= mark() && newpos < position() ||
+ newpos >= position() && newpos < mark())) {
+ // user clicked int the selection, may be trying to drag
+ drag_start = newpos;
+ return 1;
+ }
+ drag_start = -1;
+ }
+#endif
if (Fl::focus() != this) {
Fl::focus(this);
handle(FL_FOCUS);
}
break;
+ case FL_DRAG:
+#if DND_OUT
+ if (drag_start >= 0) {
+ if (Fl::event_is_click()) return 1; // debounce the mouse
+ // save the position because sometimes we don't get DND_ENTER:
+ dnd_save_position = position();
+ dnd_save_mark = mark();
+ // drag the data:
+ copy(); Fl::dnd();
+ return 1;
+ }
+#endif
+ break;
+
case FL_RELEASE:
if (Fl::event_button() == 2) {
Fl::event_is_click(0); // stop double click from picking a word
@@ -264,6 +300,48 @@ int Fl_Input::handle(int event) {
}
return 1;
+ case FL_DND_ENTER:
+ Fl::belowmouse(this); // send the leave events first
+ dnd_save_position = position();
+ dnd_save_mark = mark();
+ dnd_save_focus = Fl::focus();
+ if (dnd_save_focus != this) {
+ Fl::focus(this);
+ handle(FL_FOCUS);
+ }
+ // fall through:
+ case FL_DND_DRAG:
+ //int p = mouse_position(X, Y, W, H);
+#if DND_OUT_XXXX
+ if (Fl::focus()==this && (p>=dnd_save_position && p<=dnd_save_mark ||
+ p>=dnd_save_mark && p<=dnd_save_position)) {
+ position(dnd_save_position, dnd_save_mark);
+ return 0;
+ }
+#endif
+ {
+ Fl_Boxtype b = box();
+ Fl_Input_::handle_mouse(
+ x()+Fl::box_dx(b)+3, y()+Fl::box_dy(b),
+ w()-Fl::box_dw(b)-6, h()-Fl::box_dh(b), 0);
+ }
+ return 1;
+
+ case FL_DND_LEAVE:
+ position(dnd_save_position, dnd_save_mark);
+#if DND_OUT_XXXX
+ if (!focused())
+#endif
+ if (dnd_save_focus != this) {
+ Fl::focus(dnd_save_focus);
+ handle(FL_UNFOCUS);
+ }
+ return 1;
+
+ case FL_DND_RELEASE:
+ take_focus();
+ return 1;
+
}
Fl_Boxtype b = box();
return Fl_Input_::handletext(event,
@@ -276,5 +354,5 @@ Fl_Input::Fl_Input(int x, int y, int w, int h, const char *l)
}
//
-// End of "$Id: Fl_Input.cxx,v 1.10.2.15.2.5 2002/01/01 15:11:30 easysw Exp $".
+// End of "$Id: Fl_Input.cxx,v 1.10.2.15.2.6 2002/02/24 17:52:17 matthiaswm Exp $".
//