checklst.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/univ/checklst.h
  3. // Purpose: wxCheckListBox class for wxUniversal
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 12.09.00
  7. // Copyright: (c) Vadim Zeitlin
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_UNIV_CHECKLST_H_
  11. #define _WX_UNIV_CHECKLST_H_
  12. // ----------------------------------------------------------------------------
  13. // actions
  14. // ----------------------------------------------------------------------------
  15. #define wxACTION_CHECKLISTBOX_TOGGLE wxT("toggle")
  16. // ----------------------------------------------------------------------------
  17. // wxCheckListBox
  18. // ----------------------------------------------------------------------------
  19. class WXDLLIMPEXP_CORE wxCheckListBox : public wxCheckListBoxBase
  20. {
  21. public:
  22. // ctors
  23. wxCheckListBox() { Init(); }
  24. wxCheckListBox(wxWindow *parent,
  25. wxWindowID id,
  26. const wxPoint& pos = wxDefaultPosition,
  27. const wxSize& size = wxDefaultSize,
  28. int nStrings = 0,
  29. const wxString choices[] = NULL,
  30. long style = 0,
  31. const wxValidator& validator = wxDefaultValidator,
  32. const wxString& name = wxListBoxNameStr)
  33. {
  34. Init();
  35. Create(parent, id, pos, size, nStrings, choices, style, validator, name);
  36. }
  37. wxCheckListBox(wxWindow *parent,
  38. wxWindowID id,
  39. const wxPoint& pos,
  40. const wxSize& size,
  41. const wxArrayString& choices,
  42. long style = 0,
  43. const wxValidator& validator = wxDefaultValidator,
  44. const wxString& name = wxListBoxNameStr);
  45. bool Create(wxWindow *parent,
  46. wxWindowID id,
  47. const wxPoint& pos = wxDefaultPosition,
  48. const wxSize& size = wxDefaultSize,
  49. int nStrings = 0,
  50. const wxString choices[] = (const wxString *) NULL,
  51. long style = 0,
  52. const wxValidator& validator = wxDefaultValidator,
  53. const wxString& name = wxListBoxNameStr);
  54. bool Create(wxWindow *parent,
  55. wxWindowID id,
  56. const wxPoint& pos,
  57. const wxSize& size,
  58. const wxArrayString& choices,
  59. long style = 0,
  60. const wxValidator& validator = wxDefaultValidator,
  61. const wxString& name = wxListBoxNameStr);
  62. // implement check list box methods
  63. virtual bool IsChecked(unsigned int item) const;
  64. virtual void Check(unsigned int item, bool check = true);
  65. // and input handling
  66. virtual bool PerformAction(const wxControlAction& action,
  67. long numArg = -1l,
  68. const wxString& strArg = wxEmptyString);
  69. static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
  70. virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
  71. {
  72. return GetStdInputHandler(handlerDef);
  73. }
  74. protected:
  75. // override all methods which add/delete items to update m_checks array as
  76. // well
  77. virtual void OnItemInserted(unsigned int pos);
  78. virtual void DoDeleteOneItem(unsigned int n);
  79. virtual void DoClear();
  80. // draw the check items instead of the usual ones
  81. virtual void DoDrawRange(wxControlRenderer *renderer,
  82. int itemFirst, int itemLast);
  83. // take them also into account for size calculation
  84. virtual wxSize DoGetBestClientSize() const;
  85. // common part of all ctors
  86. void Init();
  87. private:
  88. // the array containing the checked status of the items
  89. wxArrayInt m_checks;
  90. DECLARE_DYNAMIC_CLASS(wxCheckListBox)
  91. };
  92. #endif // _WX_UNIV_CHECKLST_H_