68
68
Fl::remove_timeout() and others
71
/** signature of some label drawing functions passed as parameters */
71
/** Signature of some label drawing functions passed as parameters */
72
72
typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
74
/** signature of some label measurement functions passed as parameters */
74
/** Signature of some label measurement functions passed as parameters */
75
75
typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height);
77
/** signature of some box drawing functions passed as parameters */
77
/** Signature of some box drawing functions passed as parameters */
78
78
typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color);
80
/** signature of some timeout callback functions passed as parameters */
80
/** Signature of some timeout callback functions passed as parameters */
81
81
typedef void (*Fl_Timeout_Handler)(void *data);
83
/** signature of some wakeup callback functions passed as parameters */
83
/** Signature of some wakeup callback functions passed as parameters */
84
84
typedef void (*Fl_Awake_Handler)(void *data);
86
/** signature of add_idle callback functions passed as parameters */
86
/** Signature of add_idle callback functions passed as parameters */
87
87
typedef void (*Fl_Idle_Handler)(void *data);
89
/** signature of set_idle callback functions passed as parameters */
89
/** Signature of set_idle callback functions passed as parameters */
90
90
typedef void (*Fl_Old_Idle_Handler)();
92
/** signature of add_fd functions passed as parameters */
92
/** Signature of add_fd functions passed as parameters */
93
93
typedef void (*Fl_FD_Handler)(int fd, void *data);
95
/** signature of add_handler functions passed as parameters */
95
/** Signature of add_handler functions passed as parameters */
96
96
typedef int (*Fl_Event_Handler)(int event);
98
/** signature of set_abort functions passed as parameters */
98
/** Signature of set_abort functions passed as parameters */
99
99
typedef void (*Fl_Abort_Handler)(const char *format,...);
101
/** signature of set_atclose functions passed as parameters */
101
/** Signature of set_atclose functions passed as parameters */
102
102
typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data);
104
/** signature of args functions passed as parameters */
104
/** Signature of args functions passed as parameters */
105
105
typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
107
/** Signature of event_dispatch functions passed as parameters.
108
\see Fl::event_dispatch(Fl_Event_Dispatch) */
109
typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
107
111
/** @} */ /* group callback_functions */
110
The Fl is the FLTK global (static) containing
115
The Fl is the FLTK global (static) class containing
111
116
state information and global methods for the current application.
113
118
class FL_EXPORT Fl {
114
119
Fl() {}; // no constructor!
116
121
public: // should be private!
117
122
#ifndef FL_DOXYGEN
118
123
static int e_number;
136
142
static Fl_Window* modal_;
137
143
static Fl_Window* grab_;
138
144
static int compose_state;
139
static int visible_focus_;
140
static int dnd_text_ops_;
143
147
If true then flush() will do something.
145
149
static void damage(int d) {damage_ = d;}
152
/** Enumerator for global FLTK options.
153
These options can be set system wide, per user, or for the running
155
\see Fl::option(Fl_Option, bool)
156
\see Fl::option(Fl_Option)
159
/// When switched on, moving the text cursor beyond the start or end of
160
/// a text in a text widget will change focus to the next text widget.
161
/// When switched off, the cursor will stop at the end of the text.
162
/// Pressing Tab or Ctrl-Tab will advance the keyboard focus.
163
OPTION_ARROW_FOCUS = 0,
164
// When switched on, FLTK will use the file chooser dialog that comes
165
// with your operating system whenever possible. When switched off, FLTK
166
// will present its own file chooser.
167
// \todo implement me
168
// OPTION_NATIVE_FILECHOOSER,
169
// When Filechooser Preview is enabled, the FLTK or native file chooser
170
// will show a preview of a selected file (if possible) before the user
171
// decides to choose the file.
172
// \todo implement me
173
//OPTION_FILECHOOSER_PREVIEW,
174
/// If visible focus is switched on, FLTK will draw a dotted rectangle
175
/// inside the widget that will receive the next keystroke. If switched
176
/// off, no such indicator will be drawn and keyboard navigation
178
OPTION_VISIBLE_FOCUS,
179
/// If text drag-and-drop is enabled, the user can select and drag text
180
/// from any text widget. If disabled, no dragging is possible, however
181
/// dropping text from other applications still works.
183
/// If tooltips are enabled, hovering the mouse over a widget with a
184
/// tooltip text will open a little tooltip window until the mouse leaves
185
/// the widget. If disabled, no tooltip is shown.
186
OPTION_SHOW_TOOLTIPS,
187
// don't change this, leave it always as the last element
188
/// For internal use only.
193
static unsigned char options_[OPTION_LAST];
194
static unsigned char options_read_;
198
Return a global setting for all FLTK applications, possibly overridden
199
by a setting specifically for this application.
201
static bool option(Fl_Option opt);
204
Override an option while the application is running.
206
static void option(Fl_Option opt, bool val);
148
209
The currently executing idle callback function: DO NOT USE THIS DIRECTLY!
176
237
static double version();
178
239
// argument parsers:
179
static int arg(int, char**, int&);
180
static int args(int, char**, int&, Fl_Args_Handler ah = 0);
181
static void args(int, char**);
240
static int arg(int argc, char **argv, int& i);
241
static int args(int argc, char **argv, int& i, Fl_Args_Handler cb = 0);
242
static void args(int argc, char **argv);
183
244
Usage string displayed if Fl::args() detects an invalid argument.
184
245
This may be changed to point to customized text at run-time.
359
422
version may be able to use longjmp or an exception to continue, as long as
360
423
it does not call FLTK again. The default implementation exits with status 1
361
424
after displaying the message.
425
\note \#include <FL/Fl.H>
363
427
static void (*fatal)(const char*, ...);
366
430
/** \defgroup fl_windows Windows handling functions
367
Windows and standard dialogs handling
431
\brief Windows and standard dialogs handling declared in <FL/Fl.H>
369
433
static Fl_Window* first_window();
370
434
static void first_window(Fl_Window*);
380
444
called (grab() overrides this).
382
446
static Fl_Window* modal() {return modal_;}
384
This is used when pop-up menu systems are active.
386
Send all events to the passed window no matter where the pointer or
387
focus is (including in other programs). The window <I>does not have
388
to be shown()</I> , this lets the handle() method of a
389
"dummy" window override all event handling and allows you to
390
map and unmap a complex set of windows (under both X and WIN32
391
<I>some</I> window must be mapped because the system interface needs a
394
If grab() is on it will also affect show() of windows by doing
395
system-specific operations (on X it turns on override-redirect).
396
These are designed to make menus popup reliably
397
and faster on the system.
399
To turn off grabbing do Fl::grab(0).
401
<I>Be careful that your program does not enter an infinite loop
402
while grab() is on. On X this will lock up your screen!</I>
403
To avoid this potential lockup, all newer operating systems seem to
404
limit mouse pointer grabbing to the time during which a mouse button
405
is held down. Some OS's may not support grabbing at all.
447
/** Returns the window that currently receives all events.
449
\return The window that currently receives all events,
450
or NULL if event grabbing is currently OFF.
407
452
static Fl_Window* grab() {return grab_;}
408
/** Selects the window to grab. See Fl_Window* Fl::grab() */
453
/** Selects the window to grab.
454
This is used when pop-up menu systems are active.
456
Send all events to the passed window no matter where the pointer or
457
focus is (including in other programs). The window <I>does not have
458
to be shown()</I> , this lets the handle() method of a
459
"dummy" window override all event handling and allows you to
460
map and unmap a complex set of windows (under both X and WIN32
461
<I>some</I> window must be mapped because the system interface needs a
464
If grab() is on it will also affect show() of windows by doing
465
system-specific operations (on X it turns on override-redirect).
466
These are designed to make menus popup reliably
467
and faster on the system.
469
To turn off grabbing do Fl::grab(0).
471
<I>Be careful that your program does not enter an infinite loop
472
while grab() is on. On X this will lock up your screen!</I>
473
To avoid this potential lockup, all newer operating systems seem to
474
limit mouse pointer grabbing to the time during which a mouse button
475
is held down. Some OS's may not support grabbing at all.
409
477
static void grab(Fl_Window*); // platform dependent
412
480
/** \defgroup fl_events Events handling functions
413
Fl class events handling API
481
Fl class events handling API declared in <FL/Fl.H>
416
484
// event information:
482
550
static void event_clicks(int i) {e_clicks = i;}
484
The first form returns non-zero if the mouse has not moved far enough
485
and not enough time has passed since the last FL_PUSH or
486
FL_KEYBOARD event for it to be considered a "drag" rather than a
487
"click". You can test this on FL_DRAG, FL_RELEASE,
488
and FL_MOVE events. The second form clears the value returned
489
by Fl::event_is_click(). Useful to prevent the <I>next</I>
490
click from being counted as a double-click or to make a popup menu
491
pick an item with a single click. Don't pass non-zero to this.
552
Returns non-zero if the mouse has not moved far enough
553
and not enough time has passed since the last FL_PUSH or
554
FL_KEYBOARD event for it to be considered a "drag" rather than a
555
"click". You can test this on FL_DRAG, FL_RELEASE,
493
558
static int event_is_click() {return e_is_click;}
495
Only i=0 works! See int event_is_click().
560
Clears the value returned by Fl::event_is_click().
561
Useful to prevent the <I>next</I>
562
click from being counted as a double-click or to make a popup menu
563
pick an item with a single click. Don't pass non-zero to this.
497
565
static void event_is_click(int i) {e_is_click = i;}
618
686
static int event_length() {return e_length;}
620
688
static int compose(int &del);
622
If the user moves the cursor, be sure to call Fl::compose_reset().
623
The next call to Fl::compose() will start out in an initial state. In
624
particular it will not set "del" to non-zero. This call is very fast
625
so it is ok to call it many times and in many places.
627
static void compose_reset() {compose_state = 0;}
689
static void compose_reset();
628
690
static int event_inside(int,int,int,int);
629
691
static int event_inside(const Fl_Widget*);
630
692
static int test_shortcut(Fl_Shortcut);
632
694
// event destinations:
633
695
static int handle(int, Fl_Window*);
696
static int handle_(int, Fl_Window*);
634
697
/** Gets the widget that is below the mouse.
635
698
\see belowmouse(Fl_Widget*) */
636
699
static Fl_Widget* belowmouse() {return belowmouse_;}
644
707
static void focus(Fl_Widget*);
645
708
static void add_handler(Fl_Event_Handler h);
646
709
static void remove_handler(Fl_Event_Handler h);
710
static void event_dispatch(Fl_Event_Dispatch d);
711
static Fl_Event_Dispatch event_dispatch();
649
714
/** \defgroup fl_clipboard Selection & Clipboard functions
650
fl global copy/cut/paste functions
715
FLTK global copy/cut/paste functions declared in <FL/Fl.H>
654
Copies the data pointed to by \p stuff to the selection (0) or
655
primary (1) clipboard. The selection clipboard is used for
656
middle-mouse pastes and for drag-and-drop selections. The primary
657
clipboard is used for traditional copy/cut/paste operations.
659
static void copy(const char* stuff, int len, int clipboard = 0); // platform dependent
661
Pastes the data from the selection (0) or primary (1) clipboard into receiver.
662
The selection clipboard is used for middle-mouse pastes and for
663
drag-and-drop selections. The primary clipboard is used for
664
traditional copy/cut/paste operations.
666
static void paste(Fl_Widget &receiver, int clipboard /*=0*/); // platform dependent
668
Initiate a Drag And Drop operation. The clipboard should be
719
Copies the data pointed to by \p stuff to the selection buffer
720
(\p destination is 0) or
721
the clipboard (\p destination is 1); \p len is the number of relevant
723
The selection buffer is used for
724
middle-mouse pastes and for drag-and-drop selections. The
725
clipboard is used for traditional copy/cut/paste operations.
727
static void copy(const char* stuff, int len, int destination = 0); // platform dependent
729
Pastes the data from the selection buffer (\p source is 0) or the clipboard
730
(\p source is 1) into \p receiver.
731
Set things up so the receiver widget will be called with an FL_PASTE event some
732
time in the future with the data from the specified \p source in Fl::event_text()
733
and the number of characters in Fl::event_length().
735
should be prepared to be called \e directly by this, or for
736
it to happen \e later, or possibly <i>not at all</i>. This
737
allows the window system to take as long as necessary to retrieve
738
the paste buffer (or even to screw up completely) without complex
739
and error-prone synchronization code in FLTK.
741
The selection buffer is used for middle-mouse pastes and for
742
drag-and-drop selections. The clipboard is used for traditional
743
copy/cut/paste operations.
745
static void paste(Fl_Widget &receiver, int source /*=0*/); // platform dependent
747
Initiate a Drag And Drop operation. The selection buffer should be
669
748
filled with relevant data before calling this method. FLTK will
670
749
then initiate the system wide drag and drop handling. Dropped data
671
750
will be marked as <i>text</i>.
752
Create a selection first using:
753
Fl::copy(const char *stuff, int len, 0)
673
755
static int dnd(); // platform dependent
681
763
static void paste(Fl_Widget &receiver);
683
765
/** \defgroup fl_screen Screen functions
684
fl global screen functions
766
fl global screen functions declared in <FL/Fl.H>
687
/** Returns the origin of the current screen, where 0 indicates the left side of the screen. */
769
/** Returns the origin of the current screen work area, where 0 indicates the left side of the screen. */
688
770
static int x(); // platform dependent
689
/** Returns the origin of the current screen, where 0 indicates the top edge of the screen. */
771
/** Returns the origin of the current screen work area, where 0 indicates the top edge of the screen. */
690
772
static int y(); // platform dependent
691
/** Returns the width of the screen in pixels. */
773
/** Returns the width of the screen work area in pixels. */
692
774
static int w(); // platform dependent
693
/** Returns the height of the screen in pixels. */
775
/** Returns the height of the screen work area in pixels. */
694
776
static int h(); // platform dependent
696
778
// multi-head support:
704
786
screen_xywh(X, Y, W, H, e_x_root, e_y_root);
706
788
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
707
static void screen_xywh(int &X, int &Y, int &W, int &H, int n);
789
static void screen_xywh(int &X, int &Y, int &W, int &H, int n);
790
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
791
static void screen_dpi(float &h, float &v, int n=0);
711
795
/** \defgroup fl_attributes Color & Font functions
712
fl global color, font functions
796
fl global color, font functions.
797
These functions are declared in <FL/Fl.H> or <FL/fl_draw.H>.
718
803
Sets an entry in the fl_color index table. You can set it to any
719
804
8-bit RGB color. The color is not allocated until fl_color(i) is used.
721
static void set_color(Fl_Color, unsigned); // platform dependent
722
static Fl_Color get_color(Fl_Color);
723
static void get_color(Fl_Color, uchar&, uchar&, uchar&);
806
static void set_color(Fl_Color i, unsigned c); // platform dependent
807
static unsigned get_color(Fl_Color i);
808
static void get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue);
725
810
Frees the specified color from the colormap, if applicable.
726
811
If overlay is non-zero then the color is freed from the
727
812
overlay colormap.
729
static void free_color(Fl_Color, int overlay = 0); // platform dependent
814
static void free_color(Fl_Color i, int overlay = 0); // platform dependent
732
817
static const char* get_font(Fl_Font);
854
941
\deprecated This method is obsolete - use the add_idle() method instead.
856
943
static void set_idle(Fl_Old_Idle_Handler cb) {idle = cb;}
857
/** See Fl_Window* grab() */
858
static void grab(Fl_Window&win) {grab(&win);}
944
/** See grab(Fl_Window*) */
945
static void grab(Fl_Window& win) {grab(&win);}
859
946
/** Releases the current grabbed window, equals grab(0).
860
947
\deprecated Use Fl::grab(0) instead.
861
\see Fl_Window* grab() */
948
\see grab(Fl_Window*) */
862
949
static void release() {grab(0);}
864
951
// Visible focus methods...
867
954
non-text widgets. The default mode is to enable keyboard focus
870
static void visible_focus(int v) { visible_focus_ = v; }
957
static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); }
872
959
Gets or sets the visible keyboard focus on buttons and other
873
960
non-text widgets. The default mode is to enable keyboard focus
876
static int visible_focus() { return visible_focus_; }
963
static int visible_focus() { return option(OPTION_VISIBLE_FOCUS); }
878
965
// Drag-n-drop text operation methods...
882
969
be dragged from text fields or dragged within a text field as a
883
970
cut/paste shortcut.
885
static void dnd_text_ops(int v) { dnd_text_ops_ = v; }
972
static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); }
887
974
Gets or sets whether drag and drop text operations are
888
975
supported. This specifically affects whether selected text can
889
976
be dragged from text fields or dragged within a text field as a
890
977
cut/paste shortcut.
892
static int dnd_text_ops() { return dnd_text_ops_; }
979
static int dnd_text_ops() { return option(OPTION_DND_TEXT); }
893
980
/** \defgroup fl_multithread Multithreading support functions
894
fl multithreading support functions
981
fl multithreading support functions declared in <FL/Fl.H>
897
984
// Multithreading support:
899
986
static void unlock();
900
987
static void awake(void* message = 0);
901
988
/** See void awake(void* message=0). */
904
991
The thread_message() method returns the last message
905
992
that was sent from a child by the awake() method.
907
See also: multithreading
994
See also: \ref advanced_multithreading
909
996
static void* thread_message(); // platform dependent
912
999
/** \defgroup fl_del_widget Safe widget deletion support functions
914
These functions support deletion of widgets inside callbacks.
1001
These functions, declared in <FL/Fl.H>, support deletion of widgets inside callbacks.
916
1003
Fl::delete_widget() should be called when deleting widgets
917
1004
or complete widget trees (Fl_Group, Fl_Window, ...) inside
946
1033
static void clear_widget_pointer(Fl_Widget const *w);
1036
#ifdef FLTK_HAVE_CAIRO
950
1037
/** \defgroup group_cairo Cairo support functions and classes
954
1041
// Cairo support API
955
1042
static cairo_t * cairo_make_current(Fl_Window* w);
956
/** when HAVE_CAIRO is defined and cairo_autolink_context() is true,
1043
/** when FLTK_HAVE_CAIRO is defined and cairo_autolink_context() is true,
957
1044
any current window dc is linked to a current context.
958
1045
This is not the default, because it may not be necessary
959
1046
to add cairo support to all fltk supported windows.