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>
29 #undef WXDLLEXPORTLOCAL
30 #define WXDLLEXPORTLOCAL WXDLLEXPORT
31 WX_DEFINE_ARRAY(wxOwnerDrawn
*, wxListBoxItemsArray
);
32 #undef WXDLLEXPORTLOCAL
33 #define WXDLLEXPORTLOCAL
37 // forward decl for GetSelections()
40 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
43 class WXDLLEXPORT wxListBox
: public wxControl
45 DECLARE_DYNAMIC_CLASS(wxListBox
)
49 inline wxListBox(wxWindow
*parent
, wxWindowID id
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
52 int n
= 0, const wxString choices
[] = NULL
,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxListBoxNameStr
)
57 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
60 bool Create(wxWindow
*parent
, wxWindowID id
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
63 int n
= 0, const wxString choices
[] = NULL
,
65 const wxValidator
& validator
= wxDefaultValidator
,
66 const wxString
& name
= wxListBoxNameStr
);
70 bool MSWCommand(WXUINT param
, WXWORD id
);
73 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
74 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
76 // plug-in for derived classes
77 virtual wxOwnerDrawn
*CreateItem(size_t n
);
79 // allows to get the item and use SetXXX functions to set it's appearance
80 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
83 virtual void Append(const wxString
& item
);
84 virtual void Append(const wxString
& item
, char *clientData
);
85 virtual void Set(int n
, const wxString
* choices
, char **clientData
= NULL
);
86 virtual int FindString(const wxString
& s
) const ;
87 virtual void Clear(void);
88 virtual void SetSelection(int n
, bool select
= TRUE
);
90 virtual void Deselect(int n
);
92 // For single choice list item only
93 virtual int GetSelection() const ;
94 virtual void Delete(int n
);
95 virtual char *GetClientData(int n
) const ;
96 virtual void SetClientData(int n
, char *clientData
);
97 virtual void SetString(int n
, const wxString
& s
);
99 // For single or multiple choice list item
100 virtual int GetSelections(wxArrayInt
& aSelections
) const;
101 virtual bool Selected(int n
) const ;
102 virtual wxString
GetString(int n
) const ;
103 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
105 // Set the specified item at the first visible item
106 // or scroll to max range.
107 virtual void SetFirstItem(int n
) ;
108 virtual void SetFirstItem(const wxString
& s
) ;
110 virtual void InsertItems(int nItems
, const wxString items
[], int pos
);
112 virtual wxString
GetStringSelection(void) const ;
113 virtual bool SetStringSelection(const wxString
& s
, bool flag
= TRUE
);
114 virtual int Number(void) const ;
116 void Command(wxCommandEvent
& event
);
118 // Windows-specific code to set the horizontal extent of
119 // the listbox, if necessary. If s is non-NULL, it's
120 // used to calculate the horizontal extent.
121 // Otherwise, all strings are used.
122 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
124 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
125 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
127 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
128 virtual void SetupColours(void);
134 #if wxUSE_OWNER_DRAWN
136 wxListBoxItemsArray m_aItems
;