1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class
8 // Copyright: (c) AUTHOR
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"
20 #include "wx/dynarray.h"
22 WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr
;
24 // forward decl for GetSelections()
25 class WXDLLEXPORT wxArrayInt
;
27 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
31 WX_DEFINE_ARRAY( char * , wxListDataArray
) ;
33 class WXDLLEXPORT wxListBox
: public wxControl
35 DECLARE_DYNAMIC_CLASS(wxListBox
)
39 inline wxListBox(wxWindow
*parent
, wxWindowID id
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
42 int n
= 0, const wxString choices
[] = NULL
,
44 const wxValidator
& validator
= wxDefaultValidator
,
45 const wxString
& name
= wxListBoxNameStr
)
47 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
50 bool Create(wxWindow
*parent
, wxWindowID id
,
51 const wxPoint
& pos
= wxDefaultPosition
,
52 const wxSize
& size
= wxDefaultSize
,
53 int n
= 0, const wxString choices
[] = NULL
,
55 const wxValidator
& validator
= wxDefaultValidator
,
56 const wxString
& name
= wxListBoxNameStr
);
60 virtual void Append(const wxString
& item
);
61 virtual void Append(const wxString
& item
, char *clientData
);
62 virtual void Set(int n
, const wxString
* choices
, char **clientData
= NULL
);
63 virtual int FindString(const wxString
& s
) const ;
65 virtual void SetSelection(int n
, bool select
= TRUE
);
67 virtual void Deselect(int n
);
69 // For single choice list item only
70 virtual int GetSelection() const ;
71 virtual void Delete(int n
);
72 virtual char *GetClientData(int n
) const ;
73 virtual void SetClientData(int n
, char *clientData
);
74 virtual void SetString(int n
, const wxString
& s
);
76 // For single or multiple choice list item
77 virtual int GetSelections(wxArrayInt
& aSelections
) const;
78 virtual bool Selected(int n
) const ;
79 virtual wxString
GetString(int n
) const ;
81 // Set the specified item at the first visible item
82 // or scroll to max range.
83 virtual void SetFirstItem(int n
) ;
84 virtual void SetFirstItem(const wxString
& s
) ;
86 virtual void InsertItems(int nItems
, const wxString items
[], int pos
);
88 virtual wxString
GetStringSelection() const ;
89 virtual bool SetStringSelection(const wxString
& s
, bool flag
= TRUE
);
90 virtual int Number() const ;
92 void Command(wxCommandEvent
& event
);
94 void MacSetRedraw( bool doDraw
) ;
100 void MacDelete( int n
) ;
101 void MacInsert( int n
, const char * text
) ;
102 void MacAppend( const char * text
) ;
103 void MacSet( int n
, const char *text
) ;
105 void MacSetSelection( int n
, bool select
) ;
106 int MacGetSelection() const ;
107 int MacGetSelections(wxArrayInt
& aSelections
) const ;
108 bool MacIsSelected( int n
) const ;
109 void MacScrollTo( int n
) ;
110 void OnSize( const wxSizeEvent
&size
) ;
112 void MacDoDoubleClick() ;
115 ListHandle m_macList
;
116 wxArrayString m_stringArray
;
117 wxListDataArray m_dataArray
;
119 virtual void MacHandleControlClick( ControlHandle control
, SInt16 controlpart
) ;
120 DECLARE_EVENT_TABLE()