]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/listbox.h
Fix compilation of wxIconBundle in some particular minimal builds.
[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
bfc6fde4
VZ
41 wxListBox();
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 {
50 Create(parent, id, pos, size, n, choices, style, validator, name);
51 }
584ad2a3
MB
52 wxListBox(wxWindow *parent, wxWindowID id,
53 const wxPoint& pos,
54 const wxSize& size,
55 const wxArrayString& choices,
56 long style = 0,
57 const wxValidator& validator = wxDefaultValidator,
58 const wxString& name = wxListBoxNameStr)
59 {
60 Create(parent, id, pos, size, choices, style, validator, name);
61 }
bfc6fde4
VZ
62
63 bool Create(wxWindow *parent, wxWindowID id,
2ee3ee1b
VZ
64 const wxPoint& pos = wxDefaultPosition,
65 const wxSize& size = wxDefaultSize,
66 int n = 0, const wxString choices[] = NULL,
67 long style = 0,
68 const wxValidator& validator = wxDefaultValidator,
69 const wxString& name = wxListBoxNameStr);
584ad2a3
MB
70 bool Create(wxWindow *parent, wxWindowID id,
71 const wxPoint& pos,
72 const wxSize& size,
73 const wxArrayString& choices,
74 long style = 0,
75 const wxValidator& validator = wxDefaultValidator,
76 const wxString& name = wxListBoxNameStr);
bfc6fde4 77
2ee3ee1b 78 virtual ~wxListBox();
bfc6fde4 79
aa61d352
VZ
80 virtual unsigned int GetCount() const;
81 virtual wxString GetString(unsigned int n) const;
82 virtual void SetString(unsigned int n, const wxString& s);
853dcc57 83 virtual int FindString(const wxString& s, bool bCase = false) const;
2ee3ee1b
VZ
84
85 virtual bool IsSelected(int n) const;
2ee3ee1b
VZ
86 virtual int GetSelection() const;
87 virtual int GetSelections(wxArrayInt& aSelections) const;
88
85ee88cd
VZ
89 // return the index of the item at this position or wxNOT_FOUND
90 int HitTest(const wxPoint& pt) const { return DoHitTestList(pt); }
91 int HitTest(wxCoord x, wxCoord y) const { return DoHitTestList(wxPoint(x, y)); }
92
93 // ownerdrawn wxListBox and wxCheckListBox support
47d67540 94#if wxUSE_OWNER_DRAWN
85ee88cd 95 // override base class virtuals
85ee88cd
VZ
96 virtual bool SetFont(const wxFont &font);
97
bfc6fde4
VZ
98 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
99 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
2bda0e17 100
bfc6fde4 101 // plug-in for derived classes
2b5f62a0 102 virtual wxOwnerDrawn *CreateLboxItem(size_t n);
2bda0e17 103
bfc6fde4
VZ
104 // allows to get the item and use SetXXX functions to set it's appearance
105 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
dd3c394a
VZ
106
107 // get the index of the given item
108 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
85ee88cd
VZ
109
110 // get rect of the given item index
111 bool GetItemRect(size_t n, wxRect& rect) const;
112
113 // redraw the given item
114 bool RefreshItem(size_t n);
bfc6fde4 115#endif // wxUSE_OWNER_DRAWN
2bda0e17 116
fca418ae
VZ
117 // Windows-specific code to update the horizontal extent of the listbox, if
118 // necessary. If s is non-empty, the horizontal extent is increased to the
119 // length of this string if it's currently too short, otherwise the maximum
120 // extent of all strings is used. In any case calls InvalidateBestSize()
bfc6fde4 121 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
2bda0e17 122
2ee3ee1b 123 // Windows callbacks
2ee3ee1b 124 bool MSWCommand(WXUINT param, WXWORD id);
6f02a879
VZ
125 WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
126
127 // under XP when using "transition effect for menus and tooltips" if we
128 // return true for WM_PRINTCLIENT here then it causes noticable slowdown
129 virtual bool MSWShouldPropagatePrintChild()
130 {
131 return false;
132 }
2bda0e17 133
7a69cd96
VZ
134 virtual wxVisualAttributes GetDefaultAttributes() const
135 {
136 return GetClassDefaultAttributes(GetWindowVariant());
137 }
138
139 static wxVisualAttributes
140 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
141 {
142 return GetCompositeControlsDefaultAttributes(variant);
143 }
2bda0e17 144
a047aff2
JS
145 // returns true if the platform should explicitly apply a theme border
146 virtual bool CanApplyThemeBorder() const { return false; }
147
bfc6fde4 148protected:
743b4266
VZ
149 virtual wxSize DoGetBestClientSize() const;
150
3c75d8ba
PC
151 virtual void DoClear();
152 virtual void DoDeleteOneItem(unsigned int n);
153
6f02a879 154 virtual void DoSetSelection(int n, bool select);
a236aa20
VZ
155
156 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
157 unsigned int pos,
158 void **clientData, wxClientDataType type);
159
6f02a879 160 virtual void DoSetFirstItem(int n);
aa61d352
VZ
161 virtual void DoSetItemClientData(unsigned int n, void* clientData);
162 virtual void* DoGetItemClientData(unsigned int n) const;
85ee88cd
VZ
163
164 // this can't be called DoHitTest() because wxWindow already has this method
165 virtual int DoHitTestList(const wxPoint& point) const;
7a69cd96 166
1ddb283a
RR
167 bool m_updateHorizontalExtent;
168 virtual void OnInternalIdle();
169
aa61d352 170 unsigned int m_noItems;
2bda0e17 171
47d67540 172#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
173 // control items
174 wxListBoxItemsArray m_aItems;
2bda0e17 175#endif
2ee3ee1b
VZ
176
177private:
fc7a2a60 178 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox)
2bda0e17
KB
179};
180
1e6feb95
VZ
181#endif // wxUSE_LISTBOX
182
2bda0e17 183#endif
bbcdf8bc 184 // _WX_LISTBOX_H_