1 /////////////////////////////////////////////////////////////////////////////
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 #include "wx/control.h"
21 WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr
;
24 class WXDLLEXPORT wxOwnerDrawn
;
26 // define the array of list box items
27 #include <wx/dynarray.h>
28 WX_DEFINE_ARRAY(wxOwnerDrawn
*, wxListBoxItemsArray
);
31 // forward decl for GetSelections()
34 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
37 class WXDLLEXPORT wxListBox
: public wxControl
39 DECLARE_DYNAMIC_CLASS(wxListBox
)
43 inline wxListBox(wxWindow
*parent
, wxWindowID id
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
46 int n
= 0, const wxString choices
[] = NULL
,
48 const wxValidator
& validator
= wxDefaultValidator
,
49 const wxString
& name
= wxListBoxNameStr
)
51 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
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 bool MSWCommand(WXUINT param
, WXWORD id
);
67 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
68 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
70 // plug-in for derived classes
71 virtual wxOwnerDrawn
*CreateItem(size_t n
);
73 // allows to get the item and use SetXXX functions to set it's appearance
74 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
77 virtual void Append(const wxString
& item
);
78 virtual void Append(const wxString
& item
, char *clientData
);
79 virtual void Set(int n
, const wxString
* choices
, char **clientData
= NULL
);
80 virtual int FindString(const wxString
& s
) const ;
81 virtual void Clear(void);
82 virtual void SetSelection(int n
, bool select
= TRUE
);
84 virtual void Deselect(int n
);
86 // For single choice list item only
87 virtual int GetSelection() const ;
88 virtual void Delete(int n
);
89 virtual char *GetClientData(int n
) const ;
90 virtual void SetClientData(int n
, char *clientData
);
91 virtual void SetString(int n
, const wxString
& s
);
93 // For single or multiple choice list item
94 virtual int GetSelections(wxArrayInt
& aSelections
) const;
95 virtual bool Selected(int n
) const ;
96 virtual wxString
GetString(int n
) const ;
97 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
99 // Set the specified item at the first visible item
100 // or scroll to max range.
101 virtual void SetFirstItem(int n
) ;
102 virtual void SetFirstItem(const wxString
& s
) ;
104 virtual void InsertItems(int nItems
, const wxString items
[], int pos
);
106 virtual wxString
GetStringSelection(void) const ;
107 virtual bool SetStringSelection(const wxString
& s
, bool flag
= TRUE
);
108 virtual int Number(void) const ;
110 void Command(wxCommandEvent
& event
);
112 // Windows-specific code to set the horizontal extent of
113 // the listbox, if necessary. If s is non-NULL, it's
114 // used to calculate the horizontal extent.
115 // Otherwise, all strings are used.
116 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
118 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
119 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
121 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
122 virtual void SetupColours(void);
130 wxListBoxItemsArray m_aItems
;