FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_Widget Class Referenceabstract

Fl_Widget is the base class for all widgets in FLTK. More...

`#include <Fl_Widget.H>`

Inheritance diagram for Fl_Widget:

## Public Member Functions
void | _clear_fullscreen ()
void | _set_fullscreen ()
void | activate ()
| Activates the widget.
unsigned int | active () const
| Returns whether the widget is active.
int | active_r () const
| Returns whether the widget and all of its parents are active.
Fl_Align | align () const
| Gets the label alignment.
void | align (Fl_Align alignment)
| Sets the label alignment.
long | argument () const
| Gets the current user data (long) argument that is passed to the callback function.
void | argument (long v)
| Sets the current user data (long) argument that is passed to the callback function.
virtual class Fl_Gl_Window * | as_gl_window ()
| Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window.
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.
virtual Fl_Group const * | as_group () const
virtual Fl_Window * | as_window ()
| Returns an Fl_Window pointer if this widget is an Fl_Window.
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.
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.
void | bind_image (Fl_Image *img)
| Sets the image to use as part of the widget label when in the active state.
void | bind_image (int f)
| Bind the image to the widget, so the widget will delete the image when it is no longer needed.
Fl_Boxtype | box () const
| Gets the box type of the widget.
void | box (Fl_Boxtype new_box)
| Sets the box type for the widget.
Fl_Callback_p | callback () const
| Gets the current callback function for the widget.
void | callback (Fl_Callback *cb)
| Sets the current callback function for the widget.
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.
void | callback (Fl_Callback *cb, void *p)
| Sets the current callback function and data for the widget.
void | callback (Fl_Callback0 *cb)
| Sets the current callback function for the widget.
void | callback (Fl_Callback1 *cb, long p=0)
| Sets the current callback function for the widget.
unsigned int | changed () const
| Checks if the widget value changed since the last callback.
void | clear_active ()
| Marks the widget as inactive without sending events or changing focus.
void | clear_changed ()
| Marks the value of the widget as unchanged.
void | clear_damage (uchar c=0)
| Clears or sets the damage flags.
void | clear_output ()
| Sets a widget to accept input.
void | clear_visible ()
| Hides the widget.
void | clear_visible_focus ()
| Disables keyboard focus navigation with this widget.
Fl_Color | color () const
| Gets the background color of the widget.
void | color (Fl_Color bg)
| Sets the background color of the widget.
void | color (Fl_Color bg, Fl_Color sel)
| Sets the background and selection color of the widget.
Fl_Color | color2 () const
| For back compatibility only.
void | color2 (unsigned a)
| For back compatibility only.
int | contains (const Fl_Widget *w) const
| Checks if w is a child of this widget.
void | copy_label (const char *new_label)
| Sets the current label.
void | copy_tooltip (const char *text)
| Sets the current tooltip text.
uchar | damage () const
| Returns non-zero if draw() needs to be called.
void | damage (uchar c)
| Sets the damage bits for the widget.
void | damage (uchar c, int x, int y, int w, int h)
| Sets the damage bits for an area inside the widget.
int | damage_resize (int, int, int, int)
| Internal use only.
void | deactivate ()
| Deactivates the widget.
Fl_Image * | deimage ()
| Gets the image that is used as part of the widget label when in the inactive state.
const Fl_Image * | deimage () const
| Gets the image that is used as part of the widget label when in the inactive state.
void | deimage (Fl_Image &img)
| Sets the image to use as part of the widget label when in the inactive state.
void | deimage (Fl_Image *img)
| Sets the image to use as part of the widget label when in the inactive state.
int | deimage_bound () const
| Returns whether the inactive image is managed by the widget.
void | do_callback (Fl_Callback_Reason reason=FL_REASON_UNKNOWN)
| Calls the widget callback function with default arguments.
void | do_callback (Fl_Widget *widget, long arg, Fl_Callback_Reason reason=FL_REASON_UNKNOWN)
| Calls the widget callback function with arbitrary arguments.
void | do_callback (Fl_Widget *widget, void *arg=0, Fl_Callback_Reason reason=FL_REASON_UNKNOWN)
| Calls the widget callback function with arbitrary arguments.
virtual void | draw ()=0
| Draws the widget.
void | draw_label (int, int, int, int, Fl_Align) const
| Draws the label in an arbitrary bounding box with an arbitrary alignment.
int | h () const
| Gets the widget height.
virtual int | handle (int event)
| Handles the specified event.
virtual void | hide ()
| Makes a widget invisible.
int | horizontal_label_margin ()
| Get the spacing between the label and the horizontal edge of the widget.
void | horizontal_label_margin (int px)
| Set the spacing between the label and the horizontal edge of the widget.
Fl_Image * | image ()
| Gets the image that is used as part of the widget label when in the active state.
const Fl_Image * | image () const
| Gets the image that is used as part of the widget label when in the active state.
void | image (Fl_Image &img)
| Sets the image to use as part of the widget label when in the active state.
void | image (Fl_Image *img)
| Sets the image to use as part of the widget label when in the active state.
int | image_bound () const
| Returns whether the image is managed by the widget.
int | inside (const Fl_Widget *wgt) const
| Checks if this widget is a child of `wgt`.
int | is_label_copied () const
| Returns whether the current label was assigned with copy_label().
const char * | label () const
| Gets the current label text.
void | label (const char *text)
| Sets the current label pointer.
void | label (Fl_Labeltype a, const char *b)
| Shortcut to set the label text and type in one call.
int | label_image_spacing ()
| Return the gap size between the label and the image.
void | label_image_spacing (int gap)
| Set the gap between the label and the image in pixels.
Fl_Color | labelcolor () const
| Gets the label color.
void | labelcolor (Fl_Color c)
| Sets the label color.
Fl_Font | labelfont () const
| Gets the font to use.
void | labelfont (Fl_Font f)
| Sets the font to use.
Fl_Fontsize | labelsize () const
| Gets the font size in pixels.
void | labelsize (Fl_Fontsize pix)
| Sets the font size in pixels.
Fl_Labeltype | labeltype () const
| Gets the label type.
void | labeltype (Fl_Labeltype a)
| Sets the label type.
void | measure_label (int &ww, int &hh) const
| Sets width ww and height hh accordingly with the label size.
bool | needs_keyboard () const
| Returns whether this widget needs a keyboard.
void | needs_keyboard (bool needs)
| Sets whether this widget needs a keyboard.
unsigned int | output () const
| Returns if a widget is used for output only.
Fl_Group * | parent () const
| Returns a pointer to the parent widget.
void | parent (Fl_Group *p)
| Internal use only - "for hacks only".
void | position (int X, int Y)
| Repositions the window or widget.
void | redraw ()
| Schedules the drawing of the widget.
void | redraw_label ()
| Schedules the drawing of the label.
virtual void | resize (int x, int y, int w, int h)
| Changes the size or position of the widget.
Fl_Color | selection_color () const
| Gets the selection color.
void | selection_color (Fl_Color a)
| Sets the selection color.
void | set_active ()
| Marks the widget as active without sending events or changing focus.
void | set_changed ()
| Marks the value of the widget as changed.
void | set_output ()
| Sets a widget to output only.
void | set_visible ()
| Makes the widget visible.
void | set_visible_focus ()
| Enables keyboard focus navigation with this widget.
int | shortcut_label () const
| Returns whether the widget's label uses '&' to indicate shortcuts.
void | shortcut_label (int value)
| Sets whether the widget's label uses '&' to indicate shortcuts.
virtual void | show ()
| Makes a widget visible.
void | size (int W, int H)
| Changes the size of the widget.
int | take_focus ()
| Gives the widget the keyboard focus.
unsigned int | takesevents () const
| Returns if the widget is able to take events.
int | test_shortcut ()
| Returns true if the widget's label contains the entered '&x' shortcut.
const char * | tooltip () const
| Gets the current tooltip text.
void | tooltip (const char *text)
| Sets the current tooltip text.
Fl_Window * | top_window () const
| Returns a pointer to the top-level window for the widget.
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.
uchar | type () const
| Gets the widget type.
void | type (uchar t)
| Sets the widget type.
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.
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.
void | vertical_label_margin (int px)
| Set the spacing between the label and the vertical edge of the widget.
unsigned int | visible () const
| Returns whether a widget is visible.
unsigned int | visible_focus () const
| Checks whether this widget has a visible focus.
void | visible_focus (int v)
| Modifies keyboard focus navigation.
int | visible_r () const
| Returns whether a widget and all its parents are visible.
int | w () const
| Gets the widget width.
Fl_When | when () const
| Returns the conditions under which the callback is called.
void | when (uchar i)
| Sets the flags used to decide when a callback is called.
Fl_Window * | window () const
| Returns a pointer to the nearest parent window up the widget hierarchy.
int | x () const
| Gets the widget position in its window.
int | y () const
| Gets the widget position in its window.
virtual | ~Fl_Widget ()
| Destroys the widget.

## 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.
static unsigned int | label_shortcut (const char *t)
| Returns the Unicode value of the '&x' shortcut in a given text.
static int | test_shortcut (const char *, const bool require_alt=false)
| Returns true if the given text `t` contains the entered '&x' shortcut.

## 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.
void | draw_focus (Fl_Boxtype t, int X, int Y, int W, int H) const
| Draws a focus rectangle around the widget.
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.
void | draw_label () const
| Draws the widget's label at the defined label position.
void | draw_label (int, int, int, int) const
| Draws the label in an arbitrary bounding box.
| Fl_Widget (int x, int y, int w, int h, const char *label=0L)
| Creates a widget at the given position and size.
unsigned int | flags () const
| Gets the widget flags mask.
void | h (int v)
| Internal use only.
void | set_flag (unsigned int c)
| Sets a flag in the flags mask.
void | w (int v)
| Internal use only.
void | x (int v)
| Internal use only.
void | y (int v)
| Internal use only.

## Friends
class | Fl_Group

## Detailed Description

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.

## Member Enumeration Documentation

## ◆ anonymous enum

anonymous enum
| 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. See also Fl_Widget::needs_keyboard()
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 delete on the user_data pointer when destroying this widget; if set, user_data must point to a class derived from the class Fl_Callback_User_Data
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

## Constructor & Destructor Documentation

## ◆ Fl_Widget()

Fl_Widget::Fl_Widget | ( | int | x,
|  | int | y,
|  | int | w,
|  | int | h,
|  | const char * | label = 0L )
| 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().

Parameters

  [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

## ◆ ~Fl_Widget()

Fl_Widget::~Fl_Widget | ( |  | ) |
| 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.

Since
  FLTK 1.3, the widget's destructor removes the widget from its parent group, if it is member of a group.

Destruction removes the widget from any parent group! And groups when destroyed destroy all their children. This is convenient and fast.

## Member Function Documentation

## ◆ activate()

void Fl_Widget::activate | ( |  | ) |

Activates the widget.

Changing this value will send FL_ACTIVATE to the widget if active_r() is true.

See also
  active(), active_r(), deactivate()

## ◆ active()

unsigned int Fl_Widget::active | ( |  | ) | const
| inline

Returns whether the widget is active.

Return values

  0 | if the widget is inactive

See also
  active_r(), activate(), deactivate()

## ◆ active_r()

int Fl_Widget::active_r | ( |  | ) | const

Returns whether the widget and all of its parents are active.

Return values

  0 | if this or any of the parent widgets are inactive

See also
  active(), activate(), deactivate()

## ◆ align() [1/2]

Fl_Align Fl_Widget::align | ( |  | ) | const
| inline

Gets the label alignment.

Returns
  label alignment

See also
  label(), align(Fl_Align), Fl_Align

## ◆ align() [2/2]

void Fl_Widget::align | ( | Fl_Align | alignment | ) |
| inline

Sets the label alignment.

This controls how the label is displayed next to or inside the widget. The default value is FL_ALIGN_CENTER, which centers the label inside the widget.

Parameters

  [in] | alignment | new label alignment

See also
  align(), Fl_Align

## ◆ argument() [1/2]

long Fl_Widget::argument | ( |  | ) | const
| inline

Gets the current user data (long) argument that is passed to the callback function.

Note
  On platforms with 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.

See also
  user_data()

## ◆ argument() [2/2]

void Fl_Widget::argument | ( | long | v | ) |
| inline

Sets the current user data (long) argument that is passed to the callback function.

See also
  argument()

## ◆ as_gl_window()

virtual class Fl_Gl_Window * Fl_Widget::as_gl_window | ( |  | ) |
| inline virtual

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.

Return values

  NULL | if this widget is not derived from Fl_Gl_Window.

Note
  This method is provided to avoid dynamic_cast.

See also
  Fl_Widget::as_group(), Fl_Widget::as_window()

Reimplemented in Fl_Gl_Window.

## ◆ as_group()

virtual Fl_Group * Fl_Widget::as_group | ( |  | ) |
| inline virtual

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:

void my_callback (Fl_Widget *w, void *) {
Fl_Group *g = w->as_group();
if (g)
printf ("This group has %d children\n", g->children());
else
printf ("This widget is not a group!\n");
}
Fl_Group::children
int children() const
Returns how many child widgets the group has.
Definition Fl_Group.H:98
Fl_Widget::w
void w(int v)
Internal use only.
Definition Fl_Widget.H:154

Return values

  NULL | if this widget is not derived from Fl_Group.

Note
  This method is provided to avoid dynamic_cast.

See also
  Fl_Widget::as_window(), Fl_Widget::as_gl_window()

Reimplemented in Fl_Group.

## ◆ as_window()

virtual Fl_Window * Fl_Widget::as_window | ( |  | ) |
| inline virtual

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.

Return values

  NULL | if this widget is not derived from Fl_Window.

Note
  This method is provided to avoid dynamic_cast.

See also
  Fl_Widget::as_group(), Fl_Widget::as_gl_window()

Reimplemented in Fl_Window.

## ◆ bind_deimage() [1/2]

void Fl_Widget::bind_deimage | ( | Fl_Image * | img | ) |

Sets the image to use as part of the widget label when in the inactive state.

Parameters

  [in] | img | the new image for the deactivated widget

Note
  The image will be bound to the widget. When the widget is deleted, the image will be deleted as well.

See also
  void deimage(Fl_Image* img)

## ◆ bind_deimage() [2/2]

void Fl_Widget::bind_deimage | ( | int | f | ) |
| inline

Bind the inactive image to the widget, so the widget will delete the image when it is no longer needed.

Parameters

  f | 1: mark the image as bound, 0: mark the image as managed by the user

See also
  deimage_bound(), bind_image()

## ◆ bind_image() [1/2]

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.

Parameters

  [in] | img | the new image for the label

See also
  void image(Fl_Image* img)

## ◆ bind_image() [2/2]

void Fl_Widget::bind_image | ( | int | f | ) |
| inline

Bind the image to the widget, so the widget will delete the image when it is no longer needed.

Parameters

  f | 1: mark the image as bound, 0: mark the image as managed by the user

See also
  image_bound(), bind_deimage()

## ◆ box() [1/2]

Fl_Boxtype Fl_Widget::box | ( | void |  | ) | const
| inline

Gets the box type of the widget.

Returns
  the current box type

See also
  box(Fl_Boxtype), Fl_Boxtype

## ◆ box() [2/2]

void Fl_Widget::box | ( | Fl_Boxtype | new_box | ) |
| 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.

Parameters

  [in] | new_box | the new box type

See also
  box(), Fl_Boxtype

## ◆ callback() [1/6]

Fl_Callback_p Fl_Widget::callback | ( |  | ) | const
| inline

Gets the current callback function for the widget.

Each widget has a single callback.

Returns
  current callback

## ◆ callback() [2/6]

void Fl_Widget::callback | ( | Fl_Callback * | cb | ) |
| inline

Sets the current callback function for the widget.

Each widget has a single callback.

Parameters

  [in] | cb | new callback

## ◆ callback() [3/6]

void Fl_Widget::callback | ( | Fl_Callback * | cb,
|  | Fl_Callback_User_Data * | p,
|  | bool | auto_free )
| 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.

Parameters

  [in] | cb | new callback
  [in] | p | user data
  [in] | auto_free | if set, the widget will free user data when destroyed

## ◆ callback() [4/6]

void Fl_Widget::callback | ( | Fl_Callback * | cb,
|  | void * | p )
| inline

Sets the current callback function and data for the widget.

Each widget has a single callback.

Parameters

  [in] | cb | new callback
  [in] | p | user data

## ◆ callback() [5/6]

void Fl_Widget::callback | ( | Fl_Callback0 * | cb | ) |
| inline

Sets the current callback function for the widget.

Each widget has a single callback.

Parameters

  [in] | cb | new callback

## ◆ callback() [6/6]

void Fl_Widget::callback | ( | Fl_Callback1 * | cb,
|  | long | p = 0 )
| inline

Sets the current callback function for the widget.

Each widget has a single callback.

Parameters

  [in] | cb | new callback
  [in] | p | user data

## ◆ changed()

unsigned int Fl_Widget::changed | ( |  | ) | const
| 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.

Note
  do_callback() turns this flag off after the callback.

Return values

  0 | if the value did not change

See also
  set_changed(), clear_changed()
  do_callback(Fl_Widget *widget, void *data)

## ◆ clear_active()

void Fl_Widget::clear_active | ( |  | ) |
| inline

Marks the widget as inactive without sending events or changing focus.

This is mainly for specialized use, for normal cases you want deactivate().

See also
  deactivate()

## ◆ clear_changed()

void Fl_Widget::clear_changed | ( |  | ) |
| inline

Marks the value of the widget as unchanged.

See also
  changed(), set_changed()

## ◆ clear_damage()

void Fl_Widget::clear_damage | ( | uchar | c = 0 | ) |
| 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!

Note
  Therefore it is possible to set damage bits with this method, but this should be avoided. Use damage(uchar) instead.

Parameters

  [in] | c | new bitmask of damage flags (default: 0)

See also
  damage(uchar), damage()

## ◆ clear_output()

void Fl_Widget::clear_output | ( |  | ) |
| inline

Sets a widget to accept input.

See also
  set_output(), output()

## ◆ clear_visible()

void Fl_Widget::clear_visible | ( |  | ) |
| 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.

## ◆ clear_visible_focus()

void Fl_Widget::clear_visible_focus | ( |  | ) |
| inline

Disables keyboard focus navigation with this widget.

Normally, all widgets participate in keyboard focus navigation.

See also
  set_visible_focus(), visible_focus(), visible_focus(int)

## ◆ color() [1/3]

Fl_Color Fl_Widget::color | ( | void |  | ) | const
| inline

Gets the background color of the widget.

Returns
  current background color

See also
  color(Fl_Color), color(Fl_Color, Fl_Color)

## ◆ color() [2/3]

void Fl_Widget::color | ( | Fl_Color | bg | ) |
| 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.

Parameters

  [in] | bg | background color

See also
  color(), color(Fl_Color, Fl_Color), selection_color(Fl_Color)

## ◆ color() [3/3]

void Fl_Widget::color | ( | Fl_Color | bg,
|  | Fl_Color | sel )
| inline

Sets the background and selection color of the widget.

The two color form sets both the background and selection colors.

Parameters

  [in] | bg | background color
  [in] | sel | selection color

See also
  color(unsigned), selection_color(unsigned)

## ◆ color2() [1/2]

Fl_Color Fl_Widget::color2 | ( |  | ) | const
| inline

For back compatibility only.

Deprecated
  Use selection_color() instead.

## ◆ color2() [2/2]

void Fl_Widget::color2 | ( | unsigned | a | ) |
| inline

For back compatibility only.

Deprecated
  Use selection_color(unsigned) instead.

## ◆ contains()

int Fl_Widget::contains | ( | const Fl_Widget * | w | ) | const

Checks if w is a child of this widget.

Parameters

  [in] | w | potential child widget

Returns
  Returns 1 if `w` is a child of this widget, or is equal to this widget. Returns 0 if `w` is NULL.

## ◆ copy_label()

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.

Parameters

  [in] | new_label | the new label text

See also
  label()

## ◆ copy_tooltip()

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 ("").

Parameters

  [in] | text | New tooltip text (an internal copy is made and managed)

See also
  tooltip(const char*), tooltip()

## ◆ damage() [1/3]

uchar Fl_Widget::damage | ( |  | ) | const
| 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.

Returns
  a bitmap of flags describing the kind of damage to the widget

See also
  damage(uchar), clear_damage(uchar)

## ◆ damage() [2/3]

void Fl_Widget::damage | ( | uchar | c | ) |

Sets the damage bits for the widget.

Setting damage bits will schedule the widget for the next redraw.

Parameters

  [in] | c | bitmask of flags to set

See also
  damage(), clear_damage(uchar)

## ◆ damage() [3/3]

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.

Parameters

  [in] | c | bitmask of flags to set
  [in] | x,y,w,h | size of damaged area

See also
  damage(), clear_damage(uchar)

## ◆ deactivate()

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.

See also
  activate(), active(), active_r()

## ◆ default_callback()

void Fl_Widget::default_callback | ( | Fl_Widget * | widget,
|  | void * | data )
| 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.

Parameters

  [in] | widget | the Fl_Widget given to the callback
  [in] | data | user data associated with that callback

See also
  callback(), Fl::readqueue()
  do_callback(Fl_Widget *widget, void *data)

## ◆ deimage() [1/4]

Fl_Image * Fl_Widget::deimage | ( |  | ) |
| inline

Gets the image that is used as part of the widget label when in the inactive state.

Returns
  the current image for the deactivated widget

## ◆ deimage() [2/4]

const Fl_Image * Fl_Widget::deimage | ( |  | ) | const
| inline

Gets the image that is used as part of the widget label when in the inactive state.

Returns
  the current image for the deactivated widget

## ◆ deimage() [3/4]

void Fl_Widget::deimage | ( | Fl_Image & | img | ) |

Sets the image to use as part of the widget label when in the inactive state.

Parameters

  [in] | img | the new image for the deactivated widget

See also
  void deimage(Fl_Image* img)

## ◆ deimage() [4/4]

void Fl_Widget::deimage | ( | Fl_Image * | img | ) |

Sets the image to use as part of the widget label when in the inactive state.

Parameters

  [in] | img | the new image for the deactivated widget

Note
  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.

See also
  void bind_deimage(Fl_Image* img)

## ◆ deimage_bound()

int Fl_Widget::deimage_bound | ( |  | ) | const
| inline

Returns whether the inactive image is managed by the widget.

Return values

  0 | if the image is not bound to the widget
  1 | if the image will be deleted when the widget is deleted

See also
  image_bound(), bind_deimage()

## ◆ do_callback() [1/3]

void Fl_Widget::do_callback | ( | Fl_Callback_Reason | reason = FL_REASON_UNKNOWN | ) |
| inline

Calls the widget callback function with default arguments.

This is the same as calling

do_callback(this, user_data(), reason);
Fl_Widget::user_data
void * user_data() const
Gets the user data for this widget.
Definition Fl_Widget.H:792
Fl_Widget::do_callback
void do_callback(Fl_Callback_Reason reason=FL_REASON_UNKNOWN)
Calls the widget callback function with default arguments.
Definition Fl_Widget.H:1089

Parameters

  [in] | reason | give a reason to why this callback was called, defaults to FL_REASON_UNKNOWN

See also
  callback()
  do_callback(Fl_Widget *widget, void *data, Fl_Callback_Reason reason), Fl_Callback_Reason

## ◆ do_callback() [2/3]

void Fl_Widget::do_callback | ( | Fl_Widget * | widget,
|  | long | arg,
|  | Fl_Callback_Reason | reason = FL_REASON_UNKNOWN )
| inline

Calls the widget callback function with arbitrary arguments.

Parameters

  [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

See also
  callback()
  do_callback(Fl_Widget *widget, void *data), Fl_Callback_Reason

## ◆ do_callback() [3/3]

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.

Note
  It is legal to delete the widget in the callback (i.e. in user code), but you must not access the widget in the handle() method after calling do_callback() if the widget was deleted in the callback. We recommend to use Fl_Widget_Tracker to check whether the widget was deleted in the callback.

Parameters

  [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

See also
  default_callback()
  callback()
  class Fl_Widget_Tracker
  Fl::callback_reason()

## ◆ draw()

virtual void Fl_Widget::draw | ( |  | ) |
| 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:

Fl_Widget *s = &scrollbar; // scrollbar is an embedded Fl_Scrollbar
s->draw(); // calls Fl_Scrollbar::draw()

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_FormsText, Fl_Free, Fl_Gl_Window, Fl_Glut_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_Terminal, Fl_Text_Display, Fl_Timer, Fl_Tree, Fl_Value_Input, Fl_Value_Output, Fl_Value_Slider, Fl_Window, and Fl_Wizard.

## ◆ draw_focus() [1/3]

void Fl_Widget::draw_focus | ( |  | ) | const
| inline protected

Draws a focus rectangle around the widget.

This method uses the widget's boxtype and coordinates and its background color color().

See also
  Fl_Widget::draw_focus(Fl_Boxtype, int, int, int, int, Fl_Color) const

## ◆ draw_focus() [2/3]

void Fl_Widget::draw_focus | ( | Fl_Boxtype | t,
|  | int | X,
|  | int | Y,
|  | int | W,
|  | int | H ) const
| inline protected

Draws a focus rectangle around the widget.

This method uses the given boxtype and coordinates and the widget's background color color().

See also
  Fl_Widget::draw_focus(Fl_Boxtype, int, int, int, int, Fl_Color) const

## ◆ draw_focus() [3/3]

void Fl_Widget::draw_focus | ( | Fl_Boxtype | bt,
|  | int | X,
|  | int | Y,
|  | int | W,
|  | int | H,
|  | Fl_Color | bg ) const
| protected

Draws a focus box for the widget at the given position and size.

This method does nothing if

- the global option Fl::visible_focus() or
- the per-widget option visible_focus() is false (off).

This means that Fl_Widget::draw_focus() or one of the more specialized methods can be called without checking these visible focus options.

Note
  This method must only be called if the widget has the focus. This is not tested internally.

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.

Parameters

  [in] | bt | Boxtype that needs to be considered (frame width)
  [in] | X,Y,W,H | Bounding box
  [in] | bg | Background color

See also
  Fl_Widget::draw_focus()
  Fl_Widget::draw_focus(Fl_Boxtype, int, int, int, int) const

## ◆ draw_label() [1/3]

void Fl_Widget::draw_label | ( |  | ) | const
| protected

Draws the widget's label at the defined label position.

This is the normal call for a widget's draw() method.

## ◆ draw_label() [2/3]

void Fl_Widget::draw_label | ( | int | X,
|  | int | Y,
|  | int | W,
|  | int | H ) const
| protected

Draws the label in an arbitrary bounding box.

draw() can use this instead of draw_label(void) to change the bounding box

## ◆ draw_label() [3/3]

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.

## ◆ h() [1/2]

int Fl_Widget::h | ( |  | ) | const
| inline

Gets the widget height.

Returns
  the height of the widget in pixels.

## ◆ h() [2/2]

void Fl_Widget::h | ( | int | v | ) |
| inline protected

Internal use only.

Use position(int,int), size(int,int) or resize(int,int,int,int) instead.

## ◆ handle()

int Fl_Widget::handle | ( | int | event | ) |
| 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.

Parameters

  [in] | event | the kind of event received

Return values

  0 | if the event was not used or understood
  1 | if the event was used and can be deleted

See also
  Fl_Event

Reimplemented in Fl_Adjuster, Fl_Box, Fl_Browser_, Fl_Button, Fl_Check_Browser, Fl_Choice, Fl_Clock, Fl_Color_Chooser, Fl_Counter, Fl_Dial, Fl_File_Input, Fl_Free, Fl_Gl_Window, Fl_Glut_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_Scheme_Choice, Fl_Scroll, Fl_Scrollbar, Fl_Secret_Input, Fl_Shortcut_Button, Fl_Slider, Fl_Spinner::Fl_Spinner_Input, Fl_Spinner, Fl_Table, Fl_Table_Row, Fl_Tabs, Fl_Terminal, Fl_Text_Display, Fl_Text_Editor, Fl_Tile, Fl_Timer, Fl_Tree, Fl_Value_Input, Fl_Value_Output, Fl_Value_Slider, and Fl_Window.

## ◆ hide()

void Fl_Widget::hide | ( |  | ) |
| virtual

Makes a widget invisible.

See also
  show(), visible(), visible_r()

Reimplemented in Fl_Browser, Fl_Double_Window, Fl_Gl_Window, Fl_Overlay_Window, and Fl_Window.

## ◆ horizontal_label_margin() [1/2]

int Fl_Widget::horizontal_label_margin | ( |  | ) |
| inline

Get the spacing between the label and the horizontal edge of the widget.

Returns
  px gap in pixels

## ◆ horizontal_label_margin() [2/2]

void Fl_Widget::horizontal_label_margin | ( | int | px | ) |
| inline

Set the spacing between the label and the horizontal edge of the widget.

Parameters

  [in] | px | gap in pixels

## ◆ image() [1/4]

Fl_Image * Fl_Widget::image | ( |  | ) |
| inline

Gets the image that is used as part of the widget label when in the active state.

Returns
  the current image

## ◆ image() [2/4]

const Fl_Image * Fl_Widget::image | ( |  | ) | const
| inline

Gets the image that is used as part of the widget label when in the active state.

Returns
  the current image

## ◆ image() [3/4]

void Fl_Widget::image | ( | Fl_Image & | img | ) |

Sets the image to use as part of the widget label when in the active state.

Parameters

  [in] | img | the new image for the label

See also
  void image(Fl_Image* img)

## ◆ image() [4/4]

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.

Parameters

  [in] | img | the new image for the label

See also
  bind_image(Fl_Image* img)

## ◆ image_bound()

int Fl_Widget::image_bound | ( |  | ) | const
| inline

Returns whether the image is managed by the widget.

Return values

  0 | if the image is not bound to the widget
  1 | if the image will be deleted when the widget is deleted

See also
  deimage_bound(), bind_image()

## ◆ inside()

int Fl_Widget::inside | ( | const Fl_Widget * | wgt | ) | const
| 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.

Parameters

  [in] | wgt | the possible parent widget.

See also
  contains()

## ◆ is_label_copied()

int Fl_Widget::is_label_copied | ( |  | ) | const
| 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.

Return values

  0 | current label was assigned with label().
  1 | current label was assigned with copy_label().

## ◆ label() [1/3]

const char * Fl_Widget::label | ( |  | ) | const
| inline

Gets the current label text.

Returns
  a pointer to the current label text

See also
  label(const char *), copy_label(const char *)

## ◆ label() [2/3]

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.

Parameters

  [in] | text | pointer to new label text

See also
  copy_label()

## ◆ label() [3/3]

void Fl_Widget::label | ( | Fl_Labeltype | a,
|  | const char * | b )
| inline

Shortcut to set the label text and type in one call.

See also
  label(const char *), labeltype(Fl_Labeltype)

## ◆ label_image_spacing() [1/2]

int Fl_Widget::label_image_spacing | ( |  | ) |
| inline

Return the gap size between the label and the image.

Returns
  spacing in pixels

## ◆ label_image_spacing() [2/2]

void Fl_Widget::label_image_spacing | ( | int | gap | ) |
| inline

Set the gap between the label and the image in pixels.

This value is limited to 0..255.

Parameters

  [in] | gap | spacing in pixels

## ◆ label_shortcut()

unsigned int Fl_Widget::label_shortcut | ( | const char * | t | ) |
| 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.

Parameters

  t | text or label to search for '&x' shortcut.

Returns
  Unicode (UCS-4) value of shortcut in `t` or 0.

Note
  Internal use only.

## ◆ labelcolor() [1/2]

Fl_Color Fl_Widget::labelcolor | ( |  | ) | const
| inline

Gets the label color.

The default color is FL_FOREGROUND_COLOR.

Returns
  the current label color

## ◆ labelcolor() [2/2]

void Fl_Widget::labelcolor | ( | Fl_Color | c | ) |
| inline

Sets the label color.

The default color is FL_FOREGROUND_COLOR.

Parameters

  [in] | c | the new label color

## ◆ labelfont() [1/2]

Fl_Font Fl_Widget::labelfont | ( |  | ) | const
| 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.

Returns
  current font used by the label

See also
  Fl_Font

## ◆ labelfont() [2/2]

void Fl_Widget::labelfont | ( | Fl_Font | f | ) |
| 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.

Parameters

  [in] | f | the new font for the label

See also
  Fl_Font

## ◆ labelsize() [1/2]

Fl_Fontsize Fl_Widget::labelsize | ( |  | ) | const
| inline

Gets the font size in pixels.

The default size is 14 pixels.

Returns
  the current font size

## ◆ labelsize() [2/2]

void Fl_Widget::labelsize | ( | Fl_Fontsize | pix | ) |
| inline

Sets the font size in pixels.

Parameters

  [in] | pix | the new font size

See also
  Fl_Fontsize labelsize()

## ◆ labeltype() [1/2]

Fl_Labeltype Fl_Widget::labeltype | ( |  | ) | const
| inline

Gets the label type.

Returns
  the current label type.

See also
  Fl_Labeltype

## ◆ labeltype() [2/2]

void Fl_Widget::labeltype | ( | Fl_Labeltype | a | ) |
| 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.

Parameters

  [in] | a | new label type

See also
  Fl_Labeltype

## ◆ measure_label()

void Fl_Widget::measure_label | ( | int & | ww,
|  | int & | hh ) const
| 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

See also
  fl_measure(const char*, int&, int&, int)

## ◆ needs_keyboard() [1/2]

bool Fl_Widget::needs_keyboard | ( |  | ) | const
| inline

Returns whether this widget needs a keyboard.

Returns
  true or false

See also
  needs_keyboard(bool)

## ◆ needs_keyboard() [2/2]

void Fl_Widget::needs_keyboard | ( | bool | needs | ) |
| 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.

Note
  This flag can be set but is not yet used in FLTK 1.4.0. It is intended to be used in the future on real touch devices.

Parameters

  [in] | needs | Set this to true or false

## ◆ output()

unsigned int Fl_Widget::output | ( |  | ) | const
| 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.

Return values

  0 | if the widget is used for input and output

See also
  set_output(), clear_output()

## ◆ parent() [1/2]

Fl_Group * Fl_Widget::parent | ( |  | ) | const
| inline

Returns a pointer to the parent widget.

Usually this is a Fl_Group or Fl_Window.

Return values

  NULL | if the widget has no parent

See also
  Fl_Group::add(Fl_Widget*)

## ◆ parent() [2/2]

void Fl_Widget::parent | ( | Fl_Group * | p | ) |
| 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.

## ◆ position()

void Fl_Widget::position | ( | int | X,
|  | int | Y )
| inline

Repositions the window or widget.

position(X, Y) is a shortcut for resize(X, Y, w(), h()).

Parameters

  [in] | X,Y | new position relative to the parent window

See also
  resize(int,int,int,int), size(int,int)

## ◆ redraw()

void Fl_Widget::redraw | ( |  | ) |

Schedules the drawing of the widget.

Marks the widget as needing its draw() routine called.

## ◆ redraw_label()

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.

## ◆ resize()

void Fl_Widget::resize | ( | int | x,
|  | int | y,
|  | int | w,
|  | int | h )
| 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).

Parameters

  [in] | x,y | new position relative to the parent window
  [in] | w,h | new size

See also
  position(int,int), size(int,int)

Reimplemented in Fl_Browser_, Fl_Double_Window, Fl_Flex, Fl_Gl_Window, Fl_Grid, Fl_Group, Fl_Help_View, Fl_Input_, Fl_Input_Choice, Fl_Overlay_Window, Fl_Pack, Fl_Scroll, Fl_Spinner, Fl_Table, Fl_Tabs, Fl_Terminal, Fl_Text_Display, Fl_Tile, Fl_Tree, Fl_Value_Input, and Fl_Window.

## ◆ selection_color() [1/2]

Fl_Color Fl_Widget::selection_color | ( |  | ) | const
| inline

Gets the selection color.

Returns
  the current selection color

See also
  selection_color(Fl_Color), color(Fl_Color, Fl_Color)

## ◆ selection_color() [2/2]

void Fl_Widget::selection_color | ( | Fl_Color | a | ) |
| 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).

Parameters

  [in] | a | the new selection color

See also
  selection_color(), color(Fl_Color, Fl_Color)

## ◆ set_active()

void Fl_Widget::set_active | ( |  | ) |
| inline

Marks the widget as active without sending events or changing focus.

This is mainly for specialized use, for normal cases you want activate().

See also
  activate()

## ◆ set_changed()

void Fl_Widget::set_changed | ( |  | ) |
| inline

Marks the value of the widget as changed.

See also
  changed(), clear_changed()

## ◆ set_output()

void Fl_Widget::set_output | ( |  | ) |
| inline

Sets a widget to output only.

See also
  output(), clear_output()

## ◆ set_visible()

void Fl_Widget::set_visible | ( |  | ) |
| 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.

## ◆ set_visible_focus()

void Fl_Widget::set_visible_focus | ( |  | ) |
| 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.

See also
  visible_focus(), clear_visible_focus(), visible_focus(int)

## ◆ shortcut_label() [1/2]

int Fl_Widget::shortcut_label | ( |  | ) | const
| inline

Returns whether the widget's label uses '&' to indicate shortcuts.

See also
  void shortcut_label(int value)

## ◆ shortcut_label() [2/2]

void Fl_Widget::shortcut_label | ( | int | value | ) |
| 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.

## ◆ show()

void Fl_Widget::show | ( |  | ) |
| 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.

See also
  hide(), visible(), visible_r()

Reimplemented in Fl_Browser, Fl_Double_Window, Fl_Gl_Window, Fl_Overlay_Window, Fl_Single_Window, Fl_Tabs, and Fl_Window.

## ◆ size()

void Fl_Widget::size | ( | int | W,
|  | int | H )
| inline

Changes the size of the widget.

size(W, H) is a shortcut for resize(x(), y(), W, H).

Parameters

  [in] | W,H | new size

See also
  position(int,int), resize(int,int,int,int)

## ◆ take_focus()

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.

Returns
  true if the widget accepted the focus.

## ◆ takesevents()

unsigned int Fl_Widget::takesevents | ( |  | ) | const
| inline

Returns if the widget is able to take events.

This is the same as (active() && !output() && visible()) but is faster.

Return values

  0 | if the widget takes no events

## ◆ test_shortcut() [1/2]

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.

Returns
  true, if the entered text matches the widget's'&x' shortcut, false (0) otherwise.

Note
  Useful when a widget's handle(int) method needs dedicated processing of FL_SHORTCUT.

## ◆ test_shortcut() [2/2]

int Fl_Widget::test_shortcut | ( | const char * | t,
|  | const bool | require_alt = false )
| 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.

Parameters

  t | text or label to search for '&x' shortcut.
  require_alt | if true: match only if Alt key is pressed.

Returns
  true, if the entered text matches the '&x' shortcut in `t` false (0) otherwise.

Note
  Useful when a widget's handle(int) method needs dedicated processing of FL_SHORTCUT.

## ◆ tooltip() [1/2]

const char * Fl_Widget::tooltip | ( |  | ) | const
| inline

Gets the current tooltip text.

Returns
  a pointer to the tooltip text or NULL

See also
  tooltip(const char*), copy_tooltip(const char*)

## ◆ tooltip() [2/2]

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 ("").

Parameters

  [in] | text | New tooltip text (no copy is made)

See also
  copy_tooltip(const char*), tooltip()

## ◆ top_window()

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).

Returns
  the top-level window, or NULL if no top-level window is associated with this widget.

See also
  window()

## ◆ top_window_offset()

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.

Parameters

  [out] | xoff,yoff | Returns the x/y offset

Returns
  the top-level window (or NULL for a widget that's not in any window)

## ◆ type() [1/2]

uchar Fl_Widget::type | ( |  | ) | const
| inline

Gets the widget type.

Returns the widget type value, which gives some information about the derived widget class to which the object belongs. Noticeably, the condition type() >= FL_WINDOW indicates a widget is an Fl_Window or derived object.

## ◆ type() [2/2]

void Fl_Widget::type | ( | uchar | t | ) |
| inline

Sets the widget type.

See also
  type()

## ◆ user_data()

void * Fl_Widget::user_data | ( |  | ) | const
| inline

Gets the user data for this widget.

Gets the current user data (void *) argument that is passed to the callback function.

Returns
  user data as a pointer

## ◆ vertical_label_margin() [1/2]

int Fl_Widget::vertical_label_margin | ( |  | ) |
| inline

Get the spacing between the label and the vertical edge of the widget.

Returns
  px gap in pixels

## ◆ vertical_label_margin() [2/2]

void Fl_Widget::vertical_label_margin | ( | int | px | ) |
| inline

Set the spacing between the label and the vertical edge of the widget.

Parameters

  [in] | px | gap in pixels

## ◆ visible()

unsigned int Fl_Widget::visible | ( |  | ) | const
| inline

Returns whether a widget is visible.

Return values

  0 | if the widget is not drawn and hence invisible.

See also
  show(), hide(), visible_r()

## ◆ visible_focus() [1/2]

unsigned int Fl_Widget::visible_focus | ( |  | ) | const
| inline

Checks whether this widget has a visible focus.

Return values

  0 | if this widget has no visible focus.

See also
  visible_focus(int), set_visible_focus(), clear_visible_focus()

## ◆ visible_focus() [2/2]

void Fl_Widget::visible_focus | ( | int | v | ) |
| inline

Modifies keyboard focus navigation.

Parameters

  [in] | v | set or clear visible focus

See also
  set_visible_focus(), clear_visible_focus(), visible_focus()

## ◆ visible_r()

int Fl_Widget::visible_r | ( |  | ) | const

Returns whether a widget and all its parents are visible.

Return values

  0 | if the widget or any of its parents are invisible.

See also
  show(), hide(), visible()

## ◆ w() [1/2]

int Fl_Widget::w | ( |  | ) | const
| inline

Gets the widget width.

Returns
  the width of the widget in pixels.

## ◆ w() [2/2]

void Fl_Widget::w | ( | int | v | ) |
| inline protected

Internal use only.

Use position(int,int), size(int,int) or resize(int,int,int,int) instead.

## ◆ when() [1/2]

Fl_When Fl_Widget::when | ( |  | ) | const
| 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.

Returns
  set of flags

See also
  when(uchar), Fl_When, do_callback(), Fl::callback_reason()

## ◆ when() [2/2]

void Fl_Widget::when | ( | uchar | i | ) |
| 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:

- 0: The callback is not done, but changed() is turned on.
- FL_WHEN_CHANGED: The callback is done each time the text is changed by the user.
- FL_WHEN_RELEASE: The callback will be done when this widget loses the focus, including when the window is unmapped. This is a useful value for text fields in a panel where doing the callback on every change is wasteful. However the callback will also happen if the mouse is moved out of the window, which means it should not do anything visible (like pop up an error message). You might do better setting this to zero, and scanning all the items for changed() when the OK button on a panel is pressed.
- FL_WHEN_ENTER_KEY: If the user types the Enter key, the entire text is selected, and the callback is done if the text has changed. Normally the Enter key will navigate to the next field (or insert a newline for a Fl_Multiline_Input) - this changes the behavior.
- FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED: The Enter key will do the callback even if the text has not changed. Useful for command fields.
- FL_WHEN_CLOSED : If the user requests that the widget is closed, the callback is called with FL_REASON_CLOSED. The Fl_Tabs widget checks this flag on its children to determine whether to display a close button on the tab of that widget.

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.

Parameters

  [in] | i | set of flags

See also
  Fl_When, do_callback(), Fl::callback_reason()

## ◆ window()

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.

Return values

  NULL | if no window is associated with this widget.

Note
  for an Fl_Window widget, this returns its parent window (if any), not this window.

See also
  top_window()

## ◆ x() [1/2]

int Fl_Widget::x | ( |  | ) | const
| inline

Gets the widget position in its window.

Returns
  the x position relative to the window

## ◆ x() [2/2]

void Fl_Widget::x | ( | int | v | ) |
| inline protected

Internal use only.

Use position(int,int), size(int,int) or resize(int,int,int,int) instead.

## ◆ y() [1/2]

int Fl_Widget::y | ( |  | ) | const
| inline

Gets the widget position in its window.

Returns
  the y position relative to the window

## ◆ y() [2/2]

void Fl_Widget::y | ( | int | v | ) |
| inline protected

Internal use only.

Use position(int,int), size(int,int) or resize(int,int,int,int) instead.

The documentation for this class was generated from the following files:

- Fl_Widget.H
- Fl.cxx
- fl_boxtype.cxx
- fl_labeltype.cxx
- fl_shortcut.cxx
- Fl_Tooltip.cxx
- Fl_Widget.cxx
- Fl_Window.cxx