]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/listbox.h
Increase version to 2.9.5.
[wxWidgets.git] / include / wx / msw / listbox.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
2ee3ee1b 2// Name: wx/msw/listbox.h
2bda0e17
KB
3// Purpose: wxListBox class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_LISTBOX_H_
13#define _WX_LISTBOX_H_
2bda0e17 14
1e6feb95
VZ
15#if wxUSE_LISTBOX
16
2ee3ee1b
VZ
17// ----------------------------------------------------------------------------
18// simple types
19// ----------------------------------------------------------------------------
2bda0e17 20
47d67540 21#if wxUSE_OWNER_DRAWN
b5dbe15d 22 class WXDLLIMPEXP_FWD_CORE wxOwnerDrawn;
2bda0e17
KB
23
24 // define the array of list box items
ace954f1 25 #include "wx/dynarray.h"
184b5d99 26
d5d29b8a 27 WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn *, wxListBoxItemsArray);
2ee3ee1b 28#endif // wxUSE_OWNER_DRAWN
2bda0e17 29
7f17c6db 30// forward decl for GetSelections()
b5dbe15d 31class WXDLLIMPEXP_FWD_BASE wxArrayInt;
7f17c6db 32
2ee3ee1b
VZ
33// ----------------------------------------------------------------------------
34// List box control
35// ----------------------------------------------------------------------------
2bda0e17 36
53a2db12 37class WXDLLIMPEXP_CORE wxListBox : public wxListBoxBase
2bda0e17 38{
bfc6fde4 39public:
2ee3ee1b 40 // ctors and such
096d5447 41 wxListBox() { Init(); }
bfc6fde4
VZ
42 wxListBox(wxWindow *parent, wxWindowID id,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 int n = 0, const wxString choices[] = NULL,
46 long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
6463b9f5
JS
48 const wxString& name = wxListBoxNameStr)
49 {
096d5447
VZ
50 Init();
51
6463b9f5
JS
52 Create(parent, id, pos, size, n, choices, style, validator, name);
53 }
584ad2a3
MB
54 wxListBox(wxWindow *parent, wxWindowID id,
55 const wxPoint& pos,
56 const wxSize& size,
57 const wxArrayString& choices,
58 long style = 0,
59 const wxValidator& validator = wxDefaultValidator,
60 const wxString& name = wxListBoxNameStr)
61 {
dca0afc7
VZ
62 Init();
63
584ad2a3
MB
64 Create(parent, id, pos, size, choices, style, validator, name);
65 }
bfc6fde4
VZ
66
67 bool Create(wxWindow *parent, wxWindowID id,
2ee3ee1b
VZ
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);
584ad2a3
MB
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);
bfc6fde4 81
2ee3ee1b 82 virtual ~wxListBox();
bfc6fde4 83
aa61d352
VZ
84 virtual unsigned int GetCount() const;
85 virtual wxString GetString(unsigned int n) const;
86 virtual void SetString(unsigned int n, const wxString& s);
853dcc57 87 virtual int FindString(const wxString& s, bool bCase = false) const;
2ee3ee1b
VZ
88
89 virtual bool IsSelected(int n) const;
2ee3ee1b
VZ
90 virtual int GetSelection() const;
91 virtual int GetSelections(wxArrayInt& aSelections) const;
92
85ee88cd
VZ
93 // return the index of the item at this position or wxNOT_FOUND
94 int HitTest(const wxPoint& pt) const { return DoHitTestList(pt); }
95 int HitTest(wxCoord x, wxCoord y) const { return DoHitTestList(wxPoint(x, y)); }
96
97 // ownerdrawn wxListBox and wxCheckListBox support
47d67540 98#if wxUSE_OWNER_DRAWN
85ee88cd 99 // override base class virtuals
85ee88cd
VZ
100 virtual bool SetFont(const wxFont &font);
101
bfc6fde4
VZ
102 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
103 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
2bda0e17 104
bfc6fde4 105 // plug-in for derived classes
2b5f62a0 106 virtual wxOwnerDrawn *CreateLboxItem(size_t n);
2bda0e17 107
bfc6fde4
VZ
108 // allows to get the item and use SetXXX functions to set it's appearance
109 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
dd3c394a
VZ
110
111 // get the index of the given item
112 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
85ee88cd
VZ
113
114 // get rect of the given item index
115 bool GetItemRect(size_t n, wxRect& rect) const;
116
117 // redraw the given item
118 bool RefreshItem(size_t n);
bfc6fde4 119#endif // wxUSE_OWNER_DRAWN
2bda0e17 120
fca418ae
VZ
121 // Windows-specific code to update the horizontal extent of the listbox, if
122 // necessary. If s is non-empty, the horizontal extent is increased to the
123 // length of this string if it's currently too short, otherwise the maximum
124 // extent of all strings is used. In any case calls InvalidateBestSize()
bfc6fde4 125 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
2bda0e17 126
2ee3ee1b 127 // Windows callbacks
2ee3ee1b 128 bool MSWCommand(WXUINT param, WXWORD id);
6f02a879
VZ
129 WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
130
131 // under XP when using "transition effect for menus and tooltips" if we
132 // return true for WM_PRINTCLIENT here then it causes noticable slowdown
133 virtual bool MSWShouldPropagatePrintChild()
134 {
135 return false;
136 }
2bda0e17 137
7a69cd96
VZ
138 virtual wxVisualAttributes GetDefaultAttributes() const
139 {
140 return GetClassDefaultAttributes(GetWindowVariant());
141 }
142
143 static wxVisualAttributes
144 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
145 {
146 return GetCompositeControlsDefaultAttributes(variant);
147 }
2bda0e17 148
a047aff2
JS
149 // returns true if the platform should explicitly apply a theme border
150 virtual bool CanApplyThemeBorder() const { return false; }
151
316bba0c
VZ
152 virtual void OnInternalIdle();
153
f2eb4ad2
VZ
154 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
155
bfc6fde4 156protected:
743b4266
VZ
157 virtual wxSize DoGetBestClientSize() const;
158
3c75d8ba
PC
159 virtual void DoClear();
160 virtual void DoDeleteOneItem(unsigned int n);
161
6f02a879 162 virtual void DoSetSelection(int n, bool select);
a236aa20
VZ
163
164 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
165 unsigned int pos,
166 void **clientData, wxClientDataType type);
167
6f02a879 168 virtual void DoSetFirstItem(int n);
aa61d352
VZ
169 virtual void DoSetItemClientData(unsigned int n, void* clientData);
170 virtual void* DoGetItemClientData(unsigned int n) const;
85ee88cd
VZ
171
172 // this can't be called DoHitTest() because wxWindow already has this method
173 virtual int DoHitTestList(const wxPoint& point) const;
7a69cd96 174
316bba0c
VZ
175 // free memory (common part of Clear() and dtor)
176 void Free();
1ddb283a 177
aa61d352 178 unsigned int m_noItems;
2bda0e17 179
47d67540 180#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
181 // control items
182 wxListBoxItemsArray m_aItems;
2bda0e17 183#endif
2ee3ee1b
VZ
184
185private:
096d5447
VZ
186 // common part of all ctors
187 void Init();
188
316bba0c
VZ
189 // call this when items are added to or deleted from the listbox or an
190 // items text changes
191 void MSWOnItemsChanged();
192
193 // flag indicating whether the max horizontal extent should be updated,
194 // i.e. if we need to call SetHorizontalExtent() from OnInternalIdle()
195 bool m_updateHorizontalExtent;
196
f2eb4ad2
VZ
197 // flag set to true when we get a keyboard event and reset to false when we
198 // get a mouse one: this is used to find the correct item for the selection
199 // event
200 bool m_selectedByKeyboard;
201
fc7a2a60 202 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox)
2bda0e17
KB
203};
204
1e6feb95
VZ
205#endif // wxUSE_LISTBOX
206
2bda0e17 207#endif
bbcdf8bc 208 // _WX_LISTBOX_H_