1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/listbox.cpp
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "listbox.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/listbox.h"
27 #include "wx/settings.h"
34 #include "wx/window.h"
35 #include "wx/palmos/private.h"
37 #include "wx/dynarray.h"
41 #include "wx/ownerdrw.h"
44 #if wxUSE_EXTENDED_RTTI
45 WX_DEFINE_FLAGS( wxListBoxStyle
)
47 wxBEGIN_FLAGS( wxListBoxStyle
)
48 // new style border flags, we put them first to
49 // use them for streaming out
50 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
51 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
52 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
53 wxFLAGS_MEMBER(wxBORDER_RAISED
)
54 wxFLAGS_MEMBER(wxBORDER_STATIC
)
55 wxFLAGS_MEMBER(wxBORDER_NONE
)
57 // old style border flags
58 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
59 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
60 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
61 wxFLAGS_MEMBER(wxRAISED_BORDER
)
62 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
63 wxFLAGS_MEMBER(wxBORDER
)
65 // standard window styles
66 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
67 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
68 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
69 wxFLAGS_MEMBER(wxWANTS_CHARS
)
70 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
71 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
72 wxFLAGS_MEMBER(wxVSCROLL
)
73 wxFLAGS_MEMBER(wxHSCROLL
)
75 wxFLAGS_MEMBER(wxLB_SINGLE
)
76 wxFLAGS_MEMBER(wxLB_MULTIPLE
)
77 wxFLAGS_MEMBER(wxLB_EXTENDED
)
78 wxFLAGS_MEMBER(wxLB_HSCROLL
)
79 wxFLAGS_MEMBER(wxLB_ALWAYS_SB
)
80 wxFLAGS_MEMBER(wxLB_NEEDED_SB
)
81 wxFLAGS_MEMBER(wxLB_SORT
)
83 wxEND_FLAGS( wxListBoxStyle
)
85 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListBox
, wxControl
,"wx/listbox.h")
87 wxBEGIN_PROPERTIES_TABLE(wxListBox
)
88 wxEVENT_PROPERTY( Select
, wxEVT_COMMAND_LISTBOX_SELECTED
, wxCommandEvent
)
89 wxEVENT_PROPERTY( DoubleClick
, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, wxCommandEvent
)
91 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
92 wxPROPERTY_COLLECTION( Choices
, wxArrayString
, wxString
, AppendString
, GetStrings
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
93 wxPROPERTY( Selection
,int, SetSelection
, GetSelection
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
94 wxPROPERTY_FLAGS( WindowStyle
, wxListBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
95 wxEND_PROPERTIES_TABLE()
97 wxBEGIN_HANDLERS_TABLE(wxListBox
)
98 wxEND_HANDLERS_TABLE()
100 wxCONSTRUCTOR_4( wxListBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
)
102 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
105 // ============================================================================
106 // list box item declaration and implementation
107 // ============================================================================
109 #if wxUSE_OWNER_DRAWN
111 class wxListBoxItem
: public wxOwnerDrawn
114 wxListBoxItem(const wxString
& str
= wxEmptyString
);
117 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
119 // no bitmaps/checkmarks
123 wxOwnerDrawn
*wxListBox::CreateLboxItem(size_t WXUNUSED(n
))
125 return new wxListBoxItem();
128 #endif //USE_OWNER_DRAWN
130 // ============================================================================
131 // list box control implementation
132 // ============================================================================
134 // ----------------------------------------------------------------------------
136 // ----------------------------------------------------------------------------
139 wxListBox::wxListBox()
143 bool wxListBox::Create(wxWindow
*parent
,
147 int n
, const wxString choices
[],
149 const wxValidator
& validator
,
150 const wxString
& name
)
155 bool wxListBox::Create(wxWindow
*parent
,
159 const wxArrayString
& choices
,
161 const wxValidator
& validator
,
162 const wxString
& name
)
167 wxListBox::~wxListBox()
171 WXDWORD
wxListBox::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
176 // ----------------------------------------------------------------------------
177 // implementation of wxListBoxBase methods
178 // ----------------------------------------------------------------------------
180 void wxListBox::DoSetFirstItem(int N
)
184 void wxListBox::Delete(int N
)
188 int wxListBox::DoAppend(const wxString
& item
)
193 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
197 int wxListBox::FindString(const wxString
& s
) const
202 void wxListBox::Clear()
206 void wxListBox::Free()
210 void wxListBox::SetSelection(int N
, bool select
)
214 bool wxListBox::IsSelected(int N
) const
219 wxClientData
* wxListBox::DoGetItemClientObject(int n
) const
221 return (wxClientData
*)DoGetItemClientData(n
);
224 void *wxListBox::DoGetItemClientData(int n
) const
229 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
233 void wxListBox::DoSetItemClientData(int n
, void *clientData
)
237 // Return number of selections and an array of selected integers
238 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
243 // Get single selection, for single choice list items
244 int wxListBox::GetSelection() const
249 // Find string for position
250 wxString
wxListBox::GetString(int N
) const
258 wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
262 void wxListBox::SetString(int N
, const wxString
& s
)
266 int wxListBox::GetCount() const
271 // ----------------------------------------------------------------------------
273 // ----------------------------------------------------------------------------
275 void wxListBox::SetHorizontalExtent(const wxString
& s
)
279 wxSize
wxListBox::DoGetBestSize() const
284 // ----------------------------------------------------------------------------
286 // ----------------------------------------------------------------------------
288 bool wxListBox::MSWCommand(WXUINT param
, WXWORD
WXUNUSED(id
))
293 // ----------------------------------------------------------------------------
294 // wxCheckListBox support
295 // ----------------------------------------------------------------------------
297 #if wxUSE_OWNER_DRAWN
302 // space beneath/above each row in pixels
303 // "standard" checklistbox use 1 here, some might prefer 2. 0 is ugly.
304 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
306 // the height is the same for all items
307 // TODO should be changed for LBS_OWNERDRAWVARIABLE style listboxes
309 // NB: can't forward this to wxListBoxItem because LB_SETITEMDATA
310 // message is not yet sent when we get here!
311 bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
)
316 // forward the message to the appropriate item
317 bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT
*item
)
322 #endif // wxUSE_OWNER_DRAWN
324 #endif // wxUSE_LISTBOX