checklst.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/checklst.h
  3. // Purpose: wxCheckListBox class - a listbox with checkable items
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 16.11.97
  7. // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef __CHECKLST__H_
  11. #define __CHECKLST__H_
  12. #if !wxUSE_OWNER_DRAWN
  13. #error "wxCheckListBox class requires owner-drawn functionality."
  14. #endif
  15. class WXDLLIMPEXP_FWD_CORE wxOwnerDrawn;
  16. class WXDLLIMPEXP_FWD_CORE wxCheckListBoxItem; // fwd decl, defined in checklst.cpp
  17. class WXDLLIMPEXP_CORE wxCheckListBox : public wxCheckListBoxBase
  18. {
  19. public:
  20. // ctors
  21. wxCheckListBox();
  22. wxCheckListBox(wxWindow *parent, wxWindowID id,
  23. const wxPoint& pos = wxDefaultPosition,
  24. const wxSize& size = wxDefaultSize,
  25. int nStrings = 0,
  26. const wxString choices[] = NULL,
  27. long style = 0,
  28. const wxValidator& validator = wxDefaultValidator,
  29. const wxString& name = wxListBoxNameStr);
  30. wxCheckListBox(wxWindow *parent, wxWindowID id,
  31. const wxPoint& pos,
  32. const wxSize& size,
  33. const wxArrayString& choices,
  34. long style = 0,
  35. const wxValidator& validator = wxDefaultValidator,
  36. const wxString& name = wxListBoxNameStr);
  37. bool Create(wxWindow *parent, wxWindowID id,
  38. const wxPoint& pos = wxDefaultPosition,
  39. const wxSize& size = wxDefaultSize,
  40. int n = 0, const wxString choices[] = NULL,
  41. long style = 0,
  42. const wxValidator& validator = wxDefaultValidator,
  43. const wxString& name = wxListBoxNameStr);
  44. bool Create(wxWindow *parent, wxWindowID id,
  45. const wxPoint& pos,
  46. const wxSize& size,
  47. const wxArrayString& choices,
  48. long style = 0,
  49. const wxValidator& validator = wxDefaultValidator,
  50. const wxString& name = wxListBoxNameStr);
  51. // items may be checked
  52. virtual bool IsChecked(unsigned int uiIndex) const;
  53. virtual void Check(unsigned int uiIndex, bool bCheck = true);
  54. virtual void Toggle(unsigned int uiIndex);
  55. // we create our items ourselves and they have non-standard size,
  56. // so we need to override these functions
  57. virtual wxOwnerDrawn *CreateLboxItem(size_t n);
  58. virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
  59. protected:
  60. // pressing space or clicking the check box toggles the item
  61. void OnKeyDown(wxKeyEvent& event);
  62. void OnLeftClick(wxMouseEvent& event);
  63. // send an "item checked" event
  64. void SendEvent(unsigned int uiIndex)
  65. {
  66. wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
  67. event.SetInt(uiIndex);
  68. event.SetEventObject(this);
  69. event.SetString(GetString(uiIndex));
  70. ProcessCommand(event);
  71. }
  72. wxSize DoGetBestClientSize() const;
  73. DECLARE_EVENT_TABLE()
  74. DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox)
  75. };
  76. #endif //_CHECKLST_H