Fl_Check_Browser.H 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // "$Id: Fl_Check_Browser.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
  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. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. /* \file
  19. Fl_Check_Browser widget . */
  20. #ifndef Fl_Check_Browser_H
  21. #define Fl_Check_Browser_H
  22. #include "Fl.H"
  23. #include "Fl_Browser_.H"
  24. /**
  25. The Fl_Check_Browser widget displays a scrolling list of text
  26. lines that may be selected and/or checked by the user.
  27. */
  28. class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
  29. /* required routines for Fl_Browser_ subclass: */
  30. void *item_first() const;
  31. void *item_next(void *) const;
  32. void *item_prev(void *) const;
  33. int item_height(void *) const;
  34. int item_width(void *) const;
  35. void item_draw(void *, int, int, int, int) const;
  36. void item_select(void *, int);
  37. int item_selected(void *) const;
  38. /* private data */
  39. public: // IRIX 5.3 C++ compiler doesn't support private structures...
  40. #ifndef FL_DOXYGEN
  41. /** For internal use only. */
  42. struct cb_item {
  43. cb_item *next; /**< For internal use only. */
  44. cb_item *prev; /**< For internal use only. */
  45. char checked; /**< For internal use only. */
  46. char selected; /**< For internal use only. */
  47. char *text; /**< For internal use only. */
  48. };
  49. #endif // !FL_DOXYGEN
  50. private:
  51. cb_item *first;
  52. cb_item *last;
  53. cb_item *cache;
  54. int cached_item;
  55. int nitems_;
  56. int nchecked_;
  57. cb_item *find_item(int) const;
  58. int lineno(cb_item *) const;
  59. public:
  60. Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0);
  61. /** The destructor deletes all list items and destroys the browser. */
  62. ~Fl_Check_Browser() { clear(); }
  63. int add(char *s); // add an (unchecked) item
  64. int add(char *s, int b); // add an item and set checked
  65. // both return the new nitems()
  66. int remove(int item); // delete an item. Returns nitems()
  67. // inline const char * methods to avoid breaking binary compatibility...
  68. /** See int Fl_Check_Browser::add(char *s) */
  69. int add(const char *s) { return add((char *)s); }
  70. /** See int Fl_Check_Browser::add(char *s) */
  71. int add(const char *s, int b) { return add((char *)s, b); }
  72. void clear(); // delete all items
  73. /**
  74. Returns how many lines are in the browser. The last line number is equal to
  75. this.
  76. */
  77. int nitems() const { return nitems_; }
  78. /** Returns how many items are currently checked. */
  79. int nchecked() const { return nchecked_; }
  80. int checked(int item) const;
  81. void checked(int item, int b);
  82. /** Equivalent to Fl_Check_Browser::checked(item, 1). */
  83. void set_checked(int item) { checked(item, 1); }
  84. void check_all();
  85. void check_none();
  86. int value() const; // currently selected item
  87. char *text(int item) const; // returns pointer to internal buffer
  88. protected:
  89. int handle(int);
  90. DECLARE_CLASS_CHEAP_RTTI_2(Fl_Check_Browser, Fl_Browser_)
  91. };
  92. #endif // Fl_Check_Browser_H
  93. //
  94. // End of "$Id: Fl_Check_Browser.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
  95. //