]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/listbox.h
SN: Derive wxSpinButton from wxSpinButtonBase instead of wxControl.
[wxWidgets.git] / include / wx / os2 / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: listbox.h
3 // Purpose: wxListBox class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/09/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
14
15 // ----------------------------------------------------------------------------
16 // simple types
17 // ----------------------------------------------------------------------------
18
19 #if wxUSE_OWNER_DRAWN
20 class WXDLLEXPORT wxOwnerDrawn;
21
22 // define the array of list box items
23 #include <wx/dynarray.h>
24
25 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
26 #endif // wxUSE_OWNER_DRAWN
27
28 // forward decl for GetSelections()
29 class wxArrayInt;
30
31 // ----------------------------------------------------------------------------
32 // List box control
33 // ----------------------------------------------------------------------------
34
35 class WXDLLEXPORT wxListBox : public wxListBoxBase
36 {
37 public:
38 // ctors and such
39 wxListBox();
40 wxListBox(wxWindow *parent, wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 int n = 0, const wxString choices[] = NULL,
44 long style = 0,
45 #if wxUSE_VALIDATORS
46 const wxValidator& validator = wxDefaultValidator,
47 #endif
48 const wxString& name = wxListBoxNameStr)
49 {
50 Create(parent, id, pos, size, n, choices, style, validator, name);
51 }
52
53 bool Create(wxWindow *parent, wxWindowID id,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 int n = 0, const wxString choices[] = NULL,
57 long style = 0,
58 #if wxUSE_VALIDATORS
59 const wxValidator& validator = wxDefaultValidator,
60 #endif
61 const wxString& name = wxListBoxNameStr);
62
63 virtual ~wxListBox();
64
65 // implement base class pure virtuals
66 virtual void Clear();
67 virtual void Delete(int n);
68
69 virtual int GetCount() const;
70 virtual wxString GetString(int n) const;
71 virtual void SetString(int n, const wxString& s);
72 virtual int FindString(const wxString& s) const;
73
74 virtual bool IsSelected(int n) const;
75 virtual void SetSelection(int n, bool select = TRUE);
76 virtual int GetSelection() const;
77 virtual int GetSelections(wxArrayInt& aSelections) const;
78
79 virtual int DoAppend(const wxString& item);
80 virtual void DoInsertItems(const wxArrayString& items, int pos);
81 virtual void DoSetItems(const wxArrayString& items, void **clientData);
82
83 virtual void DoSetFirstItem(int n);
84
85 virtual void DoSetItemClientData(int n, void* clientData);
86 virtual void* DoGetItemClientData(int n) const;
87 virtual void DoSetItemClientObject(int n, wxClientData* clientData);
88 virtual wxClientData* DoGetItemClientObject(int n) const;
89
90 // wxCheckListBox support
91 #if wxUSE_OWNER_DRAWN
92 bool OS2OnMeasure(WXMEASUREITEMSTRUCT *item);
93 bool OS2OnDraw(WXDRAWITEMSTRUCT *item);
94
95 // plug-in for derived classes
96 virtual wxOwnerDrawn *CreateItem(size_t n);
97
98 // allows to get the item and use SetXXX functions to set it's appearance
99 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
100
101 // get the index of the given item
102 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
103 #endif // wxUSE_OWNER_DRAWN
104
105 // Windows-specific code to set the horizontal extent of the listbox, if
106 // necessary. If s is non-NULL, it's used to calculate the horizontal
107 // extent. Otherwise, all strings are used.
108 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
109
110 // Windows callbacks
111 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
112 WXUINT message,
113 WXWPARAM wParam, WXLPARAM lParam);
114
115 bool OS2Command(WXUINT param, WXWORD id);
116
117 virtual void SetupColours();
118
119 protected:
120 // do we have multiple selections?
121 bool HasMultipleSelection() const;
122
123 int m_noItems;
124 int m_selected;
125
126 virtual wxSize DoGetBestSize() const;
127
128 #if wxUSE_OWNER_DRAWN
129 // control items
130 wxListBoxItemsArray m_aItems;
131 #endif
132
133 private:
134 #if wxUSE_WX_RESOURCES
135 # if wxUSE_OWNER_DRAWN
136 virtual wxControl *CreateItem(const wxItemResource* childResource,
137 const wxItemResource* parentResource,
138 const wxResourceTable *table = (const wxResourceTable *) NULL)
139 { return(wxWindowBase::CreateItem(childResource, parentResource, table)); }
140 # endif
141 #endif
142 DECLARE_DYNAMIC_CLASS(wxListBox)
143 };
144
145 #endif
146 // _WX_LISTBOX_H_