mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 22:04:26 +08:00
Added an 'Options' dialog (replacing test/preferences) that can be used to set system wide or user real options like Visible Focus.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8018 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
CHANGES IN FLTK 1.3.0
|
CHANGES IN FLTK 1.3.0
|
||||||
|
|
||||||
|
- Added general Options dialog (STR #2471)
|
||||||
- Fixed Compiling with mingw-w64 (STR #2308).
|
- Fixed Compiling with mingw-w64 (STR #2308).
|
||||||
- Fixed crashes when detecting illegal utf 8 sequences
|
- Fixed crashes when detecting illegal utf 8 sequences
|
||||||
in Fl_Text_* widgets (STR #2348)
|
in Fl_Text_* widgets (STR #2348)
|
||||||
|
|||||||
@@ -137,8 +137,6 @@ public: // should be private!
|
|||||||
static Fl_Window* modal_;
|
static Fl_Window* modal_;
|
||||||
static Fl_Window* grab_;
|
static Fl_Window* grab_;
|
||||||
static int compose_state;
|
static int compose_state;
|
||||||
static int visible_focus_;
|
|
||||||
static int dnd_text_ops_;
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
If true then flush() will do something.
|
If true then flush() will do something.
|
||||||
@@ -147,13 +145,34 @@ public: // should be private!
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/// If set, the arrow keys can change focus from a text widget to another
|
/// When switched on, moving the text cursor beyond the start or end of
|
||||||
/// widget. If clear, only Tab and BackTab can.
|
/// a text in a text widget will change focus to the next text widgt.
|
||||||
|
/// When switched off, the cursor will stop at the end of the text.
|
||||||
|
/// Pressing Tab or Ctrl-Tab will advance the keyboard focus.
|
||||||
OPTION_ARROW_FOCUS = 0,
|
OPTION_ARROW_FOCUS = 0,
|
||||||
/// If set, calls to fl_file_chooser will open the native file chooser.
|
// When switched on, FLTK will use the file chooser dialog that comes
|
||||||
/// If clear, the FLTK file chooser will open instead.
|
// with your operating system whenever possible. When switched off, FLTK
|
||||||
/// \todo Fl::OPTION_NATIVE_FILECHOOSER not yet supported
|
// will present its own file chooser.
|
||||||
OPTION_NATIVE_FILECHOOSER,
|
// \todo implement me
|
||||||
|
// OPTION_NATIVE_FILECHOOSER,
|
||||||
|
// When Filechooser Preview is enabled, the FLTK or native file chooser
|
||||||
|
// will show a preview of a selected file (if possible) before the user
|
||||||
|
// decides to choose the file.
|
||||||
|
// \todo implement me
|
||||||
|
//OPTION_FILECHOOSER_PREVIEW,
|
||||||
|
/// If visible focus is switched on, FLTK will draw a dotted rectangle
|
||||||
|
/// inside the widget that will receive the next keystroke. If switched
|
||||||
|
/// off, no such indicator will be drawn and keyboard navigation
|
||||||
|
/// is disabled.
|
||||||
|
OPTION_VISIBLE_FOCUS,
|
||||||
|
/// If text drag-and-drop is enabled, the user can select and drag text
|
||||||
|
/// from any text widget. If disabled, no dragging is possible, however
|
||||||
|
/// dropping text from other applications still works.
|
||||||
|
OPTION_DND_TEXT,
|
||||||
|
/// If tooltips are enabled, hovering the mouse over a widget with a
|
||||||
|
/// tooltip text will open a little tootip window until the mouse leaves
|
||||||
|
/// the widget. If disabled, no tooltip is shown.
|
||||||
|
OPTION_SHOW_TOOLTIPS,
|
||||||
// don't change this, leave it always as the last element
|
// don't change this, leave it always as the last element
|
||||||
OPTION_LAST
|
OPTION_LAST
|
||||||
} Fl_Option;
|
} Fl_Option;
|
||||||
@@ -163,15 +182,17 @@ private:
|
|||||||
static unsigned char options_read_;
|
static unsigned char options_read_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/*
|
||||||
Return a global setting for all FLTK applications, possibly overridden
|
Return a global setting for all FLTK applications, possibly overridden
|
||||||
by a setting specifically for this application.
|
by a setting specifically for this application.
|
||||||
|
|
||||||
\param opt
|
|
||||||
\returns true or false
|
|
||||||
*/
|
*/
|
||||||
static bool option(Fl_Option opt);
|
static bool option(Fl_Option opt);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Override an option while the application is running.
|
||||||
|
*/
|
||||||
|
static void option(Fl_Option opt, bool val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The currently executing idle callback function: DO NOT USE THIS DIRECTLY!
|
The currently executing idle callback function: DO NOT USE THIS DIRECTLY!
|
||||||
|
|
||||||
@@ -913,13 +934,13 @@ public:
|
|||||||
non-text widgets. The default mode is to enable keyboard focus
|
non-text widgets. The default mode is to enable keyboard focus
|
||||||
for all widgets.
|
for all widgets.
|
||||||
*/
|
*/
|
||||||
static void visible_focus(int v) { visible_focus_ = v; }
|
static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, v); }
|
||||||
/**
|
/**
|
||||||
Gets or sets the visible keyboard focus on buttons and other
|
Gets or sets the visible keyboard focus on buttons and other
|
||||||
non-text widgets. The default mode is to enable keyboard focus
|
non-text widgets. The default mode is to enable keyboard focus
|
||||||
for all widgets.
|
for all widgets.
|
||||||
*/
|
*/
|
||||||
static int visible_focus() { return visible_focus_; }
|
static int visible_focus() { return option(OPTION_VISIBLE_FOCUS); }
|
||||||
|
|
||||||
// Drag-n-drop text operation methods...
|
// Drag-n-drop text operation methods...
|
||||||
/**
|
/**
|
||||||
@@ -928,14 +949,14 @@ public:
|
|||||||
be dragged from text fields or dragged within a text field as a
|
be dragged from text fields or dragged within a text field as a
|
||||||
cut/paste shortcut.
|
cut/paste shortcut.
|
||||||
*/
|
*/
|
||||||
static void dnd_text_ops(int v) { dnd_text_ops_ = v; }
|
static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, v); }
|
||||||
/**
|
/**
|
||||||
Gets or sets whether drag and drop text operations are
|
Gets or sets whether drag and drop text operations are
|
||||||
supported. This specifically affects whether selected text can
|
supported. This specifically affects whether selected text can
|
||||||
be dragged from text fields or dragged within a text field as a
|
be dragged from text fields or dragged within a text field as a
|
||||||
cut/paste shortcut.
|
cut/paste shortcut.
|
||||||
*/
|
*/
|
||||||
static int dnd_text_ops() { return dnd_text_ops_; }
|
static int dnd_text_ops() { return option(OPTION_DND_TEXT); }
|
||||||
/** \defgroup fl_multithread Multithreading support functions
|
/** \defgroup fl_multithread Multithreading support functions
|
||||||
fl multithreading support functions declared in <FL/Fl.H>
|
fl multithreading support functions declared in <FL/Fl.H>
|
||||||
@{ */
|
@{ */
|
||||||
|
|||||||
+3
-4
@@ -55,11 +55,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
static void hoverdelay(float f) { hoverdelay_ = f; }
|
static void hoverdelay(float f) { hoverdelay_ = f; }
|
||||||
/** Returns non-zero if tooltips are enabled. */
|
/** Returns non-zero if tooltips are enabled. */
|
||||||
static int enabled() { return enabled_; }
|
static int enabled() { return Fl::option(Fl::OPTION_SHOW_TOOLTIPS); }
|
||||||
/** Enables tooltips on all widgets (or disables if <i>b</i> is false). */
|
/** Enables tooltips on all widgets (or disables if <i>b</i> is false). */
|
||||||
static void enable(int b = 1) { enabled_ = b;}
|
static void enable(int b = 1) { Fl::option(Fl::OPTION_SHOW_TOOLTIPS, b);}
|
||||||
/** Same as enable(0), disables tooltips on all widgets. */
|
/** Same as enable(0), disables tooltips on all widgets. */
|
||||||
static void disable() { enabled_ = 0; }
|
static void disable() { enable(0); }
|
||||||
static void (*enter)(Fl_Widget* w);
|
static void (*enter)(Fl_Widget* w);
|
||||||
static void enter_area(Fl_Widget* w, int X, int Y, int W, int H, const char* tip);
|
static void enter_area(Fl_Widget* w, int X, int Y, int W, int H, const char* tip);
|
||||||
static void (*exit)(Fl_Widget *w);
|
static void (*exit)(Fl_Widget *w);
|
||||||
@@ -100,7 +100,6 @@ private:
|
|||||||
private:
|
private:
|
||||||
static float delay_; //!< delay before a tooltip is shown
|
static float delay_; //!< delay before a tooltip is shown
|
||||||
static float hoverdelay_; //!< delay between tooltips
|
static float hoverdelay_; //!< delay between tooltips
|
||||||
static int enabled_;
|
|
||||||
static Fl_Color color_;
|
static Fl_Color color_;
|
||||||
static Fl_Color textcolor_;
|
static Fl_Color textcolor_;
|
||||||
static Fl_Font font_;
|
static Fl_Font font_;
|
||||||
|
|||||||
@@ -5449,6 +5449,7 @@
|
|||||||
2DE25DB4CE986C1857B5ECF7 /* Fl_Native_File_Chooser.cxx */,
|
2DE25DB4CE986C1857B5ECF7 /* Fl_Native_File_Chooser.cxx */,
|
||||||
D1C792936D427CC48581BFAE /* Fl_Overlay_Window.cxx */,
|
D1C792936D427CC48581BFAE /* Fl_Overlay_Window.cxx */,
|
||||||
813C830680D031C1B2FCF9B6 /* Fl_Pack.cxx */,
|
813C830680D031C1B2FCF9B6 /* Fl_Pack.cxx */,
|
||||||
|
6C1C9A4F054C48CDD6A2DE44 /* Fl_Paged_Device.cxx */,
|
||||||
D79D3910F834D4B78FED92F3 /* Fl_Pixmap.cxx */,
|
D79D3910F834D4B78FED92F3 /* Fl_Pixmap.cxx */,
|
||||||
05BBBFE4BED0452E5D6A81F7 /* Fl_Positioner.cxx */,
|
05BBBFE4BED0452E5D6A81F7 /* Fl_Positioner.cxx */,
|
||||||
B4CAFA162560925C4591997A /* Fl_Printer.cxx */,
|
B4CAFA162560925C4591997A /* Fl_Printer.cxx */,
|
||||||
@@ -5558,7 +5559,6 @@
|
|||||||
FB7A9EFB3C7CDAE324E9544F /* case.c */,
|
FB7A9EFB3C7CDAE324E9544F /* case.c */,
|
||||||
6B30F6EA5CA69E305D2B82EE /* is_right2left.c */,
|
6B30F6EA5CA69E305D2B82EE /* is_right2left.c */,
|
||||||
5AE1F936F1C186E18C1B9C28 /* is_spacing.c */,
|
5AE1F936F1C186E18C1B9C28 /* is_spacing.c */,
|
||||||
6C1C9A4F054C48CDD6A2DE44 /* Fl_Paged_Device.cxx */,
|
|
||||||
);
|
);
|
||||||
name = fltk;
|
name = fltk;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
|||||||
+53
-11
@@ -90,8 +90,6 @@ int Fl::damage_,
|
|||||||
|
|
||||||
char *Fl::e_text = (char *)"";
|
char *Fl::e_text = (char *)"";
|
||||||
int Fl::e_length;
|
int Fl::e_length;
|
||||||
int Fl::visible_focus_ = 1,
|
|
||||||
Fl::dnd_text_ops_ = 1;
|
|
||||||
|
|
||||||
unsigned char Fl::options_[] = { 0, 0 };
|
unsigned char Fl::options_[] = { 0, 0 };
|
||||||
unsigned char Fl::options_read_ = 0;
|
unsigned char Fl::options_read_ = 0;
|
||||||
@@ -1760,7 +1758,7 @@ void Fl::clear_widget_pointer(Fl_Widget const *w)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief User interface options management.
|
\brief FLTK library options management.
|
||||||
|
|
||||||
This function needs to be documented in more detail. It can be used for more
|
This function needs to be documented in more detail. It can be used for more
|
||||||
optional settings, such as using a native file chooser instead of the FLTK one
|
optional settings, such as using a native file chooser instead of the FLTK one
|
||||||
@@ -1771,6 +1769,10 @@ void Fl::clear_widget_pointer(Fl_Widget const *w)
|
|||||||
|
|
||||||
There should be an application that manages options system wide, per user, and
|
There should be an application that manages options system wide, per user, and
|
||||||
per application.
|
per application.
|
||||||
|
|
||||||
|
\param opt which option
|
||||||
|
\return true or false
|
||||||
|
\see Fl_Option
|
||||||
*/
|
*/
|
||||||
bool Fl::option(Fl_Option opt)
|
bool Fl::option(Fl_Option opt)
|
||||||
{
|
{
|
||||||
@@ -1779,15 +1781,35 @@ bool Fl::option(Fl_Option opt)
|
|||||||
{ // first, read the system wide preferences
|
{ // first, read the system wide preferences
|
||||||
Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk");
|
Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk");
|
||||||
Fl_Preferences opt_prefs(prefs, "options");
|
Fl_Preferences opt_prefs(prefs, "options");
|
||||||
opt_prefs.get("ArrowFocus", tmp, 0); options_[OPTION_ARROW_FOCUS] = tmp;
|
opt_prefs.get("ArrowFocus", tmp, 0); // default: off
|
||||||
opt_prefs.get("NativeFilechooser", tmp, 0); options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
options_[OPTION_ARROW_FOCUS] = tmp;
|
||||||
|
//opt_prefs.get("NativeFilechooser", tmp, 1); // default: on
|
||||||
|
//options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
||||||
|
//opt_prefs.get("FilechooserPreview", tmp, 1); // default: on
|
||||||
|
//options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
|
||||||
|
opt_prefs.get("VisibleFocus", tmp, 1); // default: on
|
||||||
|
options_[OPTION_VISIBLE_FOCUS] = tmp;
|
||||||
|
opt_prefs.get("DNDText", tmp, 1); // default: on
|
||||||
|
options_[OPTION_DND_TEXT] = tmp;
|
||||||
|
opt_prefs.get("ShowTooltips", tmp, 1); // default: on
|
||||||
|
options_[OPTION_SHOW_TOOLTIPS] = tmp;
|
||||||
}
|
}
|
||||||
{ // next, check the user preferences
|
{ // next, check the user preferences
|
||||||
// override system options only, if the option is set ( >= 0 )
|
// override system options only, if the option is set ( >= 0 )
|
||||||
Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk");
|
Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk");
|
||||||
Fl_Preferences opt_prefs(prefs, "options");
|
Fl_Preferences opt_prefs(prefs, "options");
|
||||||
opt_prefs.get("ArrowFocus", tmp, -1); if (tmp >= 0) options_[OPTION_ARROW_FOCUS] = tmp;
|
opt_prefs.get("ArrowFocus", tmp, -1);
|
||||||
opt_prefs.get("NativeFilechooser", tmp, -1); if (tmp >= 0) options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
if (tmp >= 0) options_[OPTION_ARROW_FOCUS] = tmp;
|
||||||
|
//opt_prefs.get("NativeFilechooser", tmp, -1);
|
||||||
|
//if (tmp >= 0) options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
||||||
|
//opt_prefs.get("FilechooserPreview", tmp, -1);
|
||||||
|
//if (tmp >= 0) options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
|
||||||
|
opt_prefs.get("VisibleFocus", tmp, -1);
|
||||||
|
if (tmp >= 0) options_[OPTION_VISIBLE_FOCUS] = tmp;
|
||||||
|
opt_prefs.get("DNDText", tmp, -1);
|
||||||
|
if (tmp >= 0) options_[OPTION_DND_TEXT] = tmp;
|
||||||
|
opt_prefs.get("ShowTooltips", tmp, -1);
|
||||||
|
if (tmp >= 0) options_[OPTION_SHOW_TOOLTIPS] = tmp;
|
||||||
}
|
}
|
||||||
{ // now, if the developer has registered this app, we could as for per-application preferences
|
{ // now, if the developer has registered this app, we could as for per-application preferences
|
||||||
}
|
}
|
||||||
@@ -1798,14 +1820,34 @@ bool Fl::option(Fl_Option opt)
|
|||||||
return (bool)options_[opt];
|
return (bool)options_[opt];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Override an option while the application is running.
|
||||||
|
|
||||||
|
This function does not change any system or user settings.
|
||||||
|
|
||||||
|
\param opt which option
|
||||||
|
\param val set to true or false
|
||||||
|
\see Fl_Option
|
||||||
|
*/
|
||||||
|
void Fl::option(Fl_Option opt, bool val)
|
||||||
|
{
|
||||||
|
if (opt<0 || opt>=OPTION_LAST)
|
||||||
|
return;
|
||||||
|
if (!options_read_) {
|
||||||
|
// first read this option, so we don't override our setting later
|
||||||
|
option(opt);
|
||||||
|
}
|
||||||
|
options_[opt] = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helper class Fl_Widget_Tracker
|
// Helper class Fl_Widget_Tracker
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The constructor adds a widget to the watch list.
|
The constructor adds a widget to the watch list.
|
||||||
*/
|
*/
|
||||||
Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi) {
|
Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi)
|
||||||
|
{
|
||||||
wp_ = wi;
|
wp_ = wi;
|
||||||
Fl::watch_widget_pointer(wp_); // add pointer to watch list
|
Fl::watch_widget_pointer(wp_); // add pointer to watch list
|
||||||
}
|
}
|
||||||
@@ -1813,8 +1855,8 @@ Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi) {
|
|||||||
/**
|
/**
|
||||||
The destructor removes a widget from the watch list.
|
The destructor removes a widget from the watch list.
|
||||||
*/
|
*/
|
||||||
Fl_Widget_Tracker::~Fl_Widget_Tracker() {
|
Fl_Widget_Tracker::~Fl_Widget_Tracker()
|
||||||
|
{
|
||||||
Fl::release_widget_pointer(wp_); // remove pointer from watch list
|
Fl::release_widget_pointer(wp_); // remove pointer from watch list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3609,7 +3609,7 @@ int Fl_Text_Display::handle(int event) {
|
|||||||
if (dragType==DRAG_NONE)
|
if (dragType==DRAG_NONE)
|
||||||
return 1;
|
return 1;
|
||||||
if (dragType==DRAG_START_DND) {
|
if (dragType==DRAG_START_DND) {
|
||||||
if (!Fl::event_is_click()) {
|
if (!Fl::event_is_click() && Fl::dnd_text_ops()) {
|
||||||
const char* copy = buffer()->selection_text();
|
const char* copy = buffer()->selection_text();
|
||||||
Fl::dnd();
|
Fl::dnd();
|
||||||
free((void*)copy);
|
free((void*)copy);
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
float Fl_Tooltip::delay_ = 1.0f;
|
float Fl_Tooltip::delay_ = 1.0f;
|
||||||
float Fl_Tooltip::hoverdelay_ = 0.2f;
|
float Fl_Tooltip::hoverdelay_ = 0.2f;
|
||||||
int Fl_Tooltip::enabled_ = 1;
|
|
||||||
Fl_Color Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
|
Fl_Color Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
|
||||||
FL_NUM_GREEN - 1,
|
FL_NUM_GREEN - 1,
|
||||||
FL_NUM_BLUE - 2);
|
FL_NUM_BLUE - 2);
|
||||||
|
|||||||
+203
-289
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user