2001-08-11 18:49:51 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
// Fl_Check_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.
|
2001-08-11 18:49:51 +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
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Fl_Check_Browser_H
|
|
|
|
#define Fl_Check_Browser_H
|
|
|
|
|
|
|
|
#include "Fl.H"
|
|
|
|
#include "Fl_Browser_.H"
|
|
|
|
|
2008-09-14 16:45:42 +04:00
|
|
|
/**
|
|
|
|
The Fl_Check_Browser widget displays a scrolling list of text
|
|
|
|
lines that may be selected and/or checked by the user.
|
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
|
2001-08-11 18:49:51 +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_height(void *) const;
|
|
|
|
int item_width(void *) const;
|
|
|
|
void item_draw(void *, int, int, int, int) const;
|
|
|
|
void item_select(void *, int);
|
|
|
|
int item_selected(void *) const;
|
2001-08-11 18:49:51 +04:00
|
|
|
|
|
|
|
/* private data */
|
|
|
|
|
2001-11-01 21:53:46 +03:00
|
|
|
public: // IRIX 5.3 C++ compiler doesn't support private structures...
|
|
|
|
|
2001-08-11 18:49:51 +04:00
|
|
|
struct cb_item {
|
|
|
|
cb_item *next;
|
|
|
|
cb_item *prev;
|
|
|
|
char checked;
|
|
|
|
char selected;
|
|
|
|
char *text;
|
|
|
|
};
|
|
|
|
|
2001-11-01 21:53:46 +03:00
|
|
|
private:
|
|
|
|
|
2001-08-11 18:49:51 +04:00
|
|
|
cb_item *first;
|
|
|
|
cb_item *last;
|
|
|
|
cb_item *cache;
|
|
|
|
int cached_item;
|
|
|
|
int nitems_;
|
|
|
|
int nchecked_;
|
2002-08-14 20:49:38 +04:00
|
|
|
cb_item *find_item(int) const;
|
|
|
|
int lineno(cb_item *) const;
|
2001-08-11 18:49:51 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0);
|
2008-09-14 16:45:42 +04:00
|
|
|
/** The destructor deletes all list items and destroys the browser. */
|
2005-08-05 17:31:02 +04:00
|
|
|
~Fl_Check_Browser() { clear(); }
|
2002-08-14 20:49:38 +04:00
|
|
|
int add(char *s); // add an (unchecked) item
|
|
|
|
int add(char *s, int b); // add an item and set checked
|
2001-08-11 18:49:51 +04:00
|
|
|
// both return the new nitems()
|
2007-11-19 18:46:24 +03:00
|
|
|
int remove(int item); // delete an item. Returns nitems()
|
2002-11-15 00:05:22 +03:00
|
|
|
|
|
|
|
// inline const char * methods to avoid breaking binary compatibility...
|
2008-09-14 16:45:42 +04:00
|
|
|
/** See int Fl_Check_Browser::add(char *s) */
|
2002-11-15 00:05:22 +03:00
|
|
|
int add(const char *s) { return add((char *)s); }
|
2008-09-14 16:45:42 +04:00
|
|
|
/** See int Fl_Check_Browser::add(char *s) */
|
2002-11-15 00:05:22 +03:00
|
|
|
int add(const char *s, int b) { return add((char *)s, b); }
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
void clear(); // delete all items
|
2008-09-14 16:45:42 +04:00
|
|
|
/**
|
|
|
|
Returns how many lines are in the browser. The last line number is equal to
|
|
|
|
this.
|
|
|
|
*/
|
2001-08-11 18:49:51 +04:00
|
|
|
int nitems() const { return nitems_; }
|
2008-09-14 16:45:42 +04:00
|
|
|
/** Returns how many items are currently checked. */
|
2001-08-11 18:49:51 +04:00
|
|
|
int nchecked() const { return nchecked_; }
|
2002-08-14 20:49:38 +04:00
|
|
|
int checked(int item) const;
|
|
|
|
void checked(int item, int b);
|
2008-09-14 16:45:42 +04:00
|
|
|
/** Equivalent to Fl_Check_Browser::checked(item, 1). */
|
2001-08-11 18:49:51 +04:00
|
|
|
void set_checked(int item) { checked(item, 1); }
|
2002-08-14 20:49:38 +04:00
|
|
|
void check_all();
|
|
|
|
void check_none();
|
|
|
|
int value() const; // currently selected item
|
|
|
|
char *text(int item) const; // returns pointer to internal buffer
|
2006-04-20 07:53:41 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
int handle(int);
|
2001-08-11 18:49:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // Fl_Check_Browser_H
|
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
|