Add Fl::dnd_text_ops() methods.

Fl_Input now conditionally supports DND out via run-time option.

Fl_Input now clears selection if you click inside the selection when
DND is turned on.

Added support for scheme, dndTextOps, and visibleFocus resources under
X11.

Documented all X resources supported under X11...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2078 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-04-13 22:17:46 +00:00
parent 7f0c218c1c
commit dc355ebb54
8 changed files with 138 additions and 33 deletions

View File

@ -1,5 +1,12 @@
CHANGES IN FLTK 1.1.0 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 - Fixed some case problems in includes for the MacOS X
code. code.
- Fl_Widget::handle() returned 1 for FL_ENTER and - Fl_Widget::handle() returned 1 for FL_ENTER and

View File

@ -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). // 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 Fl_Window* grab_;
static FL_EXPORT int compose_state; static FL_EXPORT int compose_state;
static FL_EXPORT int visible_focus_; static FL_EXPORT int visible_focus_;
static FL_EXPORT int dnd_text_ops_;
static void damage(int x) {damage_ = x;} static void damage(int x) {damage_ = x;}
static FL_EXPORT void (*idle)(); static FL_EXPORT void (*idle)();
@ -237,6 +238,10 @@ public:
static void visible_focus(int v) { visible_focus_ = v; } static void visible_focus(int v) { visible_focus_ = v; }
static int visible_focus() { return visible_focus_; } 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: // Multithreading support:
static FL_EXPORT void lock(); static FL_EXPORT void lock();
static FL_EXPORT void unlock(); static FL_EXPORT void unlock();
@ -247,5 +252,5 @@ public:
#endif // !Fl_H #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 $".
// //

View File

@ -50,6 +50,7 @@ state information and global methods for the current application.</P>
<LI><A HREF="#Fl.default_atclose">default_atclose</A></LI> <LI><A HREF="#Fl.default_atclose">default_atclose</A></LI>
<LI><A HREF="#Fl.display">display</A></LI> <LI><A HREF="#Fl.display">display</A></LI>
<LI><A HREF="#Fl.dnd">dnd</A></LI> <LI><A HREF="#Fl.dnd">dnd</A></LI>
<LI><A HREF="#Fl.dnd_text_ops">dnd_text_ops</A></LI>
<LI><A HREF="#Fl.error">error</A></LI> <LI><A HREF="#Fl.error">error</A></LI>
<LI><A HREF="#Fl.event">event</A></LI> <LI><A HREF="#Fl.event">event</A></LI>
<LI><A HREF="#Fl.event_alt">event_alt</A></LI> <LI><A HREF="#Fl.event_alt">event_alt</A></LI>
@ -417,9 +418,18 @@ and does nothing useful under WIN32.
<H4><A NAME="Fl.dnd">int dnd();</A></H4> <H4><A NAME="Fl.dnd">int dnd();</A></H4>
<P>Initiate a Drag And Drop operation. The clipboard should be filled <P>Initiate a Drag And Drop operation. The clipboard should be
with relevant data before calling this method. FLTK will then initiate filled with relevant data before calling this method. FLTK will
the system wide drag'n'drop handling. Dropped data will be marked as <i>text</i>. then initiate the system wide drag and drop handling. Dropped data
will be marked as <i>text</i>.
<H4><A NAME="Fl.dnd_text_ops">void dnd_text_ops(int d);<BR>
int dnd_text_ops();</A></H4>
<P>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.
<H4><A NAME="Fl.error">void (*error)(const char*, ...);</A></H4> <H4><A NAME="Fl.error">void (*error)(const char*, ...);</A></H4>

View File

@ -366,6 +366,45 @@ window-&gt;icon((char *)p);
</TR> </TR>
</TABLE></CENTER> </TABLE></CENTER>
<H3>X Resources</H3>
<P>When the <A
HREF="Fl_Window.html#Fl_Window.show"><TT>Fl_Window::show(argc,
argv)</TT></A> method is called, FLTK looks for the following X
resources:
<UL>
<LI><TT>background</TT> - The default background color
for widgets (color).
<LI><TT>dndTextOps</TT> - The default setting for
drag and drop text operations (boolean).
<LI><TT>foreground</TT> - The default foreground (label)
color for widgets (color).
<LI><TT>scheme</TT> - The default scheme to use
(string).
<LI><TT>selectBackground</TT> - The default selection
color for menus, etc. (color).
<LI><TT>Text.background</TT> - The default background
color for text fields (color).
<LI><TT>visibleFocus</TT> - The default setting for
visible keyboard focus on non-text widgets (boolean).
</UL>
<P>Resources associated with the first window's <A
HREF="Fl_Window.html#Fl_Window.xclass"><TT>Fl_Window::xclass()</TT></A>
string are queried first, or if no class has been specified then
the class "fltk" is used (e.g. <TT>fltk.background</TT>). If no
match is found, a global search is done (e.g.
<TT>*background</TT>).
<H2>The Windows (WIN32) Interface</H2> <H2>The Windows (WIN32) Interface</H2>
<P>The Windows interface provides access to the WIN32 GDI <P>The Windows interface provides access to the WIN32 GDI

View File

@ -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). // Main event handling code for the Fast Light Tool Kit (FLTK).
// //
@ -54,7 +54,8 @@ int Fl::damage_,
Fl::e_keysym; Fl::e_keysym;
char *Fl::e_text = (char *)""; char *Fl::e_text = (char *)"";
int Fl::e_length; 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 $".
// //

View File

@ -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). // Input widget for the Fast Light Tool Kit (FLTK).
// //
@ -36,7 +36,6 @@
#include "flstring.h" #include "flstring.h"
#include <stdio.h> #include <stdio.h>
#define DND_OUT 1
void Fl_Input::draw() { void Fl_Input::draw() {
if (input_type() == FL_HIDDEN_INPUT) return; if (input_type() == FL_HIDDEN_INPUT) return;
@ -290,8 +289,7 @@ int Fl_Input::handle(int event) {
} else return handle_key(); } else return handle_key();
case FL_PUSH: case FL_PUSH:
#if DND_OUT if (Fl::dnd_text_ops()) {
{
int oldpos = position(), oldmark = mark(); int oldpos = position(), oldmark = mark();
Fl_Boxtype b = box(); Fl_Boxtype b = box();
Fl_Input_::handle_mouse( 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 && if (Fl::focus()==this && !Fl::event_state(FL_SHIFT) && input_type()!=FL_SECRET_INPUT &&
(newpos >= mark() && newpos < position() || (newpos >= mark() && newpos < position() ||
newpos >= position() && newpos < mark())) { 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; drag_start = newpos;
return 1; return 1;
} }
drag_start = -1; drag_start = -1;
} }
#endif
if (Fl::focus() != this) { if (Fl::focus() != this) {
Fl::focus(this); Fl::focus(this);
handle(FL_FOCUS); handle(FL_FOCUS);
@ -316,17 +314,17 @@ int Fl_Input::handle(int event) {
break; break;
case FL_DRAG: case FL_DRAG:
#if DND_OUT if (Fl::dnd_text_ops()) {
if (drag_start >= 0) { if (drag_start >= 0) {
if (Fl::event_is_click()) return 1; // debounce the mouse if (Fl::event_is_click()) return 1; // debounce the mouse
// save the position because sometimes we don't get DND_ENTER: // save the position because sometimes we don't get DND_ENTER:
dnd_save_position = position(); dnd_save_position = position();
dnd_save_mark = mark(); dnd_save_mark = mark();
// drag the data: // drag the data:
copy(0); Fl::dnd(); copy(0); Fl::dnd();
return 1; return 1;
}
} }
#endif
break; break;
case FL_RELEASE: case FL_RELEASE:
@ -336,6 +334,10 @@ int Fl_Input::handle(int event) {
} else if (!Fl::event_is_click()) { } else if (!Fl::event_is_click()) {
// copy drag-selected text to the clipboard. // copy drag-selected text to the clipboard.
copy(0); 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; 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 $".
// //

View File

@ -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). // 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); Fl::visible_focus(0);
i++; i++;
return 1; 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]; 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 // show a main window, use any parsed arguments
void Fl_Window::show(int argc, char **argv) { void Fl_Window::show(int argc, char **argv) {
if (!argc) {show(); return;} 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: // set colors first, so background_pixel is correct:
static char beenhere; 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, XChangeProperty(fl_display, fl_xid(this), XA_WM_COMMAND, XA_STRING, 8, 0,
(unsigned char *)buffer, p-buffer-1); (unsigned char *)buffer, p-buffer-1);
delete[] buffer; delete[] buffer;
#endif #endif // !WIN32 && !__APPLE__
} }
// Calls useful for simple demo programs, with automatic help message: // 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 #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 $".
// //

View File

@ -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). // 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)) getsyscolor(const char *key1, const char* key2, const char *arg, const char *defarg, void (*func)(uchar,uchar,uchar))
{ {
if (!arg) { if (!arg) {
arg = XGetDefault (fl_display, key1, key2); arg = XGetDefault(fl_display, key1, key2);
if (!arg) arg = defarg; if (!arg) arg = defarg;
} }
XColor x; XColor x;
@ -210,7 +210,18 @@ Fl_Image *Fl::scheme_bg_ = (Fl_Image *)0;
static Fl_Pixmap tile(tile_xpm); static Fl_Pixmap tile(tile_xpm);
int Fl::scheme(const char *s) { 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 (s) {
if (!strcasecmp(s, "none") || !*s) s = 0; if (!strcasecmp(s, "none") || !*s) s = 0;
else s = strdup(s); 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 $".
// //