FLTK 1.3.8: Fl_Widget Class Reference

FLTK 1.3.8

Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
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 Fl_Group * | as_group ()
| Returns an Fl_Group pointer if this widget is an Fl_Group.
virtual Fl_Window * | as_window ()
| Returns an Fl_Window pointer if this widget is an Fl_Window.
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, void *p)
| Sets the current callback function 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.
const Fl_Image * | deimage () const
void | deimage (Fl_Image &img)
| Sets the image to use as part of the widget label.
void | deimage (Fl_Image *img)
| Sets the image to use as part of the widget label.
void | do_callback ()
| Calls the widget callback.
void | do_callback (Fl_Widget *o, long arg)
| Calls the widget callback.
void | do_callback (Fl_Widget *o, void *arg=0)
| Calls the widget callback.
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.
Fl_Image * | image ()
| Gets the image that is used as part of the widget label.
const Fl_Image * | image () const
void | image (Fl_Image &img)
| Sets the image to use as part of the widget label.
void | image (Fl_Image *img)
| Sets the image to use as part of the widget label.
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.
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.
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.
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 (void *v)
| Sets the user data for this widget.
unsigned int | visible () const
| Returns whether a widget is visible.
unsigned int | visible_focus ()
| 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 *cb, void *d)
| 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 , 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 ()
| 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 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 winows (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 Mac OS platform, pressing and holding a key on the keyboard opens an accented-character menu window (Fl_Input_, Fl_Text_Editor)
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.

Todo:
  The user data value must be implemented using intptr_t or similar to avoid 64-bit machine incompatibilities.

## ◆ argument() [2/2]

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

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

Todo:
  The user data value must be implemented using intptr_t or similar to avoid 64-bit machine incompatibilities.

## ◆ as_gl_window()

virtual class Fl_Gl_Window * Fl_Widget::as_gl_window | ( |  | ) |
| 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.

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 | ( |  | ) |
| 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:

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
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:41
Fl_Group::children
int children() const
Returns how many child widgets the group has.
Definition: Fl_Group.H:75
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:101

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

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.

## ◆ box() [1/2]

Fl_Boxtype Fl_Widget::box | ( |  | ) | 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/5]

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/5]

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/5]

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

Sets the current callback function for the widget.

Each widget has a single callback.

Parameters

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

## ◆ callback() [4/5]

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() [5/5]

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.

Return values

  0 | if the value did not change

See also
  set_changed(), clear_changed()

## ◆ 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 | ( |  | ) | 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 * | cb,
|  | void * | d
| ) |  |
| 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().

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] | cb | the widget given to the callback
  [in] | d | user data associated with that callback

See also
  callback(), do_callback(), Fl::readqueue()

## ◆ deimage() [1/3]

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

Gets the image that is used as part of the widget label.

This image is used when drawing the widget in the inactive state.

Returns
  the current image for the deactivated widget

## ◆ deimage() [2/3]

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

Sets the image to use as part of the widget label.

This image is used when drawing the widget in the inactive state.

Parameters

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

## ◆ deimage() [3/3]

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

Sets the image to use as part of the widget label.

This image is used when drawing the widget in the inactive state.

Parameters

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

## ◆ do_callback() [1/3]

void Fl_Widget::do_callback | ( |  | ) |
| inline

Calls the widget callback.

Causes a widget to invoke its callback function with default arguments.

See also
  callback()

## ◆ do_callback() [2/3]

void Fl_Widget::do_callback | ( | Fl_Widget * | o,
|  | long | arg
| ) |  |
| inline

Calls the widget callback.

Causes a widget to invoke its callback function with arbitrary arguments.

Parameters

  [in] | o | call the callback with `o` as the widget argument
  [in] | arg | call the callback with `arg` as the user data argument

See also
  callback()

## ◆ do_callback() [3/3]

void Fl_Widget::do_callback | ( | Fl_Widget * | o,
|  | void * | arg = `0`
| ) |  |

Calls the widget callback.

Causes a widget to invoke its callback function with arbitrary arguments.

Parameters

  [in] | o | call the callback with `o` as the widget argument
  [in] | arg | use `arg` as the user data argument

See also
  callback()

## ◆ 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 = &scroll; // scroll 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_FormsBitmap, Fl_FormsPixmap, Fl_Free, Fl_Gl_Window, Fl_Group, Fl_Help_View, Fl_Input, 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_Slider, Fl_Sys_Menu_Bar, Fl_Tabs, Fl_Text_Display, Fl_Timer, Fl_Tree, Fl_Value_Input, Fl_Value_Output, Fl_Value_Slider, Fl_Window, Fl_FormsText, Fl_Glut_Window, and Fl_Table.

## ◆ 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 | ) |
| inlineprotected

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.

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_Free, Fl_Table, Fl_Text_Display, Fl_Text_Editor, Fl_Tree, Fl_Browser_, Fl_File_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_Slider, Fl_Tabs, Fl_Timer, Fl_Value_Input, Fl_Value_Output, Fl_Value_Slider, Fl_Window, and Fl_Glut_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_Menu_Window, Fl_Overlay_Window, and Fl_Window.

## ◆ image() [1/3]

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

Gets the image that is used as part of the widget label.

This image is used when drawing the widget in the active state.

Returns
  the current image

## ◆ image() [2/3]

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

Sets the image to use as part of the widget label.

This image is used when drawing the widget in the active state.

Parameters

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

## ◆ image() [3/3]

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

Sets the image to use as part of the widget label.

This image is used when drawing the widget in the active state.

Parameters

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

## ◆ 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. 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_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)

## ◆ 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_Input_Choice, Fl_Scroll, Fl_Spinner, Fl_Table, Fl_Text_Display, Fl_Tile, Fl_Window, Fl_Double_Window, Fl_Gl_Window, Fl_Group, Fl_Help_View, Fl_Input_, Fl_Overlay_Window, Fl_Tree, and Fl_Value_Input.

## ◆ 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)

## ◆ 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_Menu_Window, Fl_Overlay_Window, Fl_Single_Window, 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
  Internal use only.

## ◆ 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
  Internal use only.

## ◆ 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 is used for Forms compatibility and to simulate RTTI.

Todo:
  Explain "simulate RTTI" (currently only used to decide if a widget is a window, i.e. type()>=FL_WINDOW ?). Is type() really used in a way that ensures "Forms compatibility" ?

## ◆ type() [2/2]

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

Sets the widget type.

This is used for Forms compatibility.

## ◆ user_data() [1/2]

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

## ◆ user_data() [2/2]

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

Sets the user data for this widget.

Sets the new user data (void *) argument that is passed to the callback function.

Parameters

  [in] | v | new user data

## ◆ 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 | ( |  | ) |
| 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 | ) |
| inlineprotected

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)

## ◆ 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_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

## ◆ 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 | ) |
| inlineprotected

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

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

- Copyright © 1998-2021 by Bill Spitzak and others.