1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "listbox.h"
19 #include "wx/control.h"
21 WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr
;
22 WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr
;
25 class WXDLLEXPORT wxOwnerDrawn
;
27 // define the array of list box items
28 #include <wx/dynarray.h>
29 WX_DEFINE_ARRAY(wxOwnerDrawn
*, wxListBoxItemsArray
);
32 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
35 class WXDLLEXPORT wxListBox
: public wxControl
37 DECLARE_DYNAMIC_CLASS(wxListBox
)
41 inline wxListBox(wxWindow
*parent
, const wxWindowID id
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
44 const int n
= 0, const wxString choices
[] = NULL
,
46 const wxValidator
& validator
= wxDefaultValidator
,
47 const wxString
& name
= wxListBoxNameStr
)
49 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
52 bool Create(wxWindow
*parent
, const wxWindowID id
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
55 const int n
= 0, const wxString choices
[] = NULL
,
57 const wxValidator
& validator
= wxDefaultValidator
,
58 const wxString
& name
= wxListBoxNameStr
);
62 bool MSWCommand(const WXUINT param
, const WXWORD id
);
65 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
66 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
68 // plug-in for derived classes
69 virtual wxOwnerDrawn
*CreateItem(uint n
);
71 // allows to get the item and use SetXXX functions to set it's appearance
72 wxOwnerDrawn
*GetItem(uint n
) const { return m_aItems
[n
]; }
75 virtual void Append(const wxString
& item
);
76 virtual void Append(const wxString
& item
, char *clientData
);
77 virtual void Set(const int n
, const wxString
* choices
, char **clientData
= NULL
);
78 virtual int FindString(const wxString
& s
) const ;
79 virtual void Clear(void);
80 virtual void SetSelection(const int n
, const bool select
= TRUE
);
82 virtual void Deselect(const int n
);
84 // For single choice list item only
85 virtual int GetSelection(void) const ;
86 virtual void Delete(const int n
);
87 virtual char *GetClientData(const int n
) const ;
88 virtual void SetClientData(const int n
, char *clientData
);
89 virtual void SetString(const int n
, const wxString
& s
);
91 // For single or multiple choice list item
92 virtual int GetSelections(int **listSelections
) const ;
93 virtual bool Selected(const int n
) const ;
94 virtual wxString
GetString(const int n
) const ;
95 virtual void SetSize(const int x
, const int y
, const int width
, const int height
, const int sizeFlags
= wxSIZE_AUTO
);
97 // Set the specified item at the first visible item
98 // or scroll to max range.
99 virtual void SetFirstItem(const int n
) ;
100 virtual void SetFirstItem(const wxString
& s
) ;
102 virtual void InsertItems(const int nItems
, const wxString items
[], const int pos
);
104 virtual wxString
GetStringSelection(void) const ;
105 virtual bool SetStringSelection(const wxString
& s
, const bool flag
= TRUE
);
106 virtual int Number(void) const ;
108 void Command(wxCommandEvent
& event
);
110 // Windows-specific code to set the horizontal extent of
111 // the listbox, if necessary. If s is non-NULL, it's
112 // used to calculate the horizontal extent.
113 // Otherwise, all strings are used.
114 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
116 virtual WXHBRUSH
OnCtlColor(const WXHDC pDC
, const WXHWND pWnd
, const WXUINT nCtlColor
,
117 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
119 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
120 virtual void SetupColours(void);
129 wxListBoxItemsArray m_aItems
;