mirror of
https://github.com/fltk/fltk.git
synced 2026-09-28 15:55:22 +08:00
Refactor large static class Fl into an expandable namespace Fl (#1325)
* Change class Fl into namespace Fl. * Untangle Fl namespace into themed headers. * cut line count of FL/Fl.H in half * FL/core subdirectory now holds short headers grouped by functionality.
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// Widget Tracker header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2025 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// https://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please see the following page on how to report bugs and issues:
|
||||
//
|
||||
// https://www.fltk.org/bugs.php
|
||||
//
|
||||
|
||||
/** \file FL/Fl_Widget_Tracker.H
|
||||
\brief Track widget deletion.
|
||||
*/
|
||||
|
||||
#ifndef Fl_Widget_Tracker_H
|
||||
#define Fl_Widget_Tracker_H
|
||||
|
||||
#include <FL/fl_config.h> // build configuration
|
||||
#include <FL/Fl_Export.H>
|
||||
|
||||
class Fl_Widget;
|
||||
|
||||
|
||||
/**
|
||||
This class should be used to control safe widget deletion.
|
||||
|
||||
You can use an Fl_Widget_Tracker object to watch another widget, if you
|
||||
need to know whether this widget has been deleted during a callback.
|
||||
|
||||
This simplifies the use of the "safe widget deletion" methods
|
||||
Fl::watch_widget_pointer() and Fl::release_widget_pointer() and
|
||||
makes their use more reliable, because the destructor automatically
|
||||
releases the widget pointer from the widget watch list.
|
||||
|
||||
Fl_Widget_Tracker is intended to be used as an automatic (local/stack)
|
||||
variable, such that its destructor is called when the object's
|
||||
scope is left. This ensures that no stale widget pointers are
|
||||
left in the widget watch list (see example below).
|
||||
|
||||
You can also create Fl_Widget_Tracker objects with \c new, but then it
|
||||
is your responsibility to delete the object (and thus remove the
|
||||
widget pointer from the watch list) when it is no longer needed.
|
||||
|
||||
Example:
|
||||
|
||||
\code
|
||||
int MyClass::handle (int event) {
|
||||
|
||||
if (...) {
|
||||
Fl_Widget_Tracker wp(this); // watch myself
|
||||
do_callback(); // call the callback
|
||||
|
||||
if (wp.deleted()) return 1; // exit, if deleted
|
||||
|
||||
// Now we are sure that the widget has not been deleted,
|
||||
// and it is safe to access the widget:
|
||||
|
||||
box(FL_FLAT_BOX);
|
||||
color(FL_WHITE);
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
*/
|
||||
class FL_EXPORT Fl_Widget_Tracker {
|
||||
|
||||
Fl_Widget* wp_;
|
||||
|
||||
public:
|
||||
|
||||
Fl_Widget_Tracker(Fl_Widget *wi);
|
||||
~Fl_Widget_Tracker();
|
||||
|
||||
/**
|
||||
Returns a pointer to the watched widget.
|
||||
\return nullptr if the widget was deleted.
|
||||
*/
|
||||
Fl_Widget *widget() { return wp_; }
|
||||
|
||||
/**
|
||||
Check if the widget was deleted since the tracker was created.
|
||||
\return 1 if the watched widget has been deleted, otherwise 0
|
||||
*/
|
||||
int deleted() {return wp_ == 0;}
|
||||
|
||||
/**
|
||||
Check if the widget exists and was not deleted since the tracker was created.
|
||||
\return 1 if the watched widget exists, otherwise 0
|
||||
*/
|
||||
int exists() { return wp_ != 0; }
|
||||
|
||||
};
|
||||
|
||||
namespace Fl {
|
||||
|
||||
/** \defgroup fl_del_widget Safe widget deletion support functions
|
||||
|
||||
These functions, declared in <FL/Fl.H>, support deletion of widgets inside callbacks.
|
||||
|
||||
Fl::delete_widget() should be called when deleting widgets
|
||||
or complete widget trees (Fl_Group, Fl_Window, ...) inside
|
||||
callbacks.
|
||||
|
||||
The other functions are intended for internal use. The preferred
|
||||
way to use them is by using the helper class Fl_Widget_Tracker.
|
||||
|
||||
The following is to show how it works ...
|
||||
|
||||
There are three groups of related methods:
|
||||
|
||||
-# scheduled widget deletion
|
||||
- Fl::delete_widget() schedules widgets for deletion
|
||||
- Fl::do_widget_deletion() deletes all scheduled widgets
|
||||
-# widget watch list ("smart pointers")
|
||||
- Fl::watch_widget_pointer() adds a widget pointer to the watch list
|
||||
- Fl::release_widget_pointer() removes a widget pointer from the watch list
|
||||
- Fl::clear_widget_pointer() clears a widget pointer \e in the watch list
|
||||
-# the class Fl_Widget_Tracker:
|
||||
- the constructor calls Fl::watch_widget_pointer()
|
||||
- the destructor calls Fl::release_widget_pointer()
|
||||
- the access methods can be used to test, if a widget has been deleted
|
||||
\see Fl_Widget_Tracker.
|
||||
|
||||
@{ */
|
||||
|
||||
// Widget deletion:
|
||||
FL_EXPORT extern void delete_widget(Fl_Widget *w);
|
||||
FL_EXPORT extern void do_widget_deletion();
|
||||
FL_EXPORT extern void watch_widget_pointer(Fl_Widget *&w);
|
||||
FL_EXPORT extern void release_widget_pointer(Fl_Widget *&w);
|
||||
FL_EXPORT extern void clear_widget_pointer(Fl_Widget const *w);
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace Fl
|
||||
|
||||
#endif // !Fl_Widget_Tracker_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,141 @@
|
||||
//
|
||||
// Function types for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2025 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// https://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please see the following page on how to report bugs and issues:
|
||||
//
|
||||
// https://www.fltk.org/bugs.php
|
||||
//
|
||||
|
||||
/** \file FL/core/function_types.H
|
||||
\brief FLTK typedefs for service and widget callbacks.
|
||||
*/
|
||||
|
||||
#ifndef Fl_core_function_types_H
|
||||
#define Fl_core_function_types_H
|
||||
|
||||
|
||||
#include <FL/fl_config.h> // build configuration
|
||||
#include <FL/Fl_Export.H> // for FL_EXPORT
|
||||
#include <FL/platform_types.h> // for FL_SOCKET
|
||||
#include <FL/Enumerations.H> // for Fl_Align, Fl_Color, etc.
|
||||
|
||||
class Fl_Window;
|
||||
struct Fl_Label;
|
||||
|
||||
|
||||
/** \defgroup callback_functions Callback Function Typedefs
|
||||
|
||||
\brief Typedefs defined in <FL/core/function_types.H> for callback or handler functions passed as function parameters.
|
||||
|
||||
FLTK uses callback functions as parameters for some function calls, e.g. to
|
||||
set up global event handlers (Fl::add_handler()), to add a timeout handler
|
||||
(Fl::add_timeout()), and many more.
|
||||
|
||||
The typedefs defined in this group describe the function parameters used to set
|
||||
up or clear the callback functions and should also be referenced to define the
|
||||
callback function to handle such events in the user's code.
|
||||
|
||||
\see Fl::add_handler(), Fl::add_timeout(), Fl::repeat_timeout(),
|
||||
Fl::remove_timeout() and others
|
||||
|
||||
@{
|
||||
*/
|
||||
|
||||
//
|
||||
// Drawing and Rendering Function Types
|
||||
//
|
||||
|
||||
/** Signature of some label drawing functions passed as parameters */
|
||||
typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
|
||||
|
||||
/** Signature of some label measurement functions passed as parameters */
|
||||
typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height);
|
||||
|
||||
/** Signature of some box drawing functions passed as parameters */
|
||||
typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color);
|
||||
|
||||
/** Signature of box focus frame drawing functions */
|
||||
typedef void (Fl_Box_Draw_Focus_F)(Fl_Boxtype bt, int x, int y, int w, int h, Fl_Color fg, Fl_Color bg);
|
||||
|
||||
//
|
||||
// Timer and Scheduling Function Types
|
||||
//
|
||||
|
||||
/** Signature of timeout callback functions passed as parameters.
|
||||
Please see Fl::add_timeout() for details.
|
||||
*/
|
||||
typedef void (*Fl_Timeout_Handler)(void *data);
|
||||
|
||||
/** Signature of some wakeup callback functions passed as parameters */
|
||||
typedef void (*Fl_Awake_Handler)(void *data);
|
||||
|
||||
//
|
||||
// Idle Processing Function Types
|
||||
//
|
||||
|
||||
/** Signature of add_idle callback function passed as parameter.
|
||||
This signature allows an idle callback to use one parameter as an
|
||||
arbitrary `data` value.
|
||||
*/
|
||||
typedef void (*Fl_Idle_Handler)(void *data);
|
||||
|
||||
/** Signature of add_idle callback function passed as parameter.
|
||||
This signature allows an idle callback without parameters.
|
||||
When the callback is called it is called with an additional
|
||||
parameter (set to nullptr) which is not used by the callback.
|
||||
*/
|
||||
typedef void (*Fl_Old_Idle_Handler)();
|
||||
|
||||
//
|
||||
// File Descriptor and I/O Function Types
|
||||
//
|
||||
|
||||
/** Signature of add_fd functions passed as parameters */
|
||||
typedef void (*Fl_FD_Handler)(FL_SOCKET fd, void *data);
|
||||
|
||||
//
|
||||
// Event Handling Function Types
|
||||
//
|
||||
|
||||
/** Signature of add_handler functions passed as parameters */
|
||||
typedef int (*Fl_Event_Handler)(int event);
|
||||
|
||||
/** Signature of add_system_handler functions passed as parameters */
|
||||
typedef int (*Fl_System_Handler)(void *event, void *data);
|
||||
|
||||
/** Signature of event_dispatch functions passed as parameters.
|
||||
\see Fl::event_dispatch(Fl_Event_Dispatch) */
|
||||
typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
|
||||
|
||||
//
|
||||
// Application Lifecycle Function Types
|
||||
//
|
||||
|
||||
/** Signature of set_abort functions passed as parameters */
|
||||
typedef void (*Fl_Abort_Handler)(const char *format,...);
|
||||
|
||||
/** Signature of set_atclose functions passed as parameters */
|
||||
typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data);
|
||||
|
||||
/** Signature of args functions passed as parameters */
|
||||
typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
|
||||
|
||||
//
|
||||
// Clipboard and Data Transfer Function Types
|
||||
//
|
||||
|
||||
/** Signature of add_clipboard_notify functions passed as parameters */
|
||||
typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data);
|
||||
|
||||
/** @} */ /* group callback_functions */
|
||||
|
||||
|
||||
#endif // !Fl_core_function_types_H
|
||||
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// Core options header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2025 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// https://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please see the following page on how to report bugs and issues:
|
||||
//
|
||||
// https://www.fltk.org/bugs.php
|
||||
//
|
||||
|
||||
/** \file FL/core/options.H
|
||||
\brief Application and system wide options management.
|
||||
*/
|
||||
|
||||
#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 {
|
||||
|
||||
/** Enumerator for global FLTK options.
|
||||
These options can be set system wide, per user, or for the running
|
||||
application only.
|
||||
\see Fl::option(Fl_Option, bool)
|
||||
\see Fl::option(Fl_Option)
|
||||
*/
|
||||
typedef enum {
|
||||
|
||||
/// When switched on, moving the text cursor beyond the start or end of
|
||||
/// a text in a text widget will change focus to the next text widget.
|
||||
/// (This is considered 'old' behavior)
|
||||
///
|
||||
/// When switched off (default), the cursor will stop at the end of the text.
|
||||
/// Pressing Tab or Ctrl-Tab will advance the keyboard focus.
|
||||
///
|
||||
/// See also: Fl_Input_::tab_nav()
|
||||
///
|
||||
OPTION_ARROW_FOCUS = 0,
|
||||
|
||||
|
||||
// When switched on, FLTK will use the file chooser dialog that comes
|
||||
// with your operating system whenever possible. When switched off, FLTK
|
||||
// will present its own file chooser.
|
||||
// \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 (default), 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 (default), 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 (default), hovering the mouse over a widget with a
|
||||
/// tooltip text will open a little tooltip window until the mouse leaves
|
||||
/// the widget. If disabled, no tooltip is shown.
|
||||
OPTION_SHOW_TOOLTIPS,
|
||||
|
||||
/// When switched on (default), Fl_Native_File_Chooser runs GTK file dialogs
|
||||
/// if the GTK library is available on the platform (linux/unix only).
|
||||
/// When switched off, GTK file dialogs aren't used even if the GTK library is available.
|
||||
OPTION_FNFC_USES_GTK,
|
||||
|
||||
/// Meaningful for the Wayland/X11 platform only. When switched on, the library uses a Zenity-based file dialog.
|
||||
/// When switched off (default), no zenity-based file dialog is used.
|
||||
OPTION_FNFC_USES_ZENITY,
|
||||
|
||||
/// Meaningful for the Wayland/X11 platform only.
|
||||
/// When switched on, the library uses a kdialog-based file dialog if command 'kdialog' is available on the running system.
|
||||
/// When switched off (default), no kdialog-based file dialog is used.
|
||||
OPTION_FNFC_USES_KDIALOG,
|
||||
|
||||
/// When switched on (default), Fl_Printer runs the GTK printer dialog
|
||||
/// if the GTK library is available on the platform (linux/unix only).
|
||||
/// When switched off, the GTK printer dialog isn't used even if the GTK library is available.
|
||||
OPTION_PRINTER_USES_GTK,
|
||||
|
||||
/// When switched on (default), the library shows in a transient yellow window the zoom factor
|
||||
/// value.
|
||||
/// When switched off, no such window gets displayed.
|
||||
OPTION_SHOW_SCALING,
|
||||
|
||||
/// 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.
|
||||
OPTION_SIMPLE_ZOOM_SHORTCUT,
|
||||
|
||||
// don't change this, leave it always as the last element
|
||||
/// For internal use only.
|
||||
OPTION_LAST
|
||||
} Fl_Option;
|
||||
|
||||
/*
|
||||
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);
|
||||
|
||||
/*
|
||||
Override an option while the application is running.
|
||||
*/
|
||||
FL_EXPORT extern void option(Fl_Option opt, bool val);
|
||||
|
||||
// Visible focus methods...
|
||||
|
||||
/**
|
||||
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 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); }
|
||||
|
||||
// Drag-n-drop text operation methods...
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
FL_EXPORT inline void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); }
|
||||
|
||||
/**
|
||||
Gets whether drag and drop text operations are
|
||||
supported. This returns whether selected text can
|
||||
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
|
||||
+10
-2
@@ -189,10 +189,17 @@ if(FLTK_HAVE_CAIRO) # FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT
|
||||
list(APPEND CPPFILES Fl_Cairo.cxx)
|
||||
endif()
|
||||
|
||||
# find all header files in source directory <FL/...>
|
||||
# find all header files in includes directory <FL/...>
|
||||
file(GLOB
|
||||
HEADER_FILES
|
||||
"../FL/*.[hH]"
|
||||
"../FL/core/*.[hH]"
|
||||
)
|
||||
|
||||
# find all private header files in source directory "src/..."
|
||||
file(GLOB
|
||||
PRIVATE_HEADER_FILES
|
||||
"*.[hH]"
|
||||
)
|
||||
|
||||
# add generated header files in build directory
|
||||
@@ -409,6 +416,7 @@ else()
|
||||
endif(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND)
|
||||
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
source_group("Private Header Files" FILES ${PRIVATE_HEADER_FILES})
|
||||
source_group("Driver Source Files" FILES ${DRIVER_FILES})
|
||||
source_group("Driver Header Files" FILES ${DRIVER_HEADER_FILES})
|
||||
|
||||
@@ -622,7 +630,7 @@ endif()
|
||||
# prepare source files for shared and static FLTK libraries
|
||||
|
||||
set(SHARED_FILES ${CPPFILES} ${MMFILES} ${CFILES} ${PSFILES})
|
||||
list(APPEND SHARED_FILES ${HEADER_FILES} ${DRIVER_HEADER_FILES})
|
||||
list(APPEND SHARED_FILES ${HEADER_FILES} ${PRIVATE_HEADER_FILES} ${DRIVER_HEADER_FILES})
|
||||
|
||||
set(STATIC_FILES ${SHARED_FILES})
|
||||
|
||||
|
||||
+158
-42
File diff suppressed because it is too large
Load Diff
+52
-6
@@ -23,7 +23,7 @@
|
||||
// Preprocessor macro FLTK_HAVE_CAIRO_EXT is defined only for "CAIRO_EXT".
|
||||
// Both macros are defined in 'FL/fl_config.h'.
|
||||
|
||||
#include <FL/Fl.H> // includes <FL/fl_config.h>
|
||||
#include "Fl_Private.H" // includes <FL/fl_config.h>
|
||||
|
||||
#ifdef FLTK_HAVE_CAIRO
|
||||
|
||||
@@ -61,7 +61,53 @@
|
||||
|
||||
// static initialization
|
||||
|
||||
Fl_Cairo_State Fl::cairo_state_; ///< current Cairo context information
|
||||
Fl_Cairo_State Fl::Private::cairo_state_; ///< current Cairo context information
|
||||
|
||||
/** When FLTK_HAVE_CAIRO is defined and cairo_autolink_context() is true,
|
||||
any current window dc is linked to a current Cairo context.
|
||||
This is not the default, because it may not be necessary
|
||||
to add Cairo support to all fltk supported windows.
|
||||
When you wish to associate a Cairo context in this mode,
|
||||
you need to call explicitly in your draw() overridden method,
|
||||
Fl::cairo_make_current(Fl_Window*). This will create a Cairo context
|
||||
only for this Window.
|
||||
Still in custom Cairo application it is possible to handle
|
||||
completely this process automatically by setting \p alink to true.
|
||||
In this last case, you don't need anymore to call Fl::cairo_make_current().
|
||||
You can use Fl::cairo_cc() to get the current Cairo context anytime.
|
||||
|
||||
\note Only available if built with CMake option FLTK_OPTION_CAIRO_WINDOW=ON.
|
||||
*/
|
||||
void Fl::cairo_autolink_context(bool alink) {
|
||||
Private::cairo_state_.autolink(alink);
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the current autolink mode for Cairo support.
|
||||
\retval false if no Cairo context autolink is made for each window.
|
||||
\retval true if any fltk window is attached a Cairo context when it
|
||||
is current. \see void cairo_autolink_context(bool alink)
|
||||
|
||||
\note Only available if built with CMake option FLTK_OPTION_CAIRO_EXT=ON.
|
||||
*/
|
||||
bool Fl::cairo_autolink_context() {
|
||||
return Private::cairo_state_.autolink();
|
||||
}
|
||||
|
||||
/** Gets the current Cairo context linked with a fltk window. */
|
||||
cairo_t *Fl::cairo_cc() {
|
||||
return Private::cairo_state_.cc();
|
||||
}
|
||||
|
||||
/** Sets the current Cairo context to \p c.
|
||||
Set \p own to true if you want fltk to handle this cc deletion.
|
||||
|
||||
\note Only available if built with CMake option FLTK_OPTION_CAIRO_WINDOW=ON.
|
||||
*/
|
||||
void Fl::cairo_cc(cairo_t *c, bool own=false) {
|
||||
Private::cairo_state_.cc(c, own);
|
||||
}
|
||||
|
||||
|
||||
// Fl_Cairo_State
|
||||
|
||||
@@ -131,10 +177,10 @@ cairo_t *Fl::cairo_make_current(Fl_Window *wi) {
|
||||
#endif
|
||||
|
||||
#if defined(FLTK_USE_X11)
|
||||
cairo_ctxt = Fl::cairo_make_current(0, wi->w() * scale, wi->h() * scale);
|
||||
cairo_ctxt = Fl::Private::cairo_make_current(0, wi->w() * scale, wi->h() * scale);
|
||||
#else
|
||||
// on macOS, scaling is done before by Fl_Window::make_current(), on Windows, the size is not used
|
||||
cairo_ctxt = Fl::cairo_make_current(fl_gc, wi->w(), wi->h());
|
||||
cairo_ctxt = Fl::Private::cairo_make_current(fl_gc, wi->w(), wi->h());
|
||||
#endif
|
||||
|
||||
#if !defined(USE_MAC_OS)
|
||||
@@ -169,7 +215,7 @@ static cairo_surface_t *cairo_create_surface(void *gc, int W, int H) {
|
||||
|
||||
\note Only available if CMake FLTK_OPTION_CAIRO_WINDOW is enabled.
|
||||
*/
|
||||
cairo_t *Fl::cairo_make_current(void *gc) {
|
||||
cairo_t *Fl::Private::cairo_make_current(void *gc) {
|
||||
int W = 0, H = 0;
|
||||
#if defined(FLTK_USE_X11) || defined(FLTK_USE_WAYLAND)
|
||||
// FIXME X11 get W,H
|
||||
@@ -211,7 +257,7 @@ cairo_t *Fl::cairo_make_current(void *gc) {
|
||||
|
||||
\note Only available if CMake FLTK_OPTION_CAIRO_WINDOW is enabled.
|
||||
*/
|
||||
cairo_t *Fl::cairo_make_current(void *gc, int W, int H) {
|
||||
cairo_t *Fl::Private::cairo_make_current(void *gc, int W, int H) {
|
||||
if (gc == Fl::cairo_state_.gc() &&
|
||||
fl_window == (Window)Fl::cairo_state_.window() &&
|
||||
cairo_state_.cc() != 0) // no need to create a cc, just return that one
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// Private header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2025 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// https://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please see the following page on how to report bugs and issues:
|
||||
//
|
||||
// https://www.fltk.org/bugs.php
|
||||
//
|
||||
|
||||
/** \file src/Fl_Private.H
|
||||
\brief Fl::Private namespace.
|
||||
*/
|
||||
|
||||
#ifndef Fl_Private_H
|
||||
#define Fl_Private_H
|
||||
|
||||
#include <FL/fl_config.h> // build configuration
|
||||
#include <FL/Fl.H>
|
||||
|
||||
/**
|
||||
FLTK private global variables and functions.
|
||||
*/
|
||||
namespace Fl {
|
||||
namespace Private {
|
||||
|
||||
FL_EXPORT extern int use_high_res_GL_;
|
||||
FL_EXPORT extern int draw_GL_text_with_textures_;
|
||||
FL_EXPORT extern int box_shadow_width_;
|
||||
FL_EXPORT extern int box_border_radius_max_;
|
||||
FL_EXPORT extern int selection_to_clipboard_;
|
||||
|
||||
FL_EXPORT extern unsigned char options_[OPTION_LAST];
|
||||
FL_EXPORT extern unsigned char options_read_;
|
||||
FL_EXPORT extern int program_should_quit_; // non-zero means the program was asked to cleanly terminate
|
||||
|
||||
/**
|
||||
The currently executing idle callback function: DO NOT USE THIS DIRECTLY!
|
||||
|
||||
This is now used as part of a higher level system allowing multiple
|
||||
idle callback functions to be called.
|
||||
\see add_idle(), remove_idle()
|
||||
*/
|
||||
FL_EXPORT extern void (*idle_)();
|
||||
|
||||
FL_EXPORT extern void run_idle();
|
||||
FL_EXPORT extern void run_checks();
|
||||
|
||||
/**
|
||||
Sets an idle callback (internal use only).
|
||||
|
||||
This method is now private and is used to store the idle callback.
|
||||
The old, public set_idle() method was deprecated since 1.3.x and
|
||||
is no longer available in FLTK 1.5.
|
||||
|
||||
See documentation: use Fl::add_idle() instead.
|
||||
*/
|
||||
FL_EXPORT inline void set_idle_(Fl_Old_Idle_Handler cb) { idle_ = cb; }
|
||||
|
||||
#ifdef FLTK_HAVE_CAIRO
|
||||
|
||||
FL_EXPORT extern cairo_t *cairo_make_current(void *gc);
|
||||
FL_EXPORT extern cairo_t *cairo_make_current(void *gc, int W, int H);
|
||||
FL_EXPORT extern Fl_Cairo_State cairo_state_;
|
||||
|
||||
#endif // FLTK_HAVE_CAIRO
|
||||
|
||||
} // namespace Private
|
||||
} // namespace Fl
|
||||
|
||||
#endif // !Fl_Private_H
|
||||
@@ -58,7 +58,7 @@ class Fl_Sys_Menu_Bar_Driver;
|
||||
Each supported platform implements several of the virtual methods of this class.
|
||||
*/
|
||||
class Fl_System_Driver {
|
||||
friend class Fl;
|
||||
friend Fl_System_Driver *Fl::system_driver();
|
||||
protected:
|
||||
// implement once for each platform
|
||||
static Fl_System_Driver *newSystemDriver();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "Fl_System_Driver.H"
|
||||
#include <FL/Fl.H>
|
||||
#include "Fl_Private.H"
|
||||
#include "Fl_Timeout.h"
|
||||
#include <FL/Fl_File_Icon.H>
|
||||
#include <FL/fl_utf8.h>
|
||||
@@ -357,8 +357,8 @@ double Fl_System_Driver::wait(double time_to_wait) {
|
||||
Fl::do_widget_deletion();
|
||||
|
||||
Fl_Timeout::do_timeouts();
|
||||
Fl::run_checks();
|
||||
Fl::run_idle();
|
||||
Fl::Private::run_checks();
|
||||
Fl::Private::run_idle();
|
||||
|
||||
// The idle function may turn off idle() if *all* idle callbacks
|
||||
// are removed from the callback queue (ring), we can then wait.
|
||||
|
||||
+3
-1
@@ -173,8 +173,10 @@ void Fl::default_atclose(Fl_Window* window, void* v) {
|
||||
window->hide();
|
||||
Fl_Widget::default_callback(window, v); // put on Fl::read_queue()
|
||||
}
|
||||
|
||||
/** Back compatibility: default window callback handler \see Fl::set_atclose() */
|
||||
void (*Fl::atclose)(Fl_Window*, void*) = default_atclose;
|
||||
void (*Fl::atclose)(Fl_Window*, void*) = Fl::default_atclose;
|
||||
|
||||
/** Back compatibility: Sets the default callback v for win to call on close event */
|
||||
void Fl_Window::default_callback(Fl_Window* win, void* v) {
|
||||
Fl::atclose(win, v);
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@
|
||||
// Replaces the older set_idle() call which has been renamed to set_idle_(),
|
||||
// is now private in class Fl::, and is used to implement this.
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include "Fl_Private.H"
|
||||
|
||||
struct idle_cb {
|
||||
void (*cb)(void*);
|
||||
@@ -83,7 +83,7 @@ void Fl::add_idle(Fl_Idle_Handler cb, void* data) {
|
||||
} else {
|
||||
first = last = p;
|
||||
p->next = p;
|
||||
set_idle_(call_idle);
|
||||
Private::set_idle_(call_idle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void Fl::remove_idle(Fl_Idle_Handler cb, void* data) {
|
||||
}
|
||||
if (l == p) { // only one
|
||||
first = last = 0;
|
||||
set_idle_(0);
|
||||
Private::set_idle_(0);
|
||||
} else {
|
||||
last = l;
|
||||
first = l->next = p->next;
|
||||
|
||||
+42
-3
@@ -23,7 +23,7 @@
|
||||
// boxtypes. Other box types are in separate files so they are not
|
||||
// linked in if not used.
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include "src/Fl_Private.H"
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <config.h>
|
||||
@@ -46,8 +46,47 @@ static const uchar inactive_ramp[24] = {
|
||||
51, 51, 52, 52};
|
||||
static int draw_it_active = 1;
|
||||
|
||||
int Fl::box_border_radius_max_ = 15;
|
||||
int Fl::box_shadow_width_ = 3;
|
||||
int Fl::Private::box_border_radius_max_ = 15;
|
||||
|
||||
/** Get the maximum border radius of all "rounded" boxtypes in pixels.
|
||||
\since 1.4.0
|
||||
*/
|
||||
int Fl::box_border_radius_max() {
|
||||
return Private::box_border_radius_max_;
|
||||
}
|
||||
|
||||
/** Set the maximum border radius of all "rounded" boxtypes in pixels.
|
||||
Must be at least 5, default = 15.
|
||||
|
||||
\note This does \b not apply to the "round" boxtypes which have really round sides
|
||||
(i.e. composed of half circles) as opposed to "rounded" boxtypes that have only
|
||||
rounded corners with a straight border between corners.
|
||||
|
||||
The box border radius of "rounded" boxtypes is typically calculated as about 2/5 of
|
||||
the box height or width, whichever is smaller. The upper limit can be set by this
|
||||
method for all "rounded" boxtypes.
|
||||
\since 1.4.0
|
||||
*/
|
||||
void Fl::box_border_radius_max(int R) {
|
||||
Private::box_border_radius_max_ = R < 5 ? 5 : R;
|
||||
}
|
||||
|
||||
int Fl::Private::box_shadow_width_ = 3;
|
||||
|
||||
/** Get the box shadow width of all "shadow" boxtypes in pixels.
|
||||
\since 1.4.0
|
||||
*/
|
||||
int Fl::box_shadow_width() {
|
||||
return Private::box_shadow_width_;
|
||||
}
|
||||
|
||||
/** Set the box shadow width of all "shadow" boxtypes in pixels.
|
||||
Must be at least 1, default = 3. There is no upper limit.
|
||||
\since 1.4.0
|
||||
*/
|
||||
void Fl::box_shadow_width(int W) {
|
||||
Private::box_shadow_width_ = W < 1 ? 1 : W;
|
||||
}
|
||||
|
||||
/**
|
||||
Determines if the currently drawn box is active or inactive.
|
||||
|
||||
Reference in New Issue
Block a user