1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/listbox.h
3 // Purpose: wxListBox class
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_LISTBOX_H_
12 #define _WX_LISTBOX_H_
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
17 #include "wx/dynarray.h"
18 #include "wx/arrstr.h"
20 // forward decl for GetSelections()
23 // forward decl for wxListWidgetImpl implementation type.
24 class wxListWidgetImpl
;
28 WX_DEFINE_ARRAY( char* , wxListDataArray
);
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 class WXDLLIMPEXP_FWD_CORE wxListWidgetColumn
;
36 class WXDLLIMPEXP_FWD_CORE wxListWidgetCellValue
;
38 class WXDLLIMPEXP_CORE wxListBox
: public wxListBoxBase
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
49 int n
= 0, const wxString choices
[] = NULL
,
51 const wxValidator
& validator
= wxDefaultValidator
,
52 const wxString
& name
= wxListBoxNameStr
)
54 Create(parent
, winid
, pos
, size
, n
, choices
, style
, validator
, name
);
62 const wxArrayString
& choices
,
64 const wxValidator
& validator
= wxDefaultValidator
,
65 const wxString
& name
= wxListBoxNameStr
)
67 Create(parent
, winid
, pos
, size
, choices
, style
, validator
, name
);
73 const wxPoint
& pos
= wxDefaultPosition
,
74 const wxSize
& size
= wxDefaultSize
,
76 const wxString choices
[] = NULL
,
78 const wxValidator
& validator
= wxDefaultValidator
,
79 const wxString
& name
= wxListBoxNameStr
);
86 const wxArrayString
& choices
,
88 const wxValidator
& validator
= wxDefaultValidator
,
89 const wxString
& name
= wxListBoxNameStr
);
93 // implement base class pure virtuals
94 virtual void Refresh(bool eraseBack
= true, const wxRect
*rect
= NULL
);
96 virtual unsigned int GetCount() const;
97 virtual wxString
GetString(unsigned int n
) const;
98 virtual void SetString(unsigned int n
, const wxString
& s
);
99 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
102 virtual void GetValueCallback( unsigned int n
, wxListWidgetColumn
* col
, wxListWidgetCellValue
& value
);
103 virtual void SetValueCallback( unsigned int n
, wxListWidgetColumn
* col
, wxListWidgetCellValue
& value
);
105 virtual bool IsSelected(int n
) const;
106 virtual int GetSelection() const;
107 virtual int GetSelections(wxArrayInt
& aSelections
) const;
109 virtual void EnsureVisible(int n
);
111 virtual wxVisualAttributes
GetDefaultAttributes() const
113 return GetClassDefaultAttributes(GetWindowVariant());
116 // wxCheckListBox support
117 static wxVisualAttributes
118 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
120 wxListWidgetImpl
* GetListPeer() const;
122 bool MacGetBlockEvents() const { return m_blockEvents
; }
124 virtual void HandleLineEvent( unsigned int n
, bool doubleClick
);
126 // callback for derived classes which may have to insert additional data
127 // at a certain line - which cannot be predetermined for sorted list data
128 virtual void OnItemInserted(unsigned int pos
);
130 virtual void DoClear();
131 virtual void DoDeleteOneItem(unsigned int n
);
133 // from wxItemContainer
134 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
136 void **clientData
, wxClientDataType type
);
138 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
139 virtual void* DoGetItemClientData(unsigned int n
) const;
141 // from wxListBoxBase
142 virtual void DoSetSelection(int n
, bool select
);
143 virtual void DoSetFirstItem(int n
);
144 virtual int DoListHitTest(const wxPoint
& point
) const;
146 // free memory (common part of Clear() and dtor)
147 // prevent collision with some BSD definitions of macro Free()
150 virtual wxSize
DoGetBestSize() const;
154 wxListWidgetColumn
* m_textColumn
;
156 // data storage (copied from univ)
158 // the array containing all items (it is sorted if the listbox has
162 wxArrayString
*unsorted
;
163 wxSortedArrayString
*sorted
;
166 // and this one the client data (either void or wxClientData)
167 wxArrayPtrVoid m_itemsClientData
;
170 #ifdef __WXOSX_CARBON__
171 // It needs to call our CalcAndSendEvent().
172 friend class wxMacDataBrowserListControl
;
175 DECLARE_DYNAMIC_CLASS(wxListBox
)
176 DECLARE_EVENT_TABLE()
179 #endif // _WX_LISTBOX_H_