Contents
Previous
Next

A - Widget Reference

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 Fl_Adjuster


Class Hierarchy

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

Fl_Adjuster::Fl_Adjuster(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Adjuster::~Fl_Adjuster()

Destroys the valuator.

uchar Fl_Adjuster::soft() const
void Fl_Adjuster::soft(uchar)

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 Fl_Box


Class Hierarchy

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

Fl_Box::Fl_Box(int x, int y, int w, int h, const char * = 0)
Fl_Box::Fl_Box(Fl_Boxtype b, int x, int y, int w, int h, const char *)

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.

Fl_Box::~Fl_Box(void)

The destructor removes the box.
 
Contents
Previous
Next

class Fl_Browser


Class Hierarchy

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

Fl_Browser::Fl_Browser(int, int, int, int, const char * = 0)

The constructor makes an empty browser.

Fl_Browser::~Fl_Browser(void)

The destructor deletes all list items and destroys the browser.

void Fl_Browser::add(const char *, void * = 0)

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.

void Fl_Browser::clear()

Remove all the lines in the browser.

uchar Fl_Browser::column_char() const
void Fl_Browser::column_char(char c)

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

const int *Fl_Browser::column_widths() const
void Fl_Browser::column_widths(const int *w)

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.

void *Fl_Browser::data(int n) const
void Fl_Browser::data(int n, void *)

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.

uchar Fl_Browser::format_char() const
void Fl_Browser::format_char(char c)

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.

void Fl_Browser::hide(int n)

Makes line n invisible, preventing selection by the user. The line can still be selected under program control.

void Fl_Browser::insert(int n, const char *, void * = 0)

Insert a new line before line n. If n > size() then the line is added to the end.

int Fl_Browser::load(const char *filename)

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.

void Fl_Browser::move(int to, int from)

Line from is removed and reinserted at to; to is calculated after the line is removed.

int Fl_Browser::position() const
void Fl_Browser::position(int p)

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.

void Fl_Browser::remove(int n)

Remove line n and make the browser one line shorter.

void Fl_Browser::show(int n)

Makes line n visible for selection.

int Fl_Browser::size() const

Returns how many lines are in the browser. The last line number is equal to this.

const char *Fl_Browser::text(int n) const
void Fl_Browser::text(int n, const char *)

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.

int Fl_Browser::topline() const
void Fl_Browser::topline(int 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.

int Fl_Browser::visible(int n) const

Returns a non-zero value if line n is visible.
 
Contents
Previous
Next

class Fl_Browser_


Class Hierarchy

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

Fl_Browser::Fl_Browser(int, int, int, int, const char * = 0)

The constructor makes an empty browser.

Fl_Browser::~Fl_Browser(void)

The destructor deletes all list items and destroys the browser.

void Fl_Browser_::has_scrollbar(int h)

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.

Fl_Color Fl_Browser_::textcolor() const
void Fl_Browser_::textcolor(Fl_Color color)

The first form gets the default text color for the lines in the browser.

The second form sets the default text color to color

Fl_Font Fl_Browser_::textfont() const
void Fl_Browser_::textfont(Fl_Font font)

The first form gets the default text font for the lines in the browser.

The second form sets the default text font to font

uchar Fl_Browser_::textsize() const
void Fl_Browser_::textsize(uchar size)

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 Fl_Button


Class Hierarchy

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

Fl_Button::Fl_Button(int x, int y, int w, int h, const char *label = 0)

The constructor creates the button using the position, size, and label.

Fl_Button::~Fl_Button(void)

The destructor removed the button.

int Fl_Button::clear()

Same as value(0).

Fl_Boxtype Fl_Button::down_box() const
void Fl_Button::down_box(Fl_Boxtype bt)

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

int Fl_Button::set()

Same as value(1).

void Fl_Button::setonly()

Turns on this button and turns off all other radio buttons in the group (calling value(1) or set() does not do this).

ulong Fl_Button::shortcut() const
void Fl_Button::shortcut(ulong key)

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

uchar Fl_Button::type() const
void Fl_Button::type(uchar t)

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.

char Fl_Button::value() const
int Fl_Button::value(int)

The first form returns the current value (0 or 1). The second form sets the current value.

Fl_When Fl_Widget::when() const
void Fl_Widget::when(Fl_When w)

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 Fl_Chart


Class Hierarchy

Include Files

    #include 
    

Description

This widget displays simple charts and is provided for forms compatibility.

Methods

Fl_Chart::Fl_Chart(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Chart widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Chart::~Fl_Chart()

Destroys the Fl_Chart widget and all of its data.

void add(double value, const char *label = NULL, uchar color = 0)

The add method adds the value and optionally label and color to the chart.

uchar autosize(void) const
void autosize(uchar onoff)

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.

void bounds(double *a, double *b)
void bounds(double a, double b)

The bounds method gets or sets the lower and upper bounds of the chart values to a and b respectively.

void clear(void)

The clear method removes all values from the chart.

void insert(int pos, double value, const char *label = NULL, uchar color = 0)

The insert method inserts a data value at the given position pos. Position 0 is the first data value.

int maxsize(void) const
void maxsize(int n)

The maxsize method gets or sets the maximum number of data values for a chart.

void replace(int pos, double value, const char *label = NULL, uchar color = 0)

The replace method replaces data value pos with value, label, and color. Position 0 is the first data value.

int size(void) const

The size method returns the number of data values in the chart.

uchar type() const
void type(uchar t)

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 Fl_Check_Button


Class Hierarchy

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

Fl_Check_Button::Fl_Check_Button(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Check_Button widget using the given position, size, and label string.

Fl_Check_Button::~Fl_Check_Button()

The destructor deletes the check button.
 
Contents
Previous
Next

class Fl_Choice


Class Hierarchy

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

Fl_Choice::Fl_Choice(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Choice::~Fl_Choice()

The destructor removes the Fl_Choice widget and all of its menu items.

int Fl_Choice::value() const
int Fl_Choice::value(int)
int Fl_Choice::value(const Fl_Menu *)

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

int Fl_Widget::changed() const

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

void Fl_Widget::set_changed()

This method sets the changed() flag.

void Fl_Widget::clear_changed()

This method clears the changed() flag.

Fl_Boxtype Fl_Choice::down_box() const
void Fl_Choice::down_box(Fl_Boxtype b)

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 Fl_Clock


Class Hierarchy

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

Fl_Clock::Fl_Clock(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Clock widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Clock::~Fl_Clock()

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.

int Fl_Clock::hour() const

Returns the current hour (0 to 23).

int Fl_Clock::minute() const

Returns the current minute (0 to 59).

int Fl_Clock::second() const

Returns the current second (0 to 60, 60 = leap second).

void Fl_Clock::value(ulong v)
void Fl_Clock::value(int h, int m, int s)
ulong Fl_Clock::value(void)

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 Fl_Color_Chooser


Class Hierarchy

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

Fl_Color_Chooser::Fl_Color_Chooser(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Color_Chooser::~Fl_Color_Chooser()

The destructor removes the color chooser and all of its controls.

double Fl_Color_Chooser::hue() const

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.

double Fl_Color_Chooser::saturation() const

Returns the saturation. 0 <= saturation <= 1.

double Fl_Color_Chooser::value() const

Returns the value/brightness. 0 <= value <= 1.

double Fl_Color_Chooser::r() const

Returns the current red value. 0 <= r <= 1.

double Fl_Color_Chooser::g() const

Returns the current green value. 0 <= g <= 1.

double Fl_Color_Chooser::b() const

Returns the current blue value. 0 <= b <= 1.

int Fl_Color_Chooser::rgb(double, double, double)

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

int Fl_Color_Chooser::hsv(double,double,double)

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.

static void Fl_Color_Chooser::hsv2rgb(double, double, double, double&, double&, double&)

This static method converts HSV colors to RGB colorspace.

static void Fl_Color_Chooser::rgb2hsv(double, double, double, double&, double&, double&)

This static method converts RGB colors to HSV colorspace.
 
Contents
Previous
Next

class Fl_Counter


Class Hierarchy

Include Files

    #include 
    

Description

The Fl_Counter widget is provided for forms compatibility. It controls a single floating point value.

Methods

Fl_Counter::Fl_Counter(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Counter widget using the given position, size, and label string. The default type is FL_NORMAL_COUNTER.

virtual Fl_Counter::~Fl_Counter()

Destroys the valuator.

double Fl_Counter::lstep() const
void Fl_Counter::lstep(double)

Get or set the increment for the double-arrow buttons. The default value is 1.0.

type(uchar)

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 Fl_Dial


Class Hierarchy

Include Files

    #include 
    

Description

The Fl_Dial widget provides a circular dial to control a single floating point value.

Methods

Fl_Dial::Fl_Dial(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Dial widget using the given position, size, and label string. The default type is FL_NORMAL_DIAL.

virtual Fl_Dial::~Fl_Dial()

Destroys the valuator.

void Fl_Dial::angles(short a, short b)

Sets the angles used for the minimum and maximum values. By default these are 0 and 360, respectively.

type(uchar)

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 Fl_Double_Window


Class Hierarchy

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

Fl_Double_Window::Fl_Double_Window(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Double_Window widget using the given position, size, and label (title) string.

virtual Fl_Double_Window::~Fl_Double_Window()

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 Fl_End


Class Hierarchy

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

Fl_End::Fl_End

The constructor does Fl_Group::current()->end().
 
Contents
Previous
Next

class Fl_Float_Input


Class Hierarchy

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

Fl_Float_Input::Fl_Float_Input(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Float_Input widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Float_Input::~Fl_Float_Input()

Destroys the widget and any value associated with it.
 
Contents
Previous
Next

class Fl_Free


Class Hierarchy

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

Fl_Free(uchar type, int, int, int, int, const char*l, FL_HANDLEPTR hdl)

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
    

virtual Fl_Free::~Fl_Free()

The destructor will call the handle function with the event FL_FREE_MEM.
 
Contents
Previous
Next

class Fl_Gl_Window


Class Hierarchy

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

Fl_Gl_Window::Fl_Gl_Window(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Gl_Window::~Fl_Gl_Window()

The destructor removes the widget and destroys the OpenGL context associated with it.

virtual void Fl_Gl_Window::draw(void)

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.

const int Fl_Gl_Window::mode() const
int Fl_Gl_Window::mode(int m)

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!

static int Fl_Gl_Window::can_do(int)
int Fl_Gl_Window::can_do() const

Returns non-zero if the hardware supports the given or current OpenGL mode.

char Fl_Gl_Window::valid() const
void Fl_Gl_Window::valid(char i)

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

void Fl_Gl_Window::invalidate()

The invalidate() method turns off valid() and is equivalent to calling value(0).

void Fl_Gl_Window::ortho()

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.

void Fl_Gl_Window::make_current()

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.

void Fl_Gl_Window::make_overlay_current()

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.

void Fl_Gl_Window::swap_buffers()

The swap_buffers() method swaps the back and front buffers. It is called automatically after the draw() method is called.

void Fl_Gl_Window::hide()

Hides the window and destroys the OpenGL context.

int Fl_Gl_Window::can_do_overlay()

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.

void Fl_Gl_Window::redraw_overlay()

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.

virtual void Fl_Gl_Window::draw_overlay()

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 Fl_Group


Class Hierarchy

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

Fl_Group::Fl_Group(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Group widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Group::~Fl_Group()

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.

void Fl_Group::add(Fl_Widget &w)
void Fl_Group::add(Fl_Widget *w)

Adds a widget to the group at the end of the child array.

Fl_Group &Fl_Group::add_resizable(Fl_Widget &box)

Adds a widget to the group and makes it the resizable widget.

const Fl_Widget **Fl_Group::array() const

Returns a pointer to the array of children. This pointer can change when children are added or removed!

void Fl_Group::begin()

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!

Fl_Widget *Fl_Group::child(int n) const

Returns child n, where 0 .

int Fl_Group::children() const

Returns how many child widgets the group has.

static Fl_Group *Fl_Group::current()
static void Fl_Group::current(Fl_Group *w)

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.

void Fl_Group::end()

end() does current(this->parent()). Any new widgets added to the widget tree will be added to the parent of the group.

int Fl_Group::find(const Fl_Widget *w) const
int Fl_Group::find(const Fl_Widget &w) const

Searches the child array for the widget and returns the index. Returns children() if the widget is NULL or not found.

void Fl_Group::insert(Fl_Widget &w, int n)
void Fl_Group::insert(Fl_Widget &w, Fl_Widget *beforethis)

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.

void Fl_Group::remove(Fl_Widget &w)

Removes a widget from the group. This does nothing if the widget is not currently a child of this group.

void Fl_Group::resizable(Fl_Widget *box)
void Fl_Group::resizable(Fl_Widget &box)
Fl_Widget *Fl_Group::resizable() const

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 Fl_Hold_Browser


Class Hierarchy

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

Fl_Hold_Browser::Fl_Hold_Browser(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Hold_Browser widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Hold_Browser::~Fl_Hold_Browser()

The destructor also deletes all the items in the list.

int Fl_Browser::deselect()

Same as value(0).

int Fl_Browser::select(int,int=1)
int Fl_Browser::selected(int) const

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.

int Fl_Browser::value() const
void Fl_Browser::value(int)

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 Fl_Input


Class Hierarchy

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 1Moves the cursor to this point. Drag selects characters. Double click selects words. Triple click selects all text. Shift+click extends the selection.
Mouse button 2Insert 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 3Currently acts like button 1.
BackspaceDeletes one character to the left, or deletes the selected region.
EnterMay cause the callback, see when().
^A or HomeGo to start of line.
^B or LeftMove left
^CCopy the selection to the clipboard
^D or DeleteDeletes 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 EndGo to the end of line.
^F or RightMove right
^KDelete to the end of line (next \n character) or deletes a single \n character. These deletions are all concatenated into the clipboard.
^N or DownMove down (for Fl_Multiline_Input only, otherwise it moves to the next input field).
^P or UpMove 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.
^UDelete everything.
^V or ^YPaste the clipboard
^X or ^WCopy 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+moveMove the cursor but also extend the selection.

Methods

Fl_Input::Fl_Input(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Input widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Input::~Fl_Input()

Destroys the widget and any value associated with it.

const char *Fl_Input::value() const
int Fl_Input::value(const char*)
int Fl_Input::value(const char*, int)

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.

int Fl_Input::static_value(const char*)
int Fl_Input::static_value(const char*, int)

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.

int Fl_Input::size() const

Returns the number of characters in value(). This may be greater than strlen(value()) if there are nul characters in it.

char Fl_Input::index(int) const

Same as value()[n], but may be faster in plausible implementations. No bounds checking is done.

Fl_When Fl_Widget::when() const
void Fl_Widget::when(Fl_When)

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.

Fl_Color Fl_Input::textcolor() const
void Fl_Input::textcolor(Fl_Color)

Gets or sets the color of the text in the input field.

Fl_Font Fl_Input::textfont() const
void Fl_Input::textfont(Fl_Font)

Gets or sets the font of the text in the input field.

uchar Fl_Input::textsize() const
void Fl_Input::textsize(uchar)

Gets or sets the size of the text in the input field.

Fl_Color Fl_Input::cursor_color() const
void Fl_Input::cursor_color(Fl_Color)

Get or set the color of the cursor. This is black by default.
 
Contents
Previous
Next

class Fl_Input_


Class Hierarchy

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

Fl_Input_::Fl_Input_(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Input_ widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Input_::~Fl_Input_()

The destructor removes the widget and any value associated with it.

int Fl_Input_::wordboundary(int i) const

Returns true if position i is at the start or end of a word.

int Fl_Input_::lineboundary(int i) const

Returns true if position i is at the start or end of a line.

void Fl_Input_::drawtext(int,int,int,int)

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.

void Fl_Input_::handletext(int e,int,int,int,int)

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.

int Fl_Input_::up_down_position(int i, int keepmark=0)

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.

void Fl_Input_::maybe_do_callback()

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.

int Fl_Input_::position() const
int Fl_Input_::position(int new_position, int new_mark)
int Fl_Input_::position(int new_position_and_new_mark)

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

int Fl_Input_::mark() const
int Fl_Input_::mark(int new_mark)

Gets or sets the current selection mark. mark(n) is the same as position(position(),n).

int Fl_Input_::replace(int a, int b, const char *insert, int length=0)

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

int Fl_Input_::cut()
int Fl_Input_::cut(int n)
int Fl_Input_::cut(int a, int b);

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.

int Fl_Input_::insert(const char *t,int l=0)

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

int Fl_Input_::copy()

Put the current selection between mark() and position() into the clipboard. Does not replace the old clipboard contents if position() and mark() are equal.

int Fl_Input_::undo()

Does undo of several previous calls to replace(). Returns non-zero if any change was made.

int Fl_Input_::copy_cuts()

Copy all the previous contiguous cuts from the undo information to the clipboard. This is used to make ^K work.
 
Contents
Previous
Next

class Fl_Int_Input


Class Hierarchy

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

Fl_Int_Input::Fl_Int_Input(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Int_Input widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Int_Input::~Fl_Int_Input()

Destroys the widget and any value associated with it.
 
Contents
Previous
Next

class Fl_Light_Button


Class Hierarchy

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

Fl_Light_Button::Fl_Light_Button(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Light_Button widget using the given position, size, and label string.

Fl_Light_Button::~Fl_Light_Button()

The destructor deletes the check button.
 
Contents
Previous
Next

class Fl_Menu_


Class Hierarchy

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

Fl_Menu_::Fl_Menu_(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Menu_ widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Menu_::~Fl_Menu_()

Destroys the menu and its items.

const Fl_Menu_Item* Fl_Menu_::menu() const
void Fl_Menu_::menu(const Fl_Menu_Item*)

Get or set the menu array directly. Setting it to NULL indicates that you want the widget to allocate its own array.

int Fl_Menu_::value() const
int Fl_Menu_::value(int)
int Fl_Menu_::value(const Fl_Menu_Item*)

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.

const Fl_Menu_Item* Fl_Menu_::test_shortcut()

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.

void Fl_Menu_::global()

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

const char* Fl_Menu_::text() const
const char* Fl_Menu_::text(int i) const

Returns the title of the last item chosen, or of item i.

int Fl_Menu_::size() const

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.

int Fl_Menu_::add(const char *,const char *,Fl_Callback *,void *v=0,int f=0)
int Fl_Menu_::add(const char *)

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.

void Fl_Menu_::clear()

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.

void Fl_Menu_::replace(int n, const char *)

Changes the text of item n. The passed string is copied.

void Fl_Menu_::remove(int n)

Deletes item n from the menu.

void Fl_Menu_::shortcut(int i, int n);

Changes the shortcut of item i to n.

void Fl_Menu_::mode(int i,int x);

Changes the flags of item i.

Fl_Color Fl_Menu_::textcolor() const
void Fl_Menu_::textcolor(Fl_Color)

Get or set the current color of menu item labels.

Fl_Font Fl_Menu_::textfont() const
void Fl_Menu_::textfont(Fl_Font)

Get or set the current font of menu item labels.

uchar Fl_Menu_::textsize() const
void Fl_Menu_::textsize(uchar)

Get or set the font size of menu item labels.

Fl_Boxtype Fl_Menu_::down_box() const
void Fl_Menu_::down_box(Fl_Boxtype)

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 Fl_Menu_Bar


Class Hierarchy

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

Fl_Menu_Bar::Fl_Menu_Bar(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Menu_Bar::~Fl_Menu_Bar()

The destructor removes the Fl_Menu_Bar widget and all of its menu items.
 
Contents
Previous
Next

class Fl_Menu_Button


Class Hierarchy

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

Fl_Menu_Button::Fl_Menu_Button(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Menu_Button::~Fl_Menu_Button()

The destructor removes the Fl_Menu_Button widget and all of its menu items.

const Fl_Menu* Fl_Menu_Button::popup()

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.

void Fl_Widget::type(uchar)

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

struct Fl_Menu_Item


Class Hierarchy

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

const char* Fl_Menu_Item::label() const
void Fl_Menu_Item::label(const char*)
void Fl_Menu_Item::label(Fl_Labeltype, const char*)

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.

Fl_Labeltype Fl_Menu_Item::labeltype() const
void Fl_Menu_Item::labeltype(Fl_Labeltype)

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.

Fl_Color Fl_Menu_Item::labelcolor() const
void Fl_Menu_Item::labelcolor(Fl_Color)

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.

Fl_Font Fl_Menu_Item::labelfont() const
void Fl_Menu_Item::labelfont(Fl_Font)

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.

uchar Fl_Menu_Item::labelsize() const
void Fl_Menu_Item::labelsize(uchar)

Gets or sets the label font pixel size/height.

typedef void (Fl_Callback)(Fl_Widget*, void*)
Fl_Callback* Fl_Menu_Item::callback() const
void Fl_Menu_Item::callback(Fl_Callback*, void* = 0)
void Fl_Menu_Item::callback(void (*)(Fl_Widget*))

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.

void* Fl_Menu_Item::user_data() const
void Fl_Menu_Item::user_data(void*)

Get or set the user_data argument that is sent to the callback function.

void Fl_Menu_Item::callback(void (*)(Fl_Widget*, long), long = 0)
long Fl_Menu_Item::argument() const
void Fl_Menu_Item::argument(long)

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_Menu_Item::do_callback(Fl_Widget*)
void Fl_Menu_Item::do_callback(Fl_Widget*, void*)
void Fl_Menu_Item::do_callback(Fl_Widget*, long)

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.

ulong Fl_Menu_Item::shortcut() const
void Fl_Menu_Item::shortcut(ulong)

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

int Fl_Menu_Item::submenu() const

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.

int Fl_Menu_Item::checkbox() const

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.

int Fl_Menu_Item::radio() const

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.

int Fl_Menu_Item::value() const

Returns the current value of the check or radio item.

void Fl_Menu_Item::set()

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.

void Fl_Menu_Item::setonly()

Turns the radio item "on" for the menu item and turns off adjacent radio item.

void Fl_Menu_Item::clear()

Turns the check or radio item "off" for the menu item.

int Fl_Menu_Item::visible() const

Gets the visibility of an item.

void Fl_Menu_Item::show()

Makes an item visible in the menu.

void Fl_Menu_Item::hide()

Hides an item in the menu.

int Fl_Menu_Item::active() const

Get whether or not the item can be picked.

void Fl_Menu_Item::activate()

Allows a menu item to be picked.

void Fl_Menu_Item::deactivate()

Prevents a menu item from being picked. Note that this will also cause the menu item to appear grayed-out.

const Fl_Menu_Item *Fl_Menu_Item::popup(int X, int Y, const char* title = 0, const Fl_Menu_Item* picked = 0, const Fl_Menu_* button = 0) const

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.

const Fl_Menu_Item *Fl_Menu_Item::pulldown(int X, int Y, int W, int H, const Fl_Menu_Item* picked = 0, const Fl_Menu_* button = 0, const Fl_Menu_Item* title = 0, int menubar=0) const

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.

const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const

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 '

int Fl_Menu_Item::size()

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.

const Fl_Menu_Item* Fl_Menu_Item::next(int n=1) const
Fl_Menu_Item* Fl_Menu_Item::next(int n=1);

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 Fl_Menu_Window


Class Hierarchy

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

Fl_Menu_Window::Fl_Menu_Window(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Menu_Window widget using the given position, size, and label string.

virtual Fl_Menu_Window::~Fl_Menu_Window()

Destroys the window and all of its children.

Fl_Menu_Window::clear_overlay();

Tells FLTK to use normal drawing planes instead of overlay planes. This is usually necessary if your menu contains multi-color pixmaps.

Fl_Menu_Window::set_overlay()

Tells FLTK to use hardware overlay planes if they are available.
 
Contents
Previous
Next

class Fl_Multi_Browser


Class Hierarchy

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

Fl_Multi_Browser::Fl_Multi_Browser(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Multi_Browser widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Multi_Browser::~Fl_Multi_Browser()

The destructor also deletes all the items in the list.

int Fl_Browser::deselect()

Deselects all lines.

int Fl_Browser::select(int,int=1)
int Fl_Browser::selected(int) const

Selects one or more lines or gets the current selection state of a line.

int Fl_Browser::value() const
void Fl_Browser::value(int)

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 Fl_Multiline_Input


Class Hierarchy

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

Fl_Multiline_Input::Fl_Multiline_Input(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Multiline_Input widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Multiline_Input::~Fl_Multiline_Input()

Destroys the widget and any value associated with it.
 
Contents
Previous
Next

class Fl_Multiline_Output


Class Hierarchy

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

Fl_Multiline_Output::Fl_Multiline_Output(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Multiline_Output widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Multiline_Output::~Fl_Multiline_Output()

Destroys the widget and any value associated with it.
 
Contents
Previous
Next

class Fl_Output


Class Hierarchy

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

Fl_Output::Fl_Output(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Output widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Output::~Fl_Output()

Destroys the widget and any value associated with it.

const char *Fl_Output::value() const
int Fl_Output::value(const char*)
int Fl_Output::value(const char*, int)

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.

int Fl_Output::size() const

Returns the number of characters in value(). This may be greater than strlen(value()) if there are nul characters in it.

char Fl_Output::index(int) const

Same as value()[n], but may be faster in plausible implementations. No bounds checking is done.

Fl_Color Fl_Output::textcolor() const
void Fl_Output::textcolor(Fl_Color)

Gets or sets the color of the text in the input field.

Fl_Font Fl_Output::textfont() const
void Fl_Output::textfont(Fl_Font)

Gets or sets the font of the text in the input field.

uchar Fl_Output::textsize() const
void Fl_Output::textsize(uchar)

Gets or sets the size of the text in the input field.
 
Contents
Previous
Next

class Fl_Overlay_Window


Class Hierarchy

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

Fl_Overlay_Window::Fl_Overlay_Window(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Overlay_Window widget using the given position, size, and label (title) string.

virtual Fl_Overlay_Window::~Fl_Overlay_Window()

Destroys the window and all child widgets.

virtual void Fl_Overlay_Window::draw_overlay() = 0

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 .

void Fl_Overlay_Window::redraw_overlay()

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 Fl_Pack


Class Hierarchy

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

Fl_Pack::Fl_Pack(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Pack widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Pack::~Fl_Pack()

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.

int Fl_Pack::spacing() const
void Fl_Pack::spacing(int)

Gets or sets the number of extra pixels of blank space that are added between the children.
 
Contents
Previous
Next

class Fl_Positioner


Class Hierarchy

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

Fl_Positioner::Fl_Positioner(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Positioner widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Positioner::~Fl_Positioner()

Deletes the widget.

void Fl_Positioner::value(float *x, float *y) const

Returns the current position in x and y.

void xbounds(float *xmin, float *xmax)
void xbounds(float xmin, float xmax)

Gets or sets the X axis bounds.

void xstep(float x)

Sets the stepping value for the X axis.

float Fl_Positioner::xvalue(void) const
void Fl_Positioner::xvalue(float x)

Gets or sets the X axis coordinate.

void ybounds(float *ymin, float *ymay)
void ybounds(float ymin, float ymay)

Gets or sets the Y axis bounds.

void ystep(float y)

Sets the stepping value for the Y axis.

float Fl_Positioner::yvalue(void) const
void Fl_Positioner::yvalue(float y)

Gets or sets the Y axis coordinate.
 
Contents
Previous
Next

class Fl_Repeat_Button


Class Hierarchy

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

Fl_Repeat_Button::Fl_Repeat_Button(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Repeat_Button widget using the given position, size, and label string. The default boxtype is FL_UP_BOX.

virtual Fl_Repeat_Button::~Fl_Repeat_Button()

Deletes the button.
 
Contents
Previous
Next

class Fl_Return_Button


Class Hierarchy

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

Fl_Return_Button::Fl_Return_Button(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Return_Button widget using the given position, size, and label string. The default boxtype is FL_UP_BOX.

virtual Fl_Return_Button::~Fl_Return_Button()

Deletes the button.
 
Contents
Previous
Next

class Fl_Roller


Class Hierarchy

Include Files

    #include 
    

Description

The Fl_Roller widget is a "dolly" control commonly used to move 3D objects.

Methods

Fl_Roller::Fl_Roller(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Roller widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Roller::~Fl_Roller()

Destroys the valuator.
 
Contents
Previous
Next

class Fl_Round_Button


Class Hierarchy

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

Fl_Round_Button::Fl_Round_Button(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Round_Button widget using the given position, size, and label string.

Fl_Round_Button::~Fl_Round_Button()

The destructor deletes the check button.
 
Contents
Previous
Next

class Fl_Scroll


Class Hierarchy

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

Fl_Scroll::Fl_Scroll(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Scroll widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Scroll::~Fl_Scroll()

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.

void Fl_Widget::type(int)

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.

void Fl_Scroll::scrollbar.align(int)
void Fl_Scroll::hscrollbar.align(int)

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.

int Fl_Scroll::xposition() const

Gets the current horizontal scrolling position.

int Fl_Scroll::yposition() const

Gets the current vertical scrolling position.

void Fl_Scroll::position(int w, int h)

Sets the upper-lefthand corner of the scrolling region.
 
Contents
Previous
Next

class Fl_Scrollbar


Class Hierarchy

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

Fl_Scrollbar::Fl_Scrollbar(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Scrollbar::~Fl_Scrollbar()

Destroys the valuator.

int Fl_Scrollbar::linesize() const
void Fl_Scrollbar::linesize(int i)

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.

int Fl_Scrollbar::value()
int Fl_Scrollbar::value(int position, int size, int top, int total)

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 Fl_Secret_Input


Class Hierarchy

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

Fl_Secret_Input::Fl_Secret_Input(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Secret_Input widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Secret_Input::~Fl_Secret_Input()

Destroys the widget and any value associated with it.
 
Contents
Previous
Next

class Fl_Select_Browser


Class Hierarchy

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

Fl_Select_Browser::Fl_Select_Browser(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Select_Browser widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Select_Browser::~Fl_Select_Browser()

The destructor also deletes all the items in the list.

int Fl_Browser::deselect()

Same as value(0).

int Fl_Browser::select(int,int=1)
int Fl_Browser::selected(int) const

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.

int Fl_Browser::value() const

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 Fl_Single_Window


Class Hierarchy

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

Fl_Single_Window::Fl_Single_Window(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Single_Window widget using the given position, size, and label (title) string.

virtual Fl_Single_Window::~Fl_Single_Window()

Destroys the window and all child widgets.

 
Contents
Previous
Next

class Fl_Slider


Class Hierarchy

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

Fl_Slider::Fl_Slider(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Slider widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Slider::~Fl_Slider()

Destroys the valuator.

int Fl_Slider::scrollvalue(int windowtop, int windowsize, int first, int totalsize)

Returns Fl_Scrollbar::value().

Fl_Boxtype Fl_Slider::slider() const
void Fl_Slider::slider(Fl_Boxtype)

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

float Fl_Slider::slider_size() const
void Fl_Slider::slider_size(float)

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.

uchar Fl_Widget::type() const
void Fl_Widget::type(uchar t)

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 Fl_Tabs


Class Hierarchy

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

Fl_Tab::Fl_Tab(int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Tab::~Fl_Tab()

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.

Fl_Widget* Fl_Tabs::value() const
int Fl_Tabs::value(Fl_Widget*)

Gets or sets the currently visible widget/tab.
 
Contents
Previous
Next

class Fl_Tile


Class Hierarchy

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

Fl_Tile::Fl_Tile(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Tile widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Tile::~Fl_Tile()

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.

void Fl_Tile::position(from_x, from_y, to_x, to_y)

Drag the intersection at from_x,from_y to to_x,to_y. This redraws all the necessary children.

void Fl_Tile::resizable(Fl_Widget The "resizable" child widget (which should be invisible) limits where the border can be dragged to. If you don't set it, it will be possible to drag the borders right to the edge, and thus resize objects on the edge to zero width or height. The resizable() widget is not resized by dragging any borders.


 
Contents
Previous
Next

class Fl_Timer


Class Hierarchy

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

Fl_Timer::Fl_Timer(uchar type, int x, int y, int w, int h, const char *label = 0)

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.

virtual Fl_Timer::~Fl_Timer()

Destroys the timer and removes the timeout.

char direction() const
void direction(char d)

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

char suspended() const
void suspended(char d)

Gets or sets whether the timer is suspended.

float value() const
void value(float)

Gets or sets the current timer value.
 
Contents
Previous
Next

class Fl_Valuator


Class Hierarchy

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

Fl_Valuator::Fl_Valuator(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Valuator widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Valuator::~Fl_Valuator()

Destroys the valuator.

double Fl_Valuator::value() const
int Fl_Valuator::value(double)

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.

double Fl_Valuator::minimum() const
void Fl_Valuator::minimum(double)

Gets or sets the minimum value for the valuator.

double Fl_Valuator::maximum() const
void Fl_Valuator::maximum(double)

Gets or sets the maximum value for the valuator.

void Fl_Valuator::range(double min, double max);

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.

double Fl_Valuator::step() const
void Fl_Valuator::step(double)
void Fl_Valuator::step(int A, int B)

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.

int Fl_Valuator::format(char*, double)

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.

double Fl_Valuator::round(double)

Round the passed value to the nearest step increment. Does nothing if step is zero.

double Fl_Valuator::clamp(double)

Clamp the passed value to the valuator range.

double Fl_Valuator::increment(double,int n)

Adds n times the step value to the passed value. If step was set to zero it uses fabs(maximum() - minimum()) / 100.

int Fl_Widget::changed() const

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

void Fl_Widget::set_changed()

Sets the changed() flag.

void Fl_Widget::clear_changed()

Clears the changed() flag.
 
Contents
Previous
Next

class Fl_Value_Input


Class Hierarchy

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

Fl_Value_Input::Fl_Value_Input(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Value_Input widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Value_Input::~Fl_Value_Input()

Destroys the valuator.

Fl_Color Fl_Value_Input::cursor_color() const
void Fl_Value_Input::cursor_color(Fl_Color)

Get or set the color of the cursor. This is black by default.

uchar Fl_Value_Input::soft() const
void Fl_Value_Input::soft(uchar)

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.

Fl_Color Fl_Value_Input::textcolor() const
void Fl_Value_Input::textcolor(Fl_Color)

Gets or sets the color of the text in the value box.

Fl_Font Fl_Value_Input::textfont() const

void Fl_Value_Input::textfont(Fl_Font)

Gets or sets the typeface of the text in the value box.

uchar Fl_Value_Input::textsize() const
void Fl_Value_Input::textsize(uchar)

Gets or sets the size of the text in the value box.
 
Contents
Previous
Next

class Fl_Value_Output


Class Hierarchy

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

Fl_Value_Output::Fl_Value_Output(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Value_Output widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Value_Output::~Fl_Value_Output()

Destroys the valuator.

uchar Fl_Value_Output::soft() const
void Fl_Value_Output::soft(uchar)

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.

Fl_Color Fl_Value_Output::textcolor() const
void Fl_Value_Output::textcolor(Fl_Color)

Gets or sets the color of the text in the value box.

Fl_Font Fl_Value_Output::textfont() const

void Fl_Value_Output::textfont(Fl_Font)

Gets or sets the typeface of the text in the value box.

uchar Fl_Value_Output::textsize() const
void Fl_Value_Output::textsize(uchar)

Gets or sets the size of the text in the value box.
 
Contents
Previous
Next

class Fl_Value_Slider


Class Hierarchy

Include Files

    #include 
    

Description

The Fl_Value_Slider widget is a Fl_Slider widget with a box displaying the current value.

Methods

Fl_Value_Slider::Fl_Value_Slider(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Value_Slider widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.

virtual Fl_Value_Slider::~Fl_Value_Slider()

Destroys the valuator.

Fl_Color Fl_Value_Slider::textcolor() const
void Fl_Value_Slider::textcolor(Fl_Color)

Gets or sets the color of the text in the value box.

Fl_Font Fl_Value_Slider::textfont() const

void Fl_Value_Slider::textfont(Fl_Font)

Gets or sets the typeface of the text in the value box.

uchar Fl_Value_Slider::textsize() const
void Fl_Value_Slider::textsize(uchar)

Gets or sets the size of the text in the value box.
 
Contents
Previous
Next

class Fl_Widget


Class Hierarchy

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.

short Fl_Widget::x() const
short Fl_Widget::y() const
short Fl_Widget::w() const
short Fl_Widget::h() const

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.

virtual void Fl_Widget::resize(int,int,int,int)
void Fl_Widget::position(short x,short y)
void Fl_Widget::size(short w,short h)

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

Fl_Window* Fl_Widget::window() const;

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.

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

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.

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

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.

Fl_Color Fl_Widget::selection_color() const
void Fl_Widget::selection_color(Fl_Color)

void Fl_Widget::color(Fl_Color, Fl_Color)

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

const char* Fl_Widget::label() const
void Fl_Widget::label(const char*)

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.

void Fl_Widget::label(Fl_Labeltype, const char*)
uchar Fl_Widget::labeltype() const
void Fl_Widget::labeltype(Fl_Labeltype)

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.

Fl_Align Fl_Widget::align() const
void Fl_Widget::align(Fl_Align)

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

Fl_Color Fl_Widget::labelcolor() const
void Fl_Widget::labelcolor(Fl_Color)

This color is passed to the labeltype routine, and is typically the color of the label text. This defaults to FL_BLACK.

Fl_Font Fl_Widget::labelfont() const
void Fl_Widget::labelfont(Fl_Font)

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.

uchar Fl_Widget::labelsize() const
void Fl_Widget::labelsize(uchar)

Fonts are further identified by a point size. The default is 14.

typedef void (Fl_Callback)(Fl_Widget*, void*)
Fl_Callback* Fl_Widget::callback() const
void Fl_Widget::callback(Fl_Callback*, void* = 0)

Each widget has a single callback. You can set it or examine it with these methods.

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

You can also just change the void * second argument to the callback with the user_data methods.

void Fl_Widget::callback(void (*)(Fl_Widget*, long), long = 0)
long Fl_Widget::argument() const
void Fl_Widget::argument(long)

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.

void Fl_Widget::do_callback()
void Fl_Widget::do_callback(Fl_Widget*, void* = 0)
void Fl_Widget::do_callback(Fl_Widget*, long)

You can cause a widget to do its callback at any time, and even pass arbitrary arguments.

int Fl_Widget::changed() const
void Fl_Widget::set_changed()
void Fl_Widget::clear_changed()

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

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.

static void Fl_Widget::default_callback(Fl_Widget*, void*)

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.

int Fl_Widget::visible() const
void Fl_Widget::show()
void Fl_Widget::hide()

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.

int Fl_Widget::active() const
void Fl_Widget::activate()
void Fl_Widget::deactivate()

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.

int Fl_Widget::activevisible() const

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

void Fl_Widget::redraw()

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

uchar Fl_Widget::damage() const

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.

Fl_Widget *Fl_Widget::parent() const

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.

int Fl_Widget::inside(const Fl_Widget* a) const

Returns true if this is a child of a, or is equal to a. Returns false if a is NULL.

int Fl_Widget::take_focus()

Tries to make this widget be the Fl::focus() widget, by first sending it an FL_FOCUS event, and if it returns non-zero, setting Fl::focus() to this widget. You should use this method to assign the focus to an widget. Returns true if the widget accepted the focus.
 
Contents
Previous
Next

class Fl_Window


Class Hierarchy

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

Fl_Window::Fl_Window(int x, int y, int w, int h, const char *title = 0)
Fl_Window::Fl_Window(int w, int h, const char *title = 0)

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.

virtual Fl_Window::~Fl_Window()

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.

void Fl_Window::size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0)

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

virtual void Fl_Window::show()
int Fl_Window::show(int argc, char **argv, int i)
void Fl_Window::show(int argc, char **argv)

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.

virtual void Fl_Window::hide()

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.

int Fl_Window::shown() const

Returns non-zero if show() has been called (but not hide()). You can tell if a window is iconified with (w->shown() &!w->visible()).

void Fl_Window::iconize()

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.

Fl_Window *Fl::first_window()

Returns the first shown() window in the widget hierarchy. If no windows are displayed first_window returns NULL.

Fl_Window *Fl::next_window(const Fl_Window*)

Returns the next shown() window in the hierarchy. You can use this call to iterate through all the windows that are shown().

void Fl_Window::resize(int,int,int,int)

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.

void Fl_Window::free_position()

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.

void Fl_Window::hotspot(int x, int y, int offscreen = 0)
void Fl_Window::hotspot(const Fl_Widget*, int offscreen = 0)
void Fl_Window::hotspot(const Fl_Widgetp, int offscreen = 0)

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

void Fl_Window::fullscreen()

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.

int Fl_Window::fullscreen_off(int x, int y, int w, int h)

Turns off any side effects of fullscreen() and does resize(x,y,w,h).

int Fl_Window::border(int)
uchar Fl_Window::border() const

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.

void Fl_Window::clear_border()

clear_border() is a fast inline function to turn the border off. It only works before show() is called.

void Fl_Window::set_modal()

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

uchar Fl_Window::modal() const

Returns true if this window is modal.

void Fl_Window::set_non_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.

uchar Fl_Window::non_modal() const

Returns true if this window is modal or non-modal.

void Fl_Window::label(const char*)
const char* Fl_Window::label() const

Gets or sets the window title bar label.

void Fl_Window::iconlabel(const char*)
const char* Fl_Window::iconlabel() const

Gets or sets the icon label.

void Fl_Window::xclass(const char*)
const char* Fl_Window::xclass() const

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.

void Fl_Window::make_current()

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.

static Fl_Window* Fl_Window::current()

Returns the last window that was made current.