1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/checklst.cpp
3 // Purpose: implementation of wxCheckListBox class
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #if wxUSE_CHECKLISTBOX && wxUSE_OWNER_DRAWN
29 #include "wx/checklst.h"
32 #include "wx/object.h"
33 #include "wx/colour.h"
35 #include "wx/bitmap.h"
36 #include "wx/window.h"
37 #include "wx/listbox.h"
38 #include "wx/dcmemory.h"
40 #include "wx/settings.h"
45 #include "wx/ownerdrw.h"
47 #include "wx/palmos/wrapwin.h"
49 #include "wx/palmos/private.h"
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 // get item (converted to right type)
56 #define GetItem(n) ((wxCheckListBoxItem *)(GetItem(n)))
58 // ============================================================================
60 // ============================================================================
62 // ----------------------------------------------------------------------------
63 // declaration and implementation of wxCheckListBoxItem class
64 // ----------------------------------------------------------------------------
66 class wxCheckListBoxItem
: public wxOwnerDrawn
68 friend class WXDLLEXPORT wxCheckListBox
;
71 wxCheckListBoxItem(wxCheckListBox
*pParent
, size_t nIndex
);
74 virtual bool OnDrawItem(wxDC
& dc
, const wxRect
& rc
, wxODAction act
, wxODStatus stat
);
76 // simple accessors and operations
77 bool IsChecked() const { return m_bChecked
; }
79 void Check(bool bCheck
);
80 void Toggle() { Check(!IsChecked()); }
86 wxDECLARE_NO_COPY_CLASS(wxCheckListBoxItem
);
88 wxCheckListBox
*m_pParent
;
92 wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox
*pParent
, size_t nIndex
)
93 : wxOwnerDrawn(wxEmptyString
, true) // checkable
97 bool wxCheckListBoxItem::OnDrawItem(wxDC
& dc
, const wxRect
& rc
,
98 wxODAction act
, wxODStatus stat
)
103 // change the state of the item and redraw it
104 void wxCheckListBoxItem::Check(bool check
)
108 // send an "item checked" event
109 void wxCheckListBoxItem::SendEvent()
113 // ----------------------------------------------------------------------------
114 // implementation of wxCheckListBox class
115 // ----------------------------------------------------------------------------
117 // define event table
118 // ------------------
119 BEGIN_EVENT_TABLE(wxCheckListBox
, wxListBox
)
120 EVT_KEY_DOWN(wxCheckListBox::OnKeyDown
)
121 EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick
)
127 // def ctor: use Create() to really create the control
128 wxCheckListBox::wxCheckListBox()
132 // ctor which creates the associated control
133 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
134 const wxPoint
& pos
, const wxSize
& size
,
135 int nStrings
, const wxString choices
[],
136 long style
, const wxValidator
& val
,
137 const wxString
& name
)
139 Create(parent
, id
, pos
, size
, nStrings
, choices
, style
, val
, name
);
142 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
143 const wxPoint
& pos
, const wxSize
& size
,
144 const wxArrayString
& choices
,
145 long style
, const wxValidator
& val
,
146 const wxString
& name
)
148 Create(parent
, id
, pos
, size
, choices
, style
, val
, name
);
151 bool wxCheckListBox::Create(wxWindow
*parent
, wxWindowID id
,
152 const wxPoint
& pos
, const wxSize
& size
,
153 int n
, const wxString choices
[],
155 const wxValidator
& validator
, const wxString
& name
)
157 return wxListBox::Create(parent
, id
, pos
, size
, n
, choices
,
158 style
| wxLB_OWNERDRAW
, validator
, name
);
161 bool wxCheckListBox::Create(wxWindow
*parent
, wxWindowID id
,
162 const wxPoint
& pos
, const wxSize
& size
,
163 const wxArrayString
& choices
,
165 const wxValidator
& validator
, const wxString
& name
)
167 return wxListBox::Create(parent
, id
, pos
, size
, choices
,
168 style
| wxLB_OWNERDRAW
, validator
, name
);
171 // misc overloaded methods
172 // -----------------------
174 void wxCheckListBox::Delete(unsigned int n
)
178 bool wxCheckListBox::SetFont( const wxFont
&font
)
183 // create/retrieve item
184 // --------------------
186 // create a check list box item
187 wxOwnerDrawn
*wxCheckListBox::CreateLboxItem(size_t nIndex
)
189 wxCheckListBoxItem
*pItem
= new wxCheckListBoxItem(this, nIndex
);
195 bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
)
203 bool wxCheckListBox::IsChecked(unsigned int uiIndex
) const
208 void wxCheckListBox::Check(unsigned int uiIndex
, bool bCheck
)
215 void wxCheckListBox::OnKeyDown(wxKeyEvent
& event
)
219 void wxCheckListBox::OnLeftClick(wxMouseEvent
& event
)
223 int wxCheckListBox::DoHitTestItem(wxCoord x
, wxCoord y
) const
228 #endif // wxUSE_CHECKLISTBOX && wxUSE_OWNER_DRAWN