]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/checklst.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / msw / checklst.h
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
11 #ifndef __CHECKLST__H_
12 #define __CHECKLST__H_
13
14 #if !wxUSE_OWNER_DRAWN
15 #error "wxCheckListBox class requires owner-drawn functionality."
16 #endif
17
18 class WXDLLIMPEXP_FWD_CORE wxOwnerDrawn;
19 class WXDLLIMPEXP_FWD_CORE wxCheckListBoxItem; // fwd decl, defined in checklst.cpp
20
21 class WXDLLIMPEXP_CORE wxCheckListBox : public wxCheckListBoxBase
22 {
23 public:
24 // ctors
25 wxCheckListBox();
26 wxCheckListBox(wxWindow *parent, wxWindowID id,
27 const wxPoint& pos = wxDefaultPosition,
28 const wxSize& size = wxDefaultSize,
29 int nStrings = 0,
30 const wxString choices[] = NULL,
31 long style = 0,
32 const wxValidator& validator = wxDefaultValidator,
33 const wxString& name = wxListBoxNameStr);
34 wxCheckListBox(wxWindow *parent, wxWindowID id,
35 const wxPoint& pos,
36 const wxSize& size,
37 const wxArrayString& choices,
38 long style = 0,
39 const wxValidator& validator = wxDefaultValidator,
40 const wxString& name = wxListBoxNameStr);
41
42 bool Create(wxWindow *parent, wxWindowID id,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 int n = 0, const wxString choices[] = NULL,
46 long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxListBoxNameStr);
49 bool Create(wxWindow *parent, wxWindowID id,
50 const wxPoint& pos,
51 const wxSize& size,
52 const wxArrayString& choices,
53 long style = 0,
54 const wxValidator& validator = wxDefaultValidator,
55 const wxString& name = wxListBoxNameStr);
56
57 // items may be checked
58 virtual bool IsChecked(unsigned int uiIndex) const;
59 virtual void Check(unsigned int uiIndex, bool bCheck = true);
60 virtual void Toggle(unsigned int uiIndex);
61
62 // we create our items ourselves and they have non-standard size,
63 // so we need to override these functions
64 virtual wxOwnerDrawn *CreateLboxItem(size_t n);
65 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
66
67 protected:
68 // pressing space or clicking the check box toggles the item
69 void OnKeyDown(wxKeyEvent& event);
70 void OnLeftClick(wxMouseEvent& event);
71
72 // send an "item checked" event
73 void SendEvent(unsigned int uiIndex)
74 {
75 wxCommandEvent event(wxEVT_CHECKLISTBOX, GetId());
76 event.SetInt(uiIndex);
77 event.SetEventObject(this);
78 event.SetString(GetString(uiIndex));
79 ProcessCommand(event);
80 }
81
82 wxSize DoGetBestClientSize() const;
83
84 DECLARE_EVENT_TABLE()
85 DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox)
86 };
87
88 #endif //_CHECKLST_H