1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/checklst.h
3 // Purpose: wxCheckListBox class - a listbox with checkable items
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef __CHECKLST__H_
12 #define __CHECKLST__H_
14 #if !wxUSE_OWNER_DRAWN
15 #error "wxCheckListBox class requires owner-drawn functionality."
18 class WXDLLIMPEXP_FWD_CORE wxOwnerDrawn
;
19 class WXDLLIMPEXP_FWD_CORE wxCheckListBoxItem
; // fwd decl, defined in checklst.cpp
21 class WXDLLIMPEXP_CORE wxCheckListBox
: public wxCheckListBoxBase
26 wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
27 const wxPoint
& pos
= wxDefaultPosition
,
28 const wxSize
& size
= wxDefaultSize
,
30 const wxString choices
[] = NULL
,
32 const wxValidator
& validator
= wxDefaultValidator
,
33 const wxString
& name
= wxListBoxNameStr
);
34 wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
37 const wxArrayString
& choices
,
39 const wxValidator
& validator
= wxDefaultValidator
,
40 const wxString
& name
= wxListBoxNameStr
);
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
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxListBoxNameStr
);
49 bool Create(wxWindow
*parent
, wxWindowID id
,
52 const wxArrayString
& choices
,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxListBoxNameStr
);
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
);
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
);
68 // pressing space or clicking the check box toggles the item
69 void OnKeyDown(wxKeyEvent
& event
);
70 void OnLeftClick(wxMouseEvent
& event
);
72 // send an "item checked" event
73 void SendEvent(unsigned int uiIndex
)
75 wxCommandEvent
event(wxEVT_CHECKLISTBOX
, GetId());
76 event
.SetInt(uiIndex
);
77 event
.SetEventObject(this);
78 event
.SetString(GetString(uiIndex
));
79 ProcessCommand(event
);
82 wxSize
DoGetBestClientSize() const;
85 DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox
)