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 // forward decl for GetSelections()
35 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
38 class WXDLLEXPORT wxListBox
: public wxControl
40 DECLARE_DYNAMIC_CLASS(wxListBox
)
44 inline 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 bool MSWCommand(WXUINT param
, WXWORD id
);
68 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
69 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
71 // plug-in for derived classes
72 virtual wxOwnerDrawn
*CreateItem(uint n
);
74 // allows to get the item and use SetXXX functions to set it's appearance
75 wxOwnerDrawn
*GetItem(uint n
) const { return m_aItems
[n
]; }
78 virtual void Append(const wxString
& item
);
79 virtual void Append(const wxString
& item
, char *clientData
);
80 virtual void Set(int n
, const wxString
* choices
, char **clientData
= NULL
);
81 virtual int FindString(const wxString
& s
) const ;
82 virtual void Clear(void);
83 virtual void SetSelection(int n
, bool select
= TRUE
);
85 virtual void Deselect(int n
);
87 // For single choice list item only
88 virtual int GetSelection() const ;
89 virtual void Delete(int n
);
90 virtual char *GetClientData(int n
) const ;
91 virtual void SetClientData(int n
, char *clientData
);
92 virtual void SetString(int n
, const wxString
& s
);
94 // For single or multiple choice list item
95 virtual int GetSelections(wxArrayInt
& aSelections
) const;
96 virtual bool Selected(int n
) const ;
97 virtual wxString
GetString(int n
) const ;
98 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
100 // Set the specified item at the first visible item
101 // or scroll to max range.
102 virtual void SetFirstItem(int n
) ;
103 virtual void SetFirstItem(const wxString
& s
) ;
105 virtual void InsertItems(int nItems
, const wxString items
[], int pos
);
107 virtual wxString
GetStringSelection(void) const ;
108 virtual bool SetStringSelection(const wxString
& s
, bool flag
= TRUE
);
109 virtual int Number(void) const ;
111 void Command(wxCommandEvent
& event
);
113 // Windows-specific code to set the horizontal extent of
114 // the listbox, if necessary. If s is non-NULL, it's
115 // used to calculate the horizontal extent.
116 // Otherwise, all strings are used.
117 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
119 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
120 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
122 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
123 virtual void SetupColours(void);
131 wxListBoxItemsArray m_aItems
;