1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/checklst.h
3 // Purpose: wxCheckListBox class - a listbox with checkable items
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef __CHECKLST__H_
13 #define __CHECKLST__H_
15 #if !wxUSE_OWNER_DRAWN
16 #error "wxCheckListBox class requires owner-drawn functionality."
19 class WXDLLIMPEXP_FWD_CORE wxOwnerDrawn
;
20 class WXDLLIMPEXP_FWD_CORE wxCheckListBoxItem
; // fwd decl, defined in checklst.cpp
22 class WXDLLEXPORT wxCheckListBox
: public wxCheckListBoxBase
27 wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
31 const wxString choices
[] = NULL
,
33 const wxValidator
& validator
= wxDefaultValidator
,
34 const wxString
& name
= wxListBoxNameStr
);
35 wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
38 const wxArrayString
& choices
,
40 const wxValidator
& validator
= wxDefaultValidator
,
41 const wxString
& name
= wxListBoxNameStr
);
43 bool Create(wxWindow
*parent
, wxWindowID id
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
46 int n
= 0, const wxString choices
[] = NULL
,
48 const wxValidator
& validator
= wxDefaultValidator
,
49 const wxString
& name
= wxListBoxNameStr
);
50 bool Create(wxWindow
*parent
, wxWindowID id
,
53 const wxArrayString
& choices
,
55 const wxValidator
& validator
= wxDefaultValidator
,
56 const wxString
& name
= wxListBoxNameStr
);
58 // override base class virtuals
59 virtual void Delete(unsigned int n
);
61 virtual bool SetFont( const wxFont
&font
);
63 // items may be checked
64 virtual bool IsChecked(unsigned int uiIndex
) const;
65 virtual void Check(unsigned int uiIndex
, bool bCheck
= true);
67 // return the index of the item at this position or wxNOT_FOUND
68 int HitTest(const wxPoint
& pt
) const { return DoHitTestItem(pt
.x
, pt
.y
); }
69 int HitTest(wxCoord x
, wxCoord y
) const { return DoHitTestItem(x
, y
); }
72 size_t GetItemHeight() const { return m_nItemHeight
; }
75 // we create our items ourselves and they have non-standard size,
76 // so we need to override these functions
77 virtual wxOwnerDrawn
*CreateLboxItem(size_t n
);
78 virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
80 // this can't be called DoHitTest() because wxWindow already has this method
81 int DoHitTestItem(wxCoord x
, wxCoord y
) const;
83 // pressing space or clicking the check box toggles the item
84 void OnKeyDown(wxKeyEvent
& event
);
85 void OnLeftClick(wxMouseEvent
& event
);
88 size_t m_nItemHeight
; // height of checklistbox items (the same for all)
91 DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckListBox
)