FLTK 1.3.3

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

- File List
- File Members

Fl_Browser_.H
1 //
2 // "$Id: Fl_Browser_.H 9846 2013-03-23 21:24:18Z greg.ercolano $"
3 //
4 // Common browser header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 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 // Yes, I know this should be a template...
23
24 #ifndef Fl_Browser__H
25 #define Fl_Browser__H
26
27 #ifndef Fl_Group_H
28 #include "Fl_Group.H"
29 #endif
30 #include "Fl_Scrollbar.H"
31 #include <FL/Fl.H> // Fl::scrollbar_size()
32
33 #define FL_NORMAL_BROWSER 0
34 #define FL_SELECT_BROWSER 1
35 #define FL_HOLD_BROWSER 2
36 #define FL_MULTI_BROWSER 3
38 #define FL_SORT_ASCENDING 0
39 #define FL_SORT_DESCENDING 1
77 class FL_EXPORT Fl_Browser_ : public Fl_Group {
78 int position_; // where user wants it scrolled to
79 int real_position_; // the current vertical scrolling position
80 int hposition_; // where user wants it panned to
81 int real_hposition_; // the current horizontal scrolling position
82 int offset_; // how far down top_ item the real_position is
83 int max_width; // widest object seen so far
84 uchar has_scrollbar_; // which scrollbars are enabled
85 Fl_Font textfont_;
86 Fl_Fontsize textsize_;
87 Fl_Color textcolor_;
88 void* top_; // which item scrolling position is in
89 void* selection_; // which is selected (except for FL_MULTI_BROWSER)
90 void *redraw1,*redraw2; // minimal update pointers
91 void* max_width_item; // which item has max_width_
92 int scrollbar_size_; // size of scrollbar trough
93
94 void update_top();
95
96 protected:
97
98 // All of the following must be supplied by the subclass:
104 virtual void *item_first() const = 0;
110 virtual void *item_next(void *item) const = 0;
116 virtual void *item_prev(void *item) const = 0;
122 virtual void *item_last() const { return 0L; }
131 virtual int item_height(void *item) const = 0;
139 virtual int item_width(void *item) const = 0;
140 virtual int item_quick_height(void *item) const ;
145 virtual void item_draw(void *item,int X,int Y,int W,int H) const = 0;
151 virtual const char *item_text(void *item) const { (void)item; return 0L; }
157 virtual void item_swap(void *a,void *b) { (void)a; (void)b; }
164 virtual void *item_at(int index) const { (void)index; return 0L; }
165 // you don't have to provide these but it may help speed it up:
166 virtual int full_width() const ; // current width of all items
167 virtual int full_height() const ; // current height of all items
168 virtual int incr_height() const ; // average height of an item
169 // These only need to be done by subclass if you want a multi-browser:
170 virtual void item_select(void *item,int val=1);
171 virtual int item_selected(void *item) const ;
172
173 // things the subclass may want to call:
177 void *top() const { return top_; }
185 void *selection() const { return selection_; }
186 void new_list(); // completely clobber all data, as though list replaced
187 void deleting(void *item); // get rid of any pointers to item
188 void replacing(void *a,void *b); // change a pointers to b
189 void swapping(void *a,void *b); // exchange pointers a and b
190 void inserting(void *a,void *b); // insert b near a
191 int displayed(void *item) const ; // true if this item is visible
192 void redraw_line(void *item); // minimal update, no change in size
197 void redraw_lines() { damage(FL_DAMAGE_SCROLL); } // redraw all of them
198 void bbox(int &X,int &Y,int &W,int &H) const;
199 int leftedge() const; // x position after scrollbar & border
200 void *find_item(int ypos); // item under mouse
201
202 void draw();
203 Fl_Browser_(int X,int Y,int W,int H,const char *L=0);
204
205 public:
206
210 Fl_Scrollbar scrollbar;
214 Fl_Scrollbar hscrollbar;
215
216 int handle(int event);
217 void resize(int X,int Y,int W,int H);
218
219 int select(void *item,int val=1,int docallbacks=0);
220 int select_only(void *item,int docallbacks=0);
221 int deselect(int docallbacks=0);
229 int position() const { return position_; }
230 void position(int pos); // scroll to here
238 int hposition() const { return hposition_; }
239 void hposition(int); // pan to here
240 void display(void *item); // scroll so this item is shown
241
251 enum { // values for has_scrollbar()
252 HORIZONTAL = 1,
253 VERTICAL = 2,
254 BOTH = 3,
255 ALWAYS_ON = 4,
256 HORIZONTAL_ALWAYS = 5,
257 VERTICAL_ALWAYS = 6,
258 BOTH_ALWAYS = 7
259 };
263 uchar has_scrollbar() const { return has_scrollbar_; }
286 void has_scrollbar(uchar mode) { has_scrollbar_ = mode; }
287
292 Fl_Font textfont() const { return textfont_; }
296 void textfont(Fl_Font font) { textfont_ = font; }
297
301 Fl_Fontsize textsize() const { return textsize_; }
305 void textsize(Fl_Fontsize newSize) { textsize_ = newSize; }
306
310 Fl_Color textcolor() const { return textcolor_; }
314 void textcolor(Fl_Color col) { textcolor_ = col; }
315
325 int scrollbar_size() const {
326 return(scrollbar_size_);
327 }
347 void scrollbar_size(int newSize) {
348 scrollbar_size_ = newSize;
349 }
357 int scrollbar_width() const {
358 return(Fl::scrollbar_size());
359 }
367 void scrollbar_width(int width) {
368 Fl::scrollbar_size(width);
369 scrollbar_size_ = 0;
370 }
375 void scrollbar_right() { scrollbar.align(FL_ALIGN_RIGHT); }
380 void scrollbar_left() { scrollbar.align(FL_ALIGN_LEFT); }
381 void sort(int flags=0);
382 };
383
384 #endif
385
386 //
387 // End of "$Id: Fl_Browser_.H 9846 2013-03-23 21:24:18Z greg.ercolano $".
388 //
Fl_Browser_::textsize
Fl_Fontsize textsize() const
Gets the default text size (in pixels) for the lines in the browser.
Definition: Fl_Browser_.H:301
Fl_Browser_::scrollbar_left
void scrollbar_left()
Moves the vertical scrollbar to the lefthand side of the list.
Definition: Fl_Browser_.H:380
Fl_Widget::align
Fl_Align align() const
Gets the label alignment.
Definition: Fl_Widget.H:337
Fl_Browser_::scrollbar_size
int scrollbar_size() const
Gets the current size of the scrollbars' troughs, in pixels.
Definition: Fl_Browser_.H:325
Fl_Browser_::selection
void * selection() const
Returns the item currently selected, or NULL if there is no selection.
Definition: Fl_Browser_.H:185
Fl.H
Fl static class.
Fl_Browser_::textcolor
void textcolor(Fl_Color col)
Sets the default text color for the lines in the browser to color col.
Definition: Fl_Browser_.H:314
Fl_Browser_::textcolor
Fl_Color textcolor() const
Gets the default text color for the lines in the browser.
Definition: Fl_Browser_.H:310
Fl_Browser_
This is the base class for browsers.
Definition: Fl_Browser_.H:77
Fl_Browser_::scrollbar_right
void scrollbar_right()
Moves the vertical scrollbar to the righthand side of the list.
Definition: Fl_Browser_.H:375
Fl_Browser_::hscrollbar
Fl_Scrollbar hscrollbar
Horizontal scrollbar.
Definition: Fl_Browser_.H:214
Fl_Browser_::top
void * top() const
Returns the item that appears at the top of the list.
Definition: Fl_Browser_.H:177
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:151
Fl_Browser_::textfont
void textfont(Fl_Font font)
Sets the default text font for the lines in the browser to font.
Definition: Fl_Browser_.H:296
Fl_Browser_::scrollbar
Fl_Scrollbar scrollbar
Vertical scrollbar.
Definition: Fl_Browser_.H:210
Fl_Browser_::item_swap
virtual void item_swap(void *a, void *b)
This optional method should be provided by the subclass to efficiently swap browser items a and b...
Definition: Fl_Browser_.H:157
FL_DAMAGE_SCROLL
The Fl_Scroll widget was scrolled.
Definition: Enumerations.H:969
Fl_Browser_::textfont
Fl_Font textfont() const
Gets the default text font for the lines in the browser.
Definition: Fl_Browser_.H:292
Fl_Browser_::textsize
void textsize(Fl_Fontsize newSize)
Sets the default text size (in pixels) for the lines in the browser to size.
Definition: Fl_Browser_.H:305
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition: Enumerations.H:768
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:122
Fl_Browser_::has_scrollbar
void has_scrollbar(uchar mode)
Sets whether the widget should have scrollbars or not (default Fl_Browser_::BOTH).
Definition: Fl_Browser_.H:286
Fl_Browser_::item_at
virtual void * item_at(int index) const
This method must be provided by the subclass to return the item for the specified index...
Definition: Fl_Browser_.H:164
Fl_Browser_::scrollbar_size
void scrollbar_size(int newSize)
Sets the pixel size of the scrollbars' troughs to newSize, in pixels.
Definition: Fl_Browser_.H:347
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:796
Fl::scrollbar_size
static int scrollbar_size()
Gets the default scrollbar size used by Fl_Browser_, Fl_Help_View, Fl_Scroll, and Fl_Text_Display wid...
Definition: Fl.cxx:147
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition: Enumerations.H:739
Fl_Browser_::position
int position() const
Gets the vertical scroll position of the list as a pixel position pos.
Definition: Fl_Browser_.H:229
Fl_Browser_::has_scrollbar
uchar has_scrollbar() const
Returns the current scrollbar mode, see Fl_Browser_::has_scrollbar(uchar)
Definition: Fl_Browser_.H:263
Fl_Browser_::redraw_lines
void redraw_lines()
This method will cause the entire list to be redrawn.
Definition: Fl_Browser_.H:197
FL_ALIGN_LEFT
const Fl_Align FL_ALIGN_LEFT
Align the label at the left of the widget.
Definition: Enumerations.H:701
Fl_Browser_::scrollbar_width
int scrollbar_width() const
This method has been deprecated, existing for backwards compatibility only.
Definition: Fl_Browser_.H:357
Fl_Browser_::scrollbar_width
void scrollbar_width(int width)
This method has been deprecated, existing for backwards compatibility only.
Definition: Fl_Browser_.H:367
Fl_Scrollbar
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Definition: Fl_Scrollbar.H:43
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
FL_ALIGN_RIGHT
const Fl_Align FL_ALIGN_RIGHT
Align the label to the right of the widget.
Definition: Enumerations.H:703
Fl_Browser_::hposition
int hposition() const
Gets the horizontal scroll position of the list as a pixel position pos.
Definition: Fl_Browser_.H:238
- © 1998-2014 by Bill Spitzak and others.