diff options
| author | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-06 19:04:24 +0500 |
|---|---|---|
| committer | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-06 19:04:24 +0500 |
| commit | 793fa5a91f24358aa7ce21abf6ee4e93a17b04ee (patch) | |
| tree | e81d1e60ffdf068ac1e93e8d36d9c2046b2d7c50 /FL/core | |
| parent | b4995f979d127cea667b4e2b71c91e9db4ab52ef (diff) | |
wip
Diffstat (limited to 'FL/core')
| -rw-r--r-- | FL/core/events.H | 188 | ||||
| -rw-r--r-- | FL/core/options.H | 31 |
2 files changed, 93 insertions, 126 deletions
diff --git a/FL/core/events.H b/FL/core/events.H index 01c0fd7ed..8454fc501 100644 --- a/FL/core/events.H +++ b/FL/core/events.H @@ -16,60 +16,48 @@ /** \file FL/core/events.H \brief Global event handling variables and functions. + This file is included within class Fl in FL/Fl.H. */ -#ifndef Fl_core_events_H -#define Fl_core_events_H - -#include <FL/fl_config.h> // build configuration -#include <FL/Fl_Export.H> // for FL_EXPORT -#include <FL/core/function_types.H> // widget callbacks and services - -class Fl_Widget; - -namespace Fl { - -// -// Event Variables (Internal) +// --- Event Variables (Internal) --- // Note: These variables should be private, but would harm back compatibility. -// #ifndef FL_DOXYGEN // Core event information -FL_EXPORT extern int e_number; ///< Current event type -FL_EXPORT extern int e_state; ///< Keyboard/mouse button states +static FL_EXPORT int e_number; ///< Current event type +static FL_EXPORT int e_state; ///< Keyboard/mouse button states // Mouse position and movement -FL_EXPORT extern int e_x; ///< Mouse X position (window relative) -FL_EXPORT extern int e_y; ///< Mouse Y position (window relative) -FL_EXPORT extern int e_x_root; ///< Mouse X position (screen absolute) -FL_EXPORT extern int e_y_root; ///< Mouse Y position (screen absolute) -FL_EXPORT extern int e_dx; ///< Mouse wheel horizontal delta -FL_EXPORT extern int e_dy; ///< Mouse wheel vertical delta +static FL_EXPORT int e_x; ///< Mouse X position (window relative) +static FL_EXPORT int e_y; ///< Mouse Y position (window relative) +static FL_EXPORT int e_x_root; ///< Mouse X position (screen absolute) +static FL_EXPORT int e_y_root; ///< Mouse Y position (screen absolute) +static FL_EXPORT int e_dx; ///< Mouse wheel horizontal delta +static FL_EXPORT int e_dy; ///< Mouse wheel vertical delta // Mouse click handling -FL_EXPORT extern int e_clicks; ///< Number of consecutive clicks -FL_EXPORT extern int e_is_click; ///< True if event qualifies as click +static FL_EXPORT int e_clicks; ///< Number of consecutive clicks +static FL_EXPORT int e_is_click; ///< True if event qualifies as click // Keyboard event data -FL_EXPORT extern int e_keysym; ///< Key symbol for current event -FL_EXPORT extern int e_original_keysym; ///< Original key before NumLock translation -FL_EXPORT extern char* e_text; ///< Text associated with key event -FL_EXPORT extern int e_length; ///< Length of text in e_text +static FL_EXPORT int e_keysym; ///< Key symbol for current event +static FL_EXPORT int e_original_keysym; ///< Original key before NumLock translation +static FL_EXPORT char* e_text; ///< Text associated with key event +static FL_EXPORT int e_length; ///< Length of text in e_text // Clipboard data (for paste events) -FL_EXPORT extern void* e_clipboard_data; ///< Pasted data pointer -FL_EXPORT extern const char* e_clipboard_type; ///< Type of pasted data +static FL_EXPORT void* e_clipboard_data; ///< Pasted data pointer +static FL_EXPORT const char* e_clipboard_type; ///< Type of pasted data // Event handling infrastructure -FL_EXPORT extern Fl_Event_Dispatch e_dispatch; ///< Custom event dispatcher -FL_EXPORT extern Fl_Callback_Reason callback_reason_; ///< Reason for current callback +static FL_EXPORT Fl_Event_Dispatch e_dispatch; ///< Custom event dispatcher +static FL_EXPORT Fl_Callback_Reason callback_reason_; ///< Reason for current callback // Widget state tracking -FL_EXPORT extern Fl_Widget* belowmouse_; ///< Widget under mouse cursor -FL_EXPORT extern Fl_Widget* pushed_; ///< Widget receiving drag events -FL_EXPORT extern Fl_Widget* focus_; ///< Widget with keyboard focus +static FL_EXPORT Fl_Widget* belowmouse_; ///< Widget under mouse cursor +static FL_EXPORT Fl_Widget* pushed_; ///< Widget receiving drag events +static FL_EXPORT Fl_Widget* focus_; ///< Widget with keyboard focus // Event variables should be private, but would harm back compatibility. @@ -90,7 +78,7 @@ FL_EXPORT extern Fl_Widget* focus_; ///< Widget with keyboar to determine if a callback is being done in response to a keypress, mouse click, etc. */ -FL_EXPORT inline int event() { return e_number; } +static FL_EXPORT inline int event() { return e_number; } // // Mouse Position Functions @@ -100,13 +88,13 @@ FL_EXPORT inline int event() { return e_number; } Returns the mouse position of the event relative to the Fl_Window it was passed to. */ -FL_EXPORT inline int event_x() { return e_x; } +static FL_EXPORT inline int event_x() { return e_x; } /** Returns the mouse position of the event relative to the Fl_Window it was passed to. */ -FL_EXPORT inline int event_y() { return e_y; } +static FL_EXPORT inline int event_y() { return e_y; } /** Returns the mouse position on the screen of the event. To find the @@ -114,7 +102,7 @@ FL_EXPORT inline int event_y() { return e_y; } difference between event_x_root(),event_y_root() and event_x(),event_y(). */ -FL_EXPORT inline int event_x_root() { return e_x_root; } +static FL_EXPORT inline int event_x_root() { return e_x_root; } /** Returns the mouse position on the screen of the event. To find the @@ -122,7 +110,7 @@ FL_EXPORT inline int event_x_root() { return e_x_root; } difference between event_x_root(),event_y_root() and event_x(),event_y(). */ -FL_EXPORT inline int event_y_root() { return e_y_root; } +static FL_EXPORT inline int event_y_root() { return e_y_root; } // // Mouse Wheel Functions @@ -132,13 +120,13 @@ FL_EXPORT inline int event_y_root() { return e_y_root; } Returns the current horizontal mouse scrolling associated with the FL_MOUSEWHEEL event. Right is positive. */ -FL_EXPORT inline int event_dx() { return e_dx; } +static FL_EXPORT inline int event_dx() { return e_dx; } /** Returns the current vertical mouse scrolling associated with the FL_MOUSEWHEEL event. Down is positive. */ -FL_EXPORT inline int event_dy() { return e_dy; } +static FL_EXPORT inline int event_dy() { return e_dy; } // // Mouse Query Functions @@ -152,7 +140,7 @@ FL_EXPORT inline int event_dy() { return e_dy; } position your first window). If the display is not open, this will open it. */ -FL_EXPORT extern void get_mouse(int &,int &); +static FL_EXPORT void get_mouse(int &,int &); // // Mouse Click Functions @@ -166,7 +154,7 @@ FL_EXPORT extern void get_mouse(int &,int &); again while event_is_click() is true. */ -FL_EXPORT inline int event_clicks() { return e_clicks; } +static FL_EXPORT inline int event_clicks() { return e_clicks; } /** Manually sets the number returned by Fl::event_clicks(). @@ -175,7 +163,7 @@ FL_EXPORT inline int event_clicks() { return e_clicks; } \param[in] i corresponds to no double-click if 0, i+1 mouse clicks otherwise \see int event_clicks() */ -FL_EXPORT inline void event_clicks(int i) { e_clicks = i; } +static FL_EXPORT inline void event_clicks(int i) { e_clicks = i; } /** Returns non-zero if the mouse has not moved far enough @@ -184,7 +172,7 @@ FL_EXPORT inline void event_clicks(int i) { e_clicks = i; } "click". You can test this on FL_DRAG, FL_RELEASE, and FL_MOVE events. */ -FL_EXPORT inline int event_is_click() { return e_is_click; } +static FL_EXPORT inline int event_is_click() { return e_is_click; } /** Clears the value returned by Fl::event_is_click(). @@ -192,7 +180,7 @@ FL_EXPORT inline int event_is_click() { return e_is_click; } click from being counted as a double-click or to make a popup menu pick an item with a single click. Don't pass non-zero to this. */ -FL_EXPORT inline void event_is_click(int i) { e_is_click = i; } +static FL_EXPORT inline void event_is_click(int i) { e_is_click = i; } // // Mouse Button Functions @@ -209,7 +197,7 @@ FL_EXPORT inline void event_is_click(int i) { e_is_click = i; } \retval FL_FORWARD_MOUSE \see Fl::event_buttons(), Fl::event_state() */ -FL_EXPORT inline int event_button() { return e_keysym - FL_Button; } +static FL_EXPORT inline int event_button() { return e_keysym - FL_Button; } // // Event State Functions @@ -224,20 +212,16 @@ FL_EXPORT inline int event_button() { return e_keysym - FL_Button; } \note FLTK platforms differ in what Fl::event_state() returns when it is called while a modifier key or mouse button is being pressed or released. - - Under X11 and Wayland, Fl::event_state() indicates the state of the modifier keys and + - Under X11, Fl::event_state() indicates the state of the modifier keys and mouse buttons just \b prior to the event. Thus, during the \c FL_KEYDOWN event generated when pressing the shift key, for example, the \c FL_SHIFT bit of event_state() is 0 and becomes 1 only at the next event which can be any other event, including e.g. \c FL_MOVE. - - Under other platforms the reported state of modifier keys or mouse buttons includes that - of the key or button being pressed or released. - Fl::event_state() returns the same value under all platforms when it's called while a non-modifier key (e.g. a letter or function key) is being pressed or released. - X servers do not agree on shift states, and \c FL_NUM_LOCK, \c FL_META, and \c FL_SCROLL_LOCK may not work. - The values were selected to match the XFree86 server on Linux. - \note This inconsistency \b may be fixed (on X11 and Wayland) in a later release. - The legal event state bits are: | Device | State Bit | Key or Button | Since | @@ -255,14 +239,14 @@ FL_EXPORT inline int event_button() { return e_keysym - FL_Button; } | Mouse | FL_BUTTON4 | side button 1 (back) | 1.3.10 | | Mouse | FL_BUTTON5 | side button 2 (forward) | 1.3.10 | */ -FL_EXPORT inline int event_state() { return e_state; } +static FL_EXPORT inline int event_state() { return e_state; } /** Returns non-zero if any of the passed event state bits are turned on. Use \p mask to pass the event states you're interested in. The legal event state bits are defined in Fl::event_state(). */ -FL_EXPORT inline int event_state(int mask) { return e_state & mask; } +static FL_EXPORT inline int event_state(int mask) { return e_state & mask; } // // Keyboard Event Functions @@ -279,7 +263,7 @@ FL_EXPORT inline int event_state(int mask) { return e_state & mask; } \returns an integer 'key code', or 0 if the last event was not a key press or release. \see int event_key(int), event_text(), compose(int&). */ -FL_EXPORT inline int event_key() { return e_keysym; } +static FL_EXPORT inline int event_key() { return e_keysym; } /** Returns the keycode of the last key event, regardless of the NumLock state. @@ -289,7 +273,7 @@ FL_EXPORT inline int event_key() { return e_keysym; } event_key() returns the translated key code, whereas event_original_key() returns the keycode before NumLock translation. */ -FL_EXPORT inline int event_original_key() { return e_original_keysym; } +static FL_EXPORT inline int event_original_key() { return e_original_keysym; } /** Returns true if the given \p key was held @@ -327,17 +311,15 @@ FL_EXPORT inline int event_original_key() { return e_original_keysym; } symbols used by Fl::event_state(). On X Fl::get_key(FL_Button+n) does not work. - - On Windows Fl::get_key(FL_KP_Enter) and Fl::event_key(FL_KP_Enter) do not work. */ -FL_EXPORT extern int event_key(int key); +static FL_EXPORT int event_key(int key); /** Returns true if the given \p key is held down <I>now</I>. Under X this requires a round-trip to the server and is <I>much</I> slower than Fl::event_key(int). \see event_key(int) */ -FL_EXPORT extern int get_key(int key); // platform dependent +static FL_EXPORT int get_key(int key); // platform dependent // // Text and Clipboard Functions @@ -357,7 +339,7 @@ FL_EXPORT extern int get_key(int key); // platform dependent \returns A NULL terminated text string equivalent of the last keystroke. */ -FL_EXPORT inline const char* event_text() { return e_text; } +static FL_EXPORT inline const char* event_text() { return e_text; } /** Returns the length of the text in Fl::event_text(). There @@ -365,86 +347,86 @@ FL_EXPORT inline const char* event_text() { return e_text; } be a nul before that if the keystroke translates to a nul character or you paste a nul character. */ -FL_EXPORT inline int event_length() { return e_length; } +static FL_EXPORT inline int event_length() { return e_length; } /** Denotes plain textual data */ -FL_EXPORT extern char const * const clipboard_plain_text; +static FL_EXPORT char const * const clipboard_plain_text; /** Denotes image data */ -FL_EXPORT extern char const * const clipboard_image; +static FL_EXPORT char const * const clipboard_image; /** During an FL_PASTE event of non-textual data, returns a pointer to the pasted data. The returned data is an Fl_RGB_Image * when the result of Fl::event_clipboard_type() is Fl::clipboard_image. */ -FL_EXPORT inline void *event_clipboard() { return e_clipboard_data; } +static FL_EXPORT inline void *event_clipboard() { return e_clipboard_data; } /** Returns the type of the pasted data during an FL_PASTE event. This type can be Fl::clipboard_plain_text or Fl::clipboard_image. */ -FL_EXPORT inline const char *event_clipboard_type() { return e_clipboard_type; } +static FL_EXPORT inline const char *event_clipboard_type() { return e_clipboard_type; } // // Advanced Event Functions // -FL_EXPORT extern int compose(int &del); -FL_EXPORT extern void compose_reset(); -FL_EXPORT extern int event_inside(int,int,int,int); -FL_EXPORT extern int event_inside(const Fl_Widget*); -FL_EXPORT extern int test_shortcut(Fl_Shortcut); +static FL_EXPORT int compose(int &del); +static FL_EXPORT void compose_reset(); +static FL_EXPORT int event_inside(int,int,int,int); +static FL_EXPORT int event_inside(const Fl_Widget*); +static FL_EXPORT int test_shortcut(Fl_Shortcut); -FL_EXPORT extern void enable_im(); -FL_EXPORT extern void disable_im(); +static FL_EXPORT void enable_im(); +static FL_EXPORT void disable_im(); // // Event Handling and Widget Management // -FL_EXPORT extern int handle(int, Fl_Window*); -FL_EXPORT extern int handle_(int, Fl_Window*); +static FL_EXPORT int handle(int, Fl_Window*); +static FL_EXPORT int handle_(int, Fl_Window*); /** Gets the widget that is below the mouse. \see belowmouse(Fl_Widget*) */ -FL_EXPORT inline Fl_Widget* belowmouse() { return belowmouse_; } -FL_EXPORT extern void belowmouse(Fl_Widget*); +static FL_EXPORT inline Fl_Widget* belowmouse() { return belowmouse_; } +static FL_EXPORT void belowmouse(Fl_Widget*); /** Gets the widget that is being pushed. \see void pushed(Fl_Widget*) */ -FL_EXPORT inline Fl_Widget* pushed() { return pushed_; } -FL_EXPORT extern void pushed(Fl_Widget*); +static FL_EXPORT inline Fl_Widget* pushed() { return pushed_; } +static FL_EXPORT void pushed(Fl_Widget*); /** Gets the current Fl::focus() widget. \sa Fl::focus(Fl_Widget*) */ -FL_EXPORT inline Fl_Widget* focus() { return focus_; } -FL_EXPORT extern void focus(Fl_Widget*); +static FL_EXPORT inline Fl_Widget* focus() { return focus_; } +static FL_EXPORT void focus(Fl_Widget*); -FL_EXPORT extern void add_handler(Fl_Event_Handler ha); -FL_EXPORT extern void add_handler(Fl_Event_Handler ha, Fl_Event_Handler before); -FL_EXPORT extern Fl_Event_Handler last_handler(); -FL_EXPORT extern void remove_handler(Fl_Event_Handler h); -FL_EXPORT extern void add_system_handler(Fl_System_Handler h, void *data); -FL_EXPORT extern void remove_system_handler(Fl_System_Handler h); -FL_EXPORT extern void event_dispatch(Fl_Event_Dispatch d); -FL_EXPORT extern Fl_Event_Dispatch event_dispatch(); -FL_EXPORT extern Fl_Callback_Reason callback_reason(); +static FL_EXPORT void add_handler(Fl_Event_Handler ha); +static FL_EXPORT void add_handler(Fl_Event_Handler ha, Fl_Event_Handler before); +static FL_EXPORT Fl_Event_Handler last_handler(); +static FL_EXPORT void remove_handler(Fl_Event_Handler h); +static FL_EXPORT void add_system_handler(Fl_System_Handler h, void *data); +static FL_EXPORT void remove_system_handler(Fl_System_Handler h); +static FL_EXPORT void event_dispatch(Fl_Event_Dispatch d); +static FL_EXPORT Fl_Event_Dispatch event_dispatch(); +static FL_EXPORT Fl_Callback_Reason callback_reason(); // // Convenience State Check Functions // /** Returns non-zero if the Shift key is pressed. */ -FL_EXPORT inline int event_shift() { return e_state & FL_SHIFT; } +static FL_EXPORT inline int event_shift() { return e_state & FL_SHIFT; } /** Returns non-zero if the Control key is pressed. */ -FL_EXPORT inline int event_ctrl() { return e_state & FL_CTRL; } +static FL_EXPORT inline int event_ctrl() { return e_state & FL_CTRL; } /** Returns non-zero if the FL_COMMAND key is pressed, either FL_CTRL or on OSX FL_META. */ -FL_EXPORT inline int event_command() { return e_state & FL_COMMAND; } +static FL_EXPORT inline int event_command() { return e_state & FL_COMMAND; } /** Returns non-zero if the Alt key is pressed. */ -FL_EXPORT inline int event_alt() { return e_state & FL_ALT; } +static FL_EXPORT inline int event_alt() { return e_state & FL_ALT; } // // Mouse Button State Functions @@ -458,40 +440,36 @@ FL_EXPORT inline int event_alt() { return e_state & FL_ALT; } caused an FL_RELEASE event, you can use Fl::event_button() instead. \return a bit mask value like { [FL_BUTTON1] | [FL_BUTTON2] | ... | [FL_BUTTON5] } */ -FL_EXPORT inline int event_buttons() { return e_state & FL_BUTTONS; } +static FL_EXPORT inline int event_buttons() { return e_state & FL_BUTTONS; } /** Returns non-zero if mouse button 1 is currently held down. For more details, see Fl::event_buttons(). */ -FL_EXPORT inline int event_button1() { return e_state & FL_BUTTON1; } +static FL_EXPORT inline int event_button1() { return e_state & FL_BUTTON1; } /** Returns non-zero if mouse button 2 is currently held down. For more details, see Fl::event_buttons(). */ -FL_EXPORT inline int event_button2() { return e_state & FL_BUTTON2; } +static FL_EXPORT inline int event_button2() { return e_state & FL_BUTTON2; } /** Returns non-zero if mouse button 3 is currently held down. For more details, see Fl::event_buttons(). */ -FL_EXPORT inline int event_button3() { return e_state & FL_BUTTON3; } +static FL_EXPORT inline int event_button3() { return e_state & FL_BUTTON3; } /** Returns non-zero if mouse button 4 is currently held down. For more details, see Fl::event_buttons(). */ -FL_EXPORT inline int event_button4() { return e_state & FL_BUTTON4; } +static FL_EXPORT inline int event_button4() { return e_state & FL_BUTTON4; } /** Returns non-zero if mouse button 5 is currently held down. For more details, see Fl::event_buttons(). */ -FL_EXPORT inline int event_button5() { return e_state & FL_BUTTON5; } +static FL_EXPORT inline int event_button5() { return e_state & FL_BUTTON5; } /** @} */ - -} // namespace Fl - -#endif // !Fl_core_events_H diff --git a/FL/core/options.H b/FL/core/options.H index 43f4bec20..0ecdfabeb 100644 --- a/FL/core/options.H +++ b/FL/core/options.H @@ -16,16 +16,10 @@ /** \file FL/core/options.H \brief Application and system wide options management. + This file is included within class Fl in FL/Fl.H. */ -#ifndef Fl_core_options_H -#define Fl_core_options_H - -#include <FL/fl_config.h> // build configuration -#include <FL/Fl_Export.H> // for FL_EXPORT - - -namespace Fl { +// --- Options declarations --- /** Enumerator for global FLTK options. These options can be set system wide, per user, or for the running @@ -102,8 +96,8 @@ typedef enum { /// When switched on and when the keyboard in use has '+' in the shifted position of its key, /// pressing that key and ctrl triggers the zoom-in operation. /// When switched off (default), the zoom-in operation requires that also the shift key is pressed. - /// Under macOS, this option has no effect because the OS itself generates ⌘= followed - /// by ⌘+ when pressing ⌘ and the '=|+' key without pressing shift. + /// Under macOS, this option has no effect because the OS itself generates cmd= followed + /// by cmd+ when pressing cmd and the '=|+' key without pressing shift. OPTION_SIMPLE_ZOOM_SHORTCUT, // don't change this, leave it always as the last element @@ -115,12 +109,12 @@ typedef enum { Return a global setting for all FLTK applications, possibly overridden by a setting specifically for this application. */ -FL_EXPORT extern bool option(Fl_Option opt); +static FL_EXPORT bool option(Fl_Option opt); /* Override an option while the application is running. */ -FL_EXPORT extern void option(Fl_Option opt, bool val); +static FL_EXPORT void option(Fl_Option opt, bool val); // Visible focus methods... @@ -129,14 +123,14 @@ FL_EXPORT extern void option(Fl_Option opt, bool val); non-text widgets. The default mode is to enable keyboard focus for all widgets. */ -FL_EXPORT inline void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); } +static FL_EXPORT inline void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); } /** Gets or sets the visible keyboard focus on buttons and other non-text widgets. The default mode is to enable keyboard focus for all widgets. */ -FL_EXPORT inline int visible_focus() { return option(OPTION_VISIBLE_FOCUS); } +static FL_EXPORT inline int visible_focus() { return option(OPTION_VISIBLE_FOCUS); } // Drag-n-drop text operation methods... @@ -146,7 +140,7 @@ FL_EXPORT inline int visible_focus() { return option(OPTION_VISIBLE_FOCUS); } be dragged from text fields or dragged within a text field as a cut/paste shortcut. */ -FL_EXPORT inline void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); } +static FL_EXPORT inline void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); } /** Gets whether drag and drop text operations are @@ -154,9 +148,4 @@ FL_EXPORT inline void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); } be dragged from text fields or dragged within a text field as a cut/paste shortcut. */ -FL_EXPORT inline int dnd_text_ops() { return option(OPTION_DND_TEXT); } - -} // namespace Fl - - -#endif // !Fl_core_options_H +static FL_EXPORT inline int dnd_text_ops() { return option(OPTION_DND_TEXT); } |
