FLTK 1.3.2

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

- File List
- File Members

Fl_Browser.H

    00001 //
    00002 // "$Id: Fl_Browser.H 9682 2012-09-17 22:44:54Z greg.ercolano $"
    00003 //
    00004 // Browser header file for the Fast Light Tool Kit (FLTK).
    00005 //
    00006 // Copyright 1998-2011 by Bill Spitzak and others.
    00007 //
    00008 // This library is free software. Distribution and use rights are outlined in
    00009 // the file "COPYING" which should have been included with this file.  If this
    00010 // file is missing or damaged, see the license at:
    00011 //
    00012 //     http://www.fltk.org/COPYING.php
    00013 //
    00014 // Please report all bugs and problems on the following page:
    00015 //
    00016 //     http://www.fltk.org/str.php
    00017 //
    00018
    00019 /* \file
    00020    Fl_Browser widget . */
    00021
    00022 // Forms-compatible browser.  Probably useful for other
    00023 // lists of textual data.  Notice that the line numbers
    00024 // start from 1, and 0 means "no line".
    00025
    00026 #ifndef Fl_Browser_H
    00027 #define Fl_Browser_H
    00028
    00029 #include "Fl_Browser_.H"
    00030 #include "Fl_Image.H"
    00031
    00032 struct FL_BLINE;
    00033
    00080 class FL_EXPORT Fl_Browser : public Fl_Browser_ {
    00081
    00082   FL_BLINE *first;              // the array of lines
    00083   FL_BLINE *last;
    00084   FL_BLINE *cache;
    00085   int cacheline;                // line number of cache
    00086   int lines;                    // Number of lines
    00087   int full_height_;
    00088   const int* column_widths_;
    00089   char format_char_;            // alternative to @-sign
    00090   char column_char_;            // alternative to tab
    00091
    00092 protected:
    00093
    00094   // required routines for Fl_Browser_ subclass:
    00095   void* item_first() const ;
    00096   void* item_next(void* item) const ;
    00097   void* item_prev(void* item) const ;
    00098   void* item_last()const ;
    00099   int item_selected(void* item) const ;
    00100   void item_select(void* item, int val);
    00101   int item_height(void* item) const ;
    00102   int item_width(void* item) const ;
    00103   void item_draw(void* item, int X, int Y, int W, int H) const ;
    00104   int full_height() const ;
    00105   int incr_height() const ;
    00106   const char *item_text(void *item) const;
    00112   void item_swap(void *a, void *b) { swap((FL_BLINE*)a, (FL_BLINE*)b); }
    00118   void *item_at(int line) const { return (void*)find_line(line); }
    00119
    00120   FL_BLINE* find_line(int line) const ;
    00121   FL_BLINE* _remove(int line) ;
    00122   void insert(int line, FL_BLINE* item);
    00123   int lineno(void *item) const ;
    00124   void swap(FL_BLINE *a, FL_BLINE *b);
    00125
    00126 public:
    00127
    00128   void remove(int line);
    00129   void add(const char* newtext, void* d = 0);
    00130   void insert(int line, const char* newtext, void* d = 0);
    00131   void move(int to, int from);
    00132   int  load(const char* filename);
    00133   void swap(int a, int b);
    00134   void clear();
    00135
    00141   int size() const { return lines; }
    00142   void size(int W, int H) { Fl_Widget::size(W, H); }
    00143
    00144   int topline() const ;
    00146   enum Fl_Line_Position { TOP, BOTTOM, MIDDLE };
    00147   void lineposition(int line, Fl_Line_Position pos);
    00154   void topline(int line) { lineposition(line, TOP); }
    00161   void bottomline(int line) { lineposition(line, BOTTOM); }
    00168   void middleline(int line) { lineposition(line, MIDDLE); }
    00169
    00170   int select(int line, int val=1);
    00171   int selected(int line) const ;
    00172   void show(int line);
    00174   void show() { Fl_Widget::show(); }
    00175   void hide(int line);
    00177   void hide() { Fl_Widget::hide(); }
    00178   int visible(int line) const ;
    00179
    00180   int value() const ;
    00186   void value(int line) { select(line); }
    00187   const char* text(int line) const ;
    00188   void text(int line, const char* newtext);
    00189   void* data(int line) const ;
    00190   void data(int line, void* d);
    00191
    00192   Fl_Browser(int X, int Y, int W, int H, const char *L = 0);
    00196   ~Fl_Browser() { clear(); }
    00197
    00227   char format_char() const { return format_char_; }
    00233   void format_char(char c) { format_char_ = c; }
    00239   char column_char() const { return column_char_; }
    00246   void column_char(char c) { column_char_ = c; }
    00270   const int* column_widths() const { return column_widths_; }
    00275   void column_widths(const int* arr) { column_widths_ = arr; }
    00276
    00286   int displayed(int line) const { return Fl_Browser_::displayed(find_line(line)); }
    00287
    00295   void make_visible(int line) {
    00296     if (line < 1) Fl_Browser_::display(find_line(1));
    00297     else if (line > lines) Fl_Browser_::display(find_line(lines));
    00298     else Fl_Browser_::display(find_line(line));
    00299   }
    00300
    00301   // icon support
    00302   void icon(int line, Fl_Image* icon);
    00303   Fl_Image* icon(int line) const;
    00304   void remove_icon(int line);
    00305
    00307   void replace(int a, const char* b) { text(a, b); }
    00308   void display(int line, int val=1);
    00309 };
    00310
    00311 #endif
    00312
    00313 //
    00314 // End of "$Id: Fl_Browser.H 9682 2012-09-17 22:44:54Z greg.ercolano $".
    00315 //