2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
// Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2020-09-06 21:02:02 +03:00
|
|
|
// Copyright 1998-2020 by Bill Spitzak and others.
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// 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:
|
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/COPYING.php
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// Please see the following page on how to report bugs and issues:
|
2005-04-16 04:13:17 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/bugs.php
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Check_Browser widget . */
|
|
|
|
|
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
|
|
|
|
2019-02-02 18:24:10 +03:00
|
|
|
protected:
|
|
|
|
/* 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;
|
2020-09-06 21:02:02 +03:00
|
|
|
const char *item_text(void *item) const; // override
|
2019-02-02 18:28:18 +03:00
|
|
|
|
|
|
|
public:
|
2020-09-06 21:02:02 +03:00
|
|
|
void *item_at(int index) const; // override
|
|
|
|
void item_swap(int ia, int ib); // override
|
|
|
|
void item_swap(void *a, void *b); // override
|
2001-08-11 18:49:51 +04:00
|
|
|
|
|
|
|
/* private data */
|
|
|
|
|
2020-09-06 21:02:02 +03:00
|
|
|
public: // IRIX 5.3 C++ compiler doesn't support private structures...
|
2001-11-01 21:53:46 +03:00
|
|
|
|
2008-09-21 17:24:00 +04:00
|
|
|
#ifndef FL_DOXYGEN
|
2008-09-21 12:00:32 +04:00
|
|
|
/** For internal use only. */
|
2001-08-11 18:49:51 +04:00
|
|
|
struct cb_item {
|
2020-09-06 21:02:02 +03:00
|
|
|
cb_item *next; /**< For internal use only. */
|
|
|
|
cb_item *prev; /**< For internal use only. */
|
|
|
|
char checked; /**< For internal use only. */
|
|
|
|
char selected; /**< For internal use only. */
|
|
|
|
char *text; /**< For internal use only. */
|
2001-08-11 18:49:51 +04:00
|
|
|
};
|
2008-09-21 17:24:00 +04:00
|
|
|
#endif // !FL_DOXYGEN
|
2001-08-11 18:49:51 +04:00
|
|
|
|
2020-09-06 21:02:02 +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
|
|
|
|
2020-09-06 21:02:02 +03: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);
|
2020-09-06 21:02:02 +03: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
|
2020-07-01 19:03:10 +03: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...
|
2020-09-06 21:02:02 +03: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_; }
|
2020-09-06 21:02:02 +03: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);
|
2020-09-06 21:02:02 +03: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
|
|
|
|
2020-09-06 21:02:02 +03:00
|
|
|
protected:
|
2006-04-20 07:53:41 +04:00
|
|
|
int handle(int);
|
2001-08-11 18:49:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // Fl_Check_Browser_H
|