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 // ============================================================================
63 #if wxUSE_EXTENDED_RTTI
64 WX_DEFINE_FLAGS( wxCheckListBoxStyle
)
66 wxBEGIN_FLAGS( wxCheckListBoxStyle
)
67 // new style border flags, we put them first to
68 // use them for streaming out
69 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
70 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
71 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
72 wxFLAGS_MEMBER(wxBORDER_RAISED
)
73 wxFLAGS_MEMBER(wxBORDER_STATIC
)
74 wxFLAGS_MEMBER(wxBORDER_NONE
)
76 // old style border flags
77 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
78 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
79 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
80 wxFLAGS_MEMBER(wxRAISED_BORDER
)
81 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
82 wxFLAGS_MEMBER(wxBORDER
)
84 // standard window styles
85 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
86 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
87 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
88 wxFLAGS_MEMBER(wxWANTS_CHARS
)
89 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
90 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
91 wxFLAGS_MEMBER(wxVSCROLL
)
92 wxFLAGS_MEMBER(wxHSCROLL
)
94 wxFLAGS_MEMBER(wxLB_SINGLE
)
95 wxFLAGS_MEMBER(wxLB_MULTIPLE
)
96 wxFLAGS_MEMBER(wxLB_EXTENDED
)
97 wxFLAGS_MEMBER(wxLB_HSCROLL
)
98 wxFLAGS_MEMBER(wxLB_ALWAYS_SB
)
99 wxFLAGS_MEMBER(wxLB_NEEDED_SB
)
100 wxFLAGS_MEMBER(wxLB_SORT
)
101 wxFLAGS_MEMBER(wxLB_OWNERDRAW
)
103 wxEND_FLAGS( wxCheckListBoxStyle
)
105 IMPLEMENT_DYNAMIC_CLASS_XTI(wxCheckListBox
, wxListBox
,"wx/checklst.h")
107 wxBEGIN_PROPERTIES_TABLE(wxCheckListBox
)
108 wxEVENT_PROPERTY( Toggle
, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, wxCommandEvent
)
109 wxPROPERTY_FLAGS( WindowStyle
, wxCheckListBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, wxLB_OWNERDRAW
/*flags*/ , wxT("Helpstring") , wxT("group")) // style
110 wxEND_PROPERTIES_TABLE()
112 wxBEGIN_HANDLERS_TABLE(wxCheckListBox
)
113 wxEND_HANDLERS_TABLE()
115 wxCONSTRUCTOR_4( wxCheckListBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
)
118 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
, wxListBox
)
121 // ----------------------------------------------------------------------------
122 // declaration and implementation of wxCheckListBoxItem class
123 // ----------------------------------------------------------------------------
125 class wxCheckListBoxItem
: public wxOwnerDrawn
127 friend class WXDLLEXPORT wxCheckListBox
;
130 wxCheckListBoxItem(wxCheckListBox
*pParent
, size_t nIndex
);
133 virtual bool OnDrawItem(wxDC
& dc
, const wxRect
& rc
, wxODAction act
, wxODStatus stat
);
135 // simple accessors and operations
136 bool IsChecked() const { return m_bChecked
; }
138 void Check(bool bCheck
);
139 void Toggle() { Check(!IsChecked()); }
145 DECLARE_NO_COPY_CLASS(wxCheckListBoxItem
)
147 wxCheckListBox
*m_pParent
;
151 wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox
*pParent
, size_t nIndex
)
152 : wxOwnerDrawn(wxEmptyString
, true) // checkable
156 bool wxCheckListBoxItem::OnDrawItem(wxDC
& dc
, const wxRect
& rc
,
157 wxODAction act
, wxODStatus stat
)
162 // change the state of the item and redraw it
163 void wxCheckListBoxItem::Check(bool check
)
167 // send an "item checked" event
168 void wxCheckListBoxItem::SendEvent()
172 // ----------------------------------------------------------------------------
173 // implementation of wxCheckListBox class
174 // ----------------------------------------------------------------------------
176 // define event table
177 // ------------------
178 BEGIN_EVENT_TABLE(wxCheckListBox
, wxListBox
)
179 EVT_KEY_DOWN(wxCheckListBox::OnKeyDown
)
180 EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick
)
186 // def ctor: use Create() to really create the control
187 wxCheckListBox::wxCheckListBox()
191 // ctor which creates the associated control
192 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
193 const wxPoint
& pos
, const wxSize
& size
,
194 int nStrings
, const wxString choices
[],
195 long style
, const wxValidator
& val
,
196 const wxString
& name
)
198 Create(parent
, id
, pos
, size
, nStrings
, choices
, style
, val
, name
);
201 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
202 const wxPoint
& pos
, const wxSize
& size
,
203 const wxArrayString
& choices
,
204 long style
, const wxValidator
& val
,
205 const wxString
& name
)
207 Create(parent
, id
, pos
, size
, choices
, style
, val
, name
);
210 bool wxCheckListBox::Create(wxWindow
*parent
, wxWindowID id
,
211 const wxPoint
& pos
, const wxSize
& size
,
212 int n
, const wxString choices
[],
214 const wxValidator
& validator
, const wxString
& name
)
216 return wxListBox::Create(parent
, id
, pos
, size
, n
, choices
,
217 style
| wxLB_OWNERDRAW
, validator
, name
);
220 bool wxCheckListBox::Create(wxWindow
*parent
, wxWindowID id
,
221 const wxPoint
& pos
, const wxSize
& size
,
222 const wxArrayString
& choices
,
224 const wxValidator
& validator
, const wxString
& name
)
226 return wxListBox::Create(parent
, id
, pos
, size
, choices
,
227 style
| wxLB_OWNERDRAW
, validator
, name
);
230 // misc overloaded methods
231 // -----------------------
233 void wxCheckListBox::Delete(unsigned int n
)
237 bool wxCheckListBox::SetFont( const wxFont
&font
)
242 // create/retrieve item
243 // --------------------
245 // create a check list box item
246 wxOwnerDrawn
*wxCheckListBox::CreateLboxItem(size_t nIndex
)
248 wxCheckListBoxItem
*pItem
= new wxCheckListBoxItem(this, nIndex
);
254 bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
)
262 bool wxCheckListBox::IsChecked(unsigned int uiIndex
) const
267 void wxCheckListBox::Check(unsigned int uiIndex
, bool bCheck
)
274 void wxCheckListBox::OnKeyDown(wxKeyEvent
& event
)
278 void wxCheckListBox::OnLeftClick(wxMouseEvent
& event
)
282 int wxCheckListBox::DoHitTestItem(wxCoord x
, wxCoord y
) const
287 #endif // wxUSE_CHECKLISTBOX && wxUSE_OWNER_DRAWN