1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 class WXDLLEXPORT wxOwnerDrawn
;
22 // define the array of list box items
23 #include <wx/dynarray.h>
25 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn
*, wxListBoxItemsArray
);
26 #endif // wxUSE_OWNER_DRAWN
28 // forward decl for GetSelections()
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class WXDLLEXPORT wxListBox
: public wxListBoxBase
40 wxListBox(wxWindow
*parent
, wxWindowID id
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
43 int n
= 0, const wxString choices
[] = NULL
,
46 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxListBoxNameStr
)
50 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
53 bool Create(wxWindow
*parent
, wxWindowID id
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
56 int n
= 0, const wxString choices
[] = NULL
,
59 const wxValidator
& validator
= wxDefaultValidator
,
61 const wxString
& name
= wxListBoxNameStr
);
65 // implement base class pure virtuals
67 virtual void Delete(int n
);
69 virtual int GetCount() const;
70 virtual wxString
GetString(int n
) const;
71 virtual void SetString(int n
, const wxString
& s
);
72 virtual int FindString(const wxString
& s
) const;
74 virtual bool IsSelected(int n
) const;
75 virtual void SetSelection(int n
, bool select
= TRUE
);
76 virtual int GetSelection() const;
77 virtual int GetSelections(wxArrayInt
& aSelections
) const;
79 virtual int DoAppend(const wxString
& item
);
80 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
81 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
83 virtual void DoSetFirstItem(int n
);
85 virtual void DoSetItemClientData(int n
, void* clientData
);
86 virtual void* DoGetItemClientData(int n
) const;
87 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
88 virtual wxClientData
* DoGetItemClientObject(int n
) const;
90 // wxCheckListBox support
92 bool OS2OnMeasure(WXMEASUREITEMSTRUCT
*item
);
93 bool OS2OnDraw(WXDRAWITEMSTRUCT
*item
);
95 // plug-in for derived classes
96 virtual wxOwnerDrawn
*CreateItem(size_t n
);
98 // allows to get the item and use SetXXX functions to set it's appearance
99 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
101 // get the index of the given item
102 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
103 #endif // wxUSE_OWNER_DRAWN
105 // Windows-specific code to set the horizontal extent of the listbox, if
106 // necessary. If s is non-NULL, it's used to calculate the horizontal
107 // extent. Otherwise, all strings are used.
108 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
111 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
113 WXWPARAM wParam
, WXLPARAM lParam
);
115 bool OS2Command(WXUINT param
, WXWORD id
);
117 virtual void SetupColours();
120 // do we have multiple selections?
121 bool HasMultipleSelection() const;
126 virtual wxSize
DoGetBestSize() const;
128 #if wxUSE_OWNER_DRAWN
130 wxListBoxItemsArray m_aItems
;
134 #if wxUSE_WX_RESOURCES
135 # if wxUSE_OWNER_DRAWN
136 virtual wxControl
*CreateItem(const wxItemResource
* childResource
,
137 const wxItemResource
* parentResource
,
138 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
)
139 { return(wxWindowBase::CreateItem(childResource
, parentResource
, table
)); }
142 DECLARE_DYNAMIC_CLASS(wxListBox
)