diff --git a/CHANGES b/CHANGES index 2d411c0c3..c3db138c2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,12 @@ CHANGES IN FLTK 1.1.0 + - Added new Fl::dnd_text_ops() methods to enable/disable + drag-and-drop text operations. + - Fl_Input now supports clicking inside a selection to + set the new text position when drag-and-drop is + enabled. + - Added support of X resources for scheme, dnd_text_ops, + and visible_focus... - Fixed some case problems in includes for the MacOS X code. - Fl_Widget::handle() returned 1 for FL_ENTER and diff --git a/FL/Fl.H b/FL/Fl.H index 51146a871..dfbf51eee 100644 --- a/FL/Fl.H +++ b/FL/Fl.H @@ -1,5 +1,5 @@ // -// "$Id: Fl.H,v 1.8.2.11.2.14 2002/03/07 19:22:55 spitzak Exp $" +// "$Id: Fl.H,v 1.8.2.11.2.15 2002/04/13 22:17:45 easysw Exp $" // // Main header file for the Fast Light Tool Kit (FLTK). // @@ -64,6 +64,7 @@ public: // should be private! static FL_EXPORT Fl_Window* grab_; static FL_EXPORT int compose_state; static FL_EXPORT int visible_focus_; + static FL_EXPORT int dnd_text_ops_; static void damage(int x) {damage_ = x;} static FL_EXPORT void (*idle)(); @@ -237,6 +238,10 @@ public: static void visible_focus(int v) { visible_focus_ = v; } static int visible_focus() { return visible_focus_; } + // Drag-n-drop text operation methods... + static void dnd_text_ops(int v) { dnd_text_ops_ = v; } + static int dnd_text_ops() { return dnd_text_ops_; } + // Multithreading support: static FL_EXPORT void lock(); static FL_EXPORT void unlock(); @@ -247,5 +252,5 @@ public: #endif // !Fl_H // -// End of "$Id: Fl.H,v 1.8.2.11.2.14 2002/03/07 19:22:55 spitzak Exp $". +// End of "$Id: Fl.H,v 1.8.2.11.2.15 2002/04/13 22:17:45 easysw Exp $". // diff --git a/documentation/Fl.html b/documentation/Fl.html index 118204ced..3cefeda3f 100644 --- a/documentation/Fl.html +++ b/documentation/Fl.html @@ -50,6 +50,7 @@ state information and global methods for the current application.

  • default_atclose
  • display
  • dnd
  • +
  • dnd_text_ops
  • error
  • event
  • event_alt
  • @@ -417,9 +418,18 @@ and does nothing useful under WIN32.

    int dnd();

    -

    Initiate a Drag And Drop operation. The clipboard should be filled -with relevant data before calling this method. FLTK will then initiate -the system wide drag'n'drop handling. Dropped data will be marked as text. +

    Initiate a Drag And Drop operation. The clipboard should be +filled with relevant data before calling this method. FLTK will +then initiate the system wide drag and drop handling. Dropped data +will be marked as text. + +

    void dnd_text_ops(int d);
    +int dnd_text_ops();

    + +

    Gets or sets whether drag and drop text operations are +supported. This specifically affects whether selected text can +be dragged from text fields or dragged within a text field as a +cut/paste shortcut.

    void (*error)(const char*, ...);

    diff --git a/documentation/osissues.html b/documentation/osissues.html index 6d23c7c03..29217d06d 100644 --- a/documentation/osissues.html +++ b/documentation/osissues.html @@ -366,6 +366,45 @@ window->icon((char *)p); +

    X Resources

    + +

    When the Fl_Window::show(argc, +argv) method is called, FLTK looks for the following X +resources: + +

    + +

    Resources associated with the first window's Fl_Window::xclass() +string are queried first, or if no class has been specified then +the class "fltk" is used (e.g. fltk.background). If no +match is found, a global search is done (e.g. +*background). +

    The Windows (WIN32) Interface

    The Windows interface provides access to the WIN32 GDI diff --git a/src/Fl.cxx b/src/Fl.cxx index 860582473..b64d81ff5 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.24.2.41.2.25 2002/04/10 18:51:22 easysw Exp $" +// "$Id: Fl.cxx,v 1.24.2.41.2.26 2002/04/13 22:17:46 easysw Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -54,7 +54,8 @@ int Fl::damage_, Fl::e_keysym; char *Fl::e_text = (char *)""; int Fl::e_length; -int Fl::visible_focus_ = 1; +int Fl::visible_focus_ = 1, + Fl::dnd_text_ops_ = 1; // @@ -889,5 +890,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl.cxx,v 1.24.2.41.2.25 2002/04/10 18:51:22 easysw Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.41.2.26 2002/04/13 22:17:46 easysw Exp $". // diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx index d59555787..edd79a2c4 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.8 2002/04/11 11:52:41 easysw Exp $" +// "$Id: Fl_Input.cxx,v 1.10.2.15.2.9 2002/04/13 22:17:46 easysw Exp $" // // Input widget for the Fast Light Tool Kit (FLTK). // @@ -36,7 +36,6 @@ #include "flstring.h" #include -#define DND_OUT 1 void Fl_Input::draw() { if (input_type() == FL_HIDDEN_INPUT) return; @@ -290,8 +289,7 @@ int Fl_Input::handle(int event) { } else return handle_key(); case FL_PUSH: -#if DND_OUT - { + if (Fl::dnd_text_ops()) { int oldpos = position(), oldmark = mark(); Fl_Boxtype b = box(); Fl_Input_::handle_mouse( @@ -302,13 +300,13 @@ int Fl_Input::handle(int event) { if (Fl::focus()==this && !Fl::event_state(FL_SHIFT) && input_type()!=FL_SECRET_INPUT && (newpos >= mark() && newpos < position() || newpos >= position() && newpos < mark())) { - // user clicked int the selection, may be trying to drag + // user clicked in 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); @@ -316,17 +314,17 @@ int Fl_Input::handle(int event) { 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(0); Fl::dnd(); - return 1; + if (Fl::dnd_text_ops()) { + 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(0); Fl::dnd(); + return 1; + } } -#endif break; case FL_RELEASE: @@ -336,6 +334,10 @@ int Fl_Input::handle(int event) { } else if (!Fl::event_is_click()) { // copy drag-selected text to the clipboard. copy(0); + } else if (Fl::event_is_click() && drag_start >= 0) { + // user clicked in the field and wants to reset the cursor position... + position(drag_start, drag_start); + drag_start = -1; } return 1; @@ -393,5 +395,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.8 2002/04/11 11:52:41 easysw Exp $". +// End of "$Id: Fl_Input.cxx,v 1.10.2.15.2.9 2002/04/13 22:17:46 easysw Exp $". // diff --git a/src/Fl_arg.cxx b/src/Fl_arg.cxx index 97e9900a6..b0bb3ecd3 100644 --- a/src/Fl_arg.cxx +++ b/src/Fl_arg.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_arg.cxx,v 1.5.2.8.2.8 2002/04/11 11:52:42 easysw Exp $" +// "$Id: Fl_arg.cxx,v 1.5.2.8.2.9 2002/04/13 22:17:46 easysw Exp $" // // Optional argument initialization code for the Fast Light Tool Kit (FLTK). // @@ -91,6 +91,14 @@ int Fl::arg(int argc, char **argv, int &i) { Fl::visible_focus(0); i++; return 1; + } else if (match(s, "dnd")) { + Fl::dnd_text_ops(1); + i++; + return 1; + } else if (match(s, "nodnd", 3)) { + Fl::dnd_text_ops(0); + i++; + return 1; } const char *v = argv[i+1]; @@ -153,7 +161,29 @@ int Fl::args(int argc, char** argv, int& i, int (*cb)(int,char**,int&)) { // show a main window, use any parsed arguments void Fl_Window::show(int argc, char **argv) { if (!argc) {show(); return;} - if (!arg_called) Fl::args(argc,argv); + if (!arg_called) { +#if !defined(WIN32) && !defined(__APPLE__) + // Get defaults for drag-n-drop and focus... + const char *key = 0, *val; + + fl_open_display(); + + if (Fl::first_window()) key = Fl::first_window()->xclass(); + if (!key) key = "fltk"; + + val = XGetDefault(fl_display, key, "dndTextOps"); + if (val) Fl::dnd_text_ops(strcasecmp(val, "true") == 0 || + strcasecmp(val, "on") == 0 || + strcasecmp(val, "yes") == 0); + + val = XGetDefault(fl_display, key, "visibleFocus"); + if (val) Fl::visible_focus(strcasecmp(val, "true") == 0 || + strcasecmp(val, "on") == 0 || + strcasecmp(val, "yes") == 0); +#endif // !WIN32 && !__APPLE__ + + Fl::args(argc,argv); + } // set colors first, so background_pixel is correct: static char beenhere; @@ -200,7 +230,7 @@ void Fl_Window::show(int argc, char **argv) { XChangeProperty(fl_display, fl_xid(this), XA_WM_COMMAND, XA_STRING, 8, 0, (unsigned char *)buffer, p-buffer-1); delete[] buffer; -#endif +#endif // !WIN32 && !__APPLE__ } // Calls useful for simple demo programs, with automatic help message: @@ -364,5 +394,5 @@ int XParseGeometry(const char* string, int* x, int* y, #endif // ifdef WIN32 // -// End of "$Id: Fl_arg.cxx,v 1.5.2.8.2.8 2002/04/11 11:52:42 easysw Exp $". +// End of "$Id: Fl_arg.cxx,v 1.5.2.8.2.9 2002/04/13 22:17:46 easysw Exp $". // diff --git a/src/Fl_get_system_colors.cxx b/src/Fl_get_system_colors.cxx index 8f216af88..7a4176ddd 100644 --- a/src/Fl_get_system_colors.cxx +++ b/src/Fl_get_system_colors.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.7 2002/04/11 10:46:19 easysw Exp $" +// "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.8 2002/04/13 22:17:46 easysw Exp $" // // System color support for the Fast Light Tool Kit (FLTK). // @@ -163,7 +163,7 @@ static void getsyscolor(const char *key1, const char* key2, const char *arg, const char *defarg, void (*func)(uchar,uchar,uchar)) { if (!arg) { - arg = XGetDefault (fl_display, key1, key2); + arg = XGetDefault(fl_display, key1, key2); if (!arg) arg = defarg; } XColor x; @@ -210,7 +210,18 @@ Fl_Image *Fl::scheme_bg_ = (Fl_Image *)0; static Fl_Pixmap tile(tile_xpm); int Fl::scheme(const char *s) { - if (!s) s = getenv("FLTK_SCHEME"); + if (!s) { + if ((s = getenv("FLTK_SCHEME")) == NULL) { +#if !defined(WIN32) && !defined(__APPLE__) + const char* key = 0; + if (Fl::first_window()) key = Fl::first_window()->xclass(); + if (!key) key = "fltk"; + fl_open_display(); + s = XGetDefault(fl_display, key, "scheme"); +#endif // !WIN32 && !__APPLE__ + } + } + if (s) { if (!strcasecmp(s, "none") || !*s) s = 0; else s = strdup(s); @@ -305,5 +316,5 @@ int Fl::reload_scheme() { // -// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.7 2002/04/11 10:46:19 easysw Exp $". +// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.8 2002/04/13 22:17:46 easysw Exp $". //