Contents
Previous
Next
|
This appendix describes all of the widget classes in FLTK. For a
description of the fl_ functions and Fl:: methods, see Appendix B.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Valuator
|
+----Fl_Adjuster
Include Files
#include
Description
The Fl_Adjuster widget was stolen from Prisms, and has proven to be very useful
for values that need a large dynamic range. When you press a button
and drag to the right the value increases. When you drag to the left it
decreases. The largest button adjusts by 100 * step(), the next by 10 * step() and that smallest button by step(). Clicking on the buttons increments by 10 times the amount
dragging by a pixel does. Shift + click decrements by 10 times the
amount.
Methods
Creates a new Fl_Adjuster widget using the given position, size, and label string. It looks
best if one of the dimensions is 3 times the other.
Destroys the valuator.
If "soft" is turned on, the user is allowed to drag the value outside
the range. If they drag the value to one of the ends, let go, then
grab again and continue to drag, they can get to any value. Default is
one.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Box
Include Files
#include
Description
This widget simply draws its box, and possibly it's label. Putting it
before some other widgets and making it big enough to surround them
will let you draw a frame around them.
Methods
The first constructor sets box() to FL_NO_BOX, which means it is invisible. However such widgets are useful as
placeholders or Fl_Group::resizable() values. To change the box to something visible, use box(n).
The second form of the constructor sets the box to the specified box
type.
The destructor removes the box.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Browser_
|
+----Fl_Browser
|
+----Fl_Hold_Browser, Fl_Multi_Browser, Fl_Select_Browser
Include Files
#include
Description
The Fl_Browser widget displays a scrolling list of text lines, and manages all
the storage for the text. This is not a text editor or spreadsheet!
But it is useful for showing a vertical list of named objects to the
user.
Each line in the browser is identified by number. The numbers
start at one (this is so that zero can be reserved for "no line" in the
selective browsers). Unless otherwise noted, the methods do not
check to see if the passed line number is in range and legal. It must
always be greater than zero and <= size().
Each line contains a null-terminated string of text and a void * data pointer. The text string is displayed, the void * pointer can be used by the callbacks to reference the object the
text describes.
The base class does nothing when the user clicks on it. The
subclasses Fl_Select_Browser, Fl_Hold_Browser, and Fl_Multi_Browser react to user clicks to select lines in the browser and do
callbacks.
The base class called Fl_Browser_ provides the scrolling and selection mechanisms of this and all
the subclasses, but the dimensions and appearance of each item are
determined by the subclass. You can use Fl_Browser_ to display information other than text, or text that is
dynamically produced from your own data structures. If you find that
loading the browser is a lot of work or is inefficient, you may want to
make a subclass of Fl_Browser_.
Methods
The constructor makes an empty browser.
The destructor deletes all list items and destroys the browser.
Add a new line to the end of the browser. The text is copied using
the strdup() function. It may also be NULL to make a blank line. The void * argument is returned as the data() of the new item.
Remove all the lines in the browser.
The first form gets the current column separator character. By default
this is '\t' (tab).
The second form sets the column separator to c. This will only have an effect if you also set column_widths().
The first form gets the current column width array. This array is
zero-terminated and specifies the widths in pixels of each column. The
text is split at each column_char() and each part is formatted into it's own column. After the last
column any remaining text is formatted into the space between the last
column and the right edge of the browser, even if the text contains
instances of column_char(). The default value is a one-element array of just a zero, which
makes there are no columns.
The second form sets the current array to w. Make sure the last entry is zero.
The first form returns the data for line n. If n is out of range this returns NULL.
The second form sets the data for line n.
The first form gets the current format code prefix character, which by
default is @. A string of formatting codes at the start of each column are
stripped off and used to modify how the rest of the line is printed:
@. Print rest of line, don't look for more '@' signs
@@ Print rest of line starting with '@'
@l Use a large (24 point) font
@m Use a medium large (18 point) font
@s Use a small (11 point) font
@b Use a bold font (adds FL_BOLD to font)
@i Use an italic font (adds FL_ITALIC to font)
@f or @t Use a fixed-pitch font (sets font to FL_COURIER)
@c Center the line horizontally
@r Right-justify the text
@B0, @B1, ... @B255 Fill the backgound with fl_color(n)
@C0, @C1, ... @C255 Use fl_color(n) to draw the text
@F0, @F1, ... Use fl_font(n) to draw the text
@S1, @S2, ... Use point size n to draw the text
@u or @_ Underline the text.
@- draw an engraved line through the middle.
Notice that the @. command can be used to reliably terminate the parsing. To
print a random string in a random color, use sprintf("@C%d@.%s",
color, string) and it will work even if the string starts with a digit or has
the format character in it.
The second form sets the current prefix to c. Set the prefix to 0 to disable formatting.
Makes line n invisible, preventing selection by the user. The line can still
be selected under program control.
Insert a new line before line n. If n > size() then the line is added to the end.
Clears the browser and reads the file, adding each line from the file
to the browser. If the filename is NULL or a zero-length string then this just clears the browser. This
returns zero if there was any error in opening or reading the file, in
which case errno is set to the system error. The data() of each line is set to NULL.
Line from is removed and reinserted at to; to is calculated after the line is removed.
The first form returns the current vertical scrollbar position, where
0 corresponds to the top. If there is not vertical scrollbar then this
will always return 0.
Remove line n and make the browser one line shorter.
Makes line n visible for selection.
Returns how many lines are in the browser. The last line number is
equal to this.
The first form returns the text for line n. If n is out of range it returns NULL.
The second form sets the text for line n.
The first form returns the current top line in the browser. If there
is no vertical scrollbar then this will always return 1.
The second form sets the top line in the browser to n.
The second form sets the vertical scrollbar position to p.
Returns a non-zero value if line n is visible.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Browser_
|
+----Fl_Browser
Include Files
#include
Description
This is the base class for browsers. To be useful it must be
subclassed and several virtual functions defined. The Forms-compatable
browser and the file chooser's browser are subclassed off of this.
This has been designed so that the subclass has complete control
over the storage of the data, although because next() and prev() functions are used to index, it works best as a linked list or as
a large block of characters in which the line breaks must be searched
for.
A great deal of work has been done so that the "height" of a data
object does not need to be determined until it is drawn. This is
useful if actually figuring out the size of an object requires
accessing image data or doing stat() on a file or doing some other slow operation.
Methods
The constructor makes an empty browser.
The destructor deletes all list items and destroys the browser.
By default you can scroll in both directions, and the scrollbars
disappear if the data will fit in the widget. has_scrollbar() changes
this based on the value of h:
0 - No scrollbars
Fl_Browser_::HORIZONTAL - Only a horizontal scrollbar.
Fl_Browser_::VERTICAL - Only a vertical scrollbar.
Fl_Browser_::BOTH - The default is both scrollbars.
Fl_Browser_::HORIZONTAL_ALWAYS - Horizontal scrollbar always on, vertical always off.
Fl_Browser_::VERTICAL_ALWAYS - Vertical scrollbar always on, horizontal always off.
Fl_Browser_::BOTH_ALWAYS - Both always on.
The first form gets the default text color for the lines in the
browser.
The second form sets the default text color to color
The first form gets the default text font for the lines in the
browser.
The second form sets the default text font to font
The first form gets the default text size for the lines in the
browser.
The second form sets the default text size to size
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Button
|
+----Fl_Check_Button, Fl_Light_Button, Fl_Repeat_Button,
Fl_Return_Button, Fl_Round_Button
Include Files
#include
Description
Buttons generate callbacks when they are clicked by the user. You
control exactly when and how by changing the values for type() and when().
Buttons can also generate callbacks in response to FL_SHORTCUT events. The button can either have an explicit
shortcut() value or a letter shortcut can be indicated in the label() with an ''character before it. For the label shortcut it does
not matter if Alt is held down, but if you have an input field in the same window,
the user will have to hold down the Alt key so that the input field does not eat the event first as an
FL_KEYBOARD event.
Methods
The constructor creates the button using the position, size, and
label.
The destructor removed the button.
Same as value(0).
The first form returns the current down box type, which is drawn when
value() is non-zero.
The second form sets the down box type. The default value of 0
causes FLTK to figure out the correct matching down version of box().
Same as value(1).
Turns on this button and turns off all other radio buttons in the
group (calling value(1) or set() does not do this).
The first form returns the current shortcut key for the button.
The second form sets the shortcut key to key. Setting this overrides the use of ''in the label(). The value is a bitwise OR of a key and a set of shift flags,
for example FL_ALT | 'a' , FL_ALT | (FL_F + 10) , or just 'a' . A value of 0 disables the shortcut.
The key can be any value returned by
Fl::event_key(), but will usually be an ASCII letter. Use a lower-case letter
unless you require the shift key to be held down.
The shift flags can be any set of values accepted by
Fl::event_state(). If the bit is on that shift key must be pushed. Meta, Alt,
Ctrl, and Shift must be off if they are not in the shift flags (zero
for the other bits indicates a "don't care" setting).
The first form of type() returns the current button type, which can be one of:
0 : The value is unchanged.
FL_TOGGLE_BUTTON : The value is inverted.
FL_RADIO_BUTTON : The value is set to 1, and all other buttons in the current
group with type() == FL_RADIO_BUTTON are set to zero.
The second form sets the button type to t.
The first form returns the current value (0 or 1). The second form
sets the current value.
Controls when callbacks are done. The following values are useful,
the default value is FL_WHEN_RELEASE :
0 : The callback is not done, instead changed() is turned on.
FL_WHEN_RELEASE : The callback is done after the user successfully clicks the
button, or when a shortcut is typed.
FL_WHEN_CHANGED : The callback is done each time the value() changes (when the
user pushes and releases the button, and as the mouse is dragged
around in and out of the button).
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Chart
Include Files
#include
Description
This widget displays simple charts and is provided for forms
compatibility.
Methods
Creates a new Fl_Chart widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Destroys the Fl_Chart widget and all of its data.
The add method adds the value and optionally label and color to the chart.
The autosize method controls whether or not the chart will automatically
adjust the bounds of the chart. The first form returns a boolean value
that is non-zero if auto-sizing is enabled and zero is auto-sizing is
disabled.
The second form of autosize sets the auto-sizing property to onoff.
The bounds method gets or sets the lower and upper bounds of the chart
values to a and b respectively.
The clear method removes all values from the chart.
The insert method inserts a data value at the given position pos. Position 0 is the first data value.
The maxsize method gets or sets the maximum number of data values for a
chart.
The replace method replaces data value pos with value, label, and color. Position 0 is the first data value.
The size method returns the number of data values in the chart.
The first form of type() returns the current chart type. The chart type can be one of the
following:
- FL_BAR_CHART
- Each sample value is drawn as a vertical bar.
- FL_FILLED_CHART
- The chart is filled from the bottom of the graph to the sample
values.
- FL_HORBAR_CHART
- Each sample value is drawn as a horizontal bar.
- FL_LINE_CHART
- The chart is drawn as a polyline with vertices at each sample
value.
- FL_PIE_CHART
- A pie chart is drawn with each sample value being drawn as a
proportionate slice in the circle.
- FL_SPECIALPIE_CHART
- Like FL_PIE_CHART, but the first slice is separated from the pie.
- FL_SPIKE_CHART
- Each sample value is drawn as a vertical line.
The second form of type() sets the chart type to t.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Button
|
+----Fl_Check_Button
Include Files
#include
Description
Buttons generate callbacks when they are clicked by the user. You
control exactly when and how by changing the values for type() and when().
The Fl_Check_Button subclass display the "on" state by turning on a light, rather
than drawing pushed in. The shape of the "light" is initially set to
FL_DIAMOND_DOWN_BOX. The color of the light when on is controlled with
selection_color(), which defaults to FL_RED.
Methods
Creates a new Fl_Check_Button widget using the given position, size, and label string.
The destructor deletes the check button.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Menu_
|
+----Fl_Choice
Include Files
#include
Description
This is a button that when pushed pops up a menu (or hierarchy of
menus) defined by an array of
Fl_Menu_Item objects. Motif calls this an OptionButton.
The only difference between this and a
Fl_Menu_Button is that the name of the most recent chosen menu item is displayed
inside the box, while the label is displayed outside the box. However,
since the use of this is most often to control a single variable rather
than do individual callbacks, some of the Fl_Menu_Button methods are redescribed here in those terms.
When the user picks an item off the menu the value() is set to that item and then the callback is done.
All three mouse buttons pop up the menu. The Forms behavior of the
first two buttons to increment/decrement the choice is not implemented.
This could be added with a subclass, however.
The menu will also pop up in response to shortcuts indicated by
putting a ''character in the label(). See Fl_Button for a description of this.
Typing the shortcut() of any of the items will do exactly the same as when you pick the
item with the mouse. The ''character in item names are only looked at
when the menu is popped up, however.
Methods
Creates a new Fl_Choice widget using the given position, size, and label string. The
default boxtype is FL_UP_BOX.
The constructor sets menu() to NULL. See Fl_Menu_ for the methods to set or change the menu.
The destructor removes the Fl_Choice widget and all of its menu items.
The value is the index into the Fl_Menu array of the last item chosen by the user. It is zero initially.
You can set it as an integer, or set it with a pointer to a menu item.
The set routines return non-zero if the new value is different than
the old one. Changing it causes a redraw().
This value is true if the user picks a different value. It is
turned off by value() and just before doing a callback (the callback can turn it back
on if desired).
This method sets the changed() flag.
This method clears the changed() flag.
The first form gets the current down box, which is used when the menu
is popped up. The default down box type is FL_DOWN_BOX The second form sets the current down box type to b.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Clock
Include Files
#include
Description
This widget provides a round analog clock display and is provided for
Forms compatibility. It installs a 1-second timeout callback using
Fl::add_timeout().
Methods
Creates a new Fl_Clock widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code. A kludge has been
done so the Fl_Clock and all of it's children can be automatic (local) variables, but
you must declare the Fl_Clockfirst, so that it is destroyed last.
Returns the current hour (0 to 23).
Returns the current minute (0 to 59).
Returns the current second (0 to 60, 60 = leap second).
The first two forms of value set the displayed time to the given UNIX time value or specific
hours, minutes, and seconds.
The third form of value returns the displayed time in seconds since the UNIX epoch
(January 1, 1970).
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Group
|
+----Fl_Color_Chooser
Include Files
#include
Description
The Fl_Color_Chooser widget provides a standard RGB color chooser. You can place any
number of these into a panel of your own design. This widget contains
the hue box, value slider, and rgb input fields from the above diagram
(it does not have the color chips or the Cancel or OK buttons). The
callback is done every time the user changes the rgb value. It is not
done if they move the hue control in a way that produces the same rgb value, such as when saturation or value is zero.
Methods
Creates a new Fl_Color_Chooser widget using the given position, size, and label string. The
recommended dimensions are 200x95. The color is initialized to black.
The destructor removes the color chooser and all of its controls.
Return the current hue. 0 <= hue < 6. Zero is red, one is yellow,
two is green, etc. This value is convienent for the internal
calculations - some other systems consider hue to run from zero to one,
or from 0 to 360.
Returns the saturation. 0 <= saturation <= 1.
Returns the value/brightness. 0 <= value <= 1.
Returns the current red value. 0 <= r <= 1.
Returns the current green value. 0 <= g <= 1.
Returns the current blue value. 0 <= b <= 1.
Sets the current rgb color values. Does not do the callback. Does
not clamp (but out of range values will produce psychedelic effects in
the hue selector).
Set the hsv values. The passed values are clamped (or for hue,
modulus 6 is used) to get legal values. Does not do the callback.
This static method converts HSV colors to RGB colorspace.
This static method converts RGB colors to HSV colorspace.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Valuator
|
+----Fl_Counter
Include Files
#include
Description
The Fl_Counter widget is provided for forms compatibility. It controls a single
floating point value.
Methods
Creates a new Fl_Counter widget using the given position, size, and label string. The
default type is FL_NORMAL_COUNTER.
Destroys the valuator.
Get or set the increment for the double-arrow buttons. The default
value is 1.0.
Sets the type of counter:
- FL_NORMAL_COUNTER - Displays a counter with 4 arrow buttons.
- FL_SIMPLE_COUNTER - Displays a counter with only 2 arrow buttons.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Valuator
|
+----Fl_Dial
Include Files
#include
Description
The Fl_Dial widget provides a circular dial to control a single floating
point value.
Methods
Creates a new Fl_Dial widget using the given position, size, and label string. The
default type is FL_NORMAL_DIAL.
Destroys the valuator.
Sets the angles used for the minimum and maximum values. By default
these are 0 and 360, respectively.
Sets the type of the dial to:
- FL_NORMAL_DIAL - Draws a normal dial with a knob.
- FL_LINE_DIAL - Draws a dial with a line.
- FL_FILL_DIAL - Draws a dial with a filled arc.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Window
|
+----Fl_Double_Window
Include Files
#include
Description
The Fl_Double_Window class provides a double-buffered window. If possible this will
use the X double buffering extension (Xdbe). If not, it will draw the
window data into an off-screen pixmap, and then copy it to the
on-screen window.
It is highly recommended that you put the following code before the
first show() of any window in your program:
Fl::visual(FL_DOUBLE|FL_INDEX)
This makes sure you can use Xdbe on servers where double buffering
does not exist for every visual.
Methods
Creates a new Fl_Double_Window widget using the given position, size, and label (title) string.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Group----Fl_End
Include Files
#include
Description
This is a dummy class that allows you to end a group in a constructor
list of a class:
class MyClass {
Fl_Group group;
Fl_Button button_in_group;
Fl_End end;
Fl_Button button_outside_group;
MyClass();
};
MyClass::MyClass() :
group(10,10,100,100),
button_in_group(20,20,60,30),
end(),
button_outside_group(10,120,60,30)
{}
Methods
The constructor does Fl_Group::current()->end().
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Input
|
+----Fl_Float_Input
Include Files
#include
Description
The Fl_Float_Input class is a subclass of Fl_Input that displays its input in red when the value string is not a
legal floating point value.
Methods
Creates a new Fl_Float_Input widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Free
Include Files
#include
Description
Emulation of the Forms "free" widget. This emulation allows the free
demo to run, and appears to be useful for porting programs written in
Forms which use the free widget or make subclasses of the Forms
widgets.
There are five types of free, which determine when the handle
function is called:
#define FL_NORMAL_FREE 1
#define FL_SLEEPING_FREE 2
#define FL_INPUT_FREE 3
#define FL_CONTINUOUS_FREE 4
#define FL_ALL_FREE 5
An FL_INPUT_FREE accepts FL_FOCUS events. A FL_CONTINUOUS_FREE sets
a timeout callback 100 times a second and provides a FL_STEP event,
this has obvious detrimental effects on machine performance.
FL_ALL_FREE does both. FL_SLEEPING_FREE are deactivated.
Methods
The constructor takes both the type and the handle function. The handle function should be declared as follows:
int
handle_function(Fl_Widget *w,
int event,
float event_x,
float event_y,
char key)
This function is called from the the handle() method in response to most events, and is called by the draw() method. The event argument contains the event type:
// old event names for compatability:
#define FL_MOUSE FL_DRAG
#define FL_DRAW 0
#define FL_STEP 9
#define FL_FREEMEM 12
#define FL_FREEZE FL_UNMAP
#define FL_THAW FL_MAP
The destructor will call the handle function with the event
FL_FREE_MEM.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Gl_Window
|
+----Fl_Pack, Fl_Scroll, Fl_Tabs, Fl_Tile, Fl_Window
Include Files
#include
Description
The Fl_Gl_Window widget sets things up so OpenGL works, and also keeps an OpenGL
"context" for that window, so that changes to the lighting and
projection may be reused between redraws. Fl_Gl_Window also flushes the OpenGL streams and swaps buffers after draw() returns.
OpenGL hardware typically provides some overlay bit planes, which
are very useful for drawing UI controls atop your 3D graphics. If the
overlay hardware is not provided, FLTK tries to simulate the overlay,
This works pretty well if your graphics are double buffered, but not
very well for single-buffered.
Methods
Creates a new Fl_Gl_Window widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX. The default mode is FL_RGB|FL_DOUBLE|FL_DEPTH.
The destructor removes the widget and destroys the OpenGL context
associated with it.
Fl_Gl_Window::draw() is a pure virtual method. You must subclass Fl_Gl_Window and provide an implementation for draw(). You may also provide an implementation of draw_overlay() if you
want to draw into the overlay planes. You can avoid reinitializing the
viewport and lights and other things by checking valid() at the start of draw() and only doing the initialization if it is false.
The draw() method can only use OpenGL calls. Do not attempt to call X, any of the functions
in , or glX directly. Do not call gl_start() or gl_finish().
If double-buffering is enabled in the window, the back and front
buffers are swapped after this function is completed.
Set or change the OpenGL capabilites of the window. The value can be
any of the following OR'd together:
- FL_RGB - RGB color (not indexed)
- FL_RGB8 - RGB color with at least 8 bits of each color
- FL_INDEX - Indexed mode
- FL_SINGLE - not double buffered
- FL_DOUBLE - double buffered
- FL_ACCUM - accumulation buffer
- FL_ALPHA - alpha channel in color
- FL_DEPTH - depth buffer
- FL_STENCIL - stencil buffer
- FL_MULTISAMPLE - multisample antialiasing
FL_RGB and FL_SINGLE have a value of zero, so they are "on" unless you give
FL_INDEX or FL_DOUBLE.
If the desired combination cannot be done, FLTK will try turning off
FL_MULTISAMPLE. If this also fails the show() will call Fl::error() and not show the window.
You can change the mode while the window is displayed. This is most
useful for turning double-buffering on and off. Under X this will
cause the old X window to be destroyed and a new one to be created. If
this is a top-level window this will unfortunately also cause the
window to blink, raise to the top, and be de-iconized, and the xid() will change, possibly breaking other code. It is best to make
the GL window a child of another window if you wish to do this!
Returns non-zero if the hardware supports the given or current OpenGL
mode.
Fl_Gl_Window::valid() is turned off when FLTK creates a new context for this window or
when the window resizes, and is turned on afterdraw() is called. You can use this inside your draw() method to avoid unneccessarily initializing the OpenGL context.
Just do this:
void mywindow::draw() {
if (!valid()) {
glViewport(0,0,w(),h());
glFrustum(...);
glLight(...);
...other initialization...
}
... draw your geometry here ...
}
void Fl_Gl_Window::invalidate();
void Fl_Gl_Window::valid(char i);
Fl_Gl_Window::valid() is turned off when FLTK creates a new context for this window and
by the window resizing, and is turned on after draw() is called. You can use this inside your draw() method to
avoid unneccessarily initializing the OpenGL context. Just do this:
void mywindow::draw() {
if (!valid()) {
glViewport(0,0,w(),h());
glFrustum(...);
glLight(...);
...other initilization...
}
... draw your geometry here ...
}
You can turn valid() on by calling valid(1). You should only do this after fixing the transformation inside
a draw() or after make_current(). This is done automatically after draw() returns.
The invalidate() method turns off valid() and is equivalent to calling value(0).
Set the projection so 0,0 is in the lower left of the window and each
pixel is 1 unit wide/tall. If you are drawing 2D images, your
draw() method may want to call this if valid() is false.
The make_current() method selects the OpenGL context for the widget. It is called
automatically prior to the draw() method being called and can also be used to implement feedback
and/or selection within the handle() method.
The make_overlay_current() method selects the OpenGL context for the widget's overlay. It
is called automatically prior to the draw_overlay() method being called and can also be used to implement feedback
and/or selection within the handle() method.
The swap_buffers() method swaps the back and front buffers. It is called
automatically after the draw() method is called.
Hides the window and destroys the OpenGL context.
Returns true if the hardware overlay is possible. If this is false,
FLTK will try to simulate the overlay, with significant loss of update
speed. Calling this will cause FLTK to open the display.
This method causes draw_overlay to be called at a later time. Initially the overlay is clear, if
you want the window to display something in the overlay when it first
appears, you must call this immediately after you show() your window.
You must implement this virtual function if you want to draw into the
overlay. The overlay is cleared before this is called. You should
draw anything that is not clear using OpenGL. You must use
gl_color(i) to choose colors (it allocates them from the colormap using
system-specific calls), and remember that you are in an indexed OpenGL
mode and drawing anything other than flat-shaded will probably not
work.
Both this function and Fl_Gl_Window::draw() should check Fl_Gl_Window::valid() and set the same transformation. If you don't your code may not
work on other systems. Depending on the OS, and on whether overlays
are real or simulated, the OpenGL context may be the same or different
between the overlay and main window.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Group
|
+----Fl_Pack, Fl_Scroll, Fl_Tabs, Fl_Tile, Fl_Window
Include Files
#include
Description
The Fl_Group class is the FLTK container widget. It maintains an array of
child widgets. These children can themselves be any widget including
Fl_Group. The most important subclass of Fl_Group is Fl_Window, however groups can also be used to control radio buttons or to
enforce resize behavior.
Methods
Creates a new Fl_Group widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code. A kludge has been
done so the Fl_Group and all of it's children can be automatic (local) variables, but
you must declare the Fl_Groupfirst, so that it is destroyed last.
Adds a widget to the group at the end of the child array.
Adds a widget to the group and makes it the resizable widget.
Returns a pointer to the array of children. This pointer can change
when children are added or removed!
begin() sets the current group so you can build the widget tree by just
constructing the widgets. begin() is automatically called by the constructor for Fl_Group (and thus
for Fl_Window as well). begin() does current(this).
Don't forget to end() the group or window!
Returns child n, where 0
.
Returns how many child widgets the group has.
current() returns the currently active group in the widget tree. To prevent
widgets from being added to a group, call current() with a NULL group.
end() does current(this->parent()). Any new widgets added to the widget tree will be added to the
parent of the group.
Searches the child array for the widget and returns the index. Returns children() if the widget is NULL or not found.
Inserts a widget into the child array. It is put at index n which must be less or equal to children(). The second version
does a find(beforethis) and inserts using that index.
Removes a widget from the group. This does nothing if the widget is
not currently a child of this group.
The resizable widget defines the resizing box for the group. When the
group is resized it calculates a new size and position for all of its
children. Widgets that are horizontally or vertically inside the
dimensions of the box are scaled to the new size. Widgets outside the
box are moved.
In these examples the gray area is the resizable:

The resizable may be set to the group itself (this is the default
value for an Fl_Group, although NULL is the default for an Fl_Window), in which case all the contents are resized. If the resizable is
NULL then all widgets remain a fixed size and distance from the
top-left corner.
It is possible to achieve any type of resize behavior by using an
invisible Fl_Box as the resizable and/or by using a hierarchy of child Fl_Group's.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Browser
|
+----Fl_Hold_Browser
Include Files
#include
Description
The Fl_Hold_Browser class is a subclass of Fl_Browser which lets the user select a single item, or no items by clicking
on the empty space. As long as the mouse button is held down the item
pointed to by it is highlighted, and this highlighting remains on when
the mouse button is released. Normally the callback is done when the
user releases the mouse, but you can change this with when().
See Fl_Browser for methods to add and remove lines from the browser.
Methods
Creates a new Fl_Hold_Browser widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
The destructor also deletes all the items in the list.
Same as value(0).
You can use these for compatibility with
Fl_Multi_Browser. If you turn on the selection of more than one line the results
are unpredictable.
Set or get which line is selected. This returns zero if no line is
selected, so be aware that this can happen in a callback.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Input_
|
+----Fl_Input
|
+----Fl_Float_Input, Fl_Int_Input,
Fl_Multiline_Input, Fl_Secret_Input
Include Files
#include
Description
This is the FLTK text input widget. It displays a single line of text
and lets the user edit it. Normally it is drawn with an inset box and
a white background. The text may contain any characters (even 0), and
will correctly display anything, using ^X notation for unprintable
control characters and \nnn notation for unprintable characters with
the high bit set. It assummes the font can draw any characters in the
ISO8859-1 character set.
Mouse button 1 | Moves the cursor to this point. Drag selects characters.
Double click selects words. Triple click selects all text.
Shift+click extends the selection. |
Mouse button 2 | Insert the current X selection at the cursor (unlike Motif
this does not move the insertion point to the mouse). If the widget
does not have the input focus (and thus no cursor) it puts the cursor
where clicked and inserts the selection there. |
Mouse button 3 | Currently acts like button 1. |
Backspace | Deletes one character to the left, or deletes the selected
region. |
Enter | May cause the callback, see when(). |
^A or Home | Go to start of line. |
^B or Left | Move left |
^C | Copy the selection to the clipboard |
^D or Delete | Deletes one character to the right or deletes the selected
region. Due to silly historical X problems, the Delete key will act
like Backspace until you type a "real" backspace. |
^E or End | Go to the end of line. |
^F or Right | Move right |
^K | Delete to the end of line (next \n character) or deletes a
single \n character. These deletions are all concatenated into the
clipboard. |
^N or Down | Move down (for Fl_Multiline_Input only, otherwise it moves to
the next input field). |
^P or Up | Move up (for Fl_Multiline_Input only, otherwise it moves to
the previous input field). |
^Q or
RightCtrl or
Compose | Start a compose-character sequence. The next one or two keys typed define the character to
insert. This also can be used to "quote" control characters. |
^U | Delete everything. |
^V or ^Y | Paste the clipboard |
^X or ^W | Copy the region to the clipboard and delete it. |
^Z or ^_ | Undo. This is a single-level undo mechanism, but all adjacent
deletions and insertions are concatenated into a single "undo". Often
this will undo a lot more than you expected. |
Shift+move | Move the cursor but also extend the selection. |
Methods
Creates a new Fl_Input widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
The first form returns the current value, which is a pointer to the
internal buffer and is valid only until the next event is handled.
The second two forms change the text and set the mark and the point
to the end of it. The string is copied to the internal buffer. Passing
NULL is the same as "". This returns non-zero if the new value is
different than the current one. You can use the second version to
directly set the length if you know it already or want to put nul's in
the text.
Change the text and set the mark and the point to the end of it. The
string is not copied. If the user edits the string it is copied to the internal
buffer then. This can save a great deal of time and memory if your
program is rapidly changing the values of text fields, but this will
only work if the passed string remains unchanged until either the
Fl_Input is destroyed or value() is called again.
Returns the number of characters in value(). This may be greater than strlen(value()) if there are nul characters in it.
Same as value()[n], but may be faster in plausible implementations. No bounds
checking is done.
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_Mulitline_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.
Gets or sets the color of the text in the input field.
Gets or sets the font of the text in the input field.
Gets or sets the size of the text in the input field.
Get or set the color of the cursor. This is black by default.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Input_
|
+----Fl_Input
Include Files
#include
Description
This is a virtual base class below
Fl_Input. It has all the same interfaces, but lacks the handle() and draw() method. You may want to subclass it if you are one of those
people who likes to change how the editing keys work.
This can act like any of the subclasses of Fl_Input, by setting
type() to one of the following values:
#define FL_NORMAL_INPUT 0
#define FL_FLOAT_INPUT 1
#define FL_INT_INPUT 2
#define FL_MULTILINE_INPUT 4
#define FL_SECRET_INPUT 5
Methods
Creates a new Fl_Input_ widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
The destructor removes the widget and any value associated with it.
Returns true if position i is at the start or end of a word.
Returns true if position i is at the start or end of a line.
Draw the text in the passed bounding box. If damage()
FL_DAMAGE_ALL is true, this assummes the area has already been erased to
color(). Otherwise it does minimal update and erases the area itself.
Default handler for all event types. Your handle() method should call this for all events that it does not handle
completely. You must pass it the same bounding box as passed to
draw(). Handles FL_PUSH, FL_DRAG, FL_RELEASE to select text, handles FL_FOCUS and FL_UNFOCUS to show and hide the cursor.
Do the correct thing for arrow keys. Sets the position (and mark if
keepmark is zero) to somewhere in the same line as i, such that pressing the arrows repeatedly will cause the point to
move up and down.
Does the callback if changed() is true or if when() FL_WHEN_NOT_CHANGED is non-zero. You should call this at any point you think you
should generate a callback.
The input widget maintains two pointers into the string. The
"position" is where the cursor is. The "mark" is the other end of the
selected text. If they are equal then there is no selection. Changing
this does not affect the clipboard (use copy() to do that).
Changing these values causes a redraw(). The new values are bounds checked. The return value is
non-zero if the new position is different than the old one.
position(n) is the same as position(n,n). mark(n) is the same as position(position(),n).
Gets or sets the current selection mark. mark(n) is the same as position(position(),n).
This call does all editing of the text. It deletes the region between
a and b (either one may be less or equal to the other), and then inserts
the string insert at that point and leaves the mark() and position() after the insertion. Does the callback if when()
FL_WHEN_CHANGED and there is a change.
Set start and end equal to not delete anything. Set insert to NULL to not insert anything.
length must be zero or strlen(insert), this saves a tiny bit of time if you happen to already know the
length of the insertion, or can be used to insert a portion of a string
or a string containing nul's.
a and b are clamped to the 0..size() range, so it is safe to pass any values.
cut() and insert() are just inline functions that call replace().
Fl_Input_::cut() deletes the current selection. cut(n) deletes n characters after the position(). cut(-n) deletes n characters before the position(). cut(a,b) deletes the characters between offsets a and b. A, b, and n are all clamped to the size of the string. The mark and point
are left where the deleted text was.
If you want the data to go into the clipboard, do
Fl_Input_::copy() before calling Fl_Input_::cut(), or do Fl_Input_::copy_cuts() afterwards.
Insert the string t at the current position, and leave the mark and position after
it. If l is not zero then it is assummed to be strlen(t).
Put the current selection between mark() and position() into the clipboard. Does not replace the old clipboard contents
if position() and mark() are equal.
Does undo of several previous calls to replace(). Returns non-zero if any change was made.
Copy all the previous contiguous cuts from the undo information to the
clipboard. This is used to make ^K work.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Input
|
+----Fl_Int_Input
Include Files
#include
Description
The Fl_Int_Input class is a subclass of Fl_Input that displays its input in red when the value string is not a
legal integer value.
Methods
Creates a new Fl_Int_Input widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Button
|
+----Fl_Light_Button
Include Files
#include
Description
Buttons generate callbacks when they are clicked by the user. You
control exactly when and how by changing the values for type() and when().
The Fl_Light_Button subclass display the "on" state by turning on a light, rather
than drawing pushed in. The shape of the "light" is initially set to
FL_DOWN_BOX. The color of the light when on is controlled with
selection_color(), which defaults to FL_YELLOW.
Methods
Creates a new Fl_Light_Button widget using the given position, size, and label string.
The destructor deletes the check button.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Menu_----Fl_Menu_Item
|
+----Fl_Choice, Fl_Menu_Bar, Fl_Menu_Button
Include Files
#include
Description
All widgets that have a menu in FLTK are subclassed off of this class.
Currently FLTK provides you with
Fl_Menu_Button, Fl_Menu_Bar, and Fl_Choice.
The class contains a pointer to an array of structures of type
Fl_Menu_Item. These describe the contents of the menu. Usually the array is a
large initialization constant, but there are methods to build it
dynamically.
Methods
Creates a new Fl_Menu_ widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Destroys the menu and its items.
Get or set the menu array directly. Setting it to NULL indicates that you want the widget to allocate its own array.
The value is the index into menu() of the last item chosen by the user. It is zero initially. You
can set it as an integer, or set it with a pointer to a menu item. The
set routines return non-zero if the new value is different than the old
one.
Only call this in response to FL_SHORTCUT events. If the event matches an entry in the menu that entry is
selected and the callback will be done (or changed() will be set). This allows shortcuts directed at one window to
call menus in another.
Make the shortcuts for this menu work no matter what window has the
focus when you type it. This is done by using
Fl::add_handler(). This Fl_Menu_ widget does not have to be visible (ie the window it is in can be
hidden, or it does not have to be put in a window at all).
Currently there can be only one global()menu. Setting a new
one will replace the old one. There is no way to remove the
global() setting (including destroying the menu).
Returns the title of the last item chosen, or of item i.
This returns menu()->size(), which is how many entries are in the array, not counting the
NULL ending, but including all submenus titles and the NULL's that end them. If the menu is NULL this returns zero.
The first form adds a new menu item, with a title string, shortcut string, callback, argument to the callback, and flags. If menu() was originally set with NULL then space is allocated for the new item. If instead you gave it
an array then the array must have enough empty space for the new item.
The title string is copied, but the shortcut is not.
The second form splits the string at any | characters and then does
add(s,0,0,0,0) with each section. This is often useful if you are just using
the value, and is compatable with some Forms programs.
Text is a string of the form "foo/bar/baz", this example will result
in a submenu called "foo" and one in that called "bar" and and entry
called "baz". The text is copied to new memory and can be freed. The
other arguments are copied into the menu item unchanged.
If an item exists already with that name then it is replaced with
this new one. Otherwise this new one is added to the end of the
correct menu or submenu. The return value is the offset into the array
that the new entry was placed at.
No bounds checking is done, the table must be big enough for all the
entries you plan to add. Don't forget that there is a NULL terminator on the end, and the first time a item is added to a
submenu three items are added (the title and the NULL terminator, as well as the actual menu item)
The return value is the index into the array that the entry was put.
Delete all the menu items. Don't do this if you used menu(x) to set it to your own array. You should do this before
destroying the Fl_Menu_ widget if it uses it's own array.
Changes the text of item n. The passed string is copied.
Deletes item n from the menu.
Changes the shortcut of item i to n.
Changes the flags of item i.
Get or set the current color of menu item labels.
Get or set the current font of menu item labels.
Get or set the font size of menu item labels.
This box type is used to surround the currently-selected items in the
menus. If this is FL_NO_BOX then it acts like FL_THIN_UP_BOX and selection_color() acts like FL_WHITE, for back compatability.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Menu_
|
+----Fl_Menu_Bar
Include Files
#include
Description
This widget provides a standard menubar interface. Usually you will
put this widget along the top edge of your window. The height of the
widget should be 30 for the menu titles to draw correctly with the
default font.
The items on the bar and the menus they bring up are defined by a
single Fl_Menu_Item array. Because a Fl_Menu_Item array defines a hierarchy, the top level menu defines the items
in the menubar, while the submenus define the pull-down menus. Sub-sub
menus and lower pop up to the right of the submenus.

If there is an item in the top menu that is not a title of a
submenu, then it acts like a "button" in the menubar. Clicking on it
will pick it.
When the user picks an item off the menu, the item's callback is
done with the menubar as the Fl_Widget* argument. If the item does not have a callback the menubar's
callback is done instead.
Submenus will also pop up in response to shortcuts indicated by
putting a ''character in the name field of the menu item. If you put a
''character in a top-level "button" then the shortcut picks it. The
''character in submenus is ignored until the menu is popped up.
Typing the shortcut() of any of the menu items will cause callbacks exactly the same as
when you pick the item with the mouse.
Methods
Creates a new Fl_Menu_Bar widget using the given position, size, and label string. The
default boxtype is FL_UP_BOX.
The constructor sets menu() to NULL. See Fl_Menu_ for the methods to set or change the menu.
labelsize(), labelfont(), and labelcolor() are used to control how the menubar items are drawn. They are
initialized from the Fl_Menu static variables, but you can change them if desired.
label() is ignored unless you change align() to put it outside the menubar.
The destructor removes the Fl_Menu_Bar widget and all of its menu items.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Menu_
|
+----Fl_Menu_Button
Include Files
#include
Description
This is a button that when pushed pops up a menu (or hierarchy of
menus) defined by an array of
Fl_Menu_Item objects.

Normally any mouse button will pop up a menu and it is lined up
below the button as shown in the picture. However an Fl_Menu_Button may also control a pop-up menu. This is done by setting the
type(), see below.
The menu will also pop up in response to shortcuts indicated by
putting a ''character in the label().
Typing the shortcut() of any of the menu items will cause callbacks exactly the same as
when you pick the item with the mouse. The ''character in menu item
names are only looked at when the menu is popped up, however.
When the user picks an item off the menu, the item's callback is
done with the menu_button as the Fl_Widget* argument. If the item does not have a callback the menu_button's
callback is done instead.
Methods
Creates a new Fl_Menu_Button widget using the given position, size, and label string. The
default boxtype is FL_UP_BOX.
The constructor sets menu() to NULL. See Fl_Menu_ for the methods to set or change the menu.
The destructor removes the Fl_Menu_Button widget and all of its menu items.
Act exactly as though the user clicked the button or typed the
shortcut key. The menu appears, it waits for the user to pick an item,
and if they pick one it sets value() and does the callback or sets changed() as described above. The menu item is returned or NULLif
the user dismisses the menu.
If type() is zero a normal menu button is produced. If it is nonzero then
this is a pop-up menu. The bits in type() indicate what mouse buttons pop up the menu. For convienece the
constants Fl_Menu_Button::POPUP1, POPUP2, POPUP3, POPUP12, POPUP13,
POPUP23, and POPUP123 are defined. Fl_Menu_Button::POPUP3 is usually what you want.
A popup menu button is invisible and does not interfere with any
events other than the mouse button specified (and any shortcuts). The
widget can be stretched to cover all your other widgets by putting it
last in the hierarchy so it is "on top". You can also make several
widgets covering different areas for context-sensitive popup menus.
The popup menus appear with the cursor pointing at the previously
selected item. This is a feature. If you don't like it, do value(0) after the menu items are picked to forget the current item.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Menu_Item----Fl_Menu_
Include Files
#include
Description
The Fl_Menu_Item structure defines a single menu item that is used by the
Fl_Menu_ class. This structure is defined in
struct Fl_Menu_Item {
const char* text; // label()
ulong shortcut_;
Fl_Callback* callback_;
void* user_data_;
int flags;
uchar labeltype_;
uchar labelfont_;
uchar labelsize_;
uchar labelcolor_;
};
enum { // values for flags:
FL_MENU_INACTIVE = 1,
FL_MENU_TOGGLE = 2,
FL_MENU_VALUE = 4,
FL_MENU_RADIO = 8,
FL_MENU_INVISIBLE = 0x10,
FL_SUBMENU_POINTER = 0x20,
FL_SUBMENU = 0x40,
FL_MENU_DIVIDER = 0x80,
FL_MENU_HORIZONTAL = 0x100
};
Typically menu items are statically defined; for example:
 |
Fl_Menu_Item popup[] = {
{", FL_ALT+'a', the_cb, (void*)1},
{", FL_ALT+'b', the_cb, (void*)2},
{"gamma", FL_ALT+'c', the_cb, (void*)3, FL_MENU_DIVIDER},
{", 0, strange_cb},
{", 0, charm_cb},
{", 0, truth_cb},
{"b, 0, beauty_cb},
{"sub, 0, 0, 0, FL_SUBMENU},
{"one"},
{"two"},
{"three"},
{0},
{"inactive", FL_ALT+'i', 0, 0, FL_MENU_INACTIVE|FL_MENU_DIVIDER},
{"invisible",FL_ALT+'i', 0, 0, FL_MENU_INVISIBLE},
{"check", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE|FL_MENU_VALUE},
{"box", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE},
{0}};
|
A submenu title is identified by the bit FL_SUBMENU in the flags field, and ends with a label() that is NULL. You can nest menus to any depth. A pointer to the first item
in the submenu can be treated as an Fl_Menu array itself. It is also possible to make seperate submenu
arrays with FL_SUBMENU_POINTER flags.
You should use the method functions to access structure members and
not access them directly to avoid compatibility problems with future
releases of FLTK.
Methods
This is the title of the item. A NULL here indicates the end of the menu (or of a submenu). A ''in the
item will print an underscore under the next letter, and if the menu is
popped up that letter will be a "shortcut" to pick that item. To get a
real ''put two in a row.
A labeltype identifies a routine that draws the label of the widget. This
can be used for special effects such as emboss, or to use the
label() pointer as another form of data such as a bitmap. The value
FL_NORMAL_LABEL prints the label as text.
This color is passed to the labeltype routine, and is typically the
color of the label text. This defaults to FL_BLACK. If this color is not black fltk will not use overlay bitplanes to draw the menu - this is so that images
put in the menu draw correctly.
Fonts are identified by small 8-bit indexes into a table. See the
enumeration list for predefined fonts. The default value is a Helvetica font. The
function Fl::set_font() can define new fonts.
Gets or sets the label font pixel size/height.
Each item has space for a callback function and an argument for that
function. Due to back compatability, the Fl_Menu_Item itself is not passed to the callback, instead you have to get it
by calling ((Fl_Menu_*)w)->mvalue() where w is the widget argument.
Get or set the user_data argument that is sent to the callback function.
For convenience you can also define the callback as taking a long argument. This is implemented by casting this to a
Fl_Callback and casting the long to a void* and may not be portable to some machines.
Call the Fl_Menu_Item item's callback, and provide the Fl_Widget argument (and optionally override the user_data() argument). You
must first check that callback() is non-zero before calling this.
Sets exactly what key combination will trigger the menu item. The
value is a logical 'or' of a key and a set of shift flags, for instance
FL_ALT+'a' or FL_ALT+FL_F+10 or just 'a'. A value of zero disables the shortcut.
The key can be any value returned by
Fl::event_key(), but will usually be an ASCII letter. Use a lower-case letter
unless you require the shift key to be held down.
The shift flags can be any set of values accepted by
Fl::event_state(). If the bit is on that shift key must be pushed. Meta, Alt,
Ctrl, and Shift must be off if they are not in the shift flags (zero
for the other bits indicates a "don't care" setting).
Returns true if either FL_SUBMENU or FL_SUBMENU_POINTER is on in the flags. FL_SUBMENU indicates an embedded submenu that goes from the next item
through the next one with a NULLlabel(). FL_SUBMENU_POINTER indicates that user_data() is a pointer to another menu array.
Returns true if a checkbox will be drawn next to this item. This is
true if FL_MENU_TOGGLE or FL_MENU_RADIO is set in the flags.
Returns true if this item is a radio item. When a radio button is
selected all "adjacent" radio buttons are turned off. A set of radio
items is delimited by an item that has radio() false, or by an item with FL_MENU_DIVIDER turned on.
Returns the current value of the check or radio item.
Turns the check or radio item "on" for the menu item. Note that this
does not turn off any adjacent radio items like set_only() does.
Turns the radio item "on" for the menu item and turns off adjacent
radio item.
Turns the check or radio item "off" for the menu item.
Gets the visibility of an item.
Makes an item visible in the menu.
Hides an item in the menu.
Get whether or not the item can be picked.
Allows a menu item to be picked.
Prevents a menu item from being picked. Note that this will also cause
the menu item to appear grayed-out.
This method is called by widgets that want to display menus. The menu
stays up until the user picks an item or dismisses it. The selected
item (or NULL if none) is returned. This does not do the callbacks or change
the state of check or radio items.
X,Y is the position of the mouse cursor, relative to the window that
got the most recent event (usually you can pass Fl::event_x() and Fl::event_y() unchanged here).
title is a character string title for the menu. If non-zero a small
box appears above the menu with the title in it.
The menu is positioned so the cursor is centered over the item
picked. This will work even if picked is in a submenu. If picked is zero or not in the menu item table the menu is positioned with
the cursor in the top-left corner.
button is a pointer to an Fl_Menu_ from which the color and boxtypes for the menu are pulled. If
NULL then defaults are used.
pulldown() is similar to popup(), but a rectangle is provided to position the menu. The menu is
made at least W wide, and the picked item is centered over the rectangle (like Fl_Choice uses). If picked is zero or not found, the menu is aligned just below the
rectangle (like a pulldown menu).
The title and menubar arguments are used internally by the Fl_Menu_ widget.
This is designed to be called by a widgets handle() method in response to a FL_SHORTCUT event. If the current event matches one of the items shortcut,
that item is returned. If the keystroke does not match any shortcuts
then NULL is returned. This only matches the shortcut() fields, not the letters in the title preceeded by '
Return the offset of the NULL terminator that ends this menu, correctly skipping over submenus.
To copy a menu you should copy size() + 1 structures.
Advance a pointer by n items through a menu array, skipping the contents of submenus and
invisible items. There are two calls so that you can advance through
const and non-const data.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Single_Window
|
+----Fl_Menu_Window
Include Files
#include
Description
The Fl_Menu_Window widget is a window type used for menus. By default the window is
drawn in the hardware overlay planes if they are available so that the
menu don't force the rest of the window to redraw.
Methods
Creates a new Fl_Menu_Window widget using the given position, size, and label string.
Destroys the window and all of its children.
Tells FLTK to use normal drawing planes instead of overlay planes.
This is usually necessary if your menu contains multi-color pixmaps.
Tells FLTK to use hardware overlay planes if they are available.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Browser
|
+----Fl_Multi_Browser
Include Files
#include
Description
The Fl_Multi_Browser class is a subclass of Fl_Browser which lets the user select any set of the lines. The user
interface is Macintosh style: clicking an item turns off all the others
and selects that one, dragging selects all the items the mouse moves
over, and shift + click toggles the items. This is different then how
forms did it. Normally the callback is done when the user releases the
mouse, but you can change this with when().
See Fl_Browser for methods to add and remove lines from the browser.
Methods
Creates a new Fl_Multi_Browser widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
The destructor also deletes all the items in the list.
Deselects all lines.
Selects one or more lines or gets the current selection state of a
line.
Selects a single line or gets the last toggled line. This returns zero
if no line has been toggled, so be aware that this can happen in a
callback.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Input
|
+----Fl_Multiline_Input
Include Files
#include
Description
This input field displays '\n' characters as new lines rather than ^J,
and accepts the Return, Tab, and up and down arrow keys. This is for
editing multiline text.
This is far from the nirvana of text editors, and is probably only
good for small bits of text, 10 lines at most. I think FLTK can be
used to write a powerful text editor, but it is not going to be a
built-in feature. Powerful text editors in a toolkit are a big source
of bloat.
Methods
Creates a new Fl_Multiline_Input widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Output
|
+----Fl_Multiline_Output
Include Files
#include
Description
This widget is a subclass of Fl_Output that displays multiple lines of text. It also displays tab
characters as whitespace to the next column.
Methods
Creates a new Fl_Multiline_Output widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Input_
|
+----Fl_Output
|
+----Fl_Multiline_Output
Include Files
#include
Description
This widget displays a piece of text. When you set the value(), Fl_Output does a strcpy() to it's own storage, which is useful for program-generated
values. The user may select portions of the text using the mouse and
paste the contents into other fields or programs.

There is a single subclass,
Fl_Multiline_Output, which allows you to display multiple lines of text.
The text may contain any characters except \0, and will correctly
display anything, using ^X notation for unprintable control characters
and \nnn notation for unprintable characters with the high bit set. It
assummes the font can draw any characters in the ISO-Latin1 character
set.
Methods
Creates a new Fl_Output widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
The first form returns the current value, which is a pointer to the
internal buffer and is valid only until the value is changed.
The second two forms change the text and set the mark and the point
to the end of it. The string is copied to the internal buffer. Passing
NULL is the same as "". This returns non-zero if the new value is
different than the current one. You can use the second version to
directly set the length if you know it already or want to put nul's in
the text.
Returns the number of characters in value(). This may be greater than strlen(value()) if there are nul characters in it.
Same as value()[n], but may be faster in plausible implementations. No bounds
checking is done.
Gets or sets the color of the text in the input field.
Gets or sets the font of the text in the input field.
Gets or sets the size of the text in the input field.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Double_Window
|
+----Fl_Overlay_Window
Include Files
#include
Description
This window provides double buffering and also the ability to draw the
"overlay" which is another picture placed on top of the main image. The
overlay is designed to be a rapidly-changing but simple graphic such as
a mouse selection box. Fl_Overlay_Window uses the overlay planes provided by your graphics hardware if
they are available.
If no hardware support is found the overlay is simulated by drawing
directly into the on-screen copy of the double-buffered window, and
"erased" by copying the backbuffer over it again. This means the
overlay will blink if you change the image in the window.
Methods
Creates a new Fl_Overlay_Window widget using the given position, size, and label (title) string.
Destroys the window and all child widgets.
You must subclass Fl_Overlay_Window and provide this method. It is just like a draw() method, except it draws the overlay. The overlay will have
already been "cleared" when this is called. You can use any of the
routines described in .
Call this to indicate that the overlay data has changed and needs to
be redrawn. The overlay will be clear until the first time this is
called, so if you want an initial display you must call this after
calling show().
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Group
|
+----Fl_Pack
Include Files
#include
Description
This widget was designed to add the functionality of compressing and
aligning widgets.
If type() is FL_HORIZONTAL all the children are resized to the height of the Fl_Pack, and are moved next to each other horizontally. If type() is not FL_HORIZONTAL then the children are resized to the width and are stacked below
each other. Then the Fl_Pack resizes itself to surround the child widgets.
This widget is needed for the Fl_Tab. In addition you may want to put the Fl_Pack inside an Fl_Scroll.
Methods
Creates a new Fl_Pack widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code. A kludge has been
done so the Fl_Pack and all of it's children can be automatic (local) variables, but
you must declare the Fl_Packfirst, so that it is destroyed last.
Gets or sets the number of extra pixels of blank space that are added
between the children.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Positioner
Include Files
#include
Description
This class is provided for Forms compatibility. It provides 2D input.
It would be useful if this could be put atop another widget so that the
crosshairs are on top, but this is not implemented. The color of the
crosshairs is selection_color().

Methods
Creates a new Fl_Positioner widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Deletes the widget.
Returns the current position in x and y.
Gets or sets the X axis bounds.
Sets the stepping value for the X axis.
Gets or sets the X axis coordinate.
Gets or sets the Y axis bounds.
Sets the stepping value for the Y axis.
Gets or sets the Y axis coordinate.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Button
|
+----Fl_Repeat_Button
Include Files
#include
Description
The Fl_Repeat_Button is a subclass of Fl_Button that generates a callback when it is pressed and then repeatedly
generates callbacks as long as it is held down. The speed of the
repeat is fixed and depends on the implementation.
Methods
Creates a new Fl_Repeat_Button widget using the given position, size, and label string. The
default boxtype is FL_UP_BOX.
Deletes the button.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Button
|
+----Fl_Return_Button
Include Files
#include
Description
The Fl_Return_Button is a subclass of Fl_Button that generates a callback when it is pressed or when the user
presses the Enter key. A carriage-return symbol is drawn next to the
button label.
Methods
Creates a new Fl_Return_Button widget using the given position, size, and label string. The
default boxtype is FL_UP_BOX.
Deletes the button.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Valuator
|
+----Fl_Roller
Include Files
#include
Description
The Fl_Roller widget is a "dolly" control commonly used to move 3D objects.
Methods
Creates a new Fl_Roller widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Destroys the valuator.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Button
|
+----Fl_Round_Button
Include Files
#include
Description
Buttons generate callbacks when they are clicked by the user. You
control exactly when and how by changing the values for type() and when().
The Fl_Round_Button subclass display the "on" state by turning on a light, rather
than drawing pushed in. The shape of the "light" is initially set to
FL_ROUND_DOWN_BOX. The color of the light when on is controlled with
selection_color(), which defaults to FL_RED.
Methods
Creates a new Fl_Round_Button widget using the given position, size, and label string.
The destructor deletes the check button.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Group
|
+----Fl_Scroll
Include Files
#include
Description
This container widget lets you maneuver around a set of widgets much
larger than your window. If the child widgets are larger than the size
of this object then scrollbars will appear so that you can scroll over
to them:

If all of the child widgets are packed together into a solid
rectangle then you want to set box() to FL_NO_BOX or one of the _FRAME types. This will result in the best output. However, if the
child widgets are a sparse arrangment you must set box() to a real _BOX type. This can result in some blinking during redrawing, but
that can be solved by using a Fl_Double_Window.
This widget can also be used to pan around a single child widget
"canvas". This child widget should be of your own class, with a
draw() method that draws the contents. The scrolling is done by
changing the x() and y() of the widget, so this child must use the x() and y() to position it's drawing. To speed up drawing it should test
fl_clip().
Another very useful child is a single
Fl_Pack, which is itself a group that packs it's children together and
changes size to surround them. Filling the Fl_Pack with Fl_Tab groups (and then putting normal widgets inside those) gives you a
very powerful scrolling list of individually-openable panels.
Fluid lets you create these, but you can only lay out objects that
fit inside the Fl_Scroll without scrolling. Be sure to leave space for the scrollbars, as
Fluid won't show these either.
You cannot use Fl_Window as a child of this since the clipping is not conveyed to it when
drawn, and it will draw over the scrollbars and neighboring objects.
Methods
Creates a new Fl_Scroll widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code. A kludge has been
done so the Fl_Scroll and all of it's children can be automatic (local) variables, but
you must declare the Fl_Scrollfirst, so that it is destroyed last.
By default you can scroll in both directions, and the scrollbars
disappear if the data will fit in the area of the scroll. type() can change this:
- 0 - No scrollbars
- Fl_Scroll::HORIZONTAL - Only a horizontal scrollbar.
- Fl_Scroll::VERTICAL - Only a vertical scrollbar.
- Fl_Scroll::BOTH - The default is both scrollbars.
- Fl_Scroll::HORIZONTAL_ALWAYS - Horizontal scrollbar always on, vertical always off.
- Fl_Scroll::VERTICAL_ALWAYS - Vertical scrollbar always on, horizontal always off.
- Fl_Scroll::BOTH_ALWAYS - Both always on.
This is used to change what side the scrollbars are drawn on. If the
FL_ALIGN_LEFT bit is on, the vertical scrollbar is on the left. If the
FL_ALIGN_TOP bit is on, the horizontal scrollbar is on the top.
Gets the current horizontal scrolling position.
Gets the current vertical scrolling position.
Sets the upper-lefthand corner of the scrolling region.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Slider
|
+----Fl_Scrollbar
Include Files
#include
Description
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the
scrollbar. Clicking on the arrows move up/left and down/right by
linesize(). Scrollbars also accept FL_SHORTCUT events: the arrows move by linesize(), and vertical scrollbars take Page Up/Down (they move by the page
size minus linesize()) and Home/End (they jump to the top or bottom).
Scrollbars have step(1) preset (they always return integers). If desired you can set the
step() to non-integer values. You will then have to use casts to get at
the floating-point versions of value() from Fl_Slider.
Methods
Creates a new Fl_Scrollbar widget using the given position, size, and label string. You
need to do type(FL_HORIZONTAL) if you want a horizontal scrollbar.
Destroys the valuator.
This number controls how big the steps are that the arrow keys do. In
addition page up/down move by the size last sent to value() minus one linesize(). The default is 16.
The first form returns the integer value of the scrollbar. You can get
the floating point value with Fl_Slider::value(). The second form sets value(), range(), and slider_size() to make a variable-sized scrollbar. You should call this every
time your window changes size, your data changes size, or your scroll
position changes (even if in response to a callback from this
scrollbar). All necessary calls to redraw() are done.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Input
|
+----Fl_Secret_Input
Include Files
#include
Description
The Fl_Secret_Input class is a subclass of Fl_Input that displays its input as a string of asterisks. This subclass
is usually used to recieve passwords and other "secret" information.
Methods
Creates a new Fl_Secret_Input widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the widget and any value associated with it.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Browser
|
+----Fl_Select_Browser
Include Files
#include
Description
The Fl_Select_Browser class is a subclass of Fl_Browser which lets the user select a single item, or no items by clicking
on the empty space. As long as the mouse button is held down the item
pointed to by it is highlighted. Normally the callback is done when the
user presses the mouse, but you can change this with when().
See Fl_Browser for methods to add and remove lines from the browser.
Methods
Creates a new Fl_Select_Browser widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
The destructor also deletes all the items in the list.
Same as value(0).
You can use these for compatibility with
Fl_Multi_Browser. If you turn on the selection of more than one line the results
are unpredictable.
Returns the number of the highlighted item, or zero if none. Notice
that this is going to be zero except during a callback!
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Window
|
+----Fl_Single_Window
Include Files
#include
Description
This is the same as Fl_Window. However, it is possible that
some implementations will provide double-buffered windows by default.
This subclass can be used to force single-buffering. This may be
useful for modifying existing programs that use incremental update, or
for some types of image data, such as a movie flipbook.
Methods
Creates a new Fl_Single_Window widget using the given position, size, and label (title) string.
Destroys the window and all child widgets.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Valuator
|
+----Fl_Slider
|
+----Fl_Scrollbar, Fl_Value_Slider
Include Files
#include
Description
The Fl_Slider widget contains a sliding knob inside a box. It if often used as
a scrollbar. Moving the box all the way to the top/left sets it to the
minimum(), and to the bottom/right to the maximum(). The minimum() may be greater than the maximum() to reverse the slider direction.
Methods
Creates a new Fl_Slider widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Destroys the valuator.
Returns Fl_Scrollbar::value().
Set the type of box to draw for the moving part of the slider. The
color of the moving part (or of the notch in it for the nice sliders)
is controlled by selection_color(). The default value of zero causes the slider to figure out what
to draw from box().
Get or set the dimensions of the moving piece of slider. This is the
fraction of the size of the entire widget. If you set this to 1 then
the slider cannot move. The default value is .08.
For the "fill" sliders this is the size of the area around the end
that causes a drag effect rather than causing the slider to jump to the
mouse.
Setting this changes how the slider is drawn, which can be one of the
following:
- FL_VERTICAL - Draws a vertical slider (this is the default).
- FL_HORIZONTAL - Draws a horizontal slider.
- FL_VERT_FILL_SLIDER - Draws a filled vertical slider, useful as a progress or value
meter.
- FL_HOR_FILL_SLIDER - Draws a filled horizontal slider, useful as a progress or
value meter.
- FL_VERT_NICE_SLIDER - Draws a vertical slider with a nice looking control knob.
- FL_HOR_NICE_SLIDER - Draws a horizontal slider with a nice looking control knob.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Group
|
+----Fl_Tabs
Include Files
#include
Description
The Fl_Tabs widget is the "file card tabs" interface that allows you to put
lots and lots of buttons and switches in a panel, as popularized by
many toolkits.

Clicking the tab makes a child visible() (by calling show() on it) and all other children are invisible (by calling hide() on them). Usually the children are
Fl_Group widgets containing several widgets themselves.
Each child makes a card, and it's label() is printed on the card tab (including the label font and style).
The color of that child is used to color the card as well. Currently
this only draws nicely if you set
box() to the default FL_THIN_UP_BOX or to FL_FLAT_BOX, which gets rid of the edges drawn on the sides and bottom.
The size of the tabs is controlled by the bounding box of the
children (there should be some space between the children and the edge
of the Fl_Tabs), and the tabs may be placed "inverted" on the bottom, this is
determined by which gap is larger. It is easiest to lay this out in
fluid, using the fluid browser to select each child group and resize
them until the tabs look the way you want them to.
Methods
Creates a new Fl_Tab widget using the given position, size, and label string. The
default boxtype is FL_THIN_UP_BOX.
Use add(Fl_Widget *) to add each child (which is probably itself a Fl_Group). The children should be sized to stay away from the top or
bottom edge of the Fl_Tabs, which is where the tabs are drawn.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code. A kludge has been
done so the Fl_Tab and all of it's children can be automatic (local) variables, but
you must declare the Fl_Tabfirst, so that it is destroyed last.
Gets or sets the currently visible widget/tab.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Tile
|
+----Fl_Pack, Fl_Scroll, Fl_Tabs, Fl_Tile, Fl_Window
Include Files
#include
Description
The Fl_Tile class lets you resize the children by dragging the border between
them:

Fl_Tile allows objects to be resized to zero dimensions. To prevent this
you can use the resizable() to limit where corners can be dragged to.
Even though objects can be resized to zero sizes, they must
initially have non-zero sizes so the Fl_Tile can figure out their layout. If desired, call position() after creating the children but before displaying the window to
set the borders where you want.
The "borders" are part of the children, an Fl_Tiledoes not
draw any graphics of it's own. In the above example all the final
children have FL_DOWN_BOX types, and the "ridges" you see are two adjacent FL_DOWN_BOX's drawn next to each other.
Methods
Creates a new Fl_Tile widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code. A kludge has been
done so the Fl_Tile and all of it's children can be automatic (local) variables, but
you must declare the Fl_Tilefirst, so that it is destroyed last.
Drag the intersection at from_x,from_y to to_x,to_y. This redraws all the necessary children.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Timer
Include Files
#include
Description
This is provided only to emulate the Forms Timer widget. It works by
making a timeout callback every 1/5 second. This is wasteful and
inaccurate if you just want something to happen a fixed time in the
future. You should directly call
Fl::add_timeout() instead.
Methods
Creates a new Fl_Timer widget using the given type, position, size, and label string.
The type parameter can be any of the following symbolic constants:
- FL_NORMAL_TIMER - The timer just does the callback and displays the string
"Timer" in the widget.
- FL_VALUE_TIMER - The timer does the callback and displays the current timer
value in the widget.
- FL_HIDDEN_TIMER - The timer just does the callback and does not display
anything.
Destroys the timer and removes the timeout.
Gets or sets the direction of the timer. If the direction is zero
then the timer will count up, otherwise it will count down from the
initial value().
Gets or sets whether the timer is suspended.
Gets or sets the current timer value.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Valuator
|
+----Fl_Adjuster, Fl_Counter, Fl_Dial, Fl_Roller,
Fl_Slider, Fl_Value_Input, Fl_Value_Output,
Include Files
#include
Description
The Fl_Valuator class controls a single floating-point value and provides a
consistent interface to set the value, range, and step, and insures
that callbacks are done the same for every object.
There are probably more of these classes in fltk than any others:

In the above diagram each box surrounds an actual subclass. These
are further differentiated by setting the
type() of the widget to the symbolic value labeling the widget. The ones
labelled "0" are the default versions with a type(0). For
consistency the symbol FL_VERTICAL is defined as zero.
Methods
Creates a new Fl_Valuator widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Destroys the valuator.
Get or set the current value. The new value is not clamped or otherwise changed before storing it. Use clamp() or round() to modify the value before calling this if you want. If the new
value is different than the current one the object is redrawn. The
initial value is zero.
Gets or sets the minimum value for the valuator.
Gets or sets the maximum value for the valuator.
Sets the minimum and maximum values for the valuator. When the user
manipulates the widget, the value is limited to this range. This
clamping is done after rounding to the step value (this makes a difference if the range
is not a multiple of the step).
The minimum may be greater than the maximum. This has the effect of
"reversing" the object so the larger values are in the opposite
direction. This also switches which end of the filled sliders is
filled.
Some widgets consider this a "soft" range. This means they will
stop at the range, but if the user releases and grabs the control again
and tries to move it further, it is allowed.
The range may affect the display. You must redraw() the widget after changing the range.
Get or set the step value. As the user moves the mouse the value is
rounded to the nearest multiple of the step value. This is done
before clamping it to the range. For most objects the default step is
zero.
For precision the step is stored as the ratio of two integers, A/B.
You can set these integers directly. Currently setting a floating
point value sets the nearest A/1 or 1/B value possible.
Format the passed value to show enough digits so that for the current
step value. If the step has been set to zero then it does a %g format. The characters are written into the passed buffer.
Round the passed value to the nearest step increment. Does nothing if
step is zero.
Clamp the passed value to the valuator range.
Adds n times the step value to the passed value. If step was set to zero
it uses fabs(maximum() - minimum()) / 100.
This value is true if the user has moved the slider. It is turned off
by value(x) and just before doing a callback (the callback can turn it back
on if desired).
Sets the changed() flag.
Clears the changed() flag.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Valuator
|
+----Fl_Value_Input
Include Files
#include
Description
The Fl_Value_Input widget displays a floating point value. The user can click in the
text field and edit it (there is in fact a hidden
Fl_Value_Input widget with type(FL_FLOAT_INPUT) in there), and when they hit return or tab the value updates to
what they typed and the callback is done.
If step() is not zero, the user can also drag the mouse across the object
and thus slide the value. The left button moves one step() per pixel, the middle by 10 * step(), and the left button by 100 * step(). It is then impossible to select text by dragging across it,
although clicking can still move the insertion cursor.
Methods
Creates a new Fl_Value_Input widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Destroys the valuator.
Get or set the color of the cursor. This is black by default.
If "soft" is turned on, the user is allowed to drag the value outside
the range. If they drag the value to one of the ends, let go, then
grab again and continue to drag, they can get to any value. Default is
one.
Gets or sets the color of the text in the value box.
Gets or sets the typeface of the text in the value box.
Gets or sets the size of the text in the value box.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Valuator
|
+----Fl_Value_Output
Include Files
#include
Description
The Fl_Value_Output widget displays a floating point value. If step() is not zero, the user can adjust the value by dragging the mouse
left and right. The left button moves one step() per pixel, the middle by 10 * step(), and the right button by 100 * step().
This is much lighter-weight than
Fl_Value_Input because it contains no text editing code or character buffer.
Methods
Creates a new Fl_Value_Output widget using the given position, size, and label string. The
default boxtype is FL_NO_BOX.
Destroys the valuator.
If "soft" is turned on, the user is allowed to drag the value outside
the range. If they drag the value to one of the ends, let go, then
grab again and continue to drag, they can get to any value. Default is
one.
Gets or sets the color of the text in the value box.
Gets or sets the typeface of the text in the value box.
Gets or sets the size of the text in the value box.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Slider
|
+----Fl_Value_Slider
Include Files
#include
Description
The Fl_Value_Slider widget is a Fl_Slider widget with a box displaying the current value.

Methods
Creates a new Fl_Value_Slider widget using the given position, size, and label string. The
default boxtype is FL_DOWN_BOX.
Destroys the valuator.
Gets or sets the color of the text in the value box.
Gets or sets the typeface of the text in the value box.
Gets or sets the size of the text in the value box.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Widget
|
+----Fl_Box, Fl_Browser, Fl_Button, Fl_Chart, Fl_Clock,
Fl_Free, Fl_Group, Fl_Input, Fl_Menu_, Fl_Positioner,
Fl_Timer, Fl_Valuator
Include Files
#include
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.
Methods
Fl_Widget::Fl_Widget(int x, int y, int w, int h, const char*
label=0);
This is the protected constructor for an Fl_Widget, but all derived
widgets have a matching public constructor. It takes a value for x(),
y(), w(), h(), and an optional value for label().
virtual Fl_Widget::~Fl_Widget();
Destroying single widgets is not very common. It is your
responsibility to either remove() them from any enclosing group, or to
destroy that group immediately after destroying the children.
uchar Fl_Widget::type() const;
This value is used for Forms compatability and to simulate RTTI.
The position of the upper-left corner of the widget in its enclosing
Fl_Window (not its parent if that is not an Fl_Window), and its width and height.
Change the size or position of the widget. This is a virtual function
so the widget may implement it's own handling of resizing. The default
version does not do redraw(), that is the parent widget's responsibility (this is
because the parent may know a faster way to update the display, such as
scrolling from the old position).
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).
Return a pointer to the Fl_Window that this widget is in (it will skip any and all parent widgets
between this and the window). Returns NULL if none. Note: for an Fl_Window, this returns it's parent window (if any), not this window.
The box() identifies a routine that draws the background of the widget.
See Box Types for the available types. The default depends on the widget, but
is usually FL_NO_BOX or FL_UP_BOX.
This color is passed to the box routine. Color is an index into an
internal table of rgb colors. For most widgets this defaults to
FL_GRAY. See the enumeration list for predefined colors. Use
Fl::set_color() to redefine colors.
For Forms compatibility a second color is defined. This 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(a,b).
The label is printed somewhere on the widget or next to it. The
string is not copied, the passed pointer is stored unchanged in the widget.
A labeltype identifies a routine that draws the label of the widget. This can
be used for special effects such as emboss, or to use the label() pointer as another form of data such as a bitmap. The value
FL_NORMAL_LABEL prints the label as text.
How the label is printed next to or inside the widget. The default
value is FL_ALIGN_CENTER, which centers the label. The value can be any of these
constants or'd together:
- FL_ALIGN_CENTER
- FL_ALIGN_TOP
- FL_ALIGN_BOTTOM
- FL_ALIGN_LEFT
- FL_ALIGN_RIGHT
- FL_ALIGN_INSIDE
- FL_ALIGN_CLIP
- FL_ALIGN_WRAP
This color is passed to the labeltype routine, and is typically the
color of the label text. This defaults to FL_BLACK.
Fonts are identified by small 8-bit indexes into a table. See the
enumeration list for predefined typefaces. The default value uses a Helvetica
typeface (Arial for Microsoft® Windows®). The function
Fl::set_font() can define new typefaces.
Fonts are further identified by a point size. The default is 14.
Each widget has a single callback. You can set it or examine it with
these methods.
You can also just change the void * second argument to the callback with the user_data methods.
For convenience you can also define the callback as taking a long
argument. This is implemented by casting this to a Fl_Callback and casting the long to a void * and may not be portable to some machines.
void Fl_Widget::callback(void (*)(Fl_Widget*))
For convenience you can also define the callback as taking only one
argument. This is implemented by casting this to a Fl_Callback and may not be portable to some machines.
You can cause a widget to do its callback at any time, and even pass
arbitrary arguments.
Fl_Widget::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.
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.
The default callback, which puts a pointer to the widget on the queue
returned by Fl::readqueue(). You may want to call this from your own callback.
An invisible widget never gets redrawn and does not get events. An
widget is really visible if visible() is true on it and all it's 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.
Fl_Widget::active() returns whether the widget is active. An inactive widget does
not get any events, but it does get redrawn. A widget is active if
active() is true on it and all it's parents. Changing this value will send FL_ACTIVATE or FL_DEACTIVATE to the widget. Do not change it if the parent is not active,
as this will send false FL_ACTIVATE or FL_DEACTIVATE events to the widget.
Currently you cannot deactivate Fl_Window widgets.
This is the same as active() && visible() but is faster.
Mark the widget as needing its draw() routine called.
Non-zero if draw() needs to be called. Actually this is a bit field that the widget
subclass can use to figure out what parts to draw.
Returns a pointer to the parent widget. Usually this is a
Fl_Group or
int Fl_Widget::contains(Fl_Widget* b) const
Returns true if b is a child of this widget, or is equal to this widget. Returns
false if b is NULL.
Returns true if this is a child of a, or is equal to a. Returns false if a is NULL.
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 an widget. Returns true if the widget accepted the focus.
|
Contents
Previous
Next
|
Class Hierarchy
Fl_Group
|
+----Fl_Window
|
+----Fl_Double_Window, Fl_Gl_Window,
Fl_Overlay_Window, Fl_Single_Window
Include Files
#include
Description
This widget produces an actual window. This can either be a main
window, with a border and title and all the window management controls,
or a "subwindow" inside a window. This is controlled by whether or not
the window has a parent().
Once you create a window, you usually add children Fl_Widget's to it by using window->add(child) for each new widget. See Fl_Group for more information on how to add and remove children.
There are several subclasses of Fl_Window that provide double-buffering, overlay, menu, and OpenGL support.
The window's callback is done if the user tries to close a window
using the window manager and Fl::modal() is zero or equal to the window. Fl_Window has a default callback that calls Fl_Window::hide() and calls exit(0) if this is the last top-level window.
Methods
The first constructor takes 4 int arguments to create the window with
a preset position and size. The second constructor with 2 arguments
will create the window with a preset size, but the window manager will
choose the position according to it's own whims.
Fl_Widget::box() is set to FL_FLAT_BOX. If you plan to completely fill the window with children widgets
you should change this to FL_NO_BOX. If you turn the window border off you may want to change this to
FL_UP_BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to
keep a pointer to all the children in the user code. A kludge has been
done so the Fl_Window and all of it's children can be automatic (local) variables, but
you must declare the Fl_Windowfirst, so that it is destroyed last.
Set the allowable range the user can resize this window to. This only
works for top-level windows.
- minw and minh are the smallest the window can be.
- maxw and maxh are the largest the window can be. If either is equal to the minimum then you cannot resize in that direction. If
either is zero then FLTK picks a maximum size in that direction such
that the window will fill the screen.
- dw and dh are size increments. The window will be constrained to widths
of minw + N * dw, where N is any non-negative integer. If these are less or equal to 1
they are ignored.
- aspect is a flag that indicates that the window should preserve it's
aspect ratio. This only works if both the maximum and minimum have
the same aspect ratio.
If this function is not called, FLTK tries to figure out the range
from the setting of resizeable():
- If resizeable() is NULL (this is the default) then the window cannot be resized and the
resize border and max-size control will not be displayed for the
window.
- If either dimension of resizeable() is less than 100, then that is considered the minimum size.
Otherwise the resizeable() has a minimum size of 100.
- If either dimension of resizeable() is zero, then that is also the maximum size (so the window
cannot resize in that direction).
It is undefined what happens if the current size does not fit in the
constraints passed to size_range().
Put the window on the screen. Usually this has the side effect of
opening the display. The second two forms are used for top-level
windows and allow standard arguments to be parsed from the
command-line.
If the window is already shown then it is restored and raised to the
top. This is really convenient because your program can call show() at any time, even if the window is already up. It also means
that show() serves the purpose of raise() in other toolkits.
Remove the window from the screen. If the window is already hidden or
has not been shown then this does nothing (and is harmless). Under
the X Window System this actually destroys the xid.
Returns non-zero if show() has been called (but not hide()). You can tell if a window is iconified with (w->shown()
&!w->visible()).
Iconifies the window. If you call this when shown() is false it will show() it as an icon. If the window is already iconified this does
nothing.
Call show() to restore the window.
When a window is iconified/restored (either by these calls or by the
user) the handle() method is called with FL_HIDE and FL_SHOW events and visible() is turned on and off.
There is no way to control what is drawn in the icon except with the
string passed to Fl_Window::xclass(). You should not rely on window managers displaying the icons.
Returns the first shown() window in the widget hierarchy. If no windows are displayed
first_window returns NULL.
Returns the next shown() window in the hierarchy. You can use this call to iterate
through all the windows that are shown().
Change the size and position of the window. If shown() is true, these changes are communicated to the window server
(which may refuse that size and cause a further resize). If shown() is false, the size and position are used when show() is called. See Fl_Group for the effect of resizing on the child widgets.
You can also call the Fl_Widget methods size(x,y) and position(w,h), which are inline wrappers for this virtual function.
Undoes the effect of a previous resize() or show() so that the next time show() is called the window manager is free to position the window.
position() the window so that the mouse is pointing at the given position,
or at the center of the given widget, which may be the window itself.
If the optional offscreen parameter is non-zero, then the window is allowed to extend off
the screen (this does not work with some X window managers).
Makes the window completely fill the screen, without any window
manager border visible. You must use fullscreen_off() to undo this. This may not work with all window managers.
Turns off any side effects of fullscreen() and does resize(x,y,w,h).
Gets or sets whether or not the window manager border is around the
window. The default value is true. border(n) can be used to turn the border on and off, and returns non-zero
if the value has been changed. Under most X window managers this
does not work after show() has been called, although SGI's 4DWM does work.
clear_border() is a fast inline function to turn the border off. It only works
before show() is called.
A "modal" window, when shown(), will prevent any events from being delivered to other windows in
the same program, and will also remain on top of the other windows (if
the X window manager supports the "transient for" property). Several
modal windows may be shown at once, in which case only the last one
shown gets events. You can see which window (if any) is modal by
calling Fl::modal().
Returns true if this window is modal.
A "non-modal" window (terminology borrowed from Microsoft Windows)
acts like a modal() one in that it remains on top, but it has no effect on event
delivery. There are three states for a window: modal, non-modal, and normal.
Returns true if this window is modal or non-modal.
Gets or sets the window title bar label.
Gets or sets the icon label.
A string used to tell the system what type of window this is. Mostly
this identifies the picture to draw in the icon. Under X, this is
turned into a XA_WM_CLASS pair by truncating at the first non-alphanumeric character and
capitalizing the first character, and the second one if the first is
'x'. Thus "foo" turns into "foo, Foo", and "xprog.1" turns into
"xprog, XProg". This only works if called before calling show().
This method has no effect under Microsoft Windows.
make_current() sets things up so that the drawing functions in
will go into this window. This is useful for incremental update of
windows, such as in an idle callback, which will make your program
behave much better if it draws a slow graphic. Danger: incremental
update is very hard to debug and maintain!
This method only works for the Fl_Window and Fl_Gl_Window classes.
Returns the last window that was made current. |