1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Browser header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// Copyright 1998-2005 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
|
|
|
|
// Forms-compatable browser. Probably useful for other
|
|
|
|
// lists of textual data. Notice that the line numbers
|
|
|
|
// start from 1, and 0 means "no line".
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#ifndef Fl_Browser_H
|
|
|
|
#define Fl_Browser_H
|
|
|
|
|
|
|
|
#include "Fl_Browser_.H"
|
|
|
|
|
|
|
|
struct FL_BLINE;
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
class FL_EXPORT Fl_Browser : public Fl_Browser_ {
|
1998-10-06 22:21:25 +04:00
|
|
|
|
1999-11-16 10:39:59 +03:00
|
|
|
FL_BLINE *first; // the array of lines
|
|
|
|
FL_BLINE *last;
|
|
|
|
FL_BLINE *cache;
|
|
|
|
int cacheline; // line number of cache
|
|
|
|
int lines; // Number of lines
|
|
|
|
int full_height_;
|
|
|
|
const int* column_widths_;
|
|
|
|
char format_char_; // alternative to @-sign
|
|
|
|
char column_char_; // alternative to tab
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// required routines for Fl_Browser_ subclass:
|
2002-08-14 20:49:38 +04:00
|
|
|
void* item_first() const ;
|
|
|
|
void* item_next(void*) const ;
|
|
|
|
void* item_prev(void*) const ;
|
|
|
|
int item_selected(void*) const ;
|
|
|
|
void item_select(void*, int);
|
|
|
|
int item_height(void*) const ;
|
|
|
|
int item_width(void*) const ;
|
|
|
|
void item_draw(void*, int, int, int, int) const ;
|
|
|
|
int full_height() const ;
|
|
|
|
int incr_height() const ;
|
|
|
|
|
|
|
|
FL_BLINE* find_line(int) const ;
|
|
|
|
FL_BLINE* _remove(int) ;
|
|
|
|
void insert(int, FL_BLINE*);
|
|
|
|
int lineno(void*) const ;
|
2004-07-27 00:52:52 +04:00
|
|
|
void swap(FL_BLINE *a, FL_BLINE *b);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
void remove(int);
|
|
|
|
void add(const char*, void* = 0);
|
|
|
|
void insert(int, const char*, void* = 0);
|
|
|
|
void move(int to, int from);
|
|
|
|
int load(const char* filename);
|
2004-07-27 00:52:52 +04:00
|
|
|
void swap(int a, int b);
|
2002-08-14 20:49:38 +04:00
|
|
|
void clear();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
int size() const {return lines;}
|
2003-06-15 08:47:28 +04:00
|
|
|
void size(int W, int H) { Fl_Widget::size(W, H); }
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
int topline() const ;
|
1999-01-30 03:39:28 +03:00
|
|
|
enum Fl_Line_Position { TOP, BOTTOM, MIDDLE };
|
2002-08-14 20:49:38 +04:00
|
|
|
void lineposition(int, Fl_Line_Position);
|
1999-01-30 03:39:28 +03:00
|
|
|
void topline(int l) { lineposition(l, TOP); }
|
|
|
|
void bottomline(int l) { lineposition(l, BOTTOM); }
|
|
|
|
void middleline(int l) { lineposition(l, MIDDLE); }
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
int select(int, int=1);
|
|
|
|
int selected(int) const ;
|
|
|
|
void show(int n);
|
2000-08-19 21:10:47 +04:00
|
|
|
void show() {Fl_Widget::show();}
|
2002-08-14 20:49:38 +04:00
|
|
|
void hide(int n);
|
1998-11-05 19:04:53 +03:00
|
|
|
void hide() {Fl_Widget::hide();}
|
2002-08-14 20:49:38 +04:00
|
|
|
int visible(int n) const ;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
int value() const ;
|
1998-10-06 22:21:25 +04:00
|
|
|
void value(int v) {select(v);}
|
2002-08-14 20:49:38 +04:00
|
|
|
const char* text(int) const ;
|
|
|
|
void text(int, const char*);
|
|
|
|
void* data(int) const ;
|
|
|
|
void data(int, void* v);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
Fl_Browser(int, int, int, int, const char* = 0);
|
1999-06-20 18:38:12 +04:00
|
|
|
~Fl_Browser() { clear(); }
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
char format_char() const {return format_char_;}
|
|
|
|
void format_char(char c) {format_char_ = c;}
|
|
|
|
char column_char() const {return column_char_;}
|
|
|
|
void column_char(char c) {column_char_ = c;}
|
|
|
|
const int* column_widths() const {return column_widths_;}
|
1998-10-20 01:00:26 +04:00
|
|
|
void column_widths(const int* l) {column_widths_ = l;}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
int displayed(int n) const {return Fl_Browser_::displayed(find_line(n));}
|
2001-11-02 23:59:07 +03:00
|
|
|
void make_visible(int n) {
|
|
|
|
if (n < 1) Fl_Browser_::display(find_line(1));
|
|
|
|
else if (n > lines) Fl_Browser_::display(find_line(lines));
|
|
|
|
else Fl_Browser_::display(find_line(n));
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// for back compatability only:
|
|
|
|
void replace(int a, const char* b) {text(a, b);}
|
2002-08-14 20:49:38 +04:00
|
|
|
void display(int, int=1);
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|