]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: checklst.h | |
3 | // Purpose: wxCheckListBox class - a listbox with checkable items | |
4 | // Author: Vadim Zeitlin | |
0c35333e | 5 | // Modified by: |
2bda0e17 KB |
6 | // Created: 16.11.97 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
bbcdf8bc | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef __CHECKLST__H_ |
13 | #define __CHECKLST__H_ | |
2bda0e17 | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
0d3820b3 JS |
16 | #pragma interface "checklst.h" |
17 | #endif | |
18 | ||
f97c9854 | 19 | #if !wxUSE_OWNER_DRAWN |
2bda0e17 KB |
20 | #error "wxCheckListBox class requires owner-drawn functionality." |
21 | #endif | |
22 | ||
d90879fa VZ |
23 | class WXDLLEXPORT wxOwnerDrawn; |
24 | class WXDLLEXPORT wxCheckListBoxItem; // fwd decl, defined in checklst.cpp | |
2bda0e17 | 25 | |
d90879fa | 26 | class WXDLLEXPORT wxCheckListBox : public wxCheckListBoxBase |
2bda0e17 | 27 | { |
2bda0e17 KB |
28 | public: |
29 | // ctors | |
30 | wxCheckListBox(); | |
debe6624 | 31 | wxCheckListBox(wxWindow *parent, wxWindowID id, |
2bda0e17 KB |
32 | const wxPoint& pos = wxDefaultPosition, |
33 | const wxSize& size = wxDefaultSize, | |
0c35333e | 34 | int nStrings = 0, |
2bda0e17 | 35 | const wxString choices[] = NULL, |
debe6624 | 36 | long style = 0, |
2bda0e17 KB |
37 | const wxValidator& validator = wxDefaultValidator, |
38 | const wxString& name = wxListBoxNameStr); | |
584ad2a3 MB |
39 | wxCheckListBox(wxWindow *parent, wxWindowID id, |
40 | const wxPoint& pos, | |
41 | const wxSize& size, | |
42 | const wxArrayString& choices, | |
43 | long style = 0, | |
44 | const wxValidator& validator = wxDefaultValidator, | |
45 | const wxString& name = wxListBoxNameStr); | |
dd3c394a | 46 | |
799cea00 VS |
47 | bool Create(wxWindow *parent, wxWindowID id, |
48 | const wxPoint& pos = wxDefaultPosition, | |
49 | const wxSize& size = wxDefaultSize, | |
50 | int n = 0, const wxString choices[] = NULL, | |
51 | long style = 0, | |
52 | const wxValidator& validator = wxDefaultValidator, | |
53 | const wxString& name = wxListBoxNameStr); | |
584ad2a3 MB |
54 | bool Create(wxWindow *parent, wxWindowID id, |
55 | const wxPoint& pos, | |
56 | const wxSize& size, | |
57 | const wxArrayString& choices, | |
58 | long style = 0, | |
59 | const wxValidator& validator = wxDefaultValidator, | |
60 | const wxString& name = wxListBoxNameStr); | |
799cea00 | 61 | |
dd3c394a VZ |
62 | // override base class virtuals |
63 | virtual void Delete(int n); | |
2bda0e17 | 64 | |
0c35333e RD |
65 | virtual bool SetFont( const wxFont &font ); |
66 | ||
2bda0e17 | 67 | // items may be checked |
d90879fa VZ |
68 | virtual bool IsChecked(size_t uiIndex) const; |
69 | virtual void Check(size_t uiIndex, bool bCheck = TRUE); | |
2bda0e17 | 70 | |
15c3723c VZ |
71 | // return the index of the item at this position or wxNOT_FOUND |
72 | int HitTest(const wxPoint& pt) const { return DoHitTestItem(pt.x, pt.y); } | |
73 | int HitTest(wxCoord x, wxCoord y) const { return DoHitTestItem(x, y); } | |
74 | ||
2bda0e17 | 75 | // accessors |
dd3c394a | 76 | size_t GetItemHeight() const { return m_nItemHeight; } |
2bda0e17 KB |
77 | |
78 | protected: | |
79 | // we create our items ourselves and they have non-standard size, | |
80 | // so we need to override these functions | |
2b5f62a0 | 81 | virtual wxOwnerDrawn *CreateLboxItem(size_t n); |
2bda0e17 KB |
82 | virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); |
83 | ||
15c3723c VZ |
84 | // this can't be called DoHitTest() because wxWindow already has this method |
85 | int DoHitTestItem(wxCoord x, wxCoord y) const; | |
86 | ||
2bda0e17 | 87 | // pressing space or clicking the check box toggles the item |
d90879fa | 88 | void OnKeyDown(wxKeyEvent& event); |
2bda0e17 KB |
89 | void OnLeftClick(wxMouseEvent& event); |
90 | ||
91 | private: | |
3cda6353 | 92 | size_t m_nItemHeight; // height of checklistbox items (the same for all) |
2bda0e17 KB |
93 | |
94 | DECLARE_EVENT_TABLE() | |
fc7a2a60 | 95 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox) |
2bda0e17 KB |
96 | }; |
97 | ||
98 | #endif //_CHECKLST_H |