checklst.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: checklst.h
  3. // Purpose: interface of wxCheckListBox
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxCheckListBox
  9. A wxCheckListBox is like a wxListBox, but allows items to be checked or
  10. unchecked.
  11. When using this class under Windows wxWidgets must be compiled with
  12. wxUSE_OWNER_DRAWN set to 1.
  13. @beginEventEmissionTable{wxCommandEvent}
  14. @event{EVT_CHECKLISTBOX(id, func)}
  15. Process a @c wxEVT_CHECKLISTBOX event, when an item in
  16. the check list box is checked or unchecked. wxCommandEvent::GetInt()
  17. will contain the index of the item that was checked or unchecked.
  18. wxCommandEvent::IsChecked() is not valid! Use wxCheckListBox::IsChecked()
  19. instead.
  20. @endEventTable
  21. @library{wxcore}
  22. @category{ctrl}
  23. @appearance{checklistbox}
  24. @see wxListBox, wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
  25. */
  26. class wxCheckListBox : public wxListBox
  27. {
  28. public:
  29. /**
  30. Default constructor.
  31. */
  32. wxCheckListBox();
  33. //@{
  34. /**
  35. Constructor, creating and showing a list box.
  36. @param parent
  37. Parent window. Must not be @NULL.
  38. @param id
  39. Window identifier. The value wxID_ANY indicates a default value.
  40. @param pos
  41. Window position.
  42. If ::wxDefaultPosition is specified then a default position is chosen.
  43. @param size
  44. Window size.
  45. If ::wxDefaultSize is specified then the window is sized appropriately.
  46. @param n
  47. Number of strings with which to initialise the control.
  48. @param choices
  49. An array of strings with which to initialise the control.
  50. @param style
  51. Window style. See wxCheckListBox.
  52. @param validator
  53. Window validator.
  54. @param name
  55. Window name.
  56. @beginWxPerlOnly
  57. Not supported by wxPerl.
  58. @endWxPerlOnly
  59. */
  60. wxCheckListBox(wxWindow* parent, wxWindowID id,
  61. const wxPoint& pos = wxDefaultPosition,
  62. const wxSize& size = wxDefaultSize,
  63. int n = 0,
  64. const wxString choices[] = NULL,
  65. long style = 0,
  66. const wxValidator& validator = wxDefaultValidator,
  67. const wxString& name = "listBox");
  68. /**
  69. Constructor, creating and showing a list box.
  70. @param parent
  71. Parent window. Must not be @NULL.
  72. @param id
  73. Window identifier. The value wxID_ANY indicates a default value.
  74. @param pos
  75. Window position.
  76. @param size
  77. Window size. If wxDefaultSize is specified then the window is sized
  78. appropriately.
  79. @param choices
  80. An array of strings with which to initialise the control.
  81. @param style
  82. Window style. See wxCheckListBox.
  83. @param validator
  84. Window validator.
  85. @param name
  86. Window name.
  87. @beginWxPerlOnly
  88. Use an array reference for the @a choices parameter.
  89. @endWxPerlOnly
  90. */
  91. wxCheckListBox(wxWindow* parent, wxWindowID id,
  92. const wxPoint& pos,
  93. const wxSize& size,
  94. const wxArrayString& choices,
  95. long style = 0,
  96. const wxValidator& validator = wxDefaultValidator,
  97. const wxString& name = "listBox");
  98. //@}
  99. bool Create(wxWindow *parent,
  100. wxWindowID id,
  101. const wxPoint& pos = wxDefaultPosition,
  102. const wxSize& size = wxDefaultSize,
  103. int nStrings = 0,
  104. const wxString choices[] = NULL,
  105. long style = 0,
  106. const wxValidator& validator = wxDefaultValidator,
  107. const wxString& name = wxListBoxNameStr);
  108. bool Create(wxWindow *parent,
  109. wxWindowID id,
  110. const wxPoint& pos,
  111. const wxSize& size,
  112. const wxArrayString& choices,
  113. long style = 0,
  114. const wxValidator& validator = wxDefaultValidator,
  115. const wxString& name = wxListBoxNameStr);
  116. /**
  117. Destructor, destroying the list box.
  118. */
  119. virtual ~wxCheckListBox();
  120. /**
  121. Checks the given item. Note that calling this method does not result in
  122. a @c wxEVT_CHECKLISTBOX event being emitted.
  123. @param item
  124. Index of item to check.
  125. @param check
  126. @true if the item is to be checked, @false otherwise.
  127. */
  128. void Check(unsigned int item, bool check = true);
  129. /**
  130. Returns @true if the given item is checked, @false otherwise.
  131. @param item
  132. Index of item whose check status is to be returned.
  133. */
  134. bool IsChecked(unsigned int item) const;
  135. /**
  136. Return the indices of the checked items.
  137. @param checkedItems
  138. A reference to the array that is filled with the indices of the
  139. checked items.
  140. @return The number of checked items.
  141. @see Check(), IsChecked()
  142. @since 2.9.5
  143. */
  144. unsigned int GetCheckedItems(wxArrayInt& checkedItems) const;
  145. };