1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/listbox.h
3 // Purpose: wxListBox class
4 // Author: David Elliott
7 // Copyright: (c) 2003 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __WX_COCOA_LISTBOX_H__
12 #define __WX_COCOA_LISTBOX_H__
14 #include "wx/cocoa/NSTableView.h"
16 #include "wx/dynarray.h"
18 // ========================================================================
20 // ========================================================================
21 class WXDLLIMPEXP_CORE wxListBox
: public wxListBoxBase
, protected wxCocoaNSTableView
23 DECLARE_DYNAMIC_CLASS(wxListBox
)
25 WX_DECLARE_COCOA_OWNER(NSTableView
,NSControl
,NSView
)
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 wxListBox() { m_cocoaItems
= NULL
; m_cocoaDataSource
= NULL
; }
31 wxListBox(wxWindow
*parent
, wxWindowID winid
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
34 int n
= 0, const wxString choices
[] = NULL
,
36 const wxValidator
& validator
= wxDefaultValidator
,
37 const wxString
& name
= wxListBoxNameStr
)
39 Create(parent
, winid
, pos
, size
, n
, choices
, style
, validator
, name
);
41 wxListBox(wxWindow
*parent
, wxWindowID winid
,
44 const wxArrayString
& choices
,
46 const wxValidator
& validator
= wxDefaultValidator
,
47 const wxString
& name
= wxListBoxNameStr
)
49 Create(parent
, winid
, pos
, size
, choices
, style
, validator
, name
);
52 bool Create(wxWindow
*parent
, wxWindowID winid
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
55 int n
= 0, const wxString choices
[] = NULL
,
57 const wxValidator
& validator
= wxDefaultValidator
,
58 const wxString
& name
= wxListBoxNameStr
);
59 bool Create(wxWindow
*parent
, wxWindowID winid
,
62 const wxArrayString
& choices
,
64 const wxValidator
& validator
= wxDefaultValidator
,
65 const wxString
& name
= wxListBoxNameStr
);
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
72 virtual int CocoaDataSource_numberOfRows();
73 virtual struct objc_object
* CocoaDataSource_objectForTableColumn(
74 WX_NSTableColumn tableColumn
, int rowIndex
);
75 WX_NSMutableArray m_cocoaItems
;
76 wxArrayPtrVoid m_itemClientData
;
77 struct objc_object
*m_cocoaDataSource
;
79 inline bool _WxCocoa_GetNeedsUpdate();
80 inline void _WxCocoa_SetNeedsUpdate(bool needsUpdate
);
81 virtual void OnInternalIdle();
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
86 virtual wxSize
DoGetBestSize() const;
87 // pure virtuals from wxListBoxBase
88 virtual bool IsSelected(int n
) const;
89 virtual int GetSelections(wxArrayInt
& aSelections
) const;
91 virtual void DoSetFirstItem(int n
);
92 virtual void DoSetSelection(int n
, bool select
);
94 // pure virtuals from wxItemContainer
97 virtual void DoClear();
98 virtual void DoDeleteOneItem(unsigned int n
);
100 virtual unsigned int GetCount() const;
101 virtual wxString
GetString(unsigned int n
) const;
102 virtual void SetString(unsigned int n
, const wxString
& s
);
103 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
105 virtual int GetSelection() const;
107 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
109 void **clientData
, wxClientDataType type
);
110 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
111 virtual void* DoGetItemClientData(unsigned int n
) const;
114 #endif // __WX_COCOA_LISTBOX_H__