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"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
26 class WXDLLEXPORT wxOwnerDrawn
;
28 // define the array of list box items
29 #include "wx/dynarray.h"
31 WX_DEFINE_EXPORTED_ARRAY(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
);
57 bool Create(wxWindow
*parent
, wxWindowID id
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
60 int n
= 0, const wxString choices
[] = NULL
,
62 const wxValidator
& validator
= wxDefaultValidator
,
63 const wxString
& name
= wxListBoxNameStr
);
67 // implement base class pure virtuals
69 virtual void Delete(int n
);
71 virtual int GetCount() const;
72 virtual wxString
GetString(int n
) const;
73 virtual void SetString(int n
, const wxString
& s
);
74 virtual int FindString(const wxString
& s
) const;
76 virtual bool IsSelected(int n
) const;
77 virtual void SetSelection(int n
, bool select
= TRUE
);
78 virtual int GetSelection() const;
79 virtual int GetSelections(wxArrayInt
& aSelections
) const;
81 virtual int DoAppend(const wxString
& item
);
82 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
83 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
85 virtual void DoSetFirstItem(int n
);
87 virtual void DoSetItemClientData(int n
, void* clientData
);
88 virtual void* DoGetItemClientData(int n
) const;
89 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
90 virtual wxClientData
* DoGetItemClientObject(int n
) const;
92 // wxCheckListBox support
94 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
95 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
97 // plug-in for derived classes
98 virtual wxOwnerDrawn
*CreateItem(size_t n
);
100 // allows to get the item and use SetXXX functions to set it's appearance
101 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
103 // get the index of the given item
104 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
105 #endif // wxUSE_OWNER_DRAWN
107 // Windows-specific code to set the horizontal extent of the listbox, if
108 // necessary. If s is non-NULL, it's used to calculate the horizontal
109 // extent. Otherwise, all strings are used.
110 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
113 bool MSWCommand(WXUINT param
, WXWORD id
);
115 virtual void SetupColours();
118 // free memory (common part of Clear() and dtor)
124 virtual wxSize
DoGetBestSize() const;
126 #if wxUSE_OWNER_DRAWN
128 wxListBoxItemsArray m_aItems
;
132 DECLARE_DYNAMIC_CLASS(wxListBox
)
135 #endif // wxUSE_LISTBOX