FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Browser.H
1 //
2 // "$Id: Fl_Browser.H 9682 2012-09-17 22:44:54Z greg.ercolano $"
3 //
4 // Browser header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2011 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18
19 /* \file
20 Fl_Browser widget . */
21
22 // Forms-compatible browser. Probably useful for other
23 // lists of textual data. Notice that the line numbers
24 // start from 1, and 0 means "no line".
25
26 #ifndef Fl_Browser_H
27 #define Fl_Browser_H
28
29 #include "Fl_Browser_.H"
30 #include "Fl_Image.H"
31
32 struct FL_BLINE;
33
80 class FL_EXPORT Fl_Browser : public Fl_Browser_ {
81
82 FL_BLINE *first; // the array of lines
83 FL_BLINE *last;
84 FL_BLINE *cache;
85 int cacheline; // line number of cache
86 int lines; // Number of lines
87 int full_height_;
88 const int* column_widths_;
89 char format_char_; // alternative to @-sign
90 char column_char_; // alternative to tab
91
92 protected:
93
94 // required routines for Fl_Browser_ subclass:
95 void* item_first() const ;
96 void* item_next(void* item) const ;
97 void* item_prev(void* item) const ;
98 void* item_last()const ;
99 int item_selected(void* item) const ;
100 void item_select(void* item, int val);
101 int item_height(void* item) const ;
102 int item_width(void* item) const ;
103 void item_draw(void* item, int X, int Y, int W, int H) const ;
104 int full_height() const ;
105 int incr_height() const ;
106 const char *item_text(void *item) const;
112 void item_swap(void *a, void *b) { swap((FL_BLINE*)a, (FL_BLINE*)b); }
118 void *item_at(int line) const { return (void*)find_line(line); }
119
120 FL_BLINE* find_line(int line) const ;
121 FL_BLINE* _remove(int line) ;
122 void insert(int line, FL_BLINE* item);
123 int lineno(void *item) const ;
124 void swap(FL_BLINE *a, FL_BLINE *b);
125
126 public:
127
128 void remove(int line);
129 void add(const char* newtext, void* d = 0);
130 void insert(int line, const char* newtext, void* d = 0);
131 void move(int to, int from);
132 int load(const char* filename);
133 void swap(int a, int b);
134 void clear();
135
141 int size() const { return lines; }
142 void size(int W, int H) { Fl_Widget::size(W, H); }
143
144 int topline() const ;
146 enum Fl_Line_Position { TOP, BOTTOM, MIDDLE };
147 void lineposition(int line, Fl_Line_Position pos);
154 void topline(int line) { lineposition(line, TOP); }
161 void bottomline(int line) { lineposition(line, BOTTOM); }
168 void middleline(int line) { lineposition(line, MIDDLE); }
169
170 int select(int line, int val=1);
171 int selected(int line) const ;
172 void show(int line);
174 void show() { Fl_Widget::show(); }
175 void hide(int line);
177 void hide() { Fl_Widget::hide(); }
178 int visible(int line) const ;
179
180 int value() const ;
186 void value(int line) { select(line); }
187 const char* text(int line) const ;
188 void text(int line, const char* newtext);
189 void* data(int line) const ;
190 void data(int line, void* d);
191
192 Fl_Browser(int X, int Y, int W, int H, const char *L = 0);
196 ~Fl_Browser() { clear(); }
197
227 char format_char() const { return format_char_; }
233 void format_char(char c) { format_char_ = c; }
239 char column_char() const { return column_char_; }
246 void column_char(char c) { column_char_ = c; }
270 const int* column_widths() const { return column_widths_; }
275 void column_widths(const int* arr) { column_widths_ = arr; }
276
286 int displayed(int line) const { return Fl_Browser_::displayed(find_line(line)); }
287
295 void make_visible(int line) {
296 if (line < 1) Fl_Browser_::display(find_line(1));
297 else if (line > lines) Fl_Browser_::display(find_line(lines));
298 else Fl_Browser_::display(find_line(line));
299 }
300
301 // icon support
302 void icon(int line, Fl_Image* icon);
303 Fl_Image* icon(int line) const;
304 void remove_icon(int line);
305
307 void replace(int a, const char* b) { text(a, b); }
308 void display(int line, int val=1);
309 };
310
311 #endif
312
313 //
314 // End of "$Id: Fl_Browser.H 9682 2012-09-17 22:44:54Z greg.ercolano $".
315 //
Fl_Browser_::incr_height
virtual int incr_height() const
This method may be provided to return the average height of all items to be used for scrolling...
Definition: Fl_Browser_.cxx:1051
Fl_Browser_::select
int select(void *item, int val=1, int docallbacks=0)
Sets the selection state of item to val, and returns 1 if the state changed or 0 if it did not...
Definition: Fl_Browser_.cxx:607
Fl_Widget::visible
unsigned int visible() const
Returns whether a widget is visible.
Definition: Fl_Widget.H:647
Fl_Widget::hide
virtual void hide()
Makes a widget invisible.
Definition: Fl_Widget.cxx:264
Fl_Browser::topline
void topline(int line)
Scrolls the browser so the top item in the browser is showing the specified line. ...
Definition: Fl_Browser.H:154
Fl_Browser::item_at
void * item_at(int line) const
Return the item at specified line.
Definition: Fl_Browser.H:118
Fl_Browser_
This is the base class for browsers.
Definition: Fl_Browser_.H:58
Fl_Widget::size
void size(int W, int H)
Changes the size of the widget.
Definition: Fl_Widget.H:330
Fl_Browser::make_visible
void make_visible(int line)
Make the item at the specified line visible().
Definition: Fl_Browser.H:295
Fl_Browser_::item_height
virtual int item_height(void *item) const =0
This method must be provided by the subclass to return the height of item in pixels.
Fl_Image
Fl_Image is the base class used for caching and drawing all kinds of images in FLTK.
Definition: Fl_Image.H:44
Fl_Browser::column_char
void column_char(char c)
Sets the column separator to c.
Definition: Fl_Browser.H:246
Fl_Browser_::item_next
virtual void * item_next(void *item) const =0
This method must be provided by the subclass to return the item in the list after item...
Fl_Browser_::item_text
virtual const char * item_text(void *item) const
This optional method returns a string (label) that may be used for sorting.
Definition: Fl_Browser_.H:132
Fl_Browser_::item_draw
virtual void item_draw(void *item, int X, int Y, int W, int H) const =0
This method must be provided by the subclass to draw the item in the area indicated by X...
Fl_Browser::value
void value(int line)
Sets the browser&#39;s value(), which selects the specified line.
Definition: Fl_Browser.H:186
Fl_Group::clear
void clear()
Deletes all child widgets from memory recursively.
Definition: Fl_Group.cxx:381
Fl_Browser::item_swap
void item_swap(void *a, void *b)
Swap the items a and b.
Definition: Fl_Browser.H:112
Fl_Browser::hide
void hide()
Hides the entire Fl_Browser widget – opposite of show().
Definition: Fl_Browser.H:177
Fl_Browser_::full_height
virtual int full_height() const
This method may be provided by the subclass to indicate the full height of the item list...
Definition: Fl_Browser_.cxx:1062
Fl_Group::insert
void insert(Fl_Widget &, int i)
The widget is removed from its current group (if any) and then inserted into this group...
Definition: Fl_Group.cxx:456
Fl_Browser::replace
void replace(int a, const char *b)
For back compatibility only.
Definition: Fl_Browser.H:307
Fl_Browser::format_char
void format_char(char c)
Sets the current format code prefix character to c.
Definition: Fl_Browser.H:233
Fl_Browser_::display
void display(void *item)
Displays the item, scrolling the list as necessary.
Definition: Fl_Browser_.cxx:244
Fl_Group::add
void add(Fl_Widget &)
The widget is removed from its current group (if any) and then added to the end of this group...
Definition: Fl_Group.cxx:489
Fl_Browser::column_widths
void column_widths(const int *arr)
Sets the current array to arr.
Definition: Fl_Browser.H:275
Fl_Widget::show
virtual void show()
Makes a widget visible.
Definition: Fl_Widget.cxx:252
Fl_Browser_::item_first
virtual void * item_first() const =0
This method must be provided by the subclass to return the first item in the list.
Fl_Browser::column_widths
const int * column_widths() const
Gets the current column width array.
Definition: Fl_Browser.H:270
Fl_Browser::format_char
char format_char() const
Gets the current format code prefix character, which by default is &#39;@&#39;.
Definition: Fl_Browser.H:227
Fl_Browser_::item_last
virtual void * item_last() const
This method must be provided by the subclass to return the last item in the list. ...
Definition: Fl_Browser_.H:103
Fl_Browser::bottomline
void bottomline(int line)
Scrolls the browser so the bottom item in the browser is showing the specified line.
Definition: Fl_Browser.H:161
Fl_Browser::displayed
int displayed(int line) const
Returns non-zero if line has been scrolled to a position where it is being displayed.
Definition: Fl_Browser.H:286
Fl_Browser::Fl_Line_Position
Fl_Line_Position
For internal use only?
Definition: Fl_Browser.H:146
Fl_Browser::column_char
char column_char() const
Gets the current column separator character.
Definition: Fl_Browser.H:239
Fl_Browser_::displayed
int displayed(void *item) const
Returns non-zero if item has been scrolled to a position where it is being displayed.
Definition: Fl_Browser_.cxx:227
Fl_Browser_::item_width
virtual int item_width(void *item) const =0
This method must be provided by the subclass to return the width of the item in pixels.
Fl_Browser
The Fl_Browser widget displays a scrolling list of text lines, and manages all the storage for the te...
Definition: Fl_Browser.H:80
Fl_Browser_::item_selected
virtual int item_selected(void *item) const
This method must be implemented by the subclass if it supports multiple selections; returns the selec...
Definition: Fl_Browser_.cxx:1096
Fl_Browser_::item_prev
virtual void * item_prev(void *item) const =0
This method must be provided by the subclass to return the item in the list before item...
Fl_Browser_::item_select
virtual void item_select(void *item, int val=1)
This method must be implemented by the subclass if it supports multiple selections; sets the selectio...
Definition: Fl_Browser_.cxx:1088
Fl_Browser::show
void show()
Shows the entire Fl_Browser widget – opposite of hide().
Definition: Fl_Browser.H:174
Fl_Browser::middleline
void middleline(int line)
Scrolls the browser so the middle item in the browser is showing the specified line.
Definition: Fl_Browser.H:168
Fl_Browser::~Fl_Browser
~Fl_Browser()
The destructor deletes all list items and destroys the browser.
Definition: Fl_Browser.H:196
Fl_Browser::size
int size() const
Returns how many lines are in the browser.
Definition: Fl_Browser.H:141
- © 1998-2012 by Bill Spitzak and others.