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_
16 #pragma interface "listbox.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
24 class WXDLLEXPORT wxOwnerDrawn
;
26 // define the array of list box items
27 #include <wx/dynarray.h>
29 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn
*, wxListBoxItemsArray
);
30 #endif // wxUSE_OWNER_DRAWN
32 // forward decl for GetSelections()
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 class WXDLLEXPORT wxListBox
: public wxListBoxBase
44 wxListBox(wxWindow
*parent
, wxWindowID id
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
,
47 int n
= 0, const wxString choices
[] = NULL
,
49 const wxValidator
& validator
= wxDefaultValidator
,
50 const wxString
& name
= wxListBoxNameStr
)
52 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
55 bool Create(wxWindow
*parent
, wxWindowID id
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
58 int n
= 0, const wxString choices
[] = NULL
,
60 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 MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
93 bool MSWOnDraw(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 MSWCommand(WXUINT param
, WXWORD id
);
117 virtual void SetupColours();
120 // do we have multiple selections?
121 bool HasMultipleSelection() const;
123 // free memory (common part of Clear() and dtor)
129 virtual wxSize
DoGetBestSize();
131 #if wxUSE_OWNER_DRAWN
133 wxListBoxItemsArray m_aItems
;
137 DECLARE_DYNAMIC_CLASS(wxListBox
)