| 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: checklst.h |
| 3 | // Purpose: wxCheckListBox class - a listbox with checkable items |
| 4 | // Note: this is an optional class. |
| 5 | // Author: Stefan Csomor |
| 6 | // Modified by: |
| 7 | // Created: 1998-01-01 |
| 8 | // RCS-ID: $Id$ |
| 9 | // Copyright: (c) Stefan Csomor |
| 10 | // Licence: wxWindows licence |
| 11 | /////////////////////////////////////////////////////////////////////////////// |
| 12 | |
| 13 | #ifndef _WX_CHECKLST_H_ |
| 14 | #define _WX_CHECKLST_H_ |
| 15 | |
| 16 | #if !defined(__MWERKS__) && !defined(__UNIX__) |
| 17 | typedef unsigned int size_t; |
| 18 | #endif |
| 19 | |
| 20 | class WXDLLEXPORT wxCheckListBox : public wxCheckListBoxBase |
| 21 | { |
| 22 | DECLARE_DYNAMIC_CLASS(wxCheckListBox) |
| 23 | public: |
| 24 | // ctors |
| 25 | wxCheckListBox() { Init(); } |
| 26 | wxCheckListBox(wxWindow *parent, |
| 27 | wxWindowID id, |
| 28 | const wxPoint& pos = wxDefaultPosition, |
| 29 | const wxSize& size = wxDefaultSize, |
| 30 | int nStrings = 0, |
| 31 | const wxString *choices = NULL, |
| 32 | long style = 0, |
| 33 | const wxValidator& validator = wxDefaultValidator, |
| 34 | const wxString& name = wxListBoxNameStr) |
| 35 | { |
| 36 | Init(); |
| 37 | |
| 38 | Create(parent, id, pos, size, nStrings, choices, style, validator, name); |
| 39 | } |
| 40 | wxCheckListBox(wxWindow *parent, |
| 41 | wxWindowID id, |
| 42 | const wxPoint& pos, |
| 43 | const wxSize& size, |
| 44 | const wxArrayString& choices, |
| 45 | long style = 0, |
| 46 | const wxValidator& validator = wxDefaultValidator, |
| 47 | const wxString& name = wxListBoxNameStr) |
| 48 | { |
| 49 | Init(); |
| 50 | |
| 51 | Create(parent, id, pos, size, choices, style, validator, name); |
| 52 | } |
| 53 | |
| 54 | bool Create(wxWindow *parent, |
| 55 | wxWindowID id, |
| 56 | const wxPoint& pos = wxDefaultPosition, |
| 57 | const wxSize& size = wxDefaultSize, |
| 58 | int nStrings = 0, |
| 59 | const wxString *choices = NULL, |
| 60 | long style = 0, |
| 61 | const wxValidator& validator = wxDefaultValidator, |
| 62 | const wxString& name = wxListBoxNameStr); |
| 63 | bool Create(wxWindow *parent, |
| 64 | wxWindowID id, |
| 65 | const wxPoint& pos, |
| 66 | const wxSize& size, |
| 67 | const wxArrayString& choices, |
| 68 | long style = 0, |
| 69 | const wxValidator& validator = wxDefaultValidator, |
| 70 | const wxString& name = wxListBoxNameStr); |
| 71 | |
| 72 | // items may be checked |
| 73 | bool IsChecked(size_t uiIndex) const; |
| 74 | void Check(size_t uiIndex, bool bCheck = TRUE); |
| 75 | void OnChar(wxKeyEvent& event) ; |
| 76 | void OnLeftClick(wxMouseEvent& event) ; |
| 77 | |
| 78 | // metrics |
| 79 | wxInt32 m_checkBoxWidth; |
| 80 | wxInt32 m_checkBoxHeight; |
| 81 | wxInt32 m_TextBaseLineOffset; |
| 82 | |
| 83 | // the array containing the checked status of the items |
| 84 | wxArrayInt m_checks; |
| 85 | |
| 86 | // override all methods which add/delete items to update m_checks array as |
| 87 | // well |
| 88 | virtual void Delete(int n); |
| 89 | protected: |
| 90 | virtual int DoAppend(const wxString& item); |
| 91 | virtual void DoInsertItems(const wxArrayString& items, int pos); |
| 92 | virtual void DoSetItems(const wxArrayString& items, void **clientData); |
| 93 | virtual void DoClear(); |
| 94 | // common part of all ctors |
| 95 | void Init(); |
| 96 | private: |
| 97 | DECLARE_EVENT_TABLE() |
| 98 | }; |
| 99 | |
| 100 | #endif |
| 101 | // _WX_CHECKLST_H_ |