]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listbox.h | |
3 | // Purpose: wxListBox class | |
fb9010ed | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
fb9010ed | 6 | // Created: 10/09/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
fb9010ed DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_LISTBOX_H_ | |
13 | #define _WX_LISTBOX_H_ | |
14 | ||
dcd307ee DW |
15 | // ---------------------------------------------------------------------------- |
16 | // simple types | |
17 | // ---------------------------------------------------------------------------- | |
0e320a79 | 18 | |
fb9010ed DW |
19 | #if wxUSE_OWNER_DRAWN |
20 | class WXDLLEXPORT wxOwnerDrawn; | |
21 | ||
22 | // define the array of list box items | |
23 | #include <wx/dynarray.h> | |
24 | ||
dcd307ee DW |
25 | WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray); |
26 | #endif // wxUSE_OWNER_DRAWN | |
fb9010ed | 27 | |
0e320a79 | 28 | // forward decl for GetSelections() |
dcd307ee | 29 | class wxArrayInt; |
0e320a79 | 30 | |
dcd307ee DW |
31 | // ---------------------------------------------------------------------------- |
32 | // List box control | |
33 | // ---------------------------------------------------------------------------- | |
0e320a79 | 34 | |
dcd307ee | 35 | class WXDLLEXPORT wxListBox : public wxListBoxBase |
0e320a79 | 36 | { |
dcd307ee DW |
37 | public: |
38 | // ctors and such | |
39 | wxListBox(); | |
934dac2f DW |
40 | wxListBox( wxWindow* pParent |
41 | ,wxWindowID vId | |
42 | ,const wxPoint& rPos = wxDefaultPosition | |
43 | ,const wxSize& rSize = wxDefaultSize | |
44 | ,int n = 0 | |
45 | ,const wxString asChoices[] = NULL | |
46 | ,long lStyle = 0 | |
934dac2f | 47 | ,const wxValidator& rValidator = wxDefaultValidator |
934dac2f | 48 | ,const wxString& rsName = wxListBoxNameStr) |
dcd307ee | 49 | { |
934dac2f DW |
50 | Create( pParent |
51 | ,vId | |
52 | ,rPos | |
53 | ,rSize | |
54 | ,n | |
55 | ,asChoices | |
56 | ,lStyle | |
934dac2f | 57 | ,rValidator |
934dac2f DW |
58 | ,rsName |
59 | ); | |
dcd307ee DW |
60 | } |
61 | ||
934dac2f DW |
62 | bool Create( wxWindow* pParent |
63 | ,wxWindowID vId | |
64 | ,const wxPoint& rPos = wxDefaultPosition | |
65 | ,const wxSize& rSize = wxDefaultSize | |
66 | ,int n = 0 | |
67 | ,const wxString asChoices[] = NULL | |
68 | ,long lStyle = 0 | |
934dac2f | 69 | ,const wxValidator& rValidator = wxDefaultValidator |
934dac2f DW |
70 | ,const wxString& rsName = wxListBoxNameStr |
71 | ); | |
dcd307ee DW |
72 | |
73 | virtual ~wxListBox(); | |
74 | ||
934dac2f DW |
75 | // |
76 | // Implement base class pure virtuals | |
77 | // | |
78 | virtual void Clear(void); | |
79 | virtual void Delete(int n); | |
80 | ||
81 | virtual int GetCount(void) const; | |
82 | virtual wxString GetString(int n) const; | |
83 | virtual void SetString( int n | |
84 | ,const wxString& rsString | |
85 | ); | |
86 | virtual int FindString(const wxString& rsString) const; | |
87 | ||
88 | virtual bool IsSelected(int n) const; | |
89 | virtual void SetSelection( int n | |
90 | ,bool bSelect = TRUE | |
91 | ); | |
92 | virtual int GetSelection(void) const; | |
93 | virtual int GetSelections(wxArrayInt& raSelections) const; | |
94 | ||
95 | virtual int DoAppend(const wxString& rsItem); | |
96 | virtual void DoInsertItems( const wxArrayString& raItems | |
97 | ,int rPos | |
98 | ); | |
99 | virtual void DoSetItems( const wxArrayString& raItems | |
100 | ,void ** ppClientData | |
101 | ); | |
102 | ||
103 | virtual void DoSetFirstItem(int n); | |
104 | ||
105 | virtual void DoSetItemClientData( int n | |
106 | ,void* pClientData | |
107 | ); | |
108 | virtual void* DoGetItemClientData(int n) const; | |
109 | virtual void DoSetItemClientObject( int n | |
110 | ,wxClientData* pClientData | |
111 | ); | |
dcd307ee DW |
112 | virtual wxClientData* DoGetItemClientObject(int n) const; |
113 | ||
934dac2f | 114 | // |
dcd307ee | 115 | // wxCheckListBox support |
934dac2f | 116 | // |
fb9010ed | 117 | #if wxUSE_OWNER_DRAWN |
f5ea767e | 118 | long OS2OnMeasure(WXMEASUREITEMSTRUCT *item); |
934dac2f | 119 | bool OS2OnDraw(WXDRAWITEMSTRUCT *item); |
fb9010ed | 120 | |
934dac2f DW |
121 | virtual wxOwnerDrawn* CreateItem(size_t n); |
122 | wxOwnerDrawn* GetItem(size_t n) const { return m_aItems[n]; } | |
123 | int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } | |
fb9010ed DW |
124 | #endif // wxUSE_OWNER_DRAWN |
125 | ||
934dac2f DW |
126 | bool OS2Command( WXUINT uParam |
127 | ,WXWORD wId | |
128 | ); | |
129 | virtual void SetupColours(void); | |
fb9010ed DW |
130 | |
131 | protected: | |
dcd307ee | 132 | |
934dac2f DW |
133 | bool HasMultipleSelection(void) const; |
134 | virtual wxSize DoGetBestSize(void) const; | |
135 | ||
136 | int m_nNumItems; | |
137 | int m_nSelected; | |
fb9010ed | 138 | |
fb9010ed DW |
139 | |
140 | #if wxUSE_OWNER_DRAWN | |
934dac2f DW |
141 | // |
142 | // Control items | |
143 | // | |
144 | wxListBoxItemsArray m_aItems; | |
fb9010ed | 145 | #endif |
dcd307ee | 146 | |
fb9010ed | 147 | private: |
dcd307ee DW |
148 | #if wxUSE_WX_RESOURCES |
149 | # if wxUSE_OWNER_DRAWN | |
934dac2f DW |
150 | virtual wxControl* CreateItem( const wxItemResource* pChildResource |
151 | ,const wxItemResource* pParentResource | |
152 | ,const wxResourceTable* pTable = (const wxResourceTable *) NULL | |
153 | ) | |
154 | { | |
155 | return(wxWindowBase::CreateItem( pChildResource | |
156 | ,pParentResource | |
157 | ,pTable | |
158 | ) | |
159 | ); | |
160 | } | |
dcd307ee DW |
161 | # endif |
162 | #endif | |
163 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
934dac2f | 164 | }; // end of wxListBox |
0e320a79 DW |
165 | |
166 | #endif | |
167 | // _WX_LISTBOX_H_ |