FLTK 1.4.0
|
Fl_Widget is the base class for all widgets in FLTK. More...
#include <Fl_Widget.H>
Public Member Functions | |
void | _clear_fullscreen () |
void | _set_fullscreen () |
void | activate () |
Activates the widget. More... | |
unsigned int | active () const |
Returns whether the widget is active. More... | |
int | active_r () const |
Returns whether the widget and all of its parents are active. More... | |
Fl_Align | align () const |
Gets the label alignment. More... | |
void | align (Fl_Align alignment) |
Sets the label alignment. More... | |
long | argument () const |
Gets the current user data (long) argument that is passed to the callback function. More... | |
void | argument (long v) |
Sets the current user data (long) argument that is passed to the callback function. More... | |
virtual class Fl_Gl_Window * | as_gl_window () |
Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window. More... | |
virtual class Fl_Gl_Window const * | as_gl_window () const |
virtual Fl_Group * | as_group () |
Returns an Fl_Group pointer if this widget is an Fl_Group. More... | |
virtual Fl_Group const * | as_group () const |
virtual Fl_Window * | as_window () |
Returns an Fl_Window pointer if this widget is an Fl_Window. More... | |
virtual Fl_Window const * | as_window () const |
void | bind_deimage (Fl_Image *img) |
Sets the image to use as part of the widget label when in the inactive state. More... | |
void | bind_deimage (int f) |
Bind the inactive image to the widget, so the widget will delete the image when it is no longer needed. More... | |
void | bind_image (Fl_Image *img) |
Sets the image to use as part of the widget label when in the active state. More... | |
void | bind_image (int f) |
Bind the image to the widget, so the widget will delete the image when it is no longer needed. More... | |
Fl_Boxtype | box () const |
Gets the box type of the widget. More... | |
void | box (Fl_Boxtype new_box) |
Sets the box type for the widget. More... | |
Fl_Callback_p | callback () const |
Gets the current callback function for the widget. More... | |
void | callback (Fl_Callback *cb) |
Sets the current callback function for the widget. More... | |
void | callback (Fl_Callback *cb, Fl_Callback_User_Data *p, bool auto_free) |
Sets the current callback function and managed user data for the widget. More... | |
void | callback (Fl_Callback *cb, void *p) |
Sets the current callback function and data for the widget. More... | |
void | callback (Fl_Callback0 *cb) |
Sets the current callback function for the widget. More... | |
void | callback (Fl_Callback1 *cb, long p=0) |
Sets the current callback function for the widget. More... | |
unsigned int | changed () const |
Checks if the widget value changed since the last callback. More... | |
void | clear_active () |
Marks the widget as inactive without sending events or changing focus. More... | |
void | clear_changed () |
Marks the value of the widget as unchanged. More... | |
void | clear_damage (uchar c=0) |
Clears or sets the damage flags. More... | |
void | clear_output () |
Sets a widget to accept input. More... | |
void | clear_visible () |
Hides the widget. More... | |
void | clear_visible_focus () |
Disables keyboard focus navigation with this widget. More... | |
Fl_Color | color () const |
Gets the background color of the widget. More... | |
void | color (Fl_Color bg) |
Sets the background color of the widget. More... | |
void | color (Fl_Color bg, Fl_Color sel) |
Sets the background and selection color of the widget. More... | |
Fl_Color | color2 () const |
For back compatibility only. More... | |
void | color2 (unsigned a) |
For back compatibility only. More... | |
int | contains (const Fl_Widget *w) const |
Checks if w is a child of this widget. More... | |
void | copy_label (const char *new_label) |
Sets the current label. More... | |
void | copy_tooltip (const char *text) |
Sets the current tooltip text. More... | |
uchar | damage () const |
Returns non-zero if draw() needs to be called. More... | |
void | damage (uchar c) |
Sets the damage bits for the widget. More... | |
void | damage (uchar c, int x, int y, int w, int h) |
Sets the damage bits for an area inside the widget. More... | |
int | damage_resize (int, int, int, int) |
Internal use only. | |
void | deactivate () |
Deactivates the widget. More... | |
Fl_Image * | deimage () |
Gets the image that is used as part of the widget label when in the inactive state. More... | |
const Fl_Image * | deimage () const |
Gets the image that is used as part of the widget label when in the inactive state. More... | |
void | deimage (Fl_Image &img) |
Sets the image to use as part of the widget label when in the inactive state. More... | |
void | deimage (Fl_Image *img) |
Sets the image to use as part of the widget label when in the inactive state. More... | |
int | deimage_bound () const |
Returns whether the inactive image is managed by the widget. More... | |
void | do_callback (Fl_Callback_Reason reason=FL_REASON_UNKNOWN) |
Calls the widget callback function with default arguments. More... | |
void | do_callback (Fl_Widget *widget, long arg, Fl_Callback_Reason reason=FL_REASON_UNKNOWN) |
Calls the widget callback function with arbitrary arguments. More... | |
void | do_callback (Fl_Widget *widget, void *arg=0, Fl_Callback_Reason reason=FL_REASON_UNKNOWN) |
Calls the widget callback function with arbitrary arguments. More... | |
virtual void | draw ()=0 |
Draws the widget. More... | |
void | draw_label (int, int, int, int, Fl_Align) const |
Draws the label in an arbitrary bounding box with an arbitrary alignment. More... | |
int | h () const |
Gets the widget height. More... | |
virtual int | handle (int event) |
Handles the specified event. More... | |
virtual void | hide () |
Makes a widget invisible. More... | |
int | horizontal_label_margin () |
Get the spacing between the label and the horizontal edge of the widget. More... | |
void | horizontal_label_margin (int px) |
Set the spacing between the label and the horizontal edge of the widget. More... | |
Fl_Image * | image () |
Gets the image that is used as part of the widget label when in the active state. More... | |
const Fl_Image * | image () const |
Gets the image that is used as part of the widget label when in the active state. More... | |
void | image (Fl_Image &img) |
Sets the image to use as part of the widget label when in the active state. More... | |
void | image (Fl_Image *img) |
Sets the image to use as part of the widget label when in the active state. More... | |
int | image_bound () const |
Returns whether the image is managed by the widget. More... | |
int | inside (const Fl_Widget *wgt) const |
Checks if this widget is a child of wgt . More... | |
int | is_label_copied () const |
Returns whether the current label was assigned with copy_label(). More... | |
const char * | label () const |
Gets the current label text. More... | |
void | label (const char *text) |
Sets the current label pointer. More... | |
void | label (Fl_Labeltype a, const char *b) |
Shortcut to set the label text and type in one call. More... | |
int | label_image_spacing () |
Return the gap size between the label and the image. More... | |
void | label_image_spacing (int gap) |
Set the gap between the label and the image in pixels. More... | |
Fl_Color | labelcolor () const |
Gets the label color. More... | |
void | labelcolor (Fl_Color c) |
Sets the label color. More... | |
Fl_Font | labelfont () const |
Gets the font to use. More... | |
void | labelfont (Fl_Font f) |
Sets the font to use. More... | |
Fl_Fontsize | labelsize () const |
Gets the font size in pixels. More... | |
void | labelsize (Fl_Fontsize pix) |
Sets the font size in pixels. More... | |
Fl_Labeltype | labeltype () const |
Gets the label type. More... | |
void | labeltype (Fl_Labeltype a) |
Sets the label type. More... | |
void | measure_label (int &ww, int &hh) const |
Sets width ww and height hh accordingly with the label size. More... | |
bool | needs_keyboard () const |
Returns whether this widget needs a keyboard. More... | |
void | needs_keyboard (bool needs) |
Sets whether this widget needs a keyboard. More... | |
unsigned int | output () const |
Returns if a widget is used for output only. More... | |
Fl_Group * | parent () const |
Returns a pointer to the parent widget. More... | |
void | parent (Fl_Group *p) |
Internal use only - "for hacks only". More... | |
void | position (int X, int Y) |
Repositions the window or widget. More... | |
void | redraw () |
Schedules the drawing of the widget. More... | |
void | redraw_label () |
Schedules the drawing of the label. More... | |
virtual void | resize (int x, int y, int w, int h) |
Changes the size or position of the widget. More... | |
Fl_Color | selection_color () const |
Gets the selection color. More... | |
void | selection_color (Fl_Color a) |
Sets the selection color. More... | |
void | set_active () |
Marks the widget as active without sending events or changing focus. More... | |
void | set_changed () |
Marks the value of the widget as changed. More... | |
void | set_output () |
Sets a widget to output only. More... | |
void | set_visible () |
Makes the widget visible. More... | |
void | set_visible_focus () |
Enables keyboard focus navigation with this widget. More... | |
int | shortcut_label () const |
Returns whether the widget's label uses '&' to indicate shortcuts. More... | |
void | shortcut_label (int value) |
Sets whether the widget's label uses '&' to indicate shortcuts. More... | |
virtual void | show () |
Makes a widget visible. More... | |
void | size (int W, int H) |
Changes the size of the widget. More... | |
int | take_focus () |
Gives the widget the keyboard focus. More... | |
unsigned int | takesevents () const |
Returns if the widget is able to take events. More... | |
int | test_shortcut () |
Returns true if the widget's label contains the entered '&x' shortcut. More... | |
const char * | tooltip () const |
Gets the current tooltip text. More... | |
void | tooltip (const char *text) |
Sets the current tooltip text. More... | |
Fl_Window * | top_window () const |
Returns a pointer to the top-level window for the widget. More... | |
Fl_Window * | top_window_offset (int &xoff, int &yoff) const |
Finds the x/y offset of the current widget relative to the top-level window. More... | |
uchar | type () const |
Gets the widget type. More... | |
void | type (uchar t) |
Sets the widget type. More... | |
int | use_accents_menu () |
Returns non zero if MAC_USE_ACCENTS_MENU flag is set, 0 otherwise. | |
void * | user_data () const |
Gets the user data for this widget. More... | |
void | user_data (Fl_Callback_User_Data *v, bool auto_free) |
Sets the user data for this widget. | |
void | user_data (void *v) |
Sets the user data for this widget. | |
int | vertical_label_margin () |
Get the spacing between the label and the vertical edge of the widget. More... | |
void | vertical_label_margin (int px) |
Set the spacing between the label and the vertical edge of the widget. More... | |
unsigned int | visible () const |
Returns whether a widget is visible. More... | |
unsigned int | visible_focus () const |
Checks whether this widget has a visible focus. More... | |
void | visible_focus (int v) |
Modifies keyboard focus navigation. More... | |
int | visible_r () const |
Returns whether a widget and all its parents are visible. More... | |
int | w () const |
Gets the widget width. More... | |
Fl_When | when () const |
Returns the conditions under which the callback is called. More... | |
void | when (uchar i) |
Sets the flags used to decide when a callback is called. More... | |
Fl_Window * | window () const |
Returns a pointer to the nearest parent window up the widget hierarchy. More... | |
int | x () const |
Gets the widget position in its window. More... | |
int | y () const |
Gets the widget position in its window. More... | |
virtual | ~Fl_Widget () |
Destroys the widget. More... | |
Static Public Member Functions | |
static void | default_callback (Fl_Widget *widget, void *data) |
The default callback for all widgets that don't set a callback. More... | |
static unsigned int | label_shortcut (const char *t) |
Returns the Unicode value of the '&x' shortcut in a given text. More... | |
static int | test_shortcut (const char *, const bool require_alt=false) |
Returns true if the given text t contains the entered '&x' shortcut. More... | |
Protected Types | |
enum | { INACTIVE = 1<<0 , INVISIBLE = 1<<1 , OUTPUT = 1<<2 , NOBORDER = 1<<3 , FORCE_POSITION = 1<<4 , NON_MODAL = 1<<5 , SHORTCUT_LABEL = 1<<6 , CHANGED = 1<<7 , OVERRIDE = 1<<8 , VISIBLE_FOCUS = 1<<9 , COPIED_LABEL = 1<<10 , CLIP_CHILDREN = 1<<11 , MENU_WINDOW = 1<<12 , TOOLTIP_WINDOW = 1<<13 , MODAL = 1<<14 , NO_OVERLAY = 1<<15 , GROUP_RELATIVE = 1<<16 , COPIED_TOOLTIP = 1<<17 , FULLSCREEN = 1<<18 , MAC_USE_ACCENTS_MENU = 1<<19 , NEEDS_KEYBOARD = 1<<20 , IMAGE_BOUND = 1<<21 , DEIMAGE_BOUND = 1<<22 , AUTO_DELETE_USER_DATA = 1<<23 , MAXIMIZED = 1<<24 , POPUP = 1<<25 , USERFLAG3 = 1<<29 , USERFLAG2 = 1<<30 , USERFLAG1 = 1<<31 } |
flags possible values enumeration. More... | |
Protected Member Functions | |
void | clear_flag (unsigned int c) |
Clears a flag in the flags mask. | |
void | draw_backdrop () const |
If FL_ALIGN_IMAGE_BACKDROP is set, the image or deimage will be drawn. | |
void | draw_box () const |
Draws the widget box according its box style. | |
void | draw_box (Fl_Boxtype t, Fl_Color c) const |
Draws a box of type t, of color c at the widget's position and size. | |
void | draw_box (Fl_Boxtype t, int x, int y, int w, int h, Fl_Color c) const |
Draws a box of type t, of color c at the position X,Y and size W,H. | |
void | draw_focus () const |
Draws a focus rectangle around the widget. More... | |
void | draw_focus (Fl_Boxtype t, int X, int Y, int W, int H) const |
Draws a focus rectangle around the widget. More... | |
void | draw_focus (Fl_Boxtype t, int x, int y, int w, int h, Fl_Color bg) const |
Draws a focus box for the widget at the given position and size. More... | |
void | draw_label () const |
Draws the widget's label at the defined label position. More... | |
void | draw_label (int, int, int, int) const |
Draws the label in an arbitrary bounding box. More... | |
Fl_Widget (int x, int y, int w, int h, const char *label=0L) | |
Creates a widget at the given position and size. More... | |
unsigned int | flags () const |
Gets the widget flags mask. | |
void | h (int v) |
Internal use only. More... | |
void | set_flag (unsigned int c) |
Sets a flag in the flags mask. | |
void | w (int v) |
Internal use only. More... | |
void | x (int v) |
Internal use only. More... | |
void | y (int v) |
Internal use only. More... | |
Friends | |
class | Fl_Group |
Fl_Widget is the base class for all widgets in FLTK.
You can't create one of these because the constructor is not public. However you can subclass it.
All "property" accessing methods, such as color(), parent(), or argument() are implemented as trivial inline functions and thus are as fast and small as accessing fields in a structure. Unless otherwise noted, the property setting methods such as color(n) or label(s) are also trivial inline functions, even if they change the widget's appearance. It is up to the user code to call redraw() after these.
|
protected |
flags possible values enumeration.
See activate(), output(), visible(), changed(), set_visible_focus()
Enumerator | |
---|---|
INACTIVE | the widget can't receive focus, and is disabled but potentially visible |
INVISIBLE | the widget is not drawn, but can receive a few special events |
OUTPUT | for output only |
NOBORDER | don't draw a decoration (Fl_Window) |
FORCE_POSITION | don't let the window manager position the window (Fl_Window) |
NON_MODAL | this is a hovering toolbar window (Fl_Window) |
SHORTCUT_LABEL | the label contains a shortcut we need to draw |
CHANGED | the widget value changed |
OVERRIDE | position window on top (Fl_Window) |
VISIBLE_FOCUS | accepts keyboard focus navigation if the widget can have the focus |
COPIED_LABEL | the widget label is internally copied, its destruction is handled by the widget |
CLIP_CHILDREN | all drawing within this widget will be clipped (Fl_Group) |
MENU_WINDOW | a temporary popup window, dismissed by clicking outside (Fl_Window) |
TOOLTIP_WINDOW | a temporary popup, transparent to events, and dismissed easily (Fl_Window) |
MODAL | a window blocking input to all other windows (Fl_Window) |
NO_OVERLAY | window not using a hardware overlay plane (Fl_Menu_Window) |
GROUP_RELATIVE | Reserved, not implemented. DO NOT USE. |
COPIED_TOOLTIP | the widget tooltip is internally copied, its destruction is handled by the widget |
FULLSCREEN | a fullscreen window (Fl_Window) |
MAC_USE_ACCENTS_MENU | On the macOS platform, pressing and holding a key on the keyboard opens an accented-character menu window (Fl_Input_, Fl_Text_Editor) |
NEEDS_KEYBOARD | set on touch screen devices if a widget needs a keyboard when it gets the focus. Reserved, not yet used in 1.4.0.
|
IMAGE_BOUND | binding the image to the widget will transfer ownership, so that the widget will delete the image when it is no longer needed |
DEIMAGE_BOUND | bind the inactive image to the widget, so the widget deletes the image when it is no longer needed |
AUTO_DELETE_USER_DATA | automatically call |
MAXIMIZED | a maximized Fl_Window |
POPUP | popup window (i.e., positioned relatively to another mapped window) |
USERFLAG3 | reserved for 3rd party extensions |
USERFLAG2 | reserved for 3rd party extensions |
USERFLAG1 | reserved for 3rd party extensions |
|
protected |
Creates a widget at the given position and size.
The Fl_Widget is a protected constructor, but all derived widgets have a matching public constructor. It takes a value for x(), y(), w(), h(), and an optional value for label().
[in] | x,y | the position of the widget relative to the enclosing window |
[in] | w,h | size of the widget in pixels |
[in] | label | optional text for the widget label |
|
virtual |
Destroys the widget.
Destroys the widget, taking care of throwing focus before if any.
Destroying single widgets is not very common. You almost always want to destroy the parent group instead, which will destroy all of the child widgets and groups in that group.
Destruction removes the widget from any parent group! And groups when destroyed destroy all their children. This is convenient and fast.
void Fl_Widget::activate | ( | ) |
Activates the widget.
Changing this value will send FL_ACTIVATE to the widget if active_r() is true.
|
inline |
Returns whether the widget is active.
0 | if the widget is inactive |
int Fl_Widget::active_r | ( | ) | const |
Returns whether the widget and all of its parents are active.
0 | if this or any of the parent widgets are inactive |
|
inline |
|
inline |
|
inline |
Gets the current user data (long) argument that is passed to the callback function.
sizeof(long) < sizeof(void*)
, particularly on Windows 64-bit platforms, this method can truncate stored addresses
(void*) to the size of a long
value. Use with care and only if you are sure that the stored user_data value fits in a long
value because it was stored with argument(long) or another method using only long
values. You may want to use user_data() instead.
|
inline |
Sets the current user data (long) argument that is passed to the callback function.
|
inlinevirtual |
Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from Fl_Gl_Window. If it returns non-NULL, then the widget in question is derived from Fl_Gl_Window.
NULL | if this widget is not derived from Fl_Gl_Window. |
Reimplemented in Fl_Gl_Window.
|
inlinevirtual |
Returns an Fl_Group pointer if this widget is an Fl_Group.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from Fl_Group. If it returns non-NULL, then the widget in question is derived from Fl_Group, and you can use the returned pointer to access its children or other Fl_Group-specific methods.
Example:
NULL | if this widget is not derived from Fl_Group. |
Reimplemented in Fl_Group.
|
inlinevirtual |
Returns an Fl_Window pointer if this widget is an Fl_Window.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from Fl_Window. If it returns non-NULL, then the widget in question is derived from Fl_Window, and you can use the returned pointer to access its children or other Fl_Window-specific methods.
NULL | if this widget is not derived from Fl_Window. |
Reimplemented in Fl_Window.
void Fl_Widget::bind_deimage | ( | Fl_Image * | img | ) |
Sets the image to use as part of the widget label when in the inactive state.
[in] | img | the new image for the deactivated widget |
|
inline |
Bind the inactive image to the widget, so the widget will delete the image when it is no longer needed.
f | 1: mark the image as bound, 0: mark the image as managed by the user |
void Fl_Widget::bind_image | ( | Fl_Image * | img | ) |
Sets the image to use as part of the widget label when in the active state.
The image will be bound to the widget. When the widget is deleted, the image will be deleted as well.
Calling bind_image() with a new image will delete the old image if it was bound, and then set the new image, and bind that. If old and new image are the same, nothing happens.
Calling bind_image() with NULL will delete the old image if it was bound and not set a new image.
[in] | img | the new image for the label |
|
inline |
Bind the image to the widget, so the widget will delete the image when it is no longer needed.
f | 1: mark the image as bound, 0: mark the image as managed by the user |
|
inline |
|
inline |
Sets the box type for the widget.
This identifies a routine that draws the background of the widget. See Fl_Boxtype for the available types. The default depends on the widget, but is usually FL_NO_BOX or FL_UP_BOX.
[in] | new_box | the new box type |
|
inline |
Gets the current callback function for the widget.
Each widget has a single callback.
|
inline |
Sets the current callback function for the widget.
Each widget has a single callback.
[in] | cb | new callback |
|
inline |
Sets the current callback function and managed user data for the widget.
Setting auto_free will transfer ownership of the callback user data to the widget. Deleting the widget will then also delete the user data.
[in] | cb | new callback |
[in] | p | user data |
[in] | auto_free | if set, the widget will free user data when destroyed |
|
inline |
Sets the current callback function and data for the widget.
Each widget has a single callback.
[in] | cb | new callback |
[in] | p | user data |
|
inline |
Sets the current callback function for the widget.
Each widget has a single callback.
[in] | cb | new callback |
|
inline |
Sets the current callback function for the widget.
Each widget has a single callback.
[in] | cb | new callback |
[in] | p | user data |
|
inline |
Checks if the widget value changed since the last callback.
"Changed" is a flag that is turned on when the user changes the value stored in the widget. This is only used by subclasses of Fl_Widget that store values, but is in the base class so it is easier to scan all the widgets in a panel and do_callback() on the changed ones in response to an "OK" button.
Most widgets turn this flag off when they do the callback, and when the program sets the stored value.
0 | if the value did not change |
|
inline |
Marks the widget as inactive without sending events or changing focus.
This is mainly for specialized use, for normal cases you want deactivate().
|
inline |
Marks the value of the widget as unchanged.
|
inline |
Clears or sets the damage flags.
Damage flags are cleared when parts of the widget drawing is repaired.
The optional argument c
specifies the bits that are set after the call (default: 0) and not the bits that are cleared!
[in] | c | new bitmask of damage flags (default: 0) |
|
inline |
Sets a widget to accept input.
|
inline |
Hides the widget.
You must still redraw the parent to see a change in the window. Normally you want to use the hide() method instead.
|
inline |
Disables keyboard focus navigation with this widget.
Normally, all widgets participate in keyboard focus navigation.
|
inline |
Gets the background color of the widget.
|
inline |
Sets the background color of the widget.
The color is passed to the box routine. The color is either an index into an internal table of RGB colors or an RGB color value generated using fl_rgb_color().
The default for most widgets is FL_BACKGROUND_COLOR. Use Fl::set_color() to redefine colors in the color map.
[in] | bg | background color |
Sets the background and selection color of the widget.
The two color form sets both the background and selection colors.
[in] | bg | background color |
[in] | sel | selection color |
|
inline |
For back compatibility only.
|
inline |
For back compatibility only.
int Fl_Widget::contains | ( | const Fl_Widget * | w | ) | const |
Checks if w is a child of this widget.
[in] | w | potential child widget |
w
is a child of this widget, or is equal to this widget. Returns 0 if w
is NULL. void Fl_Widget::copy_label | ( | const char * | new_label | ) |
Sets the current label.
Unlike label(), this method allocates a copy of the label string instead of using the original string pointer.
The internal copy will automatically be freed whenever you assign a new label or when the widget is destroyed.
[in] | new_label | the new label text |
void Fl_Widget::copy_tooltip | ( | const char * | text | ) |
Sets the current tooltip text.
Unlike tooltip(), this method allocates a copy of the tooltip string instead of using the original string pointer.
The internal copy will automatically be freed whenever you assign a new tooltip or when the widget is destroyed.
If no tooltip is set, the tooltip of the parent is inherited. Setting a tooltip for a group and setting no tooltip for a child will show the group's tooltip instead. To avoid this behavior, you can set the child's tooltip to an empty string ("").
[in] | text | New tooltip text (an internal copy is made and managed) |
|
inline |
Returns non-zero if draw() needs to be called.
The damage value is actually a bit field that the widget subclass can use to figure out what parts to draw.
void Fl_Widget::damage | ( | uchar | c | ) |
Sets the damage bits for the widget.
Setting damage bits will schedule the widget for the next redraw.
[in] | c | bitmask of flags to set |
void Fl_Widget::damage | ( | uchar | c, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) |
Sets the damage bits for an area inside the widget.
Setting damage bits will schedule the widget for the next redraw.
[in] | c | bitmask of flags to set |
[in] | x,y,w,h | size of damaged area |
void Fl_Widget::deactivate | ( | ) |
Deactivates the widget.
Inactive widgets will be drawn "grayed out", e.g. with less contrast than the active widget. Inactive widgets will not receive any keyboard or mouse button events. Other events (including FL_ENTER, FL_MOVE, FL_LEAVE, FL_SHORTCUT, and others) will still be sent. A widget is only active if active() is true on it and all of its parents.
Changing this value will send FL_DEACTIVATE to the widget if active_r() is true.
Currently you cannot deactivate Fl_Window widgets.
|
static |
The default callback for all widgets that don't set a callback.
This callback function puts a pointer to the widget on the queue returned by Fl::readqueue(). This is the default for all widgets if you don't set a callback.
You can avoid the overhead of this default handling if you set the callback to NULL
explicitly.
Relying on the default callback and reading the callback queue with Fl::readqueue() is not recommended. If you need a callback, you should set one with Fl_Widget::callback(Fl_Callback *cb, void *data) or one of its variants.
[in] | widget | the Fl_Widget given to the callback |
[in] | data | user data associated with that callback |
|
inline |
Gets the image that is used as part of the widget label when in the inactive state.
|
inline |
Gets the image that is used as part of the widget label when in the inactive state.
void Fl_Widget::deimage | ( | Fl_Image & | img | ) |
Sets the image to use as part of the widget label when in the inactive state.
[in] | img | the new image for the deactivated widget |
void Fl_Widget::deimage | ( | Fl_Image * | img | ) |
Sets the image to use as part of the widget label when in the inactive state.
[in] | img | the new image for the deactivated widget |
img
is not deleted while it's used by the widget, and, if appropriate, for deleting it after the widget's deletion.
|
inline |
Returns whether the inactive image is managed by the widget.
0 | if the image is not bound to the widget |
1 | if the image will be deleted when the widget is deleted |
|
inline |
Calls the widget callback function with default arguments.
This is the same as calling
[in] | reason | give a reason to why this callback was called, defaults to FL_REASON_UNKNOWN |
|
inline |
Calls the widget callback function with arbitrary arguments.
[in] | widget | call the callback with widget as the first argument |
[in] | arg | call the callback with arg as the user data (second) argument |
[in] | reason | give a reason to why this callback was called, defaults to FL_REASON_UNKNOWN |
void Fl_Widget::do_callback | ( | Fl_Widget * | widget, |
void * | arg = 0 , |
||
Fl_Callback_Reason | reason = FL_REASON_UNKNOWN |
||
) |
Calls the widget callback function with arbitrary arguments.
All overloads of do_callback() call this method. It does nothing if the widget's callback() is NULL. It clears the widget's changed flag after the callback was called unless the callback is the default callback. Hence it is not necessary to call clear_changed() after calling do_callback() in your own widget's handle() method.
A reason
must be set for widgets if different actions can trigger the same callback.
[in] | widget | call the callback with widget as the first argument |
[in] | arg | use arg as the user data (second) argument |
[in] | reason | give a reason to why this callback was called, defaults to FL_REASON_UNKNOWN |
|
pure virtual |
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:
Implemented in Fl_Adjuster, Fl_Box, Fl_Browser_, Fl_Button, Fl_Cairo_Window, Fl_Chart, Fl_Choice, Fl_Clock_Output, Fl_Counter, Fl_Dial, Fl_File_Input, Fl_Flex, Fl_FormsBitmap, Fl_FormsPixmap, Fl_Free, Fl_Gl_Window, Fl_Grid, Fl_Group, Fl_Help_View, Fl_Input, Fl_Input_Choice, Fl_Light_Button, Fl_Menu_Bar, Fl_Menu_Button, Fl_Pack, Fl_Positioner, Fl_Progress, Fl_Return_Button, Fl_Roller, Fl_Scroll, Fl_Scrollbar, Fl_Shortcut_Button, Fl_Slider, Fl_Spinner, Fl_Sys_Menu_Bar, Fl_Table, Fl_Tabs, Fl_Text_Display, Fl_Timer, Fl_Tree, Fl_Value_Input, Fl_Value_Output, Fl_Value_Slider, Fl_Window, Fl_Wizard, Fl_FormsText, Fl_Glut_Window, and Fl_Terminal.
|
inlineprotected |
Draws a focus rectangle around the widget.
This method uses the widget's boxtype and coordinates and its background color color().
|
inlineprotected |
Draws a focus rectangle around the widget.
This method uses the given boxtype and coordinates and the widget's background color color().
|
protected |
Draws a focus box for the widget at the given position and size.
This method does nothing if
This means that Fl_Widget::draw_focus() or one of the more specialized methods can be called without checking these visible focus options.
The boxtype bt
is used to calculate the inset so the focus box is drawn inside the box borders.
The default focus box drawing color is black. The background color bg
is used to determine a better visible color if necessary by using fl_contrast() with the given background color.
[in] | bt | Boxtype that needs to be considered (frame width) |
[in] | X,Y,W,H | Bounding box |
[in] | bg | Background color |
|
protected |
Draws the widget's label at the defined label position.
This is the normal call for a widget's draw() method.
|
protected |
Draws the label in an arbitrary bounding box.
draw() can use this instead of draw_label(void) to change the bounding box
void Fl_Widget::draw_label | ( | int | X, |
int | Y, | ||
int | W, | ||
int | H, | ||
Fl_Align | a | ||
) | const |
Draws the label in an arbitrary bounding box with an arbitrary alignment.
Anybody can call this to force the label to draw anywhere.
|
inline |
Gets the widget height.
|
inlineprotected |
Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.
|
virtual |
Handles the specified event.
You normally don't call this method directly, but instead let FLTK do it when the user interacts with the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1 otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you don't short-circuit events that you don't handle. In this last case you should return the callee retval.
One exception to the rule in the previous paragraph is if you really want to override the behavior of the base class. This requires knowledge of the details of the inherited class.
In rare cases you may want to return 1 from your handle() method although you don't really handle the event. The effect would be to filter event processing, for instance if you want to dismiss non-numeric characters (keypresses) in a numeric input widget. You may "ring the bell" or show another visual indication or drop the event silently. In such a case you must not call the handle() method of the base class and tell FLTK that you consumed the event by returning 1 even if you didn't do anything with it.
[in] | event | the kind of event received |
0 | if the event was not used or understood |
1 | if the event was used and can be deleted |
Reimplemented in Fl_Color_Chooser, Fl_Free, Fl_Table, Fl_Terminal, Fl_Text_Display, Fl_Text_Editor, Fl_Tree, Fl_Browser_, Fl_File_Input, Fl_Scheme_Choice, Fl_Spinner::Fl_Spinner_Input, Fl_Spinner, Fl_Table_Row, Fl_Tile, Fl_Adjuster, Fl_Box, Fl_Button, Fl_Check_Browser, Fl_Choice, Fl_Clock, Fl_Counter, Fl_Dial, Fl_Gl_Window, Fl_Group, Fl_Help_View, Fl_Input, Fl_Light_Button, Fl_Menu_Bar, Fl_Menu_Button, Fl_Positioner, Fl_Repeat_Button, Fl_Return_Button, Fl_Roller, Fl_Scroll, Fl_Scrollbar, Fl_Secret_Input, Fl_Shortcut_Button, Fl_Slider, Fl_Tabs, Fl_Timer, Fl_Value_Input, Fl_Value_Output, Fl_Value_Slider, Fl_Window, and Fl_Glut_Window.
|
virtual |
Makes a widget invisible.
Reimplemented in Fl_Browser, Fl_Double_Window, Fl_Gl_Window, Fl_Overlay_Window, and Fl_Window.
|
inline |
Get the spacing between the label and the horizontal edge of the widget.
|
inline |
Set the spacing between the label and the horizontal edge of the widget.
[in] | px | gap in pixels |
|
inline |
Gets the image that is used as part of the widget label when in the active state.
|
inline |
Gets the image that is used as part of the widget label when in the active state.
void Fl_Widget::image | ( | Fl_Image & | img | ) |
Sets the image to use as part of the widget label when in the active state.
[in] | img | the new image for the label |
void Fl_Widget::image | ( | Fl_Image * | img | ) |
Sets the image to use as part of the widget label when in the active state.
The caller is responsible for making sure img
is not deleted while it's used by the widget, and, if appropriate, for deleting it after the widget's deletion.
Calling image() with a new image will delete the old image if it was bound, and set the new image without binding it. If old and new are the same, the image will not be deleted, but it will be unbound.
Calling image() with NULL will delete the old image if it was bound and not set a new image.
[in] | img | the new image for the label |
|
inline |
Returns whether the image is managed by the widget.
0 | if the image is not bound to the widget |
1 | if the image will be deleted when the widget is deleted |
|
inline |
Checks if this widget is a child of wgt
.
Returns 1 if this widget is a child of wgt
, or is equal to wgt
. Returns 0 if wgt
is NULL.
[in] | wgt | the possible parent widget. |
|
inline |
Returns whether the current label was assigned with copy_label().
This can be useful for temporarily overwriting the widget's label and restoring it later.
0 | current label was assigned with label(). |
1 | current label was assigned with copy_label(). |
|
inline |
Gets the current label text.
void Fl_Widget::label | ( | const char * | text | ) |
Sets the current label pointer.
The label is shown somewhere on or next to the widget. See Labels and Label Types for details about what can be put in a label. The passed pointer is stored unchanged in the widget (the string is not copied), so if you need to set the label to a formatted value, make sure the buffer is static, global, or allocated. The copy_label() method can be used to make a copy of the label string automatically.
[in] | text | pointer to new label text |
|
inline |
Shortcut to set the label text and type in one call.
|
inline |
Return the gap size between the label and the image.
|
inline |
Set the gap between the label and the image in pixels.
This value is limited to 0..255.
[in] | gap | spacing in pixels |
|
static |
Returns the Unicode value of the '&x' shortcut in a given text.
The given text t
(usually a widget's label or a menu text) is searched for a '&x' shortcut label, and if found, the Unicode value (code point) of the '&x' shortcut is returned.
t | text or label to search for '&x' shortcut. |
t
or 0.
|
inline |
Gets the label color.
The default color is FL_FOREGROUND_COLOR.
|
inline |
Sets the label color.
The default color is FL_FOREGROUND_COLOR.
[in] | c | the new label color |
|
inline |
Gets the font to use.
Fonts are identified by indexes into a table. The default value uses a Helvetica typeface (Arial for Microsoft® Windows®). The function Fl::set_font() can define new typefaces.
|
inline |
Sets the font to use.
Fonts are identified by indexes into a table. The default value uses a Helvetica typeface (Arial for Microsoft® Windows®). The function Fl::set_font() can define new typefaces.
[in] | f | the new font for the label |
|
inline |
Gets the font size in pixels.
The default size is 14 pixels.
|
inline |
|
inline |
|
inline |
Sets the label type.
The label type identifies the function that draws the label of the widget. This is generally used for special effects such as embossing or for using the label() pointer as another form of data such as an icon. The value FL_NORMAL_LABEL prints the label as plain text.
[in] | a | new label type |
|
inline |
Sets width ww and height hh accordingly with the label size.
Labels with images will return w() and h() of the image.
This calls fl_measure() internally. For more information about the arguments ww
and hh
and word wrapping
|
inline |
|
inline |
Sets whether this widget needs a keyboard.
Set this on touch screen devices if a widget needs a keyboard when it gets the focus.
[in] | needs | Set this to true or false |
|
inline |
Returns if a widget is used for output only.
output() means the same as !active() except it does not change how the widget is drawn. The widget will not receive any events. This is useful for making scrollbars or buttons that work as displays rather than input devices.
0 | if the widget is used for input and output |
|
inline |
Returns a pointer to the parent widget.
Usually this is a Fl_Group or Fl_Window.
NULL | if the widget has no parent |
|
inline |
Internal use only - "for hacks only".
It is STRONGLY recommended not to use this method, because it short-circuits Fl_Group's normal widget adding and removing methods, if the widget is already a child widget of another Fl_Group.
Use Fl_Group::add(Fl_Widget*) and/or Fl_Group::remove(Fl_Widget*) instead.
|
inline |
Repositions the window or widget.
position(X, Y) is a shortcut for resize(X, Y, w(), h()).
[in] | X,Y | new position relative to the parent window |
void Fl_Widget::redraw | ( | ) |
Schedules the drawing of the widget.
Marks the widget as needing its draw() routine called.
void Fl_Widget::redraw_label | ( | ) |
Schedules the drawing of the label.
Marks the widget or the parent as needing a redraw for the label area of a widget.
|
virtual |
Changes the size or position of the widget.
This is a virtual function so that the widget may implement its own handling of resizing. The default version does not call the redraw() method, but instead relies on the parent widget to do so because the parent may know a faster way to update the display, such as scrolling from the old position.
Some window managers under X11 call resize() a lot more often than needed. Please verify that the position or size of a widget did actually change before doing any extensive calculations.
position(X, Y) is a shortcut for resize(X, Y, w(), h()), and size(W, H) is a shortcut for resize(x(), y(), W, H).
[in] | x,y | new position relative to the parent window |
[in] | w,h | new size |
Reimplemented in Fl_Browser_, Fl_Flex, Fl_Grid, Fl_Input_Choice, Fl_Pack, Fl_Scroll, Fl_Spinner, Fl_Table, Fl_Terminal, Fl_Text_Display, Fl_Tile, Fl_Window, Fl_Double_Window, Fl_Gl_Window, Fl_Group, Fl_Help_View, Fl_Input_, Fl_Overlay_Window, Fl_Tabs, Fl_Tree, and Fl_Value_Input.
|
inline |
Gets the selection color.
|
inline |
Sets the selection color.
The selection color is defined for Forms compatibility and is usually used to color the widget when it is selected, although some widgets use this color for other purposes. You can set both colors at once with color(Fl_Color bg, Fl_Color sel).
[in] | a | the new selection color |
|
inline |
Marks the widget as active without sending events or changing focus.
This is mainly for specialized use, for normal cases you want activate().
|
inline |
Marks the value of the widget as changed.
|
inline |
Sets a widget to output only.
|
inline |
Makes the widget visible.
You must still redraw the parent widget to see a change in the window. Normally you want to use the show() method instead.
|
inline |
Enables keyboard focus navigation with this widget.
Note, however, that this will not necessarily mean that the widget will accept focus, but for widgets that can accept focus, this method enables it if it has been disabled.
|
inline |
Returns whether the widget's label uses '&' to indicate shortcuts.
|
inline |
Sets whether the widget's label uses '&' to indicate shortcuts.
By default, all objects of classes Fl_Menu_ (and derivatives), Fl_Button (and derivatives), Fl_Text_Display, Fl_Value_Input, and Fl_Input_ (and derivatives) use character '&' in their label, unless '&' is repeated, to indicate shortcuts: '&' does not appear in the drawn label, the next character after '&' in the label is drawn underlined, and typing this character triggers the corresponding menu window, button, or other widget. If the label contains 2 consecutive '&', only one is drawn and the next character is not underlined and not used as a shortcut. If value
is set to 0, all these labels don't process character '&' as indicating a shortcut: '&' is drawn in the label, the next character is not underlined and does not define a shortcut.
|
virtual |
Makes a widget visible.
An invisible widget never gets redrawn and does not get keyboard or mouse events, but can receive a few other events like FL_SHOW.
The visible() method returns true if the widget is set to be visible. The visible_r() method returns true if the widget and all of its parents are visible. A widget is only visible if visible() is true on it and all of its parents.
Changing it will send FL_SHOW or FL_HIDE events to the widget. Do not change it if the parent is not visible, as this will send false FL_SHOW or FL_HIDE events to the widget. redraw() is called if necessary on this or the parent.
Reimplemented in Fl_Browser, Fl_Double_Window, Fl_Gl_Window, Fl_Overlay_Window, Fl_Single_Window, Fl_Tabs, and Fl_Window.
|
inline |
Changes the size of the widget.
size(W, H) is a shortcut for resize(x(), y(), W, H).
[in] | W,H | new size |
int Fl_Widget::take_focus | ( | ) |
Gives the widget the keyboard focus.
Tries to make this widget be the Fl::focus() widget, by first sending it an FL_FOCUS event, and if it returns non-zero, setting Fl::focus() to this widget. You should use this method to assign the focus to a widget.
|
inline |
int Fl_Widget::test_shortcut | ( | ) |
Returns true if the widget's label contains the entered '&x' shortcut.
This method must only be called in handle() methods or callbacks after a keypress event (usually FL_KEYDOWN or FL_SHORTCUT). The widget's label is searched for a '&x' shortcut, and if found, this is compared with the entered key value.
Fl::event_text() is used to get the entered key value.
|
static |
Returns true if the given text t
contains the entered '&x' shortcut.
This method must only be called in handle() methods or callbacks after a keypress event (usually FL_KEYDOWN or FL_SHORTCUT). The given text t
(usually a widget's label or menu text) is searched for a '&x' shortcut, and if found, this is compared with the entered key value.
Fl::event_text() is used to get the entered key value. Fl::event_state() is used to get the Alt modifier, if require_alt
is true.
t | text or label to search for '&x' shortcut. |
require_alt | if true: match only if Alt key is pressed. |
t
false (0) otherwise.
|
inline |
Gets the current tooltip text.
void Fl_Widget::tooltip | ( | const char * | text | ) |
Sets the current tooltip text.
Sets a string of text to display in a popup tooltip window when the user hovers the mouse over the widget. The string is not copied, so make sure any formatted string is stored in a static, global, or allocated buffer. If you want a copy made and managed for you, use the copy_tooltip() method, which will manage the tooltip string automatically.
If no tooltip is set, the tooltip of the parent is inherited. Setting a tooltip for a group and setting no tooltip for a child will show the group's tooltip instead. To avoid this behavior, you can set the child's tooltip to an empty string ("").
[in] | text | New tooltip text (no copy is made) |
Fl_Window * Fl_Widget::top_window | ( | ) | const |
Returns a pointer to the top-level window for the widget.
In other words, the 'window manager window' that contains this widget. This method differs from window() in that it won't return sub-windows (if there are any).
Fl_Window * Fl_Widget::top_window_offset | ( | int & | xoff, |
int & | yoff | ||
) | const |
Finds the x/y offset of the current widget relative to the top-level window.
[out] | xoff,yoff | Returns the x/y offset |
|
inline |
|
inline |
Gets the user data for this widget.
Gets the current user data (void *) argument that is passed to the callback function.
|
inline |
Get the spacing between the label and the vertical edge of the widget.
|
inline |
Set the spacing between the label and the vertical edge of the widget.
[in] | px | gap in pixels |
|
inline |
Returns whether a widget is visible.
0 | if the widget is not drawn and hence invisible. |
|
inline |
Checks whether this widget has a visible focus.
0 | if this widget has no visible focus. |
|
inline |
Modifies keyboard focus navigation.
[in] | v | set or clear visible focus |
int Fl_Widget::visible_r | ( | ) | const |
|
inline |
Gets the widget width.
|
inlineprotected |
Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.
|
inline |
Returns the conditions under which the callback is called.
You can set the flags with when(uchar), the default value is FL_WHEN_RELEASE.
|
inline |
Sets the flags used to decide when a callback is called.
This controls when callbacks are done. The following values are useful, the default value is FL_WHEN_RELEASE:
Fl_Widget::when() is a set of bitflags used by subclasses of Fl_Widget to decide when to do the callback.
If the value is zero then the callback is never done. Other values are described in the individual widgets. This field is in the base class so that you can scan a panel and do_callback() on all the ones that don't do their own callbacks in response to an "OK" button.
[in] | i | set of flags |
Fl_Window * Fl_Widget::window | ( | ) | const |
Returns a pointer to the nearest parent window up the widget hierarchy.
This will return sub-windows if there are any, or the parent window if there's no sub-windows. If this widget IS the top-level window, NULL is returned.
NULL | if no window is associated with this widget. |
|
inline |
Gets the widget position in its window.
|
inlineprotected |
Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.
|
inline |
Gets the widget position in its window.
|
inlineprotected |
Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.