Class Hierarchy
Fl_Browser_
|
+----Fl_Browser
|
+----Fl_Hold_Browser, Fl_Multi_Browser, Fl_Select_Browser
Include Files
#include <FL/Fl_Browser.H>
Description
The Fl_Browser widget displays a scrolling list of text
lines, and manages all the storage for the text. This is not a text
editor or spreadsheet! But it is useful for showing a vertical list of
named objects to the user.
Each line in the browser is identified by number. The numbers
start at one (this is so that zero can be reserved for "no line" in
the selective browsers). Unless otherwise noted, the methods do not
check to see if the passed line number is in range and legal. It must
always be greater than zero and <= size().
Each line contains a null-terminated string of text and a void *
data pointer. The text string is displayed, the void *
pointer can be used by the callbacks to reference the object the text
describes.
The base class does nothing when the user clicks on it. The
subclasses
Fl_Select_Browser,
Fl_Hold_Browser, and
Fl_Multi_Browser react to user clicks to select lines in
the browser and do callbacks.
The base class called
Fl_Browser_ provides the scrolling and selection mechanisms of
this and all the subclasses, but the dimensions and appearance of each
item are determined by the subclass. You can use Fl_Browser_
to display information other than text, or text that is dynamically
produced from your own data structures. If you find that loading the
browser is a lot of work or is inefficient, you may want to make a
subclass of Fl_Browser_.
Methods
The constructor makes an empty browser.
The destructor deletes all list items and destroys the browser.
Add a new line to the end of the browser. The text is copied using
the strdup() function. It may also be NULL to make a
blank line. The void * argument is returned as the data()
of the new item.
Scrolls the browser so the bottom line in the browser is n.
Remove all the lines in the browser.
The first form gets the current column separator character. By default
this is '\t' (tab).
The second form sets the column separator to c. This will
only have an effect if you also set column_widths().
The first form gets the current column width array. This array is
zero-terminated and specifies the widths in pixels of each column. The
text is split at each column_char() and each part is formatted
into it's own column. After the last column any remaining text is
formatted into the space between the last column and the right edge of
the browser, even if the text contains instances of column_char()
. The default value is a one-element array of just a zero, which makes
there are no columns.
The second form sets the current array to w. Make sure the
last entry is zero.
The first form returns the data for line n. If n is
out of range this returns NULL.
The second form sets the data for line n.
The first form gets the current format code prefix character, which by
default is @. A string of formatting codes at the start of
each column are stripped off and used to modify how the rest of the
line is printed:
@.
Print rest of line, don't look for more '@' signs
@@
Print rest of line starting with '@'
@l
Use a large (24 point) font
@m
Use a medium large (18 point) font
@s
Use a small (11 point) font
@b
Use a bold font (adds FL_BOLD to font)
@i
Use an italic font (adds FL_ITALIC to font)
@f
or @t
Use a fixed-pitch
font (sets font to FL_COURIER)
@c
Center the line horizontally
@r
Right-justify the text
@B0, @B1, ... @B255
Fill the backgound with
fl_color(n)
@C0, @C1, ... @C255
Use fl_color(n) to draw the text
@F0, @F1, ...
Use fl_font(n) to draw the text
@S1, @S2, ...
Use point size n to draw the text
@u
or @_
Underline the text.
@-
draw an engraved line through the middle.
Notice that the @.
command can be used to reliably
terminate the parsing. To print a random string in a random color, use
sprintf("@C%d@.%s", color, string) and it will work even if the
string starts with a digit or has the format character in it.
The second form sets the current prefix to c. Set the
prefix to 0 to disable formatting.
Makes line n invisible, preventing selection by the user.
The line can still be selected under program control.
Insert a new line before line n. If n >
size() then the line is added to the end.
Clears the browser and reads the file, adding each line from the file
to the browser. If the filename is NULL or a zero-length
string then this just clears the browser. This returns zero if there
was any error in opening or reading the file, in which case errno
is set to the system error. The data() of each line is set
to NULL.
Scrolls the browser so the middle line in the browser is n.
Line from is removed and reinserted at to; to
is calculated after the line is removed.
The first form returns the current vertical scrollbar position, where
0 corresponds to the top. If there is not vertical scrollbar then this
will always return 0.
The second form sets the vertical scrollbar position to p.
Remove line n and make the browser one line shorter.
Makes line n visible for selection.
Returns how many lines are in the browser. The last line number is
equal to this.
The first form returns the text for line n. If n is
out of range it returns NULL.
The second form sets the text for line n.
The first form returns the current top line in the browser. If there
is no vertical scrollbar then this will always return 1.
The second form scrolls the browser so the top line in the browser is n.
Returns a non-zero value if line n is visible.