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 bool Create(wxWindow
*parent
, wxWindowID id
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
57 int n
= 0, const wxString choices
[] = NULL
,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxListBoxNameStr
);
64 // implement base class pure virtuals
66 virtual void Delete(int n
);
68 virtual int GetCount() const;
69 virtual wxString
GetString(int n
) const;
70 virtual void SetString(int n
, const wxString
& s
);
71 virtual int FindString(const wxString
& s
) const;
73 virtual bool IsSelected(int n
) const;
74 virtual void SetSelection(int n
, bool select
= TRUE
);
75 virtual int GetSelection() const;
76 virtual int GetSelections(wxArrayInt
& aSelections
) const;
78 virtual int DoAppend(const wxString
& item
);
79 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
80 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
82 virtual void DoSetFirstItem(int n
);
84 virtual void DoSetItemClientData(int n
, void* clientData
);
85 virtual void* DoGetItemClientData(int n
) const;
86 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
87 virtual wxClientData
* DoGetItemClientObject(int n
) const;
89 // wxCheckListBox support
91 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
92 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
94 // plug-in for derived classes
95 virtual wxOwnerDrawn
*CreateLboxItem(size_t n
);
97 // allows to get the item and use SetXXX functions to set it's appearance
98 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
100 // get the index of the given item
101 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
102 #endif // wxUSE_OWNER_DRAWN
104 // Windows-specific code to set the horizontal extent of the listbox, if
105 // necessary. If s is non-NULL, it's used to calculate the horizontal
106 // extent. Otherwise, all strings are used.
107 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
110 bool MSWCommand(WXUINT param
, WXWORD id
);
112 virtual void SetupColours();
115 // free memory (common part of Clear() and dtor)
121 virtual wxSize
DoGetBestSize() const;
123 #if wxUSE_OWNER_DRAWN
125 wxListBoxItemsArray m_aItems
;
129 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox
)
132 #endif // wxUSE_LISTBOX