Change class Fl into namespace Fl.
This commit is contained in:
parent
ccbb424046
commit
7df997f24d
@ -189,12 +189,18 @@ if(FLTK_HAVE_CAIRO) # FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT
|
|||||||
list(APPEND CPPFILES Fl_Cairo.cxx)
|
list(APPEND CPPFILES Fl_Cairo.cxx)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# find all header files in source directory <FL/...>
|
# find all header files in includes directory <FL/...>
|
||||||
file(GLOB
|
file(GLOB
|
||||||
HEADER_FILES
|
HEADER_FILES
|
||||||
"../FL/*.[hH]"
|
"../FL/*.[hH]"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# find all private header files in source directory "src/..."
|
||||||
|
file(GLOB
|
||||||
|
PRIVATE_HEADER_FILES
|
||||||
|
"*.[hH]"
|
||||||
|
)
|
||||||
|
|
||||||
# add generated header files in build directory
|
# add generated header files in build directory
|
||||||
list(APPEND HEADER_FILES
|
list(APPEND HEADER_FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../FL/fl_config.h
|
${CMAKE_CURRENT_BINARY_DIR}/../FL/fl_config.h
|
||||||
@ -409,6 +415,7 @@ else()
|
|||||||
endif(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND)
|
endif(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND)
|
||||||
|
|
||||||
source_group("Header Files" FILES ${HEADER_FILES})
|
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 Source Files" FILES ${DRIVER_FILES})
|
||||||
source_group("Driver Header Files" FILES ${DRIVER_HEADER_FILES})
|
source_group("Driver Header Files" FILES ${DRIVER_HEADER_FILES})
|
||||||
|
|
||||||
@ -622,7 +629,7 @@ endif()
|
|||||||
# prepare source files for shared and static FLTK libraries
|
# prepare source files for shared and static FLTK libraries
|
||||||
|
|
||||||
set(SHARED_FILES ${CPPFILES} ${MMFILES} ${CFILES} ${PSFILES})
|
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})
|
set(STATIC_FILES ${SHARED_FILES})
|
||||||
|
|
||||||
|
|||||||
200
src/Fl.cxx
200
src/Fl.cxx
@ -18,7 +18,7 @@
|
|||||||
Implementation of the member functions of class Fl.
|
Implementation of the member functions of class Fl.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <FL/Fl.H>
|
#include "Fl_Private.H"
|
||||||
#include <FL/platform.H>
|
#include <FL/platform.H>
|
||||||
#include "Fl_Screen_Driver.H"
|
#include "Fl_Screen_Driver.H"
|
||||||
#include "Fl_Window_Driver.H"
|
#include "Fl_Window_Driver.H"
|
||||||
@ -71,10 +71,10 @@ void *Fl::e_clipboard_data = NULL;
|
|||||||
Fl_Event_Dispatch Fl::e_dispatch = 0;
|
Fl_Event_Dispatch Fl::e_dispatch = 0;
|
||||||
Fl_Callback_Reason Fl::callback_reason_ = FL_REASON_UNKNOWN;
|
Fl_Callback_Reason Fl::callback_reason_ = FL_REASON_UNKNOWN;
|
||||||
|
|
||||||
unsigned char Fl::options_[] = { 0, 0 };
|
unsigned char Fl::Private::options_[] = { 0, 0 };
|
||||||
unsigned char Fl::options_read_ = 0;
|
unsigned char Fl::Private::options_read_ = 0;
|
||||||
|
|
||||||
int Fl::selection_to_clipboard_ = 0;
|
int Fl::Private::selection_to_clipboard_ = 0;
|
||||||
|
|
||||||
Fl_Window *fl_xfocus = NULL; // which window X thinks has focus
|
Fl_Window *fl_xfocus = NULL; // which window X thinks has focus
|
||||||
Fl_Window *fl_xmousewin; // which window X thinks has FL_ENTER
|
Fl_Window *fl_xmousewin; // which window X thinks has FL_ENTER
|
||||||
@ -86,6 +86,45 @@ Fl_Window *Fl::modal_; // topmost modal() window
|
|||||||
char const * const Fl::clipboard_plain_text = "text/plain";
|
char const * const Fl::clipboard_plain_text = "text/plain";
|
||||||
char const * const Fl::clipboard_image = "image";
|
char const * const Fl::clipboard_image = "image";
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copies selections on X11 directly to the clipboard if enabled.
|
||||||
|
|
||||||
|
This method can be called on all platforms. Other platforms than X11 are
|
||||||
|
not affected by this feature.
|
||||||
|
|
||||||
|
If this is switched on (\p mode = 1), Fl::copy() copies all data to the
|
||||||
|
clipboard regardless of its \p destination argument. If the destination is 0
|
||||||
|
(selection buffer) data is copied to both the selection buffer and the clipboard.
|
||||||
|
|
||||||
|
Drag and drop is also affected since drag-and-drop data is copied to the selection
|
||||||
|
buffer.
|
||||||
|
|
||||||
|
You can use this to make the experience of data selection and copying more like
|
||||||
|
that on other platforms (Windows, macOS, and even Wayland).
|
||||||
|
|
||||||
|
The default operation mode is the standard X11 behavior (disabled).
|
||||||
|
|
||||||
|
\note This feature is experimental and enabling it may have unexpected side effects.
|
||||||
|
It is your own responsibility if you enable it.
|
||||||
|
|
||||||
|
\since 1.4.0
|
||||||
|
|
||||||
|
\param[in] mode 1 = enable selection_to_clipboard, 0 = disable selection_to_clipboard
|
||||||
|
|
||||||
|
\see copy(const char *, int, int, const char *)
|
||||||
|
*/
|
||||||
|
void Fl::selection_to_clipboard(int mode) {
|
||||||
|
Private::selection_to_clipboard_ = mode ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Returns the current selection_to_clipboard mode.
|
||||||
|
|
||||||
|
\see void selection_to_clipboard(int)
|
||||||
|
*/
|
||||||
|
int Fl::selection_to_clipboard() {
|
||||||
|
return Private::selection_to_clipboard_;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Drivers
|
// Drivers
|
||||||
@ -500,7 +539,7 @@ int Fl::has_check(Fl_Timeout_Handler cb, void *argp) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl::run_checks()
|
void Fl::Private::run_checks()
|
||||||
{
|
{
|
||||||
// checks are a bit messy so that add/remove and wait may be called
|
// checks are a bit messy so that add/remove and wait may be called
|
||||||
// from inside them without causing an infinite loop:
|
// from inside them without causing an infinite loop:
|
||||||
@ -580,7 +619,23 @@ void fl_trigger_clipboard_notify(int source) {
|
|||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// idle/wait/run/check/ready:
|
// idle/wait/run/check/ready:
|
||||||
|
|
||||||
void (*Fl::idle_)(); // see Fl::add_idle.cxx for the add/remove functions
|
void (*Fl::Private::idle_)(); // see Fl::add_idle.cxx for the add/remove functions
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns whether at least one idle callback is currently set.
|
||||||
|
|
||||||
|
\c true means that at least one callback is currently queued, but
|
||||||
|
not necessarily active. While a callback is being executed, it is
|
||||||
|
also counted as "set" unless (i.e. before) it removes itself from
|
||||||
|
the idle callback queue (ring).
|
||||||
|
|
||||||
|
\return whether an idle callback is currently set
|
||||||
|
\retval true At least one idle callback is currently set.
|
||||||
|
\retval false No idle callback is currently set.
|
||||||
|
*/
|
||||||
|
bool Fl::idle() {
|
||||||
|
return (Private::idle_ != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Private, undocumented method to run idle callbacks.
|
Private, undocumented method to run idle callbacks.
|
||||||
@ -598,7 +653,7 @@ void (*Fl::idle_)(); // see Fl::add_idle.cxx for the add/remove functions
|
|||||||
the first idle callback and appends it to the end of the list of idle
|
the first idle callback and appends it to the end of the list of idle
|
||||||
callbacks. For details see static function call_idle() in Fl_add_idle.cxx.
|
callbacks. For details see static function call_idle() in Fl_add_idle.cxx.
|
||||||
|
|
||||||
If it is NULL then no idle callbacks are active and Fl::run_idle() returns
|
If it is NULL then no idle callbacks are active and Fl::Private::run_idle() returns
|
||||||
immediately.
|
immediately.
|
||||||
|
|
||||||
Note: idle callbacks can be queued in nested FLTK event loops like
|
Note: idle callbacks can be queued in nested FLTK event loops like
|
||||||
@ -609,11 +664,11 @@ void (*Fl::idle_)(); // see Fl::add_idle.cxx for the add/remove functions
|
|||||||
if an event (timeout or button click etc.) handler calls Fl::add_idle()
|
if an event (timeout or button click etc.) handler calls Fl::add_idle()
|
||||||
or even in Fl::flush() if a draw() method calls Fl::add_idle().
|
or even in Fl::flush() if a draw() method calls Fl::add_idle().
|
||||||
*/
|
*/
|
||||||
void Fl::run_idle() {
|
void Fl::Private::run_idle() {
|
||||||
static char in_idle;
|
static char in_idle;
|
||||||
if (Fl::idle_ && !in_idle) {
|
if (Fl::Private::idle_ && !in_idle) {
|
||||||
in_idle = 1;
|
in_idle = 1;
|
||||||
Fl::idle_(); // call the idle callback stored in Fl::idle_ == Fl::idle()
|
Fl::Private::idle_(); // call the idle callback stored in Fl::Private::idle_ == Fl::idle()
|
||||||
in_idle = 0;
|
in_idle = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -733,7 +788,27 @@ void Fl::hide_all_windows() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fl::program_should_quit_ = 0;
|
int Fl::Private::program_should_quit_ = 0;
|
||||||
|
|
||||||
|
/** Returns non-zero when a request for program termination was received and accepted.
|
||||||
|
On the MacOS platform, the "Quit xxx" item of the application menu is such a request,
|
||||||
|
that is considered accepted when all windows are closed. On other platforms, this function
|
||||||
|
returns 0 until \p Fl::program_should_quit(1) is called.
|
||||||
|
\version 1.4.0
|
||||||
|
*/
|
||||||
|
int Fl::program_should_quit() {
|
||||||
|
return Private::program_should_quit_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Indicate to the FLTK library whether a program termination request was received and accepted.
|
||||||
|
A program may set this to 1, for example, while performing a platform-independent command asking the program to cleanly
|
||||||
|
terminate, similarly to the "Quit xxx" item of the application menu under MacOS.
|
||||||
|
\version 1.4.0
|
||||||
|
*/
|
||||||
|
void Fl::program_should_quit(int should_i) {
|
||||||
|
Private::program_should_quit_ = should_i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// Window list management:
|
// Window list management:
|
||||||
@ -2046,74 +2121,74 @@ void Fl::clear_widget_pointer(Fl_Widget const *w)
|
|||||||
*/
|
*/
|
||||||
bool Fl::option(Fl_Option opt)
|
bool Fl::option(Fl_Option opt)
|
||||||
{
|
{
|
||||||
if (!options_read_) {
|
if (!Private::options_read_) {
|
||||||
int tmp;
|
int tmp;
|
||||||
{ // first, read the system wide preferences
|
{ // first, read the system wide preferences
|
||||||
Fl_Preferences prefs(Fl_Preferences::CORE_SYSTEM, "fltk.org", "fltk");
|
Fl_Preferences prefs(Fl_Preferences::CORE_SYSTEM, "fltk.org", "fltk");
|
||||||
Fl_Preferences opt_prefs(prefs, "options");
|
Fl_Preferences opt_prefs(prefs, "options");
|
||||||
opt_prefs.get("ArrowFocus", tmp, 0); // default: off
|
opt_prefs.get("ArrowFocus", tmp, 0); // default: off
|
||||||
options_[OPTION_ARROW_FOCUS] = tmp;
|
Private::options_[OPTION_ARROW_FOCUS] = tmp;
|
||||||
//opt_prefs.get("NativeFilechooser", tmp, 1); // default: on
|
//opt_prefs.get("NativeFilechooser", tmp, 1); // default: on
|
||||||
//options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
//Private::options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
||||||
//opt_prefs.get("FilechooserPreview", tmp, 1); // default: on
|
//opt_prefs.get("FilechooserPreview", tmp, 1); // default: on
|
||||||
//options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
|
//Private::options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
|
||||||
opt_prefs.get("VisibleFocus", tmp, 1); // default: on
|
opt_prefs.get("VisibleFocus", tmp, 1); // default: on
|
||||||
options_[OPTION_VISIBLE_FOCUS] = tmp;
|
Private::options_[OPTION_VISIBLE_FOCUS] = tmp;
|
||||||
opt_prefs.get("DNDText", tmp, 1); // default: on
|
opt_prefs.get("DNDText", tmp, 1); // default: on
|
||||||
options_[OPTION_DND_TEXT] = tmp;
|
Private::options_[OPTION_DND_TEXT] = tmp;
|
||||||
opt_prefs.get("ShowTooltips", tmp, 1); // default: on
|
opt_prefs.get("ShowTooltips", tmp, 1); // default: on
|
||||||
options_[OPTION_SHOW_TOOLTIPS] = tmp;
|
Private::options_[OPTION_SHOW_TOOLTIPS] = tmp;
|
||||||
opt_prefs.get("FNFCUsesGTK", tmp, 1); // default: on
|
opt_prefs.get("FNFCUsesGTK", tmp, 1); // default: on
|
||||||
options_[OPTION_FNFC_USES_GTK] = tmp;
|
Private::options_[OPTION_FNFC_USES_GTK] = tmp;
|
||||||
opt_prefs.get("PrintUsesGTK", tmp, 1); // default: on
|
opt_prefs.get("PrintUsesGTK", tmp, 1); // default: on
|
||||||
options_[OPTION_PRINTER_USES_GTK] = tmp;
|
Private::options_[OPTION_PRINTER_USES_GTK] = tmp;
|
||||||
|
|
||||||
opt_prefs.get("ShowZoomFactor", tmp, 1); // default: on
|
opt_prefs.get("ShowZoomFactor", tmp, 1); // default: on
|
||||||
options_[OPTION_SHOW_SCALING] = tmp;
|
Private::options_[OPTION_SHOW_SCALING] = tmp;
|
||||||
opt_prefs.get("UseZenity", tmp, 0); // default: off
|
opt_prefs.get("UseZenity", tmp, 0); // default: off
|
||||||
options_[OPTION_FNFC_USES_ZENITY] = tmp;
|
Private::options_[OPTION_FNFC_USES_ZENITY] = tmp;
|
||||||
opt_prefs.get("UseKdialog", tmp, 0); // default: off
|
opt_prefs.get("UseKdialog", tmp, 0); // default: off
|
||||||
options_[OPTION_FNFC_USES_KDIALOG] = tmp;
|
Private::options_[OPTION_FNFC_USES_KDIALOG] = tmp;
|
||||||
opt_prefs.get("SimpleZoomShortcut", tmp, 0); // default: off
|
opt_prefs.get("SimpleZoomShortcut", tmp, 0); // default: off
|
||||||
options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = tmp;
|
Private::options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = 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::CORE_USER, "fltk.org", "fltk");
|
Fl_Preferences prefs(Fl_Preferences::CORE_USER, "fltk.org", "fltk");
|
||||||
Fl_Preferences opt_prefs(prefs, "options");
|
Fl_Preferences opt_prefs(prefs, "options");
|
||||||
opt_prefs.get("ArrowFocus", tmp, -1);
|
opt_prefs.get("ArrowFocus", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_ARROW_FOCUS] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_ARROW_FOCUS] = tmp;
|
||||||
//opt_prefs.get("NativeFilechooser", tmp, -1);
|
//opt_prefs.get("NativeFilechooser", tmp, -1);
|
||||||
//if (tmp >= 0) options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
//if (tmp >= 0) Private::options_[OPTION_NATIVE_FILECHOOSER] = tmp;
|
||||||
//opt_prefs.get("FilechooserPreview", tmp, -1);
|
//opt_prefs.get("FilechooserPreview", tmp, -1);
|
||||||
//if (tmp >= 0) options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
|
//if (tmp >= 0) Private::options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
|
||||||
opt_prefs.get("VisibleFocus", tmp, -1);
|
opt_prefs.get("VisibleFocus", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_VISIBLE_FOCUS] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_VISIBLE_FOCUS] = tmp;
|
||||||
opt_prefs.get("DNDText", tmp, -1);
|
opt_prefs.get("DNDText", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_DND_TEXT] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_DND_TEXT] = tmp;
|
||||||
opt_prefs.get("ShowTooltips", tmp, -1);
|
opt_prefs.get("ShowTooltips", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_SHOW_TOOLTIPS] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_SHOW_TOOLTIPS] = tmp;
|
||||||
opt_prefs.get("FNFCUsesGTK", tmp, -1);
|
opt_prefs.get("FNFCUsesGTK", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_FNFC_USES_GTK] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_FNFC_USES_GTK] = tmp;
|
||||||
opt_prefs.get("PrintUsesGTK", tmp, -1);
|
opt_prefs.get("PrintUsesGTK", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_PRINTER_USES_GTK] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_PRINTER_USES_GTK] = tmp;
|
||||||
|
|
||||||
opt_prefs.get("ShowZoomFactor", tmp, -1);
|
opt_prefs.get("ShowZoomFactor", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_SHOW_SCALING] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_SHOW_SCALING] = tmp;
|
||||||
opt_prefs.get("UseZenity", tmp, -1);
|
opt_prefs.get("UseZenity", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_FNFC_USES_ZENITY] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_FNFC_USES_ZENITY] = tmp;
|
||||||
opt_prefs.get("UseKdialog", tmp, -1);
|
opt_prefs.get("UseKdialog", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_FNFC_USES_KDIALOG] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_FNFC_USES_KDIALOG] = tmp;
|
||||||
opt_prefs.get("SimpleZoomShortcut", tmp, -1);
|
opt_prefs.get("SimpleZoomShortcut", tmp, -1);
|
||||||
if (tmp >= 0) options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = tmp;
|
if (tmp >= 0) Private::options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = tmp;
|
||||||
}
|
}
|
||||||
{ // now, if the developer has registered this app, we could ask for per-application preferences
|
{ // now, if the developer has registered this app, we could ask for per-application preferences
|
||||||
}
|
}
|
||||||
options_read_ = 1;
|
Private::options_read_ = 1;
|
||||||
}
|
}
|
||||||
if (opt<0 || opt>=OPTION_LAST)
|
if (opt<0 || opt>=OPTION_LAST)
|
||||||
return false;
|
return false;
|
||||||
return (bool)(options_[opt]!=0);
|
return (bool)(Private::options_[opt]!=0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2142,11 +2217,11 @@ void Fl::option(Fl_Option opt, bool val)
|
|||||||
{
|
{
|
||||||
if (opt<0 || opt>=OPTION_LAST)
|
if (opt<0 || opt>=OPTION_LAST)
|
||||||
return;
|
return;
|
||||||
if (!options_read_) {
|
if (!Private::options_read_) {
|
||||||
// make sure that the options_ array is filled in
|
// make sure that the options_ array is filled in
|
||||||
option(opt);
|
option(opt);
|
||||||
}
|
}
|
||||||
options_[opt] = val;
|
Private::options_[opt] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2169,9 +2244,50 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fl::use_high_res_GL_ = 0;
|
int Fl::Private::use_high_res_GL_ = 0;
|
||||||
|
|
||||||
int Fl::draw_GL_text_with_textures_ = 1;
|
/** sets whether GL windows should be drawn at high resolution on Apple
|
||||||
|
computers with retina displays
|
||||||
|
\version 1.3.4
|
||||||
|
*/
|
||||||
|
void Fl::use_high_res_GL(int val) {
|
||||||
|
Private::use_high_res_GL_ = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** returns whether GL windows should be drawn at high resolution on Apple
|
||||||
|
computers with retina displays.
|
||||||
|
Default is no.
|
||||||
|
\version 1.3.4
|
||||||
|
*/
|
||||||
|
int Fl::use_high_res_GL() {
|
||||||
|
return Private::use_high_res_GL_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Fl::Private::draw_GL_text_with_textures_ = 1;
|
||||||
|
|
||||||
|
/** sets whether OpenGL uses textures to draw all text.
|
||||||
|
By default, FLTK draws OpenGL text using textures, if the necessary
|
||||||
|
hardware support is available. Call \p Fl::draw_GL_text_with_textures(0)
|
||||||
|
once in your program before the first call to gl_font() to have FLTK
|
||||||
|
draw instead OpenGL text using a legacy, platform-dependent procedure.
|
||||||
|
It's recommended not to deactivate textures under the MacOS platform
|
||||||
|
because the MacOS legacy procedure is extremely rudimentary.
|
||||||
|
\param val use 0 to prevent FLTK from drawing GL text with textures
|
||||||
|
\see gl_texture_pile_height(int max)
|
||||||
|
\version 1.4.0
|
||||||
|
*/
|
||||||
|
void Fl::draw_GL_text_with_textures(int val) {
|
||||||
|
Private::draw_GL_text_with_textures_ = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** returns whether whether OpenGL uses textures to draw all text.
|
||||||
|
Default is yes.
|
||||||
|
\see draw_GL_text_with_textures(int val)
|
||||||
|
\version 1.4.0
|
||||||
|
*/
|
||||||
|
int Fl::draw_GL_text_with_textures() {
|
||||||
|
return Private::draw_GL_text_with_textures_;
|
||||||
|
}
|
||||||
|
|
||||||
int Fl::dnd()
|
int Fl::dnd()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
// Preprocessor macro FLTK_HAVE_CAIRO_EXT is defined only for "CAIRO_EXT".
|
// Preprocessor macro FLTK_HAVE_CAIRO_EXT is defined only for "CAIRO_EXT".
|
||||||
// Both macros are defined in 'FL/fl_config.h'.
|
// 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
|
#ifdef FLTK_HAVE_CAIRO
|
||||||
|
|
||||||
@ -61,7 +61,53 @@
|
|||||||
|
|
||||||
// static initialization
|
// 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
|
// Fl_Cairo_State
|
||||||
|
|
||||||
@ -131,10 +177,10 @@ cairo_t *Fl::cairo_make_current(Fl_Window *wi) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FLTK_USE_X11)
|
#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
|
#else
|
||||||
// on macOS, scaling is done before by Fl_Window::make_current(), on Windows, the size is not used
|
// 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
|
#endif
|
||||||
|
|
||||||
#if !defined(USE_MAC_OS)
|
#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.
|
\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;
|
int W = 0, H = 0;
|
||||||
#if defined(FLTK_USE_X11) || defined(FLTK_USE_WAYLAND)
|
#if defined(FLTK_USE_X11) || defined(FLTK_USE_WAYLAND)
|
||||||
// FIXME X11 get W,H
|
// 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.
|
\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() &&
|
if (gc == Fl::cairo_state_.gc() &&
|
||||||
fl_window == (Window)Fl::cairo_state_.window() &&
|
fl_window == (Window)Fl::cairo_state_.window() &&
|
||||||
cairo_state_.cc() != 0) // no need to create a cc, just return that one
|
cairo_state_.cc() != 0) // no need to create a cc, just return that one
|
||||||
|
|||||||
77
src/Fl_Private.H
Normal file
77
src/Fl_Private.H
Normal file
@ -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.
|
Each supported platform implements several of the virtual methods of this class.
|
||||||
*/
|
*/
|
||||||
class Fl_System_Driver {
|
class Fl_System_Driver {
|
||||||
friend class Fl;
|
friend Fl_System_Driver *Fl::system_driver();
|
||||||
protected:
|
protected:
|
||||||
// implement once for each platform
|
// implement once for each platform
|
||||||
static Fl_System_Driver *newSystemDriver();
|
static Fl_System_Driver *newSystemDriver();
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Fl_System_Driver.H"
|
#include "Fl_System_Driver.H"
|
||||||
#include <FL/Fl.H>
|
#include "Fl_Private.H"
|
||||||
#include "Fl_Timeout.h"
|
#include "Fl_Timeout.h"
|
||||||
#include <FL/Fl_File_Icon.H>
|
#include <FL/Fl_File_Icon.H>
|
||||||
#include <FL/fl_utf8.h>
|
#include <FL/fl_utf8.h>
|
||||||
@ -357,8 +357,8 @@ double Fl_System_Driver::wait(double time_to_wait) {
|
|||||||
Fl::do_widget_deletion();
|
Fl::do_widget_deletion();
|
||||||
|
|
||||||
Fl_Timeout::do_timeouts();
|
Fl_Timeout::do_timeouts();
|
||||||
Fl::run_checks();
|
Fl::Private::run_checks();
|
||||||
Fl::run_idle();
|
Fl::Private::run_idle();
|
||||||
|
|
||||||
// The idle function may turn off idle() if *all* idle callbacks
|
// The idle function may turn off idle() if *all* idle callbacks
|
||||||
// are removed from the callback queue (ring), we can then wait.
|
// are removed from the callback queue (ring), we can then wait.
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
// Replaces the older set_idle() call which has been renamed to set_idle_(),
|
// 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.
|
// is now private in class Fl::, and is used to implement this.
|
||||||
|
|
||||||
#include <FL/Fl.H>
|
#include "Fl_Private.H"
|
||||||
|
|
||||||
struct idle_cb {
|
struct idle_cb {
|
||||||
void (*cb)(void*);
|
void (*cb)(void*);
|
||||||
@ -83,7 +83,7 @@ void Fl::add_idle(Fl_Idle_Handler cb, void* data) {
|
|||||||
} else {
|
} else {
|
||||||
first = last = p;
|
first = last = p;
|
||||||
p->next = 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
|
if (l == p) { // only one
|
||||||
first = last = 0;
|
first = last = 0;
|
||||||
set_idle_(0);
|
Private::set_idle_(0);
|
||||||
} else {
|
} else {
|
||||||
last = l;
|
last = l;
|
||||||
first = l->next = p->next;
|
first = l->next = p->next;
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
// boxtypes. Other box types are in separate files so they are not
|
// boxtypes. Other box types are in separate files so they are not
|
||||||
// linked in if not used.
|
// linked in if not used.
|
||||||
|
|
||||||
#include <FL/Fl.H>
|
#include "src/Fl_Private.H"
|
||||||
#include <FL/Fl_Widget.H>
|
#include <FL/Fl_Widget.H>
|
||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@ -46,8 +46,47 @@ static const uchar inactive_ramp[24] = {
|
|||||||
51, 51, 52, 52};
|
51, 51, 52, 52};
|
||||||
static int draw_it_active = 1;
|
static int draw_it_active = 1;
|
||||||
|
|
||||||
int Fl::box_border_radius_max_ = 15;
|
int Fl::Private::box_border_radius_max_ = 15;
|
||||||
int Fl::box_shadow_width_ = 3;
|
|
||||||
|
/** 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.
|
Determines if the currently drawn box is active or inactive.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user