1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Main header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2018-02-01 00:17:17 +03:00
|
|
|
// Copyright 1998-2018 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// 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:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/COPYING.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-03-31 20:01:24 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2011-02-06 13:07:28 +03:00
|
|
|
/** \file
|
2008-12-10 23:58:10 +03:00
|
|
|
Fl static class.
|
2008-09-16 11:26:22 +04:00
|
|
|
*/
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_H
|
2001-11-28 23:43:44 +03:00
|
|
|
# define Fl_H
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2016-04-06 00:15:45 +03:00
|
|
|
#include <FL/Fl_Export.H>
|
|
|
|
|
2016-04-20 01:45:22 +03:00
|
|
|
#include <FL/platform_types.h> // for FL_SOCKET
|
2011-01-06 13:24:58 +03:00
|
|
|
#ifdef FLTK_HAVE_CAIRO
|
2008-09-25 22:26:33 +04:00
|
|
|
# include <FL/Fl_Cairo.H>
|
|
|
|
#endif
|
|
|
|
|
2008-09-19 21:40:20 +04:00
|
|
|
# include "fl_utf8.h"
|
2001-11-28 23:43:44 +03:00
|
|
|
# include "Enumerations.H"
|
|
|
|
# ifndef Fl_Object
|
2008-10-04 19:54:15 +04:00
|
|
|
# define Fl_Object Fl_Widget /**< for back compatibility - use Fl_Widget! */
|
2001-11-28 23:43:44 +03:00
|
|
|
# endif
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2002-07-17 10:09:26 +04:00
|
|
|
# ifdef check
|
|
|
|
# undef check
|
|
|
|
# endif
|
|
|
|
|
2016-01-05 02:09:32 +03:00
|
|
|
# ifdef BSD
|
|
|
|
# undef BSD
|
|
|
|
# endif
|
|
|
|
|
2008-09-25 22:26:33 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
class Fl_Widget;
|
|
|
|
class Fl_Window;
|
2001-12-20 17:41:44 +03:00
|
|
|
class Fl_Image;
|
1998-10-06 22:21:25 +04:00
|
|
|
struct Fl_Label;
|
2016-02-24 11:07:30 +03:00
|
|
|
class Fl_Screen_Driver;
|
2016-04-20 01:45:22 +03:00
|
|
|
class Fl_System_Driver;
|
2008-10-04 19:54:15 +04:00
|
|
|
|
2016-04-20 10:19:19 +03:00
|
|
|
// Pointers you can use to change FLTK to another language.
|
2016-03-26 04:39:22 +03:00
|
|
|
// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx
|
|
|
|
|
|
|
|
extern FL_EXPORT const char* fl_local_alt; ///< string pointer used in shortcuts, you can change it to another language
|
|
|
|
extern FL_EXPORT const char* fl_local_ctrl; ///< string pointer used in shortcuts, you can change it to another language
|
|
|
|
extern FL_EXPORT const char* fl_local_meta; ///< string pointer used in shortcuts, you can change it to another language
|
|
|
|
extern FL_EXPORT const char* fl_local_shift; ///< string pointer used in shortcuts, you can change it to another language
|
|
|
|
|
2010-03-25 17:37:46 +03:00
|
|
|
/** \defgroup callback_functions Callback function typedefs
|
2010-12-01 20:38:29 +03:00
|
|
|
\brief Typedefs defined in <FL/Fl.H> for callback or handler functions passed as function parameters.
|
2010-03-25 17:37:46 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
@{ */
|
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of some label drawing functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
|
2008-10-04 19:54:15 +04:00
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of some label measurement functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height);
|
2008-10-04 19:54:15 +04:00
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of some box drawing functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of some timeout callback functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (*Fl_Timeout_Handler)(void *data);
|
2008-10-04 19:54:15 +04:00
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of some wakeup callback functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (*Fl_Awake_Handler)(void *data);
|
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of add_idle callback functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (*Fl_Idle_Handler)(void *data);
|
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of set_idle callback functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (*Fl_Old_Idle_Handler)();
|
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of add_fd functions passed as parameters */
|
2012-04-05 09:12:30 +04:00
|
|
|
typedef void (*Fl_FD_Handler)(FL_SOCKET fd, void *data);
|
2010-03-20 00:40:12 +03:00
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of add_handler functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef int (*Fl_Event_Handler)(int event);
|
|
|
|
|
2014-09-15 13:17:56 +04:00
|
|
|
/** Signature of add_system_handler functions passed as parameters */
|
|
|
|
typedef int (*Fl_System_Handler)(void *event, void *data);
|
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of set_abort functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (*Fl_Abort_Handler)(const char *format,...);
|
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of set_atclose functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data);
|
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of args functions passed as parameters */
|
2010-03-20 00:40:12 +03:00
|
|
|
typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
|
2000-03-08 19:02:25 +03:00
|
|
|
|
2011-03-30 16:07:52 +04:00
|
|
|
/** Signature of event_dispatch functions passed as parameters.
|
|
|
|
\see Fl::event_dispatch(Fl_Event_Dispatch) */
|
2011-01-25 22:54:09 +03:00
|
|
|
typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
|
|
|
|
|
2013-09-11 16:54:40 +04:00
|
|
|
/** Signature of add_clipboard_notify functions passed as parameters */
|
|
|
|
typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data);
|
|
|
|
|
2010-03-25 17:37:46 +03:00
|
|
|
/** @} */ /* group callback_functions */
|
|
|
|
|
2010-11-01 01:39:40 +03:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2011-03-30 16:07:52 +04:00
|
|
|
The Fl is the FLTK global (static) class containing
|
2008-09-14 02:33:03 +04:00
|
|
|
state information and global methods for the current application.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
class FL_EXPORT Fl {
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl() {}; // no constructor!
|
2016-02-10 22:49:35 +03:00
|
|
|
|
Changed OpenGL support for the Mac OS X platform: use cocoa instead of deprecated AGL.
All changes are mac-specific, except a very minor change in file src/gl_draw.cxx
where string drawing wrongly claimed to support @symbol, not possible
because symbols are drawn using non-GL primitives.
Unchanged application code can use the new FLTK code.
In addition, the new code allows mac applications to draw OpenGL scenes
at high resolution on so-called 'retina' displays, but this requires some
support from app code. They must call, before opening GL windows,
Fl::use_high_resolution(1);
and change their glViewport() calls as follows
glViewport(0, 0, pxel_w(), pixel_h());
This uses 2 new member functions of the Fl_Gl_Window class,
pixel_w() and pixel_h() returning the window dimensions in pixel
units, that is, twice the w() and h() when the window is mapped
on a retina display.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10498 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2014-12-20 10:19:23 +03:00
|
|
|
private:
|
2016-02-10 22:49:35 +03:00
|
|
|
|
Changed OpenGL support for the Mac OS X platform: use cocoa instead of deprecated AGL.
All changes are mac-specific, except a very minor change in file src/gl_draw.cxx
where string drawing wrongly claimed to support @symbol, not possible
because symbols are drawn using non-GL primitives.
Unchanged application code can use the new FLTK code.
In addition, the new code allows mac applications to draw OpenGL scenes
at high resolution on so-called 'retina' displays, but this requires some
support from app code. They must call, before opening GL windows,
Fl::use_high_resolution(1);
and change their glViewport() calls as follows
glViewport(0, 0, pxel_w(), pixel_h());
This uses 2 new member functions of the Fl_Gl_Window class,
pixel_w() and pixel_h() returning the window dimensions in pixel
units, that is, twice the w() and h() when the window is mapped
on a retina display.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10498 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2014-12-20 10:19:23 +03:00
|
|
|
static int use_high_res_GL_;
|
2018-02-07 18:34:44 +03:00
|
|
|
static int draw_GL_text_with_textures_;
|
2016-01-17 03:44:07 +03:00
|
|
|
|
2016-02-10 22:49:35 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
static Fl_Screen_Driver *screen_driver();
|
2016-04-01 13:28:03 +03:00
|
|
|
static Fl_System_Driver *system_driver();
|
2018-05-24 13:58:47 +03:00
|
|
|
static void reset_marked_text(); // resets marked text
|
|
|
|
static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point
|
2016-02-10 22:49:35 +03:00
|
|
|
|
2016-01-17 03:44:07 +03:00
|
|
|
public: // run time information about compile time configuration
|
|
|
|
/** \defgroup cfg_gfx runtime graphics driver configuration */
|
|
|
|
/** @{ */
|
|
|
|
static bool cfg_gfx_xlib; ///< X11 Xlib rendering available, usually on Linux systems
|
2016-01-19 00:23:54 +03:00
|
|
|
static bool cfg_gfx_quartz; ///< Quartz rendering available, usually on OS X systems
|
2018-02-09 17:39:42 +03:00
|
|
|
static bool cfg_gfx_gdi; ///< GDI rendering available, usually on Windows systems
|
2016-04-09 13:42:17 +03:00
|
|
|
static bool cfg_gfx_opengl; ///< OpenGL rendering available, available on many platforms
|
|
|
|
static bool cfg_gfx_cairo; ///< Cairo rendering available, available on many platforms
|
2018-02-09 17:39:42 +03:00
|
|
|
static bool cfg_gfx_directx;///< DirectX rendering available, usually on Windows systems
|
2016-01-17 03:44:07 +03:00
|
|
|
/** @} */
|
|
|
|
/** \defgroup cfg_prn runtime printer driver configuration */
|
|
|
|
/** @{ */
|
|
|
|
static bool cfg_prn_ps; ///< PostScript rendering available, usually on Linux systems
|
2016-01-19 00:23:54 +03:00
|
|
|
static bool cfg_prn_quartz; ///< Quartz rendering available, usually on OS X systems
|
2018-02-09 17:39:42 +03:00
|
|
|
static bool cfg_prn_gdi; ///< GDI rendering available, usually on Windows systems
|
2016-01-17 03:44:07 +03:00
|
|
|
/** @} */
|
|
|
|
/** \defgroup cfg_win runtime window and event manager configuration */
|
|
|
|
/** @{ */
|
|
|
|
static bool cfg_win_x11; ///< X11 window management available, usually on Linux systems
|
2016-01-19 00:23:54 +03:00
|
|
|
static bool cfg_win_cocoa; ///< Cocoa window management available, usually on OS X systems
|
2018-02-09 17:39:42 +03:00
|
|
|
static bool cfg_win_win32; ///< Windows window management available, on low level Windows
|
2016-01-17 03:44:07 +03:00
|
|
|
/** @} */
|
|
|
|
/** \defgroup cfg_sys runtime system configuration */
|
|
|
|
/** @{ */
|
|
|
|
static bool cfg_sys_posix; ///< Posix system available, usually on Linux and OS X systems, but also Cygwin
|
2018-02-09 17:39:42 +03:00
|
|
|
static bool cfg_sys_win32; ///< Windows system available, on Windows
|
2016-01-17 03:44:07 +03:00
|
|
|
/** @} */
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
public: // should be private!
|
2016-04-07 01:20:32 +03:00
|
|
|
|
2008-09-18 17:20:25 +04:00
|
|
|
#ifndef FL_DOXYGEN
|
2002-07-14 23:08:25 +04:00
|
|
|
static int e_number;
|
2002-08-14 20:19:48 +04:00
|
|
|
static int e_x;
|
|
|
|
static int e_y;
|
|
|
|
static int e_x_root;
|
|
|
|
static int e_y_root;
|
|
|
|
static int e_dx;
|
|
|
|
static int e_dy;
|
2002-07-14 23:08:25 +04:00
|
|
|
static int e_state;
|
|
|
|
static int e_clicks;
|
|
|
|
static int e_is_click;
|
|
|
|
static int e_keysym;
|
|
|
|
static char* e_text;
|
|
|
|
static int e_length;
|
2014-05-23 20:47:21 +04:00
|
|
|
static void *e_clipboard_data;
|
|
|
|
static const char *e_clipboard_type;
|
2011-01-25 22:54:09 +03:00
|
|
|
static Fl_Event_Dispatch e_dispatch;
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Widget* belowmouse_;
|
|
|
|
static Fl_Widget* pushed_;
|
|
|
|
static Fl_Widget* focus_;
|
|
|
|
static int damage_;
|
|
|
|
static Fl_Widget* selection_owner_;
|
|
|
|
static Fl_Window* modal_;
|
|
|
|
static Fl_Window* grab_;
|
2018-02-09 17:39:42 +03:00
|
|
|
static int compose_state; // used for dead keys (Windows) or marked text (MacOS)
|
2011-09-30 17:09:06 +04:00
|
|
|
static void call_screen_init(); // recompute screen number and dimensions
|
2014-05-23 20:47:21 +04:00
|
|
|
#endif // FL_DOXYGEN
|
2016-04-07 01:20:32 +03:00
|
|
|
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
If true then flush() will do something.
|
|
|
|
*/
|
2002-08-09 05:09:49 +04:00
|
|
|
static void damage(int d) {damage_ = d;}
|
2010-11-01 01:39:40 +03:00
|
|
|
|
|
|
|
public:
|
2011-03-30 16:07:52 +04:00
|
|
|
/** 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)
|
|
|
|
*/
|
2010-11-01 01:39:40 +03:00
|
|
|
typedef enum {
|
2014-04-29 11:48:46 +04:00
|
|
|
/// 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)
|
2014-04-29 06:56:34 +04:00
|
|
|
///
|
2014-06-07 16:01:59 +04:00
|
|
|
/// When switched off (default), the cursor will stop at the end of the text.
|
2014-04-29 11:48:46 +04:00
|
|
|
/// Pressing Tab or Ctrl-Tab will advance the keyboard focus.
|
2014-04-29 06:56:34 +04:00
|
|
|
///
|
|
|
|
/// See also: Fl_Input_::tab_nav()
|
|
|
|
///
|
2010-11-01 01:39:40 +03:00
|
|
|
OPTION_ARROW_FOCUS = 0,
|
2010-12-12 22:52:26 +03:00
|
|
|
// 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,
|
2014-06-07 16:01:59 +04:00
|
|
|
/// If visible focus is switched on (default), FLTK will draw a dotted rectangle
|
2010-12-12 22:52:26 +03:00
|
|
|
/// 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,
|
2014-06-07 16:01:59 +04:00
|
|
|
/// If text drag-and-drop is enabled (default), the user can select and drag text
|
2010-12-12 22:52:26 +03:00
|
|
|
/// from any text widget. If disabled, no dragging is possible, however
|
|
|
|
/// dropping text from other applications still works.
|
|
|
|
OPTION_DND_TEXT,
|
2014-06-07 16:01:59 +04:00
|
|
|
/// If tooltips are enabled (default), hovering the mouse over a widget with a
|
2011-03-30 16:07:52 +04:00
|
|
|
/// tooltip text will open a little tooltip window until the mouse leaves
|
2010-12-12 22:52:26 +03:00
|
|
|
/// the widget. If disabled, no tooltip is shown.
|
|
|
|
OPTION_SHOW_TOOLTIPS,
|
2014-06-07 16:01:59 +04:00
|
|
|
/// 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,
|
2018-08-08 23:08:10 +03:00
|
|
|
/// 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,
|
2010-12-12 22:52:26 +03:00
|
|
|
// don't change this, leave it always as the last element
|
2011-03-30 16:07:52 +04:00
|
|
|
/// For internal use only.
|
2010-11-01 01:39:40 +03:00
|
|
|
OPTION_LAST
|
|
|
|
} Fl_Option;
|
2011-03-30 16:07:52 +04:00
|
|
|
|
2010-11-01 01:39:40 +03:00
|
|
|
private:
|
|
|
|
static unsigned char options_[OPTION_LAST];
|
|
|
|
static unsigned char options_read_;
|
2018-02-06 20:26:11 +03:00
|
|
|
static int program_should_quit_; // non-zero means the program was asked to cleanly terminate
|
|
|
|
|
2010-11-01 01:39:40 +03:00
|
|
|
public:
|
2010-12-12 22:52:26 +03:00
|
|
|
/*
|
|
|
|
Return a global setting for all FLTK applications, possibly overridden
|
|
|
|
by a setting specifically for this application.
|
2010-11-01 01:39:40 +03:00
|
|
|
*/
|
|
|
|
static bool option(Fl_Option opt);
|
|
|
|
|
2010-12-12 22:52:26 +03:00
|
|
|
/*
|
|
|
|
Override an option while the application is running.
|
|
|
|
*/
|
|
|
|
static void option(Fl_Option opt, bool val);
|
|
|
|
|
2008-10-04 19:54:15 +04:00
|
|
|
/**
|
|
|
|
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()
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static void (*idle)();
|
2008-09-18 23:09:34 +04:00
|
|
|
|
|
|
|
#ifndef FL_DOXYGEN
|
2007-03-06 20:15:03 +03:00
|
|
|
static Fl_Awake_Handler *awake_ring_;
|
|
|
|
static void **awake_data_;
|
|
|
|
static int awake_ring_size_;
|
|
|
|
static int awake_ring_head_;
|
|
|
|
static int awake_ring_tail_;
|
2001-12-20 17:41:44 +03:00
|
|
|
static const char* scheme_;
|
|
|
|
static Fl_Image* scheme_bg_;
|
|
|
|
|
2006-06-09 11:48:08 +04:00
|
|
|
static int e_original_keysym; // late addition
|
2009-04-02 10:44:34 +04:00
|
|
|
static int scrollbar_size_;
|
2018-03-31 20:17:37 +03:00
|
|
|
static int menu_linespacing_; // STR #2927
|
2008-09-18 23:09:34 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static int add_awake_handler_(Fl_Awake_Handler, void*);
|
|
|
|
static int get_awake_handler_(Fl_Awake_Handler&, void*&);
|
2006-06-09 11:48:08 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
public:
|
|
|
|
|
2001-11-28 21:00:17 +03:00
|
|
|
// API version number
|
2002-07-14 23:08:25 +04:00
|
|
|
static double version();
|
2015-04-04 18:36:04 +03:00
|
|
|
static int api_version();
|
|
|
|
|
|
|
|
// ABI version number
|
|
|
|
static int abi_version();
|
2001-11-28 21:00:17 +03:00
|
|
|
|
2015-10-24 12:55:18 +03:00
|
|
|
/**
|
2015-04-04 19:21:52 +03:00
|
|
|
Returns whether the runtime library ABI version is correct.
|
|
|
|
|
|
|
|
This enables you to check the ABI version of the linked FLTK
|
|
|
|
library at runtime.
|
|
|
|
|
|
|
|
Returns 1 (true) if the compiled ABI version (in the header files)
|
|
|
|
and the linked library ABI version (used at runtime) are the same,
|
|
|
|
0 (false) otherwise.
|
|
|
|
|
|
|
|
Argument \p val can be used to query a particular library ABI version.
|
|
|
|
Use for instance 10303 to query if the runtime library is compatible
|
|
|
|
with FLTK ABI version 1.3.3. This is rarely useful.
|
|
|
|
|
2015-04-04 19:51:37 +03:00
|
|
|
The default \p val argument is FL_ABI_VERSION, which checks the version
|
2015-04-04 19:21:52 +03:00
|
|
|
defined at configure time (i.e. in the header files at program
|
|
|
|
compilation time) against the linked library version used at runtime.
|
|
|
|
This is particularly useful if you linked with a shared object library,
|
|
|
|
but it also concerns static linking.
|
|
|
|
|
|
|
|
\see Fl::abi_version()
|
|
|
|
*/
|
|
|
|
static inline int abi_check(const int val = FL_ABI_VERSION) {
|
|
|
|
return val == abi_version();
|
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// argument parsers:
|
2010-10-23 20:34:22 +04:00
|
|
|
static int arg(int argc, char **argv, int& i);
|
|
|
|
static int args(int argc, char **argv, int& i, Fl_Args_Handler cb = 0);
|
|
|
|
static void args(int argc, char **argv);
|
2008-10-04 19:54:15 +04:00
|
|
|
/**
|
|
|
|
Usage string displayed if Fl::args() detects an invalid argument.
|
|
|
|
This may be changed to point to customized text at run-time.
|
|
|
|
*/
|
2008-09-14 02:33:03 +04:00
|
|
|
static const char* const help;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// things called by initialization:
|
2002-07-14 23:08:25 +04:00
|
|
|
static void display(const char*);
|
|
|
|
static int visual(int);
|
2008-09-15 23:21:20 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
This does the same thing as Fl::visual(int) but also requires OpenGL
|
|
|
|
drawing to work. This <I>must</I> be done if you want to draw in
|
|
|
|
normal windows with OpenGL with gl_start() and gl_end().
|
|
|
|
It may be useful to call this so your X windows use the same visual
|
|
|
|
as an Fl_Gl_Window, which on some servers will reduce colormap flashing.
|
|
|
|
|
|
|
|
See Fl_Gl_Window for a list of additional values for the argument.
|
2008-09-15 23:21:20 +04:00
|
|
|
*/
|
|
|
|
static int gl_visual(int, int *alist=0); // platform dependent
|
2002-07-14 23:08:25 +04:00
|
|
|
static void own_colormap();
|
|
|
|
static void get_system_colors();
|
|
|
|
static void foreground(uchar, uchar, uchar);
|
|
|
|
static void background(uchar, uchar, uchar);
|
|
|
|
static void background2(uchar, uchar, uchar);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2001-12-20 17:41:44 +03:00
|
|
|
// schemes:
|
2014-01-21 17:29:15 +04:00
|
|
|
static int scheme(const char *name);
|
2008-09-14 02:33:03 +04:00
|
|
|
/** See void scheme(const char *name) */
|
2001-12-20 17:41:44 +03:00
|
|
|
static const char* scheme() {return scheme_;}
|
2014-01-21 17:29:15 +04:00
|
|
|
|
|
|
|
/** Returns whether the current scheme is the given name.
|
|
|
|
|
|
|
|
This is a fast inline convenience function to support scheme-specific
|
|
|
|
code in widgets, e.g. in their draw() methods, if required.
|
|
|
|
|
|
|
|
Use a valid scheme name, not \p NULL (although \p NULL is allowed,
|
|
|
|
this is not a useful argument - see below).
|
|
|
|
|
|
|
|
If Fl::scheme() has not been set or has been set to the default
|
|
|
|
scheme ("none" or "base"), then this will always return 0 regardless
|
|
|
|
of the argument, because Fl::scheme() is \p NULL in this case.
|
|
|
|
|
|
|
|
\note The stored scheme name is always lowercase, and this method will
|
2014-01-21 18:00:43 +04:00
|
|
|
do a case-sensitive compare, so you \b must provide a lowercase string to
|
2014-01-21 17:29:15 +04:00
|
|
|
return the correct value. This is intentional for performance reasons.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
\code
|
2014-02-01 01:51:53 +04:00
|
|
|
if (Fl::is_scheme("gtk+")) { your_code_here(); }
|
2014-01-21 17:29:15 +04:00
|
|
|
\endcode
|
|
|
|
|
|
|
|
\param[in] name \b lowercase string of requested scheme name.
|
|
|
|
|
|
|
|
\return 1 if the given scheme is active, 0 otherwise.
|
|
|
|
|
|
|
|
\see Fl::scheme(const char *name)
|
|
|
|
*/
|
2014-02-01 01:51:53 +04:00
|
|
|
static int is_scheme(const char *name) {
|
2014-01-21 17:29:15 +04:00
|
|
|
return (scheme_ && name && !strcmp(name,scheme_));
|
|
|
|
}
|
|
|
|
/**
|
2008-09-14 02:33:03 +04:00
|
|
|
Called by scheme according to scheme name.
|
|
|
|
Loads or reloads the current scheme selection.
|
|
|
|
See void scheme(const char *name)
|
|
|
|
*/
|
|
|
|
static int reload_scheme(); // platform dependent
|
2006-11-17 02:17:13 +03:00
|
|
|
static int scrollbar_size();
|
|
|
|
static void scrollbar_size(int W);
|
2018-03-31 20:17:37 +03:00
|
|
|
static int menu_linespacing();
|
|
|
|
static void menu_linespacing(int H);
|
2001-12-20 17:41:44 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// execution:
|
2002-07-14 23:08:25 +04:00
|
|
|
static int wait();
|
|
|
|
static double wait(double time);
|
|
|
|
static int check();
|
|
|
|
static int ready();
|
|
|
|
static int run();
|
2018-02-06 20:26:11 +03:00
|
|
|
/** 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.
|
2018-02-08 10:37:43 +03:00
|
|
|
\version 1.4.0
|
2018-02-06 20:26:11 +03:00
|
|
|
*/
|
|
|
|
static int program_should_quit() {return 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
|
2018-02-08 10:37:43 +03:00
|
|
|
terminate, similarly to the "Quit xxx" item of the application menu under MacOS.
|
|
|
|
\version 1.4.0
|
|
|
|
*/
|
2018-02-06 20:26:11 +03:00
|
|
|
static void program_should_quit(int should_i) { program_should_quit_ = should_i; }
|
|
|
|
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Widget* readqueue();
|
2008-09-15 23:21:20 +04:00
|
|
|
/**
|
|
|
|
Adds a one-shot timeout callback. The function will be called by
|
|
|
|
Fl::wait() at <i>t</i> seconds after this function is called.
|
|
|
|
The optional void* argument is passed to the callback.
|
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
You can have multiple timeout callbacks. To remove a timeout
|
2008-09-15 23:21:20 +04:00
|
|
|
callback use Fl::remove_timeout().
|
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
If you need more accurate, repeated timeouts, use Fl::repeat_timeout() to
|
|
|
|
reschedule the subsequent timeouts.
|
2008-09-15 23:21:20 +04:00
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
The following code will print "TICK" each second on
|
|
|
|
stdout with a fair degree of accuracy:
|
2008-09-15 23:21:20 +04:00
|
|
|
|
|
|
|
\code
|
2016-01-28 20:16:32 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Window.H>
|
|
|
|
void callback(void*) {
|
|
|
|
printf("TICK\n");
|
|
|
|
Fl::repeat_timeout(1.0, callback); // retrigger timeout
|
|
|
|
}
|
|
|
|
int main() {
|
|
|
|
Fl_Window win(100,100);
|
|
|
|
win.show();
|
|
|
|
Fl::add_timeout(1.0, callback); // set up first timeout
|
|
|
|
return Fl::run();
|
|
|
|
}
|
2008-09-15 23:21:20 +04:00
|
|
|
\endcode
|
|
|
|
*/
|
|
|
|
static void add_timeout(double t, Fl_Timeout_Handler,void* = 0); // platform dependent
|
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
Repeats a timeout callback from the expiration of the
|
2008-09-15 23:21:20 +04:00
|
|
|
previous timeout, allowing for more accurate timing. You may only call
|
|
|
|
this method inside a timeout callback.
|
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
The following code will print "TICK" each second on
|
|
|
|
stdout with a fair degree of accuracy:
|
2008-09-15 23:21:20 +04:00
|
|
|
|
|
|
|
\code
|
|
|
|
void callback(void*) {
|
|
|
|
puts("TICK");
|
|
|
|
Fl::repeat_timeout(1.0, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
Fl::add_timeout(1.0, callback);
|
|
|
|
return Fl::run();
|
|
|
|
}
|
|
|
|
\endcode
|
|
|
|
*/
|
2010-03-20 00:40:12 +03:00
|
|
|
static void repeat_timeout(double t, Fl_Timeout_Handler, void* = 0); // platform dependent
|
2002-07-14 23:08:25 +04:00
|
|
|
static int has_timeout(Fl_Timeout_Handler, void* = 0);
|
|
|
|
static void remove_timeout(Fl_Timeout_Handler, void* = 0);
|
|
|
|
static void add_check(Fl_Timeout_Handler, void* = 0);
|
|
|
|
static int has_check(Fl_Timeout_Handler, void* = 0);
|
|
|
|
static void remove_check(Fl_Timeout_Handler, void* = 0);
|
2016-02-13 19:12:57 +03:00
|
|
|
// private
|
|
|
|
static void run_checks();
|
2010-03-20 00:40:12 +03:00
|
|
|
static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent
|
|
|
|
static void add_fd(int fd, Fl_FD_Handler cb, void* = 0); // platform dependent
|
2008-09-14 02:33:03 +04:00
|
|
|
/** Removes a file descriptor handler. */
|
|
|
|
static void remove_fd(int, int when); // platform dependent
|
|
|
|
/** Removes a file descriptor handler. */
|
|
|
|
static void remove_fd(int); // platform dependent
|
|
|
|
|
2010-03-20 00:40:12 +03:00
|
|
|
static void add_idle(Fl_Idle_Handler cb, void* data = 0);
|
|
|
|
static int has_idle(Fl_Idle_Handler cb, void* data = 0);
|
|
|
|
static void remove_idle(Fl_Idle_Handler cb, void* data = 0);
|
2008-09-14 02:33:03 +04:00
|
|
|
/** If true then flush() will do something. */
|
2002-07-14 23:08:25 +04:00
|
|
|
static int damage() {return damage_;}
|
|
|
|
static void redraw();
|
|
|
|
static void flush();
|
2008-10-03 15:20:50 +04:00
|
|
|
/** \addtogroup group_comdlg
|
2008-09-18 17:20:25 +04:00
|
|
|
@{ */
|
2008-10-03 15:20:50 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
FLTK calls Fl::warning() to output a warning message.
|
|
|
|
|
|
|
|
The default version on Windows returns \e without printing a warning
|
|
|
|
message, because Windows programs normally don't have stderr (a console
|
|
|
|
window) enabled.
|
|
|
|
|
|
|
|
The default version on all other platforms prints the warning message to stderr.
|
|
|
|
|
|
|
|
You can override the behavior by setting the function pointer to your
|
2008-09-14 02:33:03 +04:00
|
|
|
own routine.
|
2008-12-10 23:58:10 +03:00
|
|
|
|
|
|
|
Fl::warning() means that there was a recoverable problem, the display may
|
|
|
|
be messed up, but the user can probably keep working - all X protocol
|
|
|
|
errors call this, for example. The default implementation returns after
|
|
|
|
displaying the message.
|
2010-12-01 20:38:29 +03:00
|
|
|
\note \#include <FL/Fl.H>
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static void (*warning)(const char*, ...);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
FLTK calls Fl::error() to output a normal error message.
|
|
|
|
|
|
|
|
The default version on Windows displays the error message in a MessageBox window.
|
|
|
|
|
|
|
|
The default version on all other platforms prints the error message to stderr.
|
|
|
|
|
|
|
|
You can override the behavior by setting the function pointer to your
|
2008-09-14 02:33:03 +04:00
|
|
|
own routine.
|
2008-12-10 23:58:10 +03:00
|
|
|
|
|
|
|
Fl::error() means there is a recoverable error such as the inability to read
|
|
|
|
an image file. The default implementation returns after displaying the message.
|
2010-12-01 20:38:29 +03:00
|
|
|
\note \#include <FL/Fl.H>
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static void (*error)(const char*, ...);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
FLTK calls Fl::fatal() to output a fatal error message.
|
|
|
|
|
|
|
|
The default version on Windows displays the error message in a MessageBox window.
|
|
|
|
|
|
|
|
The default version on all other platforms prints the error message to stderr.
|
|
|
|
|
|
|
|
You can override the behavior by setting the function pointer to your
|
2008-09-14 02:33:03 +04:00
|
|
|
own routine.
|
2008-12-10 23:58:10 +03:00
|
|
|
|
|
|
|
Fl::fatal() must not return, as FLTK is in an unusable state, however your
|
|
|
|
version may be able to use longjmp or an exception to continue, as long as
|
|
|
|
it does not call FLTK again. The default implementation exits with status 1
|
|
|
|
after displaying the message.
|
2010-12-01 20:38:29 +03:00
|
|
|
\note \#include <FL/Fl.H>
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static void (*fatal)(const char*, ...);
|
2008-10-03 15:20:50 +04:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** \defgroup fl_windows Windows handling functions
|
2010-12-01 20:48:59 +03:00
|
|
|
\brief Windows and standard dialogs handling declared in <FL/Fl.H>
|
2008-10-03 15:20:50 +04:00
|
|
|
@{ */
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Window* first_window();
|
|
|
|
static void first_window(Fl_Window*);
|
|
|
|
static Fl_Window* next_window(const Fl_Window*);
|
2008-10-03 15:20:50 +04:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns the top-most modal() window currently shown.
|
2008-12-10 23:58:10 +03:00
|
|
|
|
|
|
|
This is the most recently shown() window with modal() true, or NULL
|
|
|
|
if there are no modal() windows shown().
|
2008-09-14 02:33:03 +04:00
|
|
|
The modal() window has its handle() method called
|
|
|
|
for all events, and no other windows will have handle()
|
|
|
|
called (grab() overrides this).
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Window* modal() {return modal_;}
|
2011-01-30 11:06:06 +03:00
|
|
|
/** Returns the window that currently receives all events.
|
|
|
|
|
|
|
|
\return The window that currently receives all events,
|
|
|
|
or NULL if event grabbing is currently OFF.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Window* grab() {return grab_;}
|
2011-01-30 11:06:06 +03:00
|
|
|
/** Selects the window to grab.
|
|
|
|
This is used when pop-up menu systems are active.
|
|
|
|
|
|
|
|
Send all events to the passed window no matter where the pointer or
|
|
|
|
focus is (including in other programs). The window <I>does not have
|
|
|
|
to be shown()</I> , this lets the handle() method of a
|
|
|
|
"dummy" window override all event handling and allows you to
|
2018-02-09 17:39:42 +03:00
|
|
|
map and unmap a complex set of windows (under both X and Windows
|
2011-01-30 11:06:06 +03:00
|
|
|
<I>some</I> window must be mapped because the system interface needs a
|
|
|
|
window id).
|
|
|
|
|
|
|
|
If grab() is on it will also affect show() of windows by doing
|
|
|
|
system-specific operations (on X it turns on override-redirect).
|
|
|
|
These are designed to make menus popup reliably
|
|
|
|
and faster on the system.
|
|
|
|
|
|
|
|
To turn off grabbing do Fl::grab(0).
|
|
|
|
|
|
|
|
<I>Be careful that your program does not enter an infinite loop
|
|
|
|
while grab() is on. On X this will lock up your screen!</I>
|
|
|
|
To avoid this potential lockup, all newer operating systems seem to
|
|
|
|
limit mouse pointer grabbing to the time during which a mouse button
|
|
|
|
is held down. Some OS's may not support grabbing at all.
|
|
|
|
*/
|
2008-09-14 02:33:03 +04:00
|
|
|
static void grab(Fl_Window*); // platform dependent
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-03 12:05:48 +04:00
|
|
|
/** \defgroup fl_events Events handling functions
|
2010-12-01 20:48:59 +03:00
|
|
|
Fl class events handling API declared in <FL/Fl.H>
|
2008-09-18 17:20:25 +04:00
|
|
|
@{
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
// event information:
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns the last event that was processed. This can be used
|
|
|
|
to determine if a callback is being done in response to a
|
|
|
|
keypress, mouse click, etc.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event() {return e_number;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns the mouse position of the event relative to the Fl_Window
|
|
|
|
it was passed to.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_x() {return e_x;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns the mouse position of the event relative to the Fl_Window
|
|
|
|
it was passed to.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_y() {return e_y;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns the mouse position on the screen of the event. To find the
|
|
|
|
absolute position of an Fl_Window on the screen, use the
|
|
|
|
difference between event_x_root(),event_y_root() and
|
|
|
|
event_x(),event_y().
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_x_root() {return e_x_root;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns the mouse position on the screen of the event. To find the
|
|
|
|
absolute position of an Fl_Window on the screen, use the
|
|
|
|
difference between event_x_root(),event_y_root() and
|
|
|
|
event_x(),event_y().
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_y_root() {return e_y_root;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns the current horizontal mouse scrolling associated with the
|
|
|
|
FL_MOUSEWHEEL event. Right is positive.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_dx() {return e_dx;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
Returns the current vertical mouse scrolling associated with the
|
2008-09-14 02:33:03 +04:00
|
|
|
FL_MOUSEWHEEL event. Down is positive.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_dy() {return e_dy;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Return where the mouse is on the screen by doing a round-trip query to
|
|
|
|
the server. You should use Fl::event_x_root() and
|
|
|
|
Fl::event_y_root() if possible, but this is necessary if you are
|
|
|
|
not sure if a mouse event has been processed recently (such as to
|
|
|
|
position your first window). If the display is not open, this will
|
|
|
|
open it.
|
|
|
|
*/
|
2016-04-15 17:18:37 +03:00
|
|
|
static void get_mouse(int &,int &);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-10-04 18:15:16 +04:00
|
|
|
Returns non zero if we had a double click event.
|
|
|
|
\retval Non-zero if the most recent FL_PUSH or FL_KEYBOARD was a "double click".
|
|
|
|
\retval N-1 for N clicks.
|
|
|
|
A double click is counted if the same button is pressed
|
2008-09-14 02:33:03 +04:00
|
|
|
again while event_is_click() is true.
|
|
|
|
|
2008-10-04 18:15:16 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_clicks() {return e_clicks;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-10-04 18:15:16 +04:00
|
|
|
Manually sets the number returned by Fl::event_clicks().
|
|
|
|
This can be used to set it to zero so that
|
|
|
|
later code does not think an item was double-clicked.
|
2008-12-10 23:58:10 +03:00
|
|
|
\param[in] i corresponds to no double-click if 0, i+1 mouse clicks otherwise
|
2008-10-04 18:15:16 +04:00
|
|
|
\see int event_clicks()
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static void event_clicks(int i) {e_clicks = i;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2011-01-30 11:18:52 +03:00
|
|
|
Returns non-zero if the mouse has not moved far enough
|
|
|
|
and not enough time has passed since the last FL_PUSH or
|
|
|
|
FL_KEYBOARD event for it to be considered a "drag" rather than a
|
|
|
|
"click". You can test this on FL_DRAG, FL_RELEASE,
|
|
|
|
and FL_MOVE events.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_is_click() {return e_is_click;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2011-01-30 11:18:52 +03:00
|
|
|
Clears the value returned by Fl::event_is_click().
|
|
|
|
Useful to prevent the <I>next</I>
|
|
|
|
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.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
|
|
|
static void event_is_click(int i) {e_is_click = i;}
|
|
|
|
/**
|
2014-11-25 17:18:23 +03:00
|
|
|
Gets which particular mouse button caused the current event.
|
|
|
|
|
2008-10-04 18:15:16 +04:00
|
|
|
This returns garbage if the most recent event was not a FL_PUSH or FL_RELEASE event.
|
2018-03-18 18:25:08 +03:00
|
|
|
\retval FL_LEFT_MOUSE
|
|
|
|
\retval FL_MIDDLE_MOUSE
|
|
|
|
\retval FL_RIGHT_MOUSE.
|
2008-10-04 18:15:16 +04:00
|
|
|
\see Fl::event_buttons()
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_button() {return e_keysym-FL_Button;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2014-11-25 17:18:23 +03:00
|
|
|
Returns the keyboard and mouse button states of the last event.
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
This is a bitfield of what shift states were on and what mouse buttons
|
2014-11-25 17:18:23 +03:00
|
|
|
were held down during the most recent event.
|
|
|
|
|
|
|
|
The legal event state bits are:
|
|
|
|
|
|
|
|
- FL_SHIFT
|
|
|
|
- FL_CAPS_LOCK
|
|
|
|
- FL_CTRL
|
|
|
|
- FL_ALT
|
|
|
|
- FL_NUM_LOCK
|
|
|
|
- FL_META
|
|
|
|
- FL_SCROLL_LOCK
|
|
|
|
- FL_BUTTON1
|
|
|
|
- FL_BUTTON2
|
|
|
|
- FL_BUTTON3
|
2008-09-14 02:33:03 +04:00
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
X servers do not agree on shift states, and FL_NUM_LOCK, FL_META, and
|
|
|
|
FL_SCROLL_LOCK may not work. The values were selected to match the
|
|
|
|
XFree86 server on Linux. In addition there is a bug in the way X works
|
|
|
|
so that the shift state is not correctly reported until the first event
|
|
|
|
<I>after</I> the shift key is pressed or released.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_state() {return e_state;}
|
2014-11-25 17:18:23 +03:00
|
|
|
|
|
|
|
/** 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().
|
|
|
|
*/
|
|
|
|
static int event_state(int mask) {return e_state&mask;}
|
2009-09-20 05:25:44 +04:00
|
|
|
/**
|
|
|
|
Gets which key on the keyboard was last pushed.
|
|
|
|
|
|
|
|
The returned integer 'key code' is not necessarily a text
|
|
|
|
equivalent for the keystroke. For instance: if someone presses '5' on the
|
|
|
|
numeric keypad with numlock on, Fl::event_key() may return the 'key code'
|
|
|
|
for this key, and NOT the character '5'. To always get the '5', use Fl::event_text() instead.
|
|
|
|
|
|
|
|
\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&).
|
|
|
|
*/
|
2008-10-04 18:15:16 +04:00
|
|
|
static int event_key() {return e_keysym;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
Returns the keycode of the last key event, regardless of the NumLock state.
|
2009-09-20 05:08:03 +04:00
|
|
|
|
2008-10-04 18:15:16 +04:00
|
|
|
If NumLock is deactivated, FLTK translates events from the
|
|
|
|
numeric keypad into the corresponding arrow key events.
|
|
|
|
event_key() returns the translated key code, whereas
|
2009-09-20 05:08:03 +04:00
|
|
|
event_original_key() returns the keycode before NumLock translation.
|
2008-10-04 18:15:16 +04:00
|
|
|
*/
|
|
|
|
static int event_original_key(){return e_original_keysym;}
|
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Returns true if the given \p key was held
|
2008-09-14 02:33:03 +04:00
|
|
|
down (or pressed) <I>during</I> the last event. This is constant until
|
|
|
|
the next event is read from the server.
|
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
Fl::get_key(int) returns true if the given 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).
|
2008-09-14 02:33:03 +04:00
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
Keys are identified by the <I>unshifted</I> values. FLTK defines a
|
2008-09-14 02:33:03 +04:00
|
|
|
set of symbols that should work on most modern machines for every key
|
|
|
|
on the keyboard:
|
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
\li All keys on the main keyboard producing a printable ASCII
|
|
|
|
character use the value of that ASCII character (as though shift,
|
|
|
|
ctrl, and caps lock were not on). The space bar is 32.
|
|
|
|
\li All keys on the numeric keypad producing a printable ASCII
|
|
|
|
character use the value of that ASCII character plus FL_KP.
|
|
|
|
The highest possible value is FL_KP_Last so you can
|
|
|
|
range-check to see if something is on the keypad.
|
|
|
|
\li All numbered function keys use the number on the function key plus
|
|
|
|
FL_F. The highest possible number is FL_F_Last, so you
|
|
|
|
can range-check a value.
|
|
|
|
\li Buttons on the mouse are considered keys, and use the button
|
|
|
|
number (where the left button is 1) plus FL_Button.
|
|
|
|
\li All other keys on the keypad have a symbol: FL_Escape,
|
|
|
|
FL_BackSpace, FL_Tab, FL_Enter, FL_Print, FL_Scroll_Lock, FL_Pause,
|
|
|
|
FL_Insert, FL_Home, FL_Page_Up, FL_Delete, FL_End, FL_Page_Down,
|
2012-03-26 20:54:54 +04:00
|
|
|
FL_Left, FL_Up, FL_Right, FL_Down, FL_Iso_Key, FL_Shift_L, FL_Shift_R,
|
2008-12-10 23:58:10 +03:00
|
|
|
FL_Control_L, FL_Control_R, FL_Caps_Lock, FL_Alt_L, FL_Alt_R,
|
|
|
|
FL_Meta_L, FL_Meta_R, FL_Menu, FL_Num_Lock, FL_KP_Enter. Be
|
|
|
|
careful not to confuse these with the very similar, but all-caps,
|
|
|
|
symbols used by Fl::event_state().
|
|
|
|
|
|
|
|
On X Fl::get_key(FL_Button+n) does not work.
|
2008-09-14 02:33:03 +04:00
|
|
|
|
2018-02-09 17:39:42 +03:00
|
|
|
On Windows Fl::get_key(FL_KP_Enter) and Fl::event_key(FL_KP_Enter) do not work.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2008-10-04 18:15:16 +04:00
|
|
|
static int event_key(int key);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Returns true if the given \p key is held down <I>now</I>.
|
2008-12-10 23:58:10 +03:00
|
|
|
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)
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2008-10-04 18:15:16 +04:00
|
|
|
static int get_key(int key); // platform dependent
|
2009-09-20 05:08:03 +04:00
|
|
|
/**
|
|
|
|
Returns the text associated with the current event, including FL_PASTE or FL_DND_RELEASE events.
|
2012-04-11 01:18:35 +04:00
|
|
|
This can be used in response to FL_KEYUP, FL_KEYDOWN, FL_PASTE, and FL_DND_RELEASE.
|
2009-09-20 05:08:03 +04:00
|
|
|
|
|
|
|
When responding to FL_KEYUP/FL_KEYDOWN, use this function instead of Fl::event_key()
|
|
|
|
to get the text equivalent of keystrokes suitable for inserting into strings
|
|
|
|
and text widgets.
|
|
|
|
|
2012-04-11 01:18:35 +04:00
|
|
|
The returned string is guaranteed to be NULL terminated.
|
2009-09-20 05:08:03 +04:00
|
|
|
However, see Fl::event_length() for the actual length of the string,
|
|
|
|
in case the string itself contains NULLs that are part of the text data.
|
|
|
|
|
|
|
|
\returns A NULL terminated text string equivalent of the last keystroke.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static const char* event_text() {return e_text;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
Returns the length of the text in Fl::event_text(). There
|
|
|
|
will always be a nul at this position in the text. However there may
|
2008-09-14 02:33:03 +04:00
|
|
|
be a nul before that if the keystroke translates to a nul character or
|
|
|
|
you paste a nul character.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_length() {return e_length;}
|
2014-05-23 20:47:21 +04:00
|
|
|
|
|
|
|
/** During an FL_PASTE event of non-textual data, returns a pointer to the pasted data.
|
2016-05-03 17:28:45 +03:00
|
|
|
The returned data is an Fl_RGB_Image * when the result of Fl::event_clipboard_type() is Fl::clipboard_image.
|
2014-05-23 20:47:21 +04:00
|
|
|
*/
|
|
|
|
static 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.
|
|
|
|
*/
|
|
|
|
static const char *event_clipboard_type() {return e_clipboard_type; }
|
|
|
|
|
2008-09-18 17:20:25 +04:00
|
|
|
|
2002-07-14 23:08:25 +04:00
|
|
|
static int compose(int &del);
|
2011-03-21 19:32:37 +03:00
|
|
|
static void compose_reset();
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_inside(int,int,int,int);
|
|
|
|
static int event_inside(const Fl_Widget*);
|
2009-09-18 02:12:24 +04:00
|
|
|
static int test_shortcut(Fl_Shortcut);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2014-09-15 13:44:35 +04:00
|
|
|
static void enable_im();
|
|
|
|
static void disable_im();
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// event destinations:
|
2002-07-14 23:08:25 +04:00
|
|
|
static int handle(int, Fl_Window*);
|
2011-01-26 22:14:38 +03:00
|
|
|
static int handle_(int, Fl_Window*);
|
2008-10-04 18:15:16 +04:00
|
|
|
/** Gets the widget that is below the mouse.
|
|
|
|
\see belowmouse(Fl_Widget*) */
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Widget* belowmouse() {return belowmouse_;}
|
|
|
|
static void belowmouse(Fl_Widget*);
|
2008-12-10 23:58:10 +03:00
|
|
|
/** Gets the widget that is being pushed.
|
|
|
|
\see void pushed(Fl_Widget*) */
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Widget* pushed() {return pushed_;}
|
|
|
|
static void pushed(Fl_Widget*);
|
2008-09-29 02:25:23 +04:00
|
|
|
/** Gets the current Fl::focus() widget. \sa Fl::focus(Fl_Widget*) */
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Widget* focus() {return focus_;}
|
|
|
|
static void focus(Fl_Widget*);
|
2010-03-20 00:40:12 +03:00
|
|
|
static void add_handler(Fl_Event_Handler h);
|
|
|
|
static void remove_handler(Fl_Event_Handler h);
|
2014-09-15 13:17:56 +04:00
|
|
|
static void add_system_handler(Fl_System_Handler h, void *data);
|
|
|
|
static void remove_system_handler(Fl_System_Handler h);
|
2011-01-26 22:14:38 +03:00
|
|
|
static void event_dispatch(Fl_Event_Dispatch d);
|
|
|
|
static Fl_Event_Dispatch event_dispatch();
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-03 12:05:48 +04:00
|
|
|
/** \defgroup fl_clipboard Selection & Clipboard functions
|
2010-12-01 20:48:59 +03:00
|
|
|
FLTK global copy/cut/paste functions declared in <FL/Fl.H>
|
2008-09-18 17:20:25 +04:00
|
|
|
@{ */
|
1998-10-06 22:21:25 +04:00
|
|
|
// cut/paste:
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2010-12-22 20:06:09 +03:00
|
|
|
Copies the data pointed to by \p stuff to the selection buffer
|
2015-05-18 12:10:06 +03:00
|
|
|
(\p destination is 0), the clipboard (\p destination is 1), or
|
|
|
|
both (\p destination is 2). Copying to both is only relevant on X11,
|
|
|
|
on other platforms it maps to the clipboard (1).
|
2014-05-23 20:47:21 +04:00
|
|
|
\p len is the number of relevant bytes in \p stuff.
|
|
|
|
\p type is always Fl::clipboard_plain_text.
|
2010-12-22 20:06:09 +03:00
|
|
|
The selection buffer is used for
|
|
|
|
middle-mouse pastes and for drag-and-drop selections. The
|
|
|
|
clipboard is used for traditional copy/cut/paste operations.
|
2014-05-23 20:47:21 +04:00
|
|
|
|
|
|
|
\note This function is, at present, intended only to copy UTF-8 encoded textual data.
|
|
|
|
To copy graphical data, use the Fl_Copy_Surface class. The \p type argument may allow
|
|
|
|
in the future to copy other kinds of data.
|
2010-12-22 20:06:09 +03:00
|
|
|
*/
|
2014-05-23 20:47:21 +04:00
|
|
|
static void copy(const char* stuff, int len, int destination = 0, const char *type = Fl::clipboard_plain_text); // platform dependent
|
2016-01-04 01:54:29 +03:00
|
|
|
|
2010-12-22 20:06:09 +03:00
|
|
|
/**
|
2016-09-16 12:27:32 +03:00
|
|
|
Pastes the data from the selection buffer (\p source is 0) or the clipboard
|
|
|
|
(\p source is 1) into \p receiver.
|
2016-05-05 11:35:52 +03:00
|
|
|
|
2016-09-16 12:27:32 +03:00
|
|
|
The selection buffer (\p source is 0) is used for middle-mouse pastes and for
|
|
|
|
drag-and-drop selections. The clipboard (\p source is 1) is used for
|
|
|
|
copy/cut/paste operations.
|
|
|
|
|
|
|
|
If \p source is 1, the optional \p type argument indicates what type of data is requested from the clipboard.
|
|
|
|
At present, Fl::clipboard_plain_text (requesting text data) and
|
|
|
|
Fl::clipboard_image (requesting image data) are possible.
|
|
|
|
Set things up so the handle function of the \p receiver widget will be called with an FL_PASTE event some
|
|
|
|
time in the future if the clipboard does contain data of the requested type.
|
2018-12-05 16:53:27 +03:00
|
|
|
|
|
|
|
The handle function of \p receiver can process the FL_PASTE event as follows:
|
|
|
|
\li If the \p receiver widget is known to only receive text data, the text string
|
|
|
|
from the specified \p source is in Fl::event_text() with UTF-8 encoding, and the
|
|
|
|
number of bytes is in Fl::event_length(). If Fl::paste() gets called during the
|
|
|
|
drop step of a files-drag-and-drop operation,
|
2016-09-16 12:27:32 +03:00
|
|
|
Fl::event_text() contains a list of filenames (see \ref events_dnd).
|
2018-12-05 16:53:27 +03:00
|
|
|
\li If the \p receiver widget can potentially receive non-text data, use
|
|
|
|
Fl::event_clipboard_type() to determine what sort of data is being sent.
|
|
|
|
If Fl::event_clipboard_type() returns Fl::clipboard_plain_text, proceed as above.
|
|
|
|
It it returns Fl::clipboard_image, the pointer returned by Fl::event_clipboard()
|
|
|
|
can be safely cast to type Fl_RGB_Image * to obtain a pointer to the pasted image.
|
2016-09-16 12:27:32 +03:00
|
|
|
If \p receiver accepts the clipboard image, receiver.handle() should return 1 and the
|
|
|
|
application should take ownership of this image (that is, delete it after use).
|
|
|
|
Conversely, if receiver.handle() returns 0, the application must not use the image.
|
2010-12-12 01:34:05 +03:00
|
|
|
|
2016-09-16 12:27:32 +03:00
|
|
|
The receiver should be prepared to be called \e directly by this, or for
|
|
|
|
it to happen \e later, or possibly <i>not at all</i>. This
|
|
|
|
allows the window system to take as long as necessary to retrieve
|
|
|
|
the paste buffer (or even to screw up completely) without complex
|
|
|
|
and error-prone synchronization code in FLTK.
|
2014-05-23 20:47:21 +04:00
|
|
|
|
|
|
|
\par Platform details for image data:
|
2016-09-16 12:27:32 +03:00
|
|
|
\li Unix/Linux platform: Clipboard images in PNG or BMP formats are recognized. Requires linking with the fltk_images library.
|
2018-02-09 17:39:42 +03:00
|
|
|
\li Windows platform: Both bitmap and vectorial (Enhanced metafile) data from clipboard
|
2014-05-23 20:47:21 +04:00
|
|
|
can be pasted as image data.
|
|
|
|
\li Mac OS X platform: Both bitmap (TIFF) and vectorial (PDF) data from clipboard
|
|
|
|
can be pasted as image data.
|
|
|
|
*/
|
2016-09-16 12:27:32 +03:00
|
|
|
static void paste(Fl_Widget &receiver, int source, const char *type = Fl::clipboard_plain_text);
|
|
|
|
|
2013-09-11 16:54:40 +04:00
|
|
|
/**
|
|
|
|
FLTK will call the registered callback whenever there is a change to the
|
|
|
|
selection buffer or the clipboard. The source argument indicates which
|
|
|
|
of the two has changed. Only changes by other applications are reported.
|
2013-09-14 02:57:30 +04:00
|
|
|
|
|
|
|
Example:
|
|
|
|
\code
|
|
|
|
void clip_callback(int source, void *data) {
|
|
|
|
if ( source == 0 ) printf("CLIP CALLBACK: selection buffer changed\n");
|
|
|
|
if ( source == 1 ) printf("CLIP CALLBACK: clipboard changed\n");
|
|
|
|
}
|
|
|
|
[..]
|
|
|
|
int main() {
|
|
|
|
[..]
|
|
|
|
Fl::add_clipboard_notify(clip_callback);
|
|
|
|
[..]
|
|
|
|
}
|
|
|
|
\endcode
|
2013-09-11 16:54:40 +04:00
|
|
|
\note Some systems require polling to monitor the clipboard and may
|
|
|
|
therefore have some delay in detecting changes.
|
|
|
|
*/
|
|
|
|
static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data = 0);
|
|
|
|
/**
|
|
|
|
Stop calling the specified callback when there are changes to the selection
|
|
|
|
buffer or the clipboard.
|
|
|
|
*/
|
|
|
|
static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h);
|
2014-05-23 20:47:21 +04:00
|
|
|
/** Returns non 0 if the clipboard contains data matching \p type.
|
|
|
|
\p type can be Fl::clipboard_plain_text or Fl::clipboard_image.
|
|
|
|
*/
|
|
|
|
static int clipboard_contains(const char *type);
|
|
|
|
/** Denotes plain textual data
|
|
|
|
*/
|
|
|
|
static char const * const clipboard_plain_text;
|
|
|
|
/** Denotes image data
|
|
|
|
*/
|
|
|
|
static char const * const clipboard_image;
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2010-12-22 20:06:09 +03:00
|
|
|
Initiate a Drag And Drop operation. The selection buffer should be
|
2008-09-14 02:33:03 +04:00
|
|
|
filled with relevant data before calling this method. FLTK will
|
|
|
|
then initiate the system wide drag and drop handling. Dropped data
|
|
|
|
will be marked as <i>text</i>.
|
2010-12-03 01:59:30 +03:00
|
|
|
|
|
|
|
Create a selection first using:
|
|
|
|
Fl::copy(const char *stuff, int len, 0)
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
|
|
|
static int dnd(); // platform dependent
|
2008-09-18 17:20:25 +04:00
|
|
|
|
2008-09-15 21:46:42 +04:00
|
|
|
// These are for back-compatibility only:
|
2008-10-04 18:15:16 +04:00
|
|
|
/** back-compatibility only: Gets the widget owning the current selection
|
|
|
|
\see Fl_Widget* selection_owner(Fl_Widget*) */
|
2002-07-14 23:08:25 +04:00
|
|
|
static Fl_Widget* selection_owner() {return selection_owner_;}
|
|
|
|
static void selection_owner(Fl_Widget*);
|
|
|
|
static void selection(Fl_Widget &owner, const char*, int len);
|
|
|
|
static void paste(Fl_Widget &receiver);
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
2016-02-10 22:49:35 +03:00
|
|
|
|
|
|
|
|
2008-10-03 12:05:48 +04:00
|
|
|
/** \defgroup fl_screen Screen functions
|
2018-08-09 14:51:38 +03:00
|
|
|
Fl global screen functions declared in <FL/Fl.H>.
|
2018-08-08 23:08:10 +03:00
|
|
|
FLTK supports high-DPI screens using a screen scaling factor.
|
2018-08-09 14:51:38 +03:00
|
|
|
The scaling factor is initialized by the library to a value
|
|
|
|
based on information obtained from the OS. If this initial value
|
|
|
|
is not satisfactory, the FLTK_SCALING_FACTOR environment variable
|
|
|
|
can be set to a value FLTK will use as initial scaling factor.
|
|
|
|
The scaling factor value can be further changed at runtime
|
|
|
|
by typing ctrl-/+/-/0/ (cmd-/+/-/0/ under MacOS). FLTK sends the
|
|
|
|
\ref FL_ZOOM_EVENT when the factor value is changed, to which a
|
|
|
|
callback can be associated with Fl::add_handler().
|
2018-08-08 23:08:10 +03:00
|
|
|
By default, FLTK also displays the new scaling factor value in a yellow, transient window.
|
2018-08-09 14:51:38 +03:00
|
|
|
This can be changed with option Fl::OPTION_SHOW_SCALING.
|
2018-08-08 23:08:10 +03:00
|
|
|
The scaling factor value is programmatically get and set with the Fl::screen_scale() functions.
|
|
|
|
|
2008-09-18 17:20:25 +04:00
|
|
|
@{ */
|
2016-02-10 22:49:35 +03:00
|
|
|
static int x(); // via screen driver
|
|
|
|
static int y(); // via screen driver
|
|
|
|
static int w(); // via screen driver
|
|
|
|
static int h(); // via screen driver
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2005-03-31 20:01:24 +04:00
|
|
|
// multi-head support:
|
2016-02-10 22:49:35 +03:00
|
|
|
static int screen_count(); // via screen driver
|
|
|
|
static void screen_xywh(int &X, int &Y, int &W, int &H); // via screen driver
|
|
|
|
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my); // via screen driver
|
|
|
|
static void screen_xywh(int &X, int &Y, int &W, int &H, int n); // via screen driver
|
|
|
|
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh); // via screen driver
|
|
|
|
static int screen_num(int x, int y); // via screen driver
|
|
|
|
static int screen_num(int x, int y, int w, int h); // via screen driver
|
|
|
|
static void screen_dpi(float &h, float &v, int n=0); // via screen driver
|
|
|
|
static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my); // via screen driver
|
|
|
|
static void screen_work_area(int &X, int &Y, int &W, int &H, int n); // via screen driver
|
|
|
|
static void screen_work_area(int &X, int &Y, int &W, int &H); // via screen driver
|
2018-05-22 20:00:27 +03:00
|
|
|
static float screen_scale(int n); // via screen driver
|
2018-08-08 23:08:10 +03:00
|
|
|
static void screen_scale(int n, float factor); // via screen driver
|
|
|
|
static int screen_scaling_supported();
|
|
|
|
|
2016-02-10 22:49:35 +03:00
|
|
|
/** @} */
|
2005-03-31 20:01:24 +04:00
|
|
|
|
2008-09-18 17:20:25 +04:00
|
|
|
|
2008-10-03 12:05:48 +04:00
|
|
|
/** \defgroup fl_attributes Color & Font functions
|
2010-12-01 20:38:29 +03:00
|
|
|
fl global color, font functions.
|
|
|
|
These functions are declared in <FL/Fl.H> or <FL/fl_draw.H>.
|
2008-09-18 17:20:25 +04:00
|
|
|
@{ */
|
2008-12-28 14:21:03 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// color map:
|
2002-07-14 23:08:25 +04:00
|
|
|
static void set_color(Fl_Color, uchar, uchar, uchar);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
Sets an entry in the fl_color index table. You can set it to any
|
|
|
|
8-bit RGB color. The color is not allocated until fl_color(i) is used.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2010-10-28 02:07:55 +04:00
|
|
|
static void set_color(Fl_Color i, unsigned c); // platform dependent
|
|
|
|
static unsigned get_color(Fl_Color i);
|
|
|
|
static void get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Frees the specified color from the colormap, if applicable.
|
|
|
|
If overlay is non-zero then the color is freed from the
|
|
|
|
overlay colormap.
|
|
|
|
*/
|
2010-10-28 02:07:55 +04:00
|
|
|
static void free_color(Fl_Color i, int overlay = 0); // platform dependent
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// fonts:
|
2002-07-14 23:08:25 +04:00
|
|
|
static const char* get_font(Fl_Font);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Get a human-readable string describing the family of this face. This
|
|
|
|
is useful if you are presenting a choice to the user. There is no
|
|
|
|
guarantee that each face has a different name. The return value points
|
|
|
|
to a static buffer that is overwritten each call.
|
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
The integer pointed to by \p attributes (if the pointer is not
|
2008-09-14 02:33:03 +04:00
|
|
|
zero) is set to zero, FL_BOLD or FL_ITALIC or
|
2008-09-17 19:44:43 +04:00
|
|
|
FL_BOLD | FL_ITALIC. To locate a "family" of fonts, search
|
2008-09-14 02:33:03 +04:00
|
|
|
forward and back for a set with non-zero attributes, these faces along
|
|
|
|
with the face with a zero attribute before them constitute a family.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static const char* get_font_name(Fl_Font, int* attributes = 0);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Return an array of sizes in \p sizep. The return value is the
|
2008-09-14 02:33:03 +04:00
|
|
|
length of this array. The sizes are sorted from smallest to largest
|
|
|
|
and indicate what sizes can be given to fl_font() that will
|
|
|
|
be matched exactly (fl_font() will pick the closest size for
|
|
|
|
other sizes). A zero in the first location of the array indicates a
|
|
|
|
scalable font, where any size works, although the array may list sizes
|
2008-09-17 19:44:43 +04:00
|
|
|
that work "better" than others. Warning: the returned array
|
2008-09-14 02:33:03 +04:00
|
|
|
points at a static buffer that is overwritten each call. Under X this
|
|
|
|
will open the display.
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int get_font_sizes(Fl_Font, int*& sizep);
|
|
|
|
static void set_font(Fl_Font, const char*);
|
|
|
|
static void set_font(Fl_Font, Fl_Font);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
FLTK will open the display, and add every fonts on the server to the
|
2008-09-17 19:44:43 +04:00
|
|
|
face table. It will attempt to put "families" of faces together, so
|
2008-09-14 02:33:03 +04:00
|
|
|
that the normal one is first, followed by bold, italic, and bold
|
|
|
|
italic.
|
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
The optional argument is a string to describe the set of fonts to
|
2008-09-14 02:33:03 +04:00
|
|
|
add. Passing NULL will select only fonts that have the
|
|
|
|
ISO8859-1 character set (and are thus usable by normal text). Passing
|
2008-09-17 19:44:43 +04:00
|
|
|
"-*" will select all fonts with any encoding as long as they have
|
|
|
|
normal X font names with dashes in them. Passing "*" will list every
|
2008-09-14 02:33:03 +04:00
|
|
|
font that exists (on X this may produce some strange output). Other
|
2018-02-09 17:39:42 +03:00
|
|
|
values may be useful but are system dependent. With Windows NULL
|
2008-09-14 02:33:03 +04:00
|
|
|
selects fonts with ISO8859-1 encoding and non-NULL selects
|
|
|
|
all fonts.
|
|
|
|
|
2008-12-10 23:58:10 +03:00
|
|
|
The return value is how many faces are in the table after this is done.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
|
|
|
static Fl_Font set_fonts(const char* = 0); // platform dependent
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
2008-12-28 14:21:03 +03:00
|
|
|
/** \defgroup fl_drawings Drawing functions
|
2010-10-12 16:34:19 +04:00
|
|
|
FLTK global graphics and GUI drawing functions.
|
|
|
|
These functions are declared in <FL/fl_draw.H>,
|
2018-02-01 00:17:17 +03:00
|
|
|
and in <FL/platform.H> for offscreen buffer-related ones.
|
2008-12-28 14:21:03 +03:00
|
|
|
@{ */
|
|
|
|
// <Hack to re-order the 'Drawing functions' group>
|
|
|
|
/** @} */
|
2008-09-18 17:20:25 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// labeltypes:
|
2002-07-14 23:08:25 +04:00
|
|
|
static void set_labeltype(Fl_Labeltype,Fl_Label_Draw_F*,Fl_Label_Measure_F*);
|
2008-09-14 02:33:03 +04:00
|
|
|
/** Sets the functions to call to draw and measure a specific labeltype. */
|
|
|
|
static void set_labeltype(Fl_Labeltype, Fl_Labeltype from); // is it defined ?
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// boxtypes:
|
2002-07-30 18:57:02 +04:00
|
|
|
static Fl_Box_Draw_F *get_boxtype(Fl_Boxtype);
|
2002-07-14 23:08:25 +04:00
|
|
|
static void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F*,uchar,uchar,uchar,uchar);
|
|
|
|
static void set_boxtype(Fl_Boxtype, Fl_Boxtype from);
|
|
|
|
static int box_dx(Fl_Boxtype);
|
|
|
|
static int box_dy(Fl_Boxtype);
|
|
|
|
static int box_dw(Fl_Boxtype);
|
|
|
|
static int box_dh(Fl_Boxtype);
|
2015-07-09 03:10:44 +03:00
|
|
|
|
2002-07-14 23:08:25 +04:00
|
|
|
static int draw_box_active();
|
2015-07-09 03:10:44 +03:00
|
|
|
static Fl_Color box_color(Fl_Color);
|
|
|
|
static void set_box_color(Fl_Color);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-15 21:46:42 +04:00
|
|
|
// back compatibility:
|
2008-09-18 17:20:25 +04:00
|
|
|
/** \addtogroup fl_windows
|
|
|
|
@{ */
|
2008-10-04 18:15:16 +04:00
|
|
|
/** For back compatibility, sets the void Fl::fatal handler callback */
|
2010-03-20 00:40:12 +03:00
|
|
|
static void set_abort(Fl_Abort_Handler f) {fatal = f;}
|
2002-07-14 23:08:25 +04:00
|
|
|
static void (*atclose)(Fl_Window*,void*);
|
|
|
|
static void default_atclose(Fl_Window*,void*);
|
2008-10-04 18:15:16 +04:00
|
|
|
/** For back compatibility, sets the Fl::atclose handler callback. You
|
2008-12-10 23:58:10 +03:00
|
|
|
can now simply change the callback for the window instead.
|
|
|
|
\see Fl_Window::callback(Fl_Callback*) */
|
2010-03-20 00:40:12 +03:00
|
|
|
static void set_atclose(Fl_Atclose_Handler f) {atclose = f;}
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** \addtogroup fl_events
|
|
|
|
@{ */
|
2008-09-14 02:33:03 +04:00
|
|
|
/** Returns non-zero if the Shift key is pressed. */
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_shift() {return e_state&FL_SHIFT;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/** Returns non-zero if the Control key is pressed. */
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_ctrl() {return e_state&FL_CTRL;}
|
2009-12-22 17:17:22 +03:00
|
|
|
/** Returns non-zero if the FL_COMMAND key is pressed, either FL_CTRL or on OSX FL_META. */
|
|
|
|
static int event_command() {return e_state&FL_COMMAND;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/** Returns non-zero if the Alt key is pressed. */
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_alt() {return e_state&FL_ALT;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-10-04 18:15:16 +04:00
|
|
|
Returns the mouse buttons state bits; if non-zero, then at least one
|
|
|
|
button is pressed now. This function returns the button state at the
|
2008-09-14 02:33:03 +04:00
|
|
|
time of the event. During an FL_RELEASE event, the state
|
|
|
|
of the released button will be 0. To find out, which button
|
2008-10-04 18:15:16 +04:00
|
|
|
caused an FL_RELEASE event, you can use Fl::event_button() instead.
|
|
|
|
\return a bit mask value like { [FL_BUTTON1] | [FL_BUTTON2] | [FL_BUTTON3] }
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_buttons() {return e_state&0x7f000000;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-10-04 18:15:16 +04:00
|
|
|
Returns non-zero if mouse button 1 is currently held down.
|
2008-09-14 02:33:03 +04:00
|
|
|
For more details, see Fl::event_buttons().
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_button1() {return e_state&FL_BUTTON1;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns non-zero if button 2 is currently held down.
|
|
|
|
For more details, see Fl::event_buttons().
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_button2() {return e_state&FL_BUTTON2;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns non-zero if button 3 is currently held down.
|
|
|
|
For more details, see Fl::event_buttons().
|
|
|
|
*/
|
2002-07-14 23:08:25 +04:00
|
|
|
static int event_button3() {return e_state&FL_BUTTON3;}
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Sets an idle callback.
|
2008-12-10 23:58:10 +03:00
|
|
|
|
|
|
|
\deprecated This method is obsolete - use the add_idle() method instead.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2010-03-20 00:40:12 +03:00
|
|
|
static void set_idle(Fl_Old_Idle_Handler cb) {idle = cb;}
|
2011-01-30 11:06:06 +03:00
|
|
|
/** See grab(Fl_Window*) */
|
|
|
|
static void grab(Fl_Window& win) {grab(&win);}
|
2008-12-10 23:58:10 +03:00
|
|
|
/** Releases the current grabbed window, equals grab(0).
|
|
|
|
\deprecated Use Fl::grab(0) instead.
|
2011-01-30 11:06:06 +03:00
|
|
|
\see grab(Fl_Window*) */
|
2002-07-14 23:08:25 +04:00
|
|
|
static void release() {grab(0);}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2001-11-03 08:11:34 +03:00
|
|
|
// Visible focus methods...
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2011-01-23 01:38:55 +03:00
|
|
|
static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); }
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2010-12-12 22:52:26 +03:00
|
|
|
static int visible_focus() { return option(OPTION_VISIBLE_FOCUS); }
|
2001-12-07 01:16:49 +03:00
|
|
|
|
2002-04-14 02:17:46 +04:00
|
|
|
// Drag-n-drop text operation methods...
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2017-10-25 08:26:49 +03:00
|
|
|
Sets whether drag and drop text operations are supported.
|
2008-12-10 23:58:10 +03:00
|
|
|
This specifically affects whether selected text can
|
2008-09-14 02:33:03 +04:00
|
|
|
be dragged from text fields or dragged within a text field as a
|
|
|
|
cut/paste shortcut.
|
|
|
|
*/
|
2011-01-23 01:38:55 +03:00
|
|
|
static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); }
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2017-10-25 08:26:49 +03:00
|
|
|
Gets whether drag and drop text operations are
|
|
|
|
supported. This returns whether selected text can
|
2008-09-14 02:33:03 +04:00
|
|
|
be dragged from text fields or dragged within a text field as a
|
|
|
|
cut/paste shortcut.
|
|
|
|
*/
|
2010-12-12 22:52:26 +03:00
|
|
|
static int dnd_text_ops() { return option(OPTION_DND_TEXT); }
|
2008-10-03 12:05:48 +04:00
|
|
|
/** \defgroup fl_multithread Multithreading support functions
|
2010-12-01 20:48:59 +03:00
|
|
|
fl multithreading support functions declared in <FL/Fl.H>
|
2008-09-18 17:20:25 +04:00
|
|
|
@{ */
|
2002-04-14 02:17:46 +04:00
|
|
|
|
2001-12-07 01:16:49 +03:00
|
|
|
// Multithreading support:
|
2011-02-06 22:46:11 +03:00
|
|
|
static int lock();
|
2002-07-14 23:08:25 +04:00
|
|
|
static void unlock();
|
|
|
|
static void awake(void* message = 0);
|
2008-09-14 02:33:03 +04:00
|
|
|
/** See void awake(void* message=0). */
|
2007-03-06 20:15:03 +03:00
|
|
|
static int awake(Fl_Awake_Handler cb, void* message = 0);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
The thread_message() method returns the last message
|
|
|
|
that was sent from a child by the awake() method.
|
|
|
|
|
2011-01-28 11:37:49 +03:00
|
|
|
See also: \ref advanced_multithreading
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
|
|
|
static void* thread_message(); // platform dependent
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
2004-11-23 22:47:52 +03:00
|
|
|
|
2008-10-03 12:05:48 +04:00
|
|
|
/** \defgroup fl_del_widget Safe widget deletion support functions
|
2008-12-10 02:14:25 +03:00
|
|
|
|
2010-12-01 20:48:59 +03:00
|
|
|
These functions, declared in <FL/Fl.H>, support deletion of widgets inside callbacks.
|
2008-12-10 02:14:25 +03:00
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
Fl::delete_widget() should be called when deleting widgets
|
|
|
|
or complete widget trees (Fl_Group, Fl_Window, ...) inside
|
2009-02-08 17:44:15 +03:00
|
|
|
callbacks.
|
2008-12-10 02:14:25 +03:00
|
|
|
|
2009-02-08 17:44:15 +03:00
|
|
|
The other functions are intended for internal use. The preferred
|
2009-04-19 16:47:36 +04:00
|
|
|
way to use them is by using the helper class Fl_Widget_Tracker.
|
2009-02-08 17:44:15 +03:00
|
|
|
|
|
|
|
The following is to show how it works ...
|
|
|
|
|
|
|
|
There are three groups of related methods:
|
|
|
|
|
|
|
|
-# scheduled widget deletion
|
2009-04-19 16:47:36 +04:00
|
|
|
- Fl::delete_widget() schedules widgets for deletion
|
|
|
|
- Fl::do_widget_deletion() deletes all scheduled widgets
|
2009-02-08 17:44:15 +03:00
|
|
|
-# widget watch list ("smart pointers")
|
2009-04-19 16:47:36 +04:00
|
|
|
- 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
|
2009-02-15 16:49:34 +03:00
|
|
|
-# the class Fl_Widget_Tracker:
|
2009-04-19 16:47:36 +04:00
|
|
|
- the constructor calls Fl::watch_widget_pointer()
|
|
|
|
- the destructor calls Fl::release_widget_pointer()
|
2009-02-08 17:44:15 +03:00
|
|
|
- the access methods can be used to test, if a widget has been deleted
|
2009-04-19 16:47:36 +04:00
|
|
|
\see Fl_Widget_Tracker.
|
2008-12-10 02:14:25 +03:00
|
|
|
|
2008-09-18 17:20:25 +04:00
|
|
|
@{ */
|
2004-11-23 22:47:52 +03:00
|
|
|
// Widget deletion:
|
|
|
|
static void delete_widget(Fl_Widget *w);
|
|
|
|
static void do_widget_deletion();
|
2006-04-28 01:40:47 +04:00
|
|
|
static void watch_widget_pointer(Fl_Widget *&w);
|
|
|
|
static void release_widget_pointer(Fl_Widget *&w);
|
|
|
|
static void clear_widget_pointer(Fl_Widget const *w);
|
2008-09-18 17:20:25 +04:00
|
|
|
/** @} */
|
Changed OpenGL support for the Mac OS X platform: use cocoa instead of deprecated AGL.
All changes are mac-specific, except a very minor change in file src/gl_draw.cxx
where string drawing wrongly claimed to support @symbol, not possible
because symbols are drawn using non-GL primitives.
Unchanged application code can use the new FLTK code.
In addition, the new code allows mac applications to draw OpenGL scenes
at high resolution on so-called 'retina' displays, but this requires some
support from app code. They must call, before opening GL windows,
Fl::use_high_resolution(1);
and change their glViewport() calls as follows
glViewport(0, 0, pxel_w(), pixel_h());
This uses 2 new member functions of the Fl_Gl_Window class,
pixel_w() and pixel_h() returning the window dimensions in pixel
units, that is, twice the w() and h() when the window is mapped
on a retina display.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10498 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2014-12-20 10:19:23 +03:00
|
|
|
|
|
|
|
/** sets whether GL windows should be drawn at high resolution on Apple
|
|
|
|
computers with retina displays
|
2015-01-19 16:14:15 +03:00
|
|
|
\version 1.3.4
|
Changed OpenGL support for the Mac OS X platform: use cocoa instead of deprecated AGL.
All changes are mac-specific, except a very minor change in file src/gl_draw.cxx
where string drawing wrongly claimed to support @symbol, not possible
because symbols are drawn using non-GL primitives.
Unchanged application code can use the new FLTK code.
In addition, the new code allows mac applications to draw OpenGL scenes
at high resolution on so-called 'retina' displays, but this requires some
support from app code. They must call, before opening GL windows,
Fl::use_high_resolution(1);
and change their glViewport() calls as follows
glViewport(0, 0, pxel_w(), pixel_h());
This uses 2 new member functions of the Fl_Gl_Window class,
pixel_w() and pixel_h() returning the window dimensions in pixel
units, that is, twice the w() and h() when the window is mapped
on a retina display.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10498 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2014-12-20 10:19:23 +03:00
|
|
|
*/
|
|
|
|
static void use_high_res_GL(int val) { use_high_res_GL_ = val; }
|
|
|
|
/** returns whether GL windows should be drawn at high resolution on Apple
|
|
|
|
computers with retina displays.
|
|
|
|
Default is no.
|
2015-01-19 16:14:15 +03:00
|
|
|
\version 1.3.4
|
Changed OpenGL support for the Mac OS X platform: use cocoa instead of deprecated AGL.
All changes are mac-specific, except a very minor change in file src/gl_draw.cxx
where string drawing wrongly claimed to support @symbol, not possible
because symbols are drawn using non-GL primitives.
Unchanged application code can use the new FLTK code.
In addition, the new code allows mac applications to draw OpenGL scenes
at high resolution on so-called 'retina' displays, but this requires some
support from app code. They must call, before opening GL windows,
Fl::use_high_resolution(1);
and change their glViewport() calls as follows
glViewport(0, 0, pxel_w(), pixel_h());
This uses 2 new member functions of the Fl_Gl_Window class,
pixel_w() and pixel_h() returning the window dimensions in pixel
units, that is, twice the w() and h() when the window is mapped
on a retina display.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10498 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2014-12-20 10:19:23 +03:00
|
|
|
*/
|
|
|
|
static int use_high_res_GL() { return use_high_res_GL_; }
|
2018-02-07 18:34:44 +03:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
*/
|
|
|
|
static void draw_GL_text_with_textures(int val) { 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
|
|
|
|
*/
|
|
|
|
static int draw_GL_text_with_textures() { return draw_GL_text_with_textures_; }
|
|
|
|
|
2008-09-18 17:20:25 +04:00
|
|
|
|
2011-01-06 13:24:58 +03:00
|
|
|
#ifdef FLTK_HAVE_CAIRO
|
2016-02-13 21:02:17 +03:00
|
|
|
/** \defgroup group_cairo Cairo Support Functions and Classes
|
2008-09-25 22:26:33 +04:00
|
|
|
@{
|
|
|
|
*/
|
|
|
|
public:
|
|
|
|
// Cairo support API
|
|
|
|
static cairo_t * cairo_make_current(Fl_Window* w);
|
2016-02-13 21:02:17 +03:00
|
|
|
/** when FLTK_HAVE_CAIRO is defined and cairo_autolink_context() is true,
|
|
|
|
any current window dc is linked to a current cairo context.
|
2008-12-10 23:58:10 +03:00
|
|
|
This is not the default, because it may not be necessary
|
2008-09-25 22:26:33 +04:00
|
|
|
to add cairo support to all fltk supported windows.
|
|
|
|
When you wish to associate a cairo context in this mode,
|
2008-12-10 23:58:10 +03:00
|
|
|
you need to call explicitly in your draw() overridden method,
|
2016-02-13 21:02:17 +03:00
|
|
|
Fl::cairo_make_current(Fl_Window*). This will create a cairo context
|
2008-09-25 22:26:33 +04:00
|
|
|
but only for this Window.
|
|
|
|
Still in custom cairo application it is possible to handle
|
2009-03-24 04:40:44 +03:00
|
|
|
completely this process automatically by setting \p alink to true.
|
2008-12-10 23:58:10 +03:00
|
|
|
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.
|
2008-09-25 22:26:33 +04:00
|
|
|
\note Only available when configure has the --enable-cairo option
|
|
|
|
*/
|
|
|
|
static void cairo_autolink_context(bool alink) {cairo_state_.autolink(alink);}
|
|
|
|
/**
|
2008-12-10 23:58:10 +03:00
|
|
|
Gets the current autolink mode for cairo support.
|
2008-09-25 22:26:33 +04:00
|
|
|
\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 when configure has the --enable-cairo option
|
|
|
|
*/
|
|
|
|
static bool cairo_autolink_context() {return cairo_state_.autolink();}
|
|
|
|
/** Gets the current cairo context linked with a fltk window. */
|
|
|
|
static cairo_t * cairo_cc() { return cairo_state_.cc(); }
|
2009-03-24 04:40:44 +03:00
|
|
|
/** Sets the current cairo context to \p c.
|
|
|
|
Set \p own to true if you want fltk to handle this cc deletion.
|
2008-09-25 22:26:33 +04:00
|
|
|
\note Only available when configure has the --enable-cairo option
|
|
|
|
*/
|
|
|
|
static void cairo_cc(cairo_t * c, bool own=false){ cairo_state_.cc(c, own); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
static cairo_t * cairo_make_current(void* gc);
|
|
|
|
static cairo_t * cairo_make_current(void* gc, int W, int H);
|
|
|
|
static Fl_Cairo_State cairo_state_;
|
|
|
|
public:
|
|
|
|
/** @} */
|
|
|
|
|
2011-01-06 13:24:58 +03:00
|
|
|
#endif // FLTK_HAVE_CAIRO
|
2008-09-25 22:26:33 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
2009-02-08 17:44:15 +03:00
|
|
|
/**
|
|
|
|
This class should be used to control safe widget deletion.
|
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
You can use an Fl_Widget_Tracker object to watch another widget, if you
|
2017-07-20 18:06:11 +03:00
|
|
|
need to know whether this widget has been deleted during a callback.
|
2009-02-08 17:44:15 +03:00
|
|
|
|
|
|
|
This simplifies the use of the "safe widget deletion" methods
|
2009-04-19 16:47:36 +04:00
|
|
|
Fl::watch_widget_pointer() and Fl::release_widget_pointer() and
|
2017-07-20 18:06:11 +03:00
|
|
|
makes their use more reliable, because the destructor automatically
|
2009-02-08 17:44:15 +03:00
|
|
|
releases the widget pointer from the widget watch list.
|
|
|
|
|
2017-07-20 18:06:11 +03:00
|
|
|
Fl_Widget_Tracker is intended to be used as an automatic (local/stack)
|
|
|
|
variable, such that its destructor is called when the object's
|
2009-02-08 17:44:15 +03:00
|
|
|
scope is left. This ensures that no stale widget pointers are
|
|
|
|
left in the widget watch list (see example below).
|
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
You can also create Fl_Widget_Tracker objects with \c new, but then it
|
2009-02-08 17:44:15 +03:00
|
|
|
is your responsibility to delete the object (and thus remove the
|
2017-07-20 18:06:11 +03:00
|
|
|
widget pointer from the watch list) when it is no longer needed.
|
2009-02-08 17:44:15 +03:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
\code
|
2017-07-20 18:06:11 +03:00
|
|
|
int MyClass::handle (int event) {
|
2009-02-08 17:44:15 +03:00
|
|
|
|
2017-07-20 18:06:11 +03:00
|
|
|
if (...) {
|
|
|
|
Fl_Widget_Tracker wp(this); // watch myself
|
|
|
|
do_callback(); // call the callback
|
2009-02-08 17:44:15 +03:00
|
|
|
|
2017-07-20 18:06:11 +03:00
|
|
|
if (wp.deleted()) return 1; // exit, if deleted
|
2009-02-08 17:44:15 +03:00
|
|
|
|
2017-07-20 18:06:11 +03:00
|
|
|
// Now we are sure that the widget has not been deleted,
|
|
|
|
// and it is safe to access the widget:
|
2009-02-08 17:44:15 +03:00
|
|
|
|
2017-07-20 18:06:11 +03:00
|
|
|
box(FL_FLAT_BOX);
|
|
|
|
color(FL_WHITE);
|
|
|
|
redraw();
|
2009-02-08 17:44:15 +03:00
|
|
|
}
|
2017-07-20 18:06:11 +03:00
|
|
|
}
|
2009-02-08 17:44:15 +03:00
|
|
|
\endcode
|
|
|
|
|
|
|
|
*/
|
2009-02-15 16:49:34 +03:00
|
|
|
class FL_EXPORT Fl_Widget_Tracker {
|
2009-02-08 17:44:15 +03:00
|
|
|
|
|
|
|
Fl_Widget* wp_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-02-15 16:49:34 +03:00
|
|
|
Fl_Widget_Tracker(Fl_Widget *wi);
|
|
|
|
~Fl_Widget_Tracker();
|
2009-02-08 17:44:15 +03:00
|
|
|
|
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
Returns a pointer to the watched widget.
|
2009-02-08 17:44:15 +03:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
This pointer is \c NULL, if the widget has been deleted.
|
2009-02-08 17:44:15 +03:00
|
|
|
*/
|
|
|
|
Fl_Widget *widget() {return wp_;}
|
|
|
|
|
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
Returns 1, if the watched widget has been deleted.
|
2009-02-08 17:44:15 +03:00
|
|
|
|
|
|
|
This is a convenience method. You can also use something like
|
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
<tt> if (wp.widget() == 0) // ...</tt>
|
2009-02-08 17:44:15 +03:00
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
where \p wp is an Fl_Widget_Tracker object.
|
2009-02-08 17:44:15 +03:00
|
|
|
*/
|
|
|
|
int deleted() {return wp_ == 0;}
|
|
|
|
|
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
Returns 1, if the watched widget exists (has not been deleted).
|
2009-02-08 17:44:15 +03:00
|
|
|
|
|
|
|
This is a convenience method. You can also use something like
|
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
<tt> if (wp.widget() != 0) // ...</tt>
|
2009-02-08 17:44:15 +03:00
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
where \p wp is an Fl_Widget_Tracker object.
|
2009-02-08 17:44:15 +03:00
|
|
|
*/
|
|
|
|
int exists() {return wp_ != 0;}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-04-15 12:35:28 +04:00
|
|
|
/** \defgroup fl_unicode Unicode and UTF-8 functions
|
2010-12-01 20:48:59 +03:00
|
|
|
fl global Unicode and UTF-8 handling functions declared in <FL/fl_utf8.h>
|
2009-04-15 12:35:28 +04:00
|
|
|
@{ */
|
|
|
|
/** @} */
|
|
|
|
|
2001-11-28 23:43:44 +03:00
|
|
|
#endif // !Fl_H
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|