1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/listbox.h
3 // Purpose: wxListBox class
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
22 class WXDLLEXPORT wxOwnerDrawn
;
24 // define the array of list box items
25 #include "wx/dynarray.h"
27 WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn
*, wxListBoxItemsArray
);
28 #endif // wxUSE_OWNER_DRAWN
30 // forward decl for GetSelections()
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxListBox
: public wxListBoxBase
42 wxListBox(wxWindow
*parent
, wxWindowID id
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
45 int n
= 0, const wxString choices
[] = NULL
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxListBoxNameStr
)
50 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
52 wxListBox(wxWindow
*parent
, wxWindowID id
,
55 const wxArrayString
& choices
,
57 const wxValidator
& validator
= wxDefaultValidator
,
58 const wxString
& name
= wxListBoxNameStr
)
60 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
63 bool Create(wxWindow
*parent
, wxWindowID id
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
,
66 int n
= 0, const wxString choices
[] = NULL
,
68 const wxValidator
& validator
= wxDefaultValidator
,
69 const wxString
& name
= wxListBoxNameStr
);
70 bool Create(wxWindow
*parent
, wxWindowID id
,
73 const wxArrayString
& choices
,
75 const wxValidator
& validator
= wxDefaultValidator
,
76 const wxString
& name
= wxListBoxNameStr
);
80 // implement base class pure virtuals
82 virtual void Delete(int n
);
84 virtual int GetCount() const;
85 virtual wxString
GetString(int n
) const;
86 virtual void SetString(int n
, const wxString
& s
);
88 virtual bool IsSelected(int n
) const;
89 virtual void DoSetSelection(int n
, bool select
);
90 virtual int GetSelection() const;
91 virtual int GetSelections(wxArrayInt
& aSelections
) const;
93 virtual int DoAppend(const wxString
& item
);
94 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
95 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
97 virtual void DoSetFirstItem(int n
);
99 virtual void DoSetItemClientData(int n
, void* clientData
);
100 virtual void* DoGetItemClientData(int n
) const;
101 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
102 virtual wxClientData
* DoGetItemClientObject(int n
) const;
104 // wxCheckListBox support
105 #if wxUSE_OWNER_DRAWN
106 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
107 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
109 // plug-in for derived classes
110 virtual wxOwnerDrawn
*CreateLboxItem(size_t n
);
112 // allows to get the item and use SetXXX functions to set it's appearance
113 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
115 // get the index of the given item
116 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
117 #endif // wxUSE_OWNER_DRAWN
119 // Windows-specific code to set the horizontal extent of the listbox, if
120 // necessary. If s is non-NULL, it's used to calculate the horizontal
121 // extent. Otherwise, all strings are used.
122 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
125 bool MSWCommand(WXUINT param
, WXWORD id
);
127 virtual wxVisualAttributes
GetDefaultAttributes() const
129 return GetClassDefaultAttributes(GetWindowVariant());
132 static wxVisualAttributes
133 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
135 return GetCompositeControlsDefaultAttributes(variant
);
139 WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
141 // free memory (common part of Clear() and dtor)
147 virtual wxSize
DoGetBestSize() const;
149 #if wxUSE_OWNER_DRAWN
151 wxListBoxItemsArray m_aItems
;
155 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox
)
158 #endif // wxUSE_LISTBOX