Fl_Browser_.H
//
// "$Id: Fl_Browser_.H 9846 2013-03-23 21:24:18Z greg.ercolano $"
//
// Common browser header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
/* \file
Fl_Browser_ widget . */
// Yes, I know this should be a template...
#ifndef Fl_Browser__H
#define Fl_Browser__H
#ifndef Fl_Group_H
#include "Fl_Group.H"
#endif
#include "Fl_Scrollbar.H"
#include <FL/Fl.H> // Fl::scrollbar_size()
#define FL_NORMAL_BROWSER 0
#define FL_SELECT_BROWSER 1
#define FL_HOLD_BROWSER 2
#define FL_MULTI_BROWSER 3
#define FL_SORT_ASCENDING 0
#define FL_SORT_DESCENDING 1
class FL_EXPORT Fl_Browser_ : public Fl_Group {
int position_; // where user wants it scrolled to
int real_position_; // the current vertical scrolling position
int hposition_; // where user wants it panned to
int real_hposition_; // the current horizontal scrolling position
int offset_; // how far down top_ item the real_position is
int max_width; // widest object seen so far
uchar has_scrollbar_; // which scrollbars are enabled
Fl_Font textfont_;
Fl_Fontsize textsize_;
Fl_Color textcolor_;
void* top_; // which item scrolling position is in
void* selection_; // which is selected (except for FL_MULTI_BROWSER)
void *redraw1,*redraw2; // minimal update pointers
void* max_width_item; // which item has max_width_
int scrollbar_size_; // size of scrollbar trough
void update_top();
protected:
// All of the following must be supplied by the subclass:
virtual void *item_first() const = 0;
virtual void *item_next(void *item) const = 0;
virtual void *item_prev(void *item) const = 0;
virtual void *item_last() const { return 0L; }
virtual int item_height(void *item) const = 0;
virtual int item_width(void *item) const = 0;
virtual int item_quick_height(void *item) const ;
virtual void item_draw(void *item,int X,int Y,int W,int H) const = 0;
virtual const char *item_text(void *item) const { (void)item; return 0L; }
virtual void item_swap(void *a,void *b) { (void)a; (void)b; }
virtual void *item_at(int index) const { (void)index; return 0L; }
// you don't have to provide these but it may help speed it up:
virtual int full_width() const ; // current width of all items
virtual int full_height() const ; // current height of all items
virtual int incr_height() const ; // average height of an item
// These only need to be done by subclass if you want a multi-browser:
virtual void item_select(void *item,int val=1);
virtual int item_selected(void *item) const ;
// things the subclass may want to call:
void *top() const { return top_; }
void *selection() const { return selection_; }
void new_list(); // completely clobber all data, as though list replaced
void deleting(void *item); // get rid of any pointers to item
void replacing(void *a,void *b); // change a pointers to b
void swapping(void *a,void *b); // exchange pointers a and b
void inserting(void *a,void *b); // insert b near a
int displayed(void *item) const ; // true if this item is visible
void redraw_line(void *item); // minimal update, no change in size
void redraw_lines() { damage(FL_DAMAGE_SCROLL); } // redraw all of them
void bbox(int &X,int &Y,int &W,int &H) const;
int leftedge() const; // x position after scrollbar & border
void *find_item(int ypos); // item under mouse
void draw();
Fl_Browser_(int X,int Y,int W,int H,const char *L=0);
public:
Fl_Scrollbar scrollbar;
Fl_Scrollbar hscrollbar;
int handle(int event);
void resize(int X,int Y,int W,int H);
int select(void *item,int val=1,int docallbacks=0);
int select_only(void *item,int docallbacks=0);
int deselect(int docallbacks=0);
int position() const { return position_; }
void position(int pos); // scroll to here
int hposition() const { return hposition_; }
void hposition(int); // pan to here
void display(void *item); // scroll so this item is shown
enum { // values for has_scrollbar()
HORIZONTAL = 1,
VERTICAL = 2,
BOTH = 3,
ALWAYS_ON = 4,
HORIZONTAL_ALWAYS = 5,
VERTICAL_ALWAYS = 6,
BOTH_ALWAYS = 7
};
uchar has_scrollbar() const { return has_scrollbar_; }
void has_scrollbar(uchar mode) { has_scrollbar_ = mode; }
Fl_Font textfont() const { return textfont_; }
void textfont(Fl_Font font) { textfont_ = font; }
Fl_Fontsize textsize() const { return textsize_; }
void textsize(Fl_Fontsize newSize) { textsize_ = newSize; }
Fl_Color textcolor() const { return textcolor_; }
void textcolor(Fl_Color col) { textcolor_ = col; }
int scrollbar_size() const {
return(scrollbar_size_);
}
void scrollbar_size(int newSize) {
scrollbar_size_ = newSize;
}
int scrollbar_width() const {
return(Fl::scrollbar_size());
}
void scrollbar_width(int width) {
Fl::scrollbar_size(width);
scrollbar_size_ = 0;
}
void scrollbar_right() { scrollbar.align(FL_ALIGN_RIGHT); }
void scrollbar_left() { scrollbar.align(FL_ALIGN_LEFT); }
void sort(int flags=0);
};
#endif
//
// End of "$Id: Fl_Browser_.H 9846 2013-03-23 21:24:18Z greg.ercolano $".
//
- © 1998-2012 by Bill Spitzak and others.