You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.7KB

  1. //
  2. // "$Id: Fl_Check_Browser.H 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. /* \file
  28. Fl_Check_Browser widget . */
  29. #ifndef Fl_Check_Browser_H
  30. #define Fl_Check_Browser_H
  31. #include "Fl.H"
  32. #include "Fl_Browser_.H"
  33. /**
  34. The Fl_Check_Browser widget displays a scrolling list of text
  35. lines that may be selected and/or checked by the user.
  36. */
  37. class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
  38. /* required routines for Fl_Browser_ subclass: */
  39. void *item_first() const;
  40. void *item_next(void *) const;
  41. void *item_prev(void *) const;
  42. int item_height(void *) const;
  43. int item_width(void *) const;
  44. void item_draw(void *, int, int, int, int) const;
  45. void item_select(void *, int);
  46. int item_selected(void *) const;
  47. /* private data */
  48. public: // IRIX 5.3 C++ compiler doesn't support private structures...
  49. #ifndef FL_DOXYGEN
  50. /** For internal use only. */
  51. struct cb_item {
  52. cb_item *next; /**< For internal use only. */
  53. cb_item *prev; /**< For internal use only. */
  54. char checked; /**< For internal use only. */
  55. char selected; /**< For internal use only. */
  56. char *text; /**< For internal use only. */
  57. };
  58. #endif // !FL_DOXYGEN
  59. private:
  60. cb_item *first;
  61. cb_item *last;
  62. cb_item *cache;
  63. int cached_item;
  64. int nitems_;
  65. int nchecked_;
  66. cb_item *find_item(int) const;
  67. int lineno(cb_item *) const;
  68. public:
  69. Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0);
  70. /** The destructor deletes all list items and destroys the browser. */
  71. ~Fl_Check_Browser() { clear(); }
  72. int add(char *s); // add an (unchecked) item
  73. int add(char *s, int b); // add an item and set checked
  74. // both return the new nitems()
  75. int remove(int item); // delete an item. Returns nitems()
  76. // inline const char * methods to avoid breaking binary compatibility...
  77. /** See int Fl_Check_Browser::add(char *s) */
  78. int add(const char *s) { return add((char *)s); }
  79. /** See int Fl_Check_Browser::add(char *s) */
  80. int add(const char *s, int b) { return add((char *)s, b); }
  81. void clear(); // delete all items
  82. /**
  83. Returns how many lines are in the browser. The last line number is equal to
  84. this.
  85. */
  86. int nitems() const { return nitems_; }
  87. /** Returns how many items are currently checked. */
  88. int nchecked() const { return nchecked_; }
  89. int checked(int item) const;
  90. void checked(int item, int b);
  91. /** Equivalent to Fl_Check_Browser::checked(item, 1). */
  92. void set_checked(int item) { checked(item, 1); }
  93. void check_all();
  94. void check_none();
  95. int value() const; // currently selected item
  96. char *text(int item) const; // returns pointer to internal buffer
  97. protected:
  98. int handle(int);
  99. };
  100. #endif // Fl_Check_Browser_H
  101. //
  102. // End of "$Id: Fl_Check_Browser.H 7903 2010-11-28 21:06:39Z matt $".
  103. //