1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxCheckListBox class - a listbox with checkable items
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef __CHECKLST__H_
13 #define __CHECKLST__H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "checklst.h"
19 #if !wxUSE_OWNER_DRAWN
20 #error "wxCheckListBox class requires owner-drawn functionality."
23 class WXDLLEXPORT wxOwnerDrawn
;
24 class WXDLLEXPORT wxCheckListBoxItem
; // fwd decl, defined in checklst.cpp
26 class WXDLLEXPORT wxCheckListBox
: public wxCheckListBoxBase
31 wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
35 const wxString choices
[] = NULL
,
37 const wxValidator
& validator
= wxDefaultValidator
,
38 const wxString
& name
= wxListBoxNameStr
);
39 wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
42 const wxArrayString
& choices
,
44 const wxValidator
& validator
= wxDefaultValidator
,
45 const wxString
& name
= wxListBoxNameStr
);
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
,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxListBoxNameStr
);
54 bool Create(wxWindow
*parent
, wxWindowID id
,
57 const wxArrayString
& choices
,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxListBoxNameStr
);
62 // override base class virtuals
63 virtual void Delete(int n
);
65 virtual bool SetFont( const wxFont
&font
);
67 // items may be checked
68 virtual bool IsChecked(size_t uiIndex
) const;
69 virtual void Check(size_t uiIndex
, bool bCheck
= TRUE
);
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
); }
76 size_t GetItemHeight() const { return m_nItemHeight
; }
79 // we create our items ourselves and they have non-standard size,
80 // so we need to override these functions
81 virtual wxOwnerDrawn
*CreateLboxItem(size_t n
);
82 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
84 // this can't be called DoHitTest() because wxWindow already has this method
85 int DoHitTestItem(wxCoord x
, wxCoord y
) const;
87 // pressing space or clicking the check box toggles the item
88 void OnKeyDown(wxKeyEvent
& event
);
89 void OnLeftClick(wxMouseEvent
& event
);
92 size_t m_nItemHeight
; // height of checklistbox items (the same for all)
95 DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox
)