• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

Fl_Browser.H

00001 //
00002 // "$Id$"
00003 //
00004 // Browser header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2016 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 
00147   Fl_Fontsize textsize() const { return Fl_Browser_::textsize(); }
00148 
00149   /*
00150     Sets the default text size for the lines in the browser to newSize.
00151     Defined and documented in Fl_Browser.cxx
00152   */
00153   void textsize(Fl_Fontsize newSize);
00154 
00155   int topline() const ;
00157   enum Fl_Line_Position { TOP, BOTTOM, MIDDLE };
00158   void lineposition(int line, Fl_Line_Position pos);
00165   void topline(int line) { lineposition(line, TOP); }
00172   void bottomline(int line) { lineposition(line, BOTTOM); }
00179   void middleline(int line) { lineposition(line, MIDDLE); }
00180 
00181   int select(int line, int val=1);
00182   int selected(int line) const ;
00183   void show(int line);
00185   void show() { Fl_Widget::show(); }
00186   void hide(int line);
00188   void hide() { Fl_Widget::hide(); }
00189   int visible(int line) const ;
00190 
00191   int value() const ;
00197   void value(int line) { select(line); }
00198   const char* text(int line) const ;
00199   void text(int line, const char* newtext);
00200   void* data(int line) const ;
00201   void data(int line, void* d);
00202 
00203   Fl_Browser(int X, int Y, int W, int H, const char *L = 0);
00207   ~Fl_Browser() { clear(); }
00208 
00238   char format_char() const { return format_char_; }
00244   void format_char(char c) { format_char_ = c; }
00250   char column_char() const { return column_char_; }
00257   void column_char(char c) { column_char_ = c; }
00281   const int* column_widths() const { return column_widths_; }
00286   void column_widths(const int* arr) { column_widths_ = arr; }
00287 
00297   int displayed(int line) const { return Fl_Browser_::displayed(find_line(line)); }
00298 
00306   void make_visible(int line) {
00307     if (line < 1) Fl_Browser_::display(find_line(1));
00308     else if (line > lines) Fl_Browser_::display(find_line(lines));
00309     else Fl_Browser_::display(find_line(line));
00310   }
00311 
00312   // icon support
00313   void icon(int line, Fl_Image* icon);
00314   Fl_Image* icon(int line) const;
00315   void remove_icon(int line);
00316 
00318   void replace(int a, const char* b) { text(a, b); }
00319   void display(int line, int val=1);
00320 };
00321 
00322 #endif
00323 
00324 //
00325 // End of "$Id$".
00326 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.