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