class Fl_Browser : public Fl_Browser_
This is the Forms compatible browser. It displays a scrolling list of
text lines, and manages all the storage for the text. This widget
does nothing when the user clicks on it. There are subclasses that
react to user clicks to select lines in the browser and do callbacks:
There is a base class called Fl_Browser_. This 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_.
Notice that the first line is No. 1, this is so that zero can be
reserved for "no line" in the selective browsers.
Fl_Browser::Fl_Browser(int,int,int,int,const char * =0);
The constructor makes an empty browser.
void Fl_Browser::add(const char *);
Add a new line to the end of the browser. The text is strdup'ed. It
may also be null to make a blank line.
void Fl_Browser::remove(int);
Remove line n and make the browser one line shorter. N must be
greater than zero and <= size().
void Fl_Browser::insert(int,const char *);
Insert a new line before line n, it becomes the new line n. N must
be greater than zero. If N is
greater than size() the line is added to the end.
void Fl_Browser::replace(int,const char *);
Replace the text for line n with this text. N must be
greater than zero and <= size().
void Fl_Browser::clear();
Remove all the lines in the browser.
int Fl_Browser::load(const char *filename);
Clears the browser, then reads the file and adds 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.
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) const ;
Returns the text for line n.
int Fl_Browser::topline() const ;
void Fl_Browser::topline(int);
Get or set which line is at the top of the browser, due to scrolling.
If there are fewer lines than the size of the browser (and thus no
scrollbar) than this is always set to 1.
int Fl_Browser::position() const ;
void Fl_Browser::position(int);
Get or set the scrolling position of the browser. This is measured in
pixels, with 0 at the top. If there are fewer lines than the size of
the browser (and thus no scrollbar) than this is always set to 0.
void Fl_Browser::display(int,int=1);
int Fl_Browser::displayed(int) const ;
Set or get the "displayed" property for line n. If this is false
then the line takes no space and cannot be chosen.
uchar Fl_Browser::textfont() const ;
void Fl_Browser::textfont(uchar);
uchar Fl_Browser::textsize() const ;
void Fl_Browser::textsize(uchar);
uchar Fl_Browser::textcolor() const ;
void Fl_Browser::textcolor(uchar);
Set or get the default font, font size, or color used to draw the lines.
uchar Fl_Browser::column_char() const ;
void Fl_Browser::column_char(char);
Get or set the character used to seperate columns. By default this is
'\t' (tab). 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*);
Get or set the array of column widths. This is a zero-terminated
(make sure the last entry is zero) array of widths, in pixels, of each
column. The text is split at the column_char()'s 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 be no columns.
uchar Fl_Browser::format_char() const ;
void Fl_Browser::format_char(char);
Get or set the character used to introduce formatting codes, which by
default is '@'. Set this to zero to prevent formatting. 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 an @ sign in
it.