1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_LISTBOX_H_
14 #define _WX_LISTBOX_H_
16 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
17 #pragma interface "listbox.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
23 #include "wx/dynarray.h"
24 #include "wx/arrstr.h"
26 // forward decl for GetSelections()
31 WX_DEFINE_ARRAY( char * , wxListDataArray
) ;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxListBox
: public wxListBoxBase
42 wxListBox(wxWindow
*parent
, wxWindowID id
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
45 int n
= 0, const wxString choices
[] = NULL
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxListBoxNameStr
)
50 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
52 wxListBox(wxWindow
*parent
, wxWindowID id
,
55 const wxArrayString
& choices
,
57 const wxValidator
& validator
= wxDefaultValidator
,
58 const wxString
& name
= wxListBoxNameStr
)
60 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
63 bool Create(wxWindow
*parent
, wxWindowID id
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
,
66 int n
= 0, const wxString choices
[] = NULL
,
68 const wxValidator
& validator
= wxDefaultValidator
,
69 const wxString
& name
= wxListBoxNameStr
);
70 bool Create(wxWindow
*parent
, wxWindowID id
,
73 const wxArrayString
& choices
,
75 const wxValidator
& validator
= wxDefaultValidator
,
76 const wxString
& name
= wxListBoxNameStr
);
79 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
81 // implement base class pure virtuals
83 virtual void Delete(int n
);
85 virtual int GetCount() const;
86 virtual wxString
GetString(int n
) const;
87 virtual void SetString(int n
, const wxString
& s
);
88 virtual int FindString(const wxString
& s
) const;
90 virtual bool IsSelected(int n
) const;
91 virtual void DoSetSelection(int n
, bool select
);
92 virtual int GetSelection() const;
93 virtual int GetSelections(wxArrayInt
& aSelections
) const;
95 virtual int DoAppend(const wxString
& item
);
96 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
97 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
99 virtual void DoSetFirstItem(int n
);
101 virtual void DoSetItemClientData(int n
, void* clientData
);
102 virtual void* DoGetItemClientData(int n
) const;
103 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
104 virtual wxClientData
* DoGetItemClientObject(int n
) const;
105 virtual void DoSetSize(int x
, int y
,int width
, int height
,int sizeFlags
= wxSIZE_AUTO
) ;
107 // wxCheckListBox support
108 static wxVisualAttributes
109 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
112 #ifndef __WXMAC_OSX__
113 void OnChar(wxKeyEvent
& event
);
117 wxArrayString m_stringArray
;
118 wxListDataArray m_dataArray
;
120 // as we are getting the same events for human and API selection we have to suppress
121 // events in the latter case
122 bool MacIsSelectionSuppressed() const { return m_suppressSelection
; }
124 void MacDelete( int n
) ;
125 void MacInsert( int n
, const wxString
& item
) ;
126 void MacAppend( const wxString
& item
) ;
127 void MacSet( int n
, const wxString
& item
) ;
129 void MacDeselectAll() ;
130 void MacSetSelection( int n
, bool select
) ;
131 int MacGetSelection() const ;
132 int MacGetSelections(wxArrayInt
& aSelections
) const ;
133 bool MacIsSelected( int n
) const ;
134 void MacScrollTo( int n
) ;
135 bool MacSuppressSelection( bool suppress
) ;
137 // free memory (common part of Clear() and dtor)
138 // prevent collision with some BSD definitions of macro Free()
143 bool m_suppressSelection
;
147 virtual wxSize
DoGetBestSize() const;
150 DECLARE_DYNAMIC_CLASS(wxListBox
)
151 DECLARE_EVENT_TABLE()
154 #endif // _WX_LISTBOX_H_