1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/listbox.h
3 // Purpose: wxListBox class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "listbox.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
26 class WXDLLEXPORT wxOwnerDrawn
;
28 // define the array of list box items
29 #include "wx/dynarray.h"
31 WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn
*, wxListBoxItemsArray
);
32 #endif // wxUSE_OWNER_DRAWN
34 // forward decl for GetSelections()
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 class WXDLLEXPORT wxListBox
: public wxListBoxBase
46 wxListBox(wxWindow
*parent
, wxWindowID id
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
49 int n
= 0, const wxString choices
[] = NULL
,
51 const wxValidator
& validator
= wxDefaultValidator
,
52 const wxString
& name
= wxListBoxNameStr
)
54 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
56 wxListBox(wxWindow
*parent
, wxWindowID id
,
59 const wxArrayString
& choices
,
61 const wxValidator
& validator
= wxDefaultValidator
,
62 const wxString
& name
= wxListBoxNameStr
)
64 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
67 bool Create(wxWindow
*parent
, wxWindowID id
,
68 const wxPoint
& pos
= wxDefaultPosition
,
69 const wxSize
& size
= wxDefaultSize
,
70 int n
= 0, const wxString choices
[] = NULL
,
72 const wxValidator
& validator
= wxDefaultValidator
,
73 const wxString
& name
= wxListBoxNameStr
);
74 bool Create(wxWindow
*parent
, wxWindowID id
,
77 const wxArrayString
& choices
,
79 const wxValidator
& validator
= wxDefaultValidator
,
80 const wxString
& name
= wxListBoxNameStr
);
84 // implement base class pure virtuals
86 virtual void Delete(int n
);
88 virtual int GetCount() const;
89 virtual wxString
GetString(int n
) const;
90 virtual void SetString(int n
, const wxString
& s
);
91 virtual int FindString(const wxString
& s
) const;
93 virtual bool IsSelected(int n
) const;
94 virtual void SetSelection(int n
, bool select
= TRUE
);
95 virtual int GetSelection() const;
96 virtual int GetSelections(wxArrayInt
& aSelections
) const;
98 virtual int DoAppend(const wxString
& item
);
99 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
100 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
102 virtual void DoSetFirstItem(int n
);
104 virtual void DoSetItemClientData(int n
, void* clientData
);
105 virtual void* DoGetItemClientData(int n
) const;
106 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
107 virtual wxClientData
* DoGetItemClientObject(int n
) const;
109 // wxCheckListBox support
110 #if wxUSE_OWNER_DRAWN
111 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
112 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
114 // plug-in for derived classes
115 virtual wxOwnerDrawn
*CreateLboxItem(size_t n
);
117 // allows to get the item and use SetXXX functions to set it's appearance
118 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
120 // get the index of the given item
121 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
122 #endif // wxUSE_OWNER_DRAWN
124 // Windows-specific code to set the horizontal extent of the listbox, if
125 // necessary. If s is non-NULL, it's used to calculate the horizontal
126 // extent. Otherwise, all strings are used.
127 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
130 bool MSWCommand(WXUINT param
, WXWORD id
);
132 virtual wxVisualAttributes
GetDefaultAttributes() const
134 return GetClassDefaultAttributes(GetWindowVariant());
137 static wxVisualAttributes
138 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
140 return GetCompositeControlsDefaultAttributes(variant
);
144 WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
146 // free memory (common part of Clear() and dtor)
152 virtual wxSize
DoGetBestSize() const;
154 #if wxUSE_OWNER_DRAWN
156 wxListBoxItemsArray m_aItems
;
160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox
)
163 #endif // wxUSE_LISTBOX