]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/listbox.h
compilation fix for raw bitmaps (can't include wx/rawbmp.h from wx/bitmap.h as the...
[wxWidgets.git] / include / wx / palmos / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/listbox.h
3 // Purpose: wxListBox class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "listbox.h"
17 #endif
18
19 #if wxUSE_LISTBOX
20
21 // ----------------------------------------------------------------------------
22 // simple types
23 // ----------------------------------------------------------------------------
24
25 #if wxUSE_OWNER_DRAWN
26 class WXDLLEXPORT wxOwnerDrawn;
27
28 // define the array of list box items
29 #include "wx/dynarray.h"
30
31 WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn *, wxListBoxItemsArray);
32 #endif // wxUSE_OWNER_DRAWN
33
34 // forward decl for GetSelections()
35 class wxArrayInt;
36
37 // ----------------------------------------------------------------------------
38 // List box control
39 // ----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxListBox : public wxListBoxBase
42 {
43 public:
44 // ctors and such
45 wxListBox();
46 wxListBox(wxWindow *parent, wxWindowID id,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 int n = 0, const wxString choices[] = NULL,
50 long style = 0,
51 const wxValidator& validator = wxDefaultValidator,
52 const wxString& name = wxListBoxNameStr)
53 {
54 Create(parent, id, pos, size, n, choices, style, validator, name);
55 }
56 wxListBox(wxWindow *parent, wxWindowID id,
57 const wxPoint& pos,
58 const wxSize& size,
59 const wxArrayString& choices,
60 long style = 0,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxListBoxNameStr)
63 {
64 Create(parent, id, pos, size, choices, style, validator, name);
65 }
66
67 bool Create(wxWindow *parent, wxWindowID id,
68 const wxPoint& pos = wxDefaultPosition,
69 const wxSize& size = wxDefaultSize,
70 int n = 0, const wxString choices[] = NULL,
71 long style = 0,
72 const wxValidator& validator = wxDefaultValidator,
73 const wxString& name = wxListBoxNameStr);
74 bool Create(wxWindow *parent, wxWindowID id,
75 const wxPoint& pos,
76 const wxSize& size,
77 const wxArrayString& choices,
78 long style = 0,
79 const wxValidator& validator = wxDefaultValidator,
80 const wxString& name = wxListBoxNameStr);
81
82 virtual ~wxListBox();
83
84 // implement base class pure virtuals
85 virtual void Clear();
86 virtual void Delete(int n);
87
88 virtual int GetCount() const;
89 virtual wxString GetString(int n) const;
90 virtual void SetString(int n, const wxString& s);
91 virtual int FindString(const wxString& s) const;
92
93 virtual bool IsSelected(int n) const;
94 virtual void DoSetSelection(int n, bool select);
95 virtual int GetSelection() const;
96 virtual int GetSelections(wxArrayInt& aSelections) const;
97
98 virtual int DoAppend(const wxString& item);
99 virtual void DoInsertItems(const wxArrayString& items, int pos);
100 virtual void DoSetItems(const wxArrayString& items, void **clientData);
101
102 virtual void DoSetFirstItem(int n);
103
104 virtual void DoSetItemClientData(int n, void* clientData);
105 virtual void* DoGetItemClientData(int n) const;
106 virtual void DoSetItemClientObject(int n, wxClientData* clientData);
107 virtual wxClientData* DoGetItemClientObject(int n) const;
108
109 // wxCheckListBox support
110 #if wxUSE_OWNER_DRAWN
111 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
112 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
113
114 // plug-in for derived classes
115 virtual wxOwnerDrawn *CreateLboxItem(size_t n);
116
117 // allows to get the item and use SetXXX functions to set it's appearance
118 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
119
120 // get the index of the given item
121 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
122 #endif // wxUSE_OWNER_DRAWN
123
124 // Windows-specific code to set the horizontal extent of the listbox, if
125 // necessary. If s is non-NULL, it's used to calculate the horizontal
126 // extent. Otherwise, all strings are used.
127 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
128
129 // Windows callbacks
130 bool MSWCommand(WXUINT param, WXWORD id);
131
132 virtual wxVisualAttributes GetDefaultAttributes() const
133 {
134 return GetClassDefaultAttributes(GetWindowVariant());
135 }
136
137 static wxVisualAttributes
138 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
139 {
140 return GetCompositeControlsDefaultAttributes(variant);
141 }
142
143 protected:
144 WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
145
146 // free memory (common part of Clear() and dtor)
147 void Free();
148
149 int m_noItems;
150 int m_selected;
151
152 virtual wxSize DoGetBestSize() const;
153
154 #if wxUSE_OWNER_DRAWN
155 // control items
156 wxListBoxItemsArray m_aItems;
157 #endif
158
159 private:
160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox)
161 };
162
163 #endif // wxUSE_LISTBOX
164
165 #endif
166 // _WX_LISTBOX_H_