Fl_Widget is the base class for all widgets in FLTK. You cannot create one directly because the constructor is protected, but you can subclass it to create custom widgets. All property accessing methods, such asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fltk/fltk/llms.txt
Use this file to discover all available pages before exploring further.
color(), parent(), or argument() are implemented as trivial inline functions and are as fast as accessing fields in a structure.
Constructor
Position of the widget relative to the enclosing window
Size of the widget in pixels
Optional text label for the widget
Core Methods
draw()
Draws the widget (pure virtual).handle()
Handles events.Event type (FL_PUSH, FL_RELEASE, FL_KEYBOARD, etc.)
handle() for events you don’t handle.
Example:
redraw()
Schedules the widget for redrawing.draw() method called.
redraw_label()
Schedules just the label for redrawing.Position and Size
x(), y(), w(), h()
Gets widget position and size.resize()
Changes widget size and/or position.New position relative to parent window
New size in pixels
redraw().
position()
Repositions the widget.New position relative to parent window
resize(X, Y, w(), h()).
size()
Changes the widget size.New width and height in pixels
resize(x(), y(), W, H).
Appearance
color()
Gets or sets the background color.Background color
Selection color (optional)
selection_color()
Gets or sets the selection color.New selection color
box()
Gets or sets the box type.New box type (FL_UP_BOX, FL_DOWN_BOX, etc.)
Labels
label()
Gets or sets the label text.New label text (pointer stored, not copied)
Label type
copy_label() instead.
copy_label()
Sets the label with automatic copying.Label text to copy
labeltype()
Gets or sets the label type.Label type (FL_NORMAL_LABEL, FL_SHADOW_LABEL, etc.)
labelcolor()
Gets or sets the label color.New label color
labelfont()
Gets or sets the label font.Font index (FL_HELVETICA, FL_COURIER, etc.)
labelsize()
Gets or sets the label font size.Font size in pixels
align()
Gets or sets the label alignment.Alignment flags (FL_ALIGN_CENTER, FL_ALIGN_LEFT, etc.)
Images
image()
Gets or sets the image for active state.Image to display when widget is active
bind_image()
Sets and binds an image (widget takes ownership).Image to bind to widget
deimage()
Gets or sets the image for inactive state.Image to display when widget is inactive
Callbacks
callback()
Gets or sets the callback function.Callback function pointer
User data passed to callback
do_callback()
Calls the callback function.Widget to pass as first argument
User data to pass as second argument
when()
Gets or sets when the callback is called.When flags (FL_WHEN_RELEASE, FL_WHEN_CHANGED, etc.)
user_data()
Gets or sets user data.User data pointer
State
visible()
Checks if widget is visible.visible_r()
Checks if widget and all parents are visible.show()
Makes the widget visible.hide()
Makes the widget invisible.active()
Checks if widget is active.active_r()
Checks if widget and all parents are active.activate()
Activates the widget.deactivate()
Deactivates the widget.takesevents()
Checks if widget can receive events.changed()
Checks if widget value has changed.set_changed()
Marks the value as changed.clear_changed()
Clears the changed flag.Focus
take_focus()
Gives keyboard focus to the widget.visible_focus()
Gets or sets visible focus.1 to enable visible focus, 0 to disable
Hierarchy
parent()
Gets the parent widget.window()
Gets the window containing this widget.top_window()
Gets the top-level window.contains()
Checks if a widget is a child.Widget to check
inside()
Checks if this widget is inside another.Potential parent widget
Type Checking
as_group()
Returns this widget as Fl_Group if applicable.as_window()
Returns this widget as Fl_Window if applicable.as_gl_window()
Returns this widget as Fl_Gl_Window if applicable.Tooltip
tooltip()
Gets or sets the tooltip text.Tooltip text to display
copy_tooltip()
Sets tooltip with automatic copying.Tooltip text to copy
Related
- Fl (Global Namespace) - Global functions and event loop
- Fl_Window - Window class
- Fl_Group - Container widget class