1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/listbox.cpp
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
22 #include "wx/listbox.h"
23 #include "wx/settings.h"
30 #include "wx/window.h"
31 #include "wx/palmos/private.h"
33 #include "wx/dynarray.h"
37 #include "wx/ownerdrw.h"
40 #if wxUSE_EXTENDED_RTTI
41 WX_DEFINE_FLAGS( wxListBoxStyle
)
43 wxBEGIN_FLAGS( wxListBoxStyle
)
44 // new style border flags, we put them first to
45 // use them for streaming out
46 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
47 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
48 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
49 wxFLAGS_MEMBER(wxBORDER_RAISED
)
50 wxFLAGS_MEMBER(wxBORDER_STATIC
)
51 wxFLAGS_MEMBER(wxBORDER_NONE
)
53 // old style border flags
54 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
55 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
56 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
57 wxFLAGS_MEMBER(wxRAISED_BORDER
)
58 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
59 wxFLAGS_MEMBER(wxBORDER
)
61 // standard window styles
62 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
63 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
64 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
65 wxFLAGS_MEMBER(wxWANTS_CHARS
)
66 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
67 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
68 wxFLAGS_MEMBER(wxVSCROLL
)
69 wxFLAGS_MEMBER(wxHSCROLL
)
71 wxFLAGS_MEMBER(wxLB_SINGLE
)
72 wxFLAGS_MEMBER(wxLB_MULTIPLE
)
73 wxFLAGS_MEMBER(wxLB_EXTENDED
)
74 wxFLAGS_MEMBER(wxLB_HSCROLL
)
75 wxFLAGS_MEMBER(wxLB_ALWAYS_SB
)
76 wxFLAGS_MEMBER(wxLB_NEEDED_SB
)
77 wxFLAGS_MEMBER(wxLB_SORT
)
79 wxEND_FLAGS( wxListBoxStyle
)
81 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListBox
, wxControl
,"wx/listbox.h")
83 wxBEGIN_PROPERTIES_TABLE(wxListBox
)
84 wxEVENT_PROPERTY( Select
, wxEVT_COMMAND_LISTBOX_SELECTED
, wxCommandEvent
)
85 wxEVENT_PROPERTY( DoubleClick
, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, wxCommandEvent
)
87 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
88 wxPROPERTY_COLLECTION( Choices
, wxArrayString
, wxString
, AppendString
, GetStrings
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
89 wxPROPERTY( Selection
,int, SetSelection
, GetSelection
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
90 wxPROPERTY_FLAGS( WindowStyle
, wxListBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
91 wxEND_PROPERTIES_TABLE()
93 wxBEGIN_HANDLERS_TABLE(wxListBox
)
94 wxEND_HANDLERS_TABLE()
96 wxCONSTRUCTOR_4( wxListBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
)
98 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
101 // ============================================================================
102 // list box item declaration and implementation
103 // ============================================================================
105 #if wxUSE_OWNER_DRAWN
107 class wxListBoxItem
: public wxOwnerDrawn
110 wxListBoxItem(const wxString
& str
= wxEmptyString
);
113 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, false)
115 // no bitmaps/checkmarks
119 wxOwnerDrawn
*wxListBox::CreateLboxItem(size_t WXUNUSED(n
))
121 return new wxListBoxItem();
124 #endif //USE_OWNER_DRAWN
126 // ============================================================================
127 // list box control implementation
128 // ============================================================================
130 // ----------------------------------------------------------------------------
132 // ----------------------------------------------------------------------------
135 wxListBox::wxListBox()
139 bool wxListBox::Create(wxWindow
*parent
,
143 int n
, const wxString choices
[],
145 const wxValidator
& validator
,
146 const wxString
& name
)
151 bool wxListBox::Create(wxWindow
*parent
,
155 const wxArrayString
& choices
,
157 const wxValidator
& validator
,
158 const wxString
& name
)
163 wxListBox::~wxListBox()
167 WXDWORD
wxListBox::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
172 // ----------------------------------------------------------------------------
173 // implementation of wxListBoxBase methods
174 // ----------------------------------------------------------------------------
176 void wxListBox::DoSetFirstItem(int N
)
180 void wxListBox::Delete(int N
)
184 int wxListBox::DoAppend(const wxString
& item
)
189 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
193 void wxListBox::Clear()
197 void wxListBox::Free()
201 void wxListBox::DoSetSelection(int N
, bool select
)
205 bool wxListBox::IsSelected(int N
) const
210 wxClientData
* wxListBox::DoGetItemClientObject(int n
) const
212 return (wxClientData
*)DoGetItemClientData(n
);
215 void *wxListBox::DoGetItemClientData(int n
) const
220 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
224 void wxListBox::DoSetItemClientData(int n
, void *clientData
)
228 // Return number of selections and an array of selected integers
229 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
234 // Get single selection, for single choice list items
235 int wxListBox::GetSelection() const
240 // Find string for position
241 wxString
wxListBox::GetString(int N
) const
249 wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
253 void wxListBox::SetString(int N
, const wxString
& s
)
257 size_t wxListBox::GetCount() const
262 // ----------------------------------------------------------------------------
264 // ----------------------------------------------------------------------------
266 void wxListBox::SetHorizontalExtent(const wxString
& s
)
270 wxSize
wxListBox::DoGetBestSize() const
275 // ----------------------------------------------------------------------------
277 // ----------------------------------------------------------------------------
279 bool wxListBox::MSWCommand(WXUINT param
, WXWORD
WXUNUSED(id
))
284 // ----------------------------------------------------------------------------
285 // wxCheckListBox support
286 // ----------------------------------------------------------------------------
288 #if wxUSE_OWNER_DRAWN
293 // space beneath/above each row in pixels
294 // "standard" checklistbox use 1 here, some might prefer 2. 0 is ugly.
295 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
297 // the height is the same for all items
298 // TODO should be changed for LBS_OWNERDRAWVARIABLE style listboxes
300 // NB: can't forward this to wxListBoxItem because LB_SETITEMDATA
301 // message is not yet sent when we get here!
302 bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
)
307 // forward the message to the appropriate item
308 bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT
*item
)
313 #endif // wxUSE_OWNER_DRAWN
315 #endif // wxUSE_LISTBOX