]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/listbox.h
Add wxActivateEvent::GetActivationReason().
[wxWidgets.git] / include / wx / cocoa / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/listbox.h
3 // Purpose: wxListBox class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/03/16
7 // Copyright: (c) 2003 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef __WX_COCOA_LISTBOX_H__
12 #define __WX_COCOA_LISTBOX_H__
13
14 #include "wx/cocoa/NSTableView.h"
15
16 #include "wx/dynarray.h"
17
18 // ========================================================================
19 // wxListBox
20 // ========================================================================
21 class WXDLLIMPEXP_CORE wxListBox: public wxListBoxBase, protected wxCocoaNSTableView
22 {
23 DECLARE_DYNAMIC_CLASS(wxListBox)
24 DECLARE_EVENT_TABLE()
25 WX_DECLARE_COCOA_OWNER(NSTableView,NSControl,NSView)
26 // ------------------------------------------------------------------------
27 // initialization
28 // ------------------------------------------------------------------------
29 public:
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,
35 long style = 0,
36 const wxValidator& validator = wxDefaultValidator,
37 const wxString& name = wxListBoxNameStr)
38 {
39 Create(parent, winid, pos, size, n, choices, style, validator, name);
40 }
41 wxListBox(wxWindow *parent, wxWindowID winid,
42 const wxPoint& pos,
43 const wxSize& size,
44 const wxArrayString& choices,
45 long style = 0,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString& name = wxListBoxNameStr)
48 {
49 Create(parent, winid, pos, size, choices, style, validator, name);
50 }
51
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,
56 long style = 0,
57 const wxValidator& validator = wxDefaultValidator,
58 const wxString& name = wxListBoxNameStr);
59 bool Create(wxWindow *parent, wxWindowID winid,
60 const wxPoint& pos,
61 const wxSize& size,
62 const wxArrayString& choices,
63 long style = 0,
64 const wxValidator& validator = wxDefaultValidator,
65 const wxString& name = wxListBoxNameStr);
66 virtual ~wxListBox();
67
68 // ------------------------------------------------------------------------
69 // Cocoa callbacks
70 // ------------------------------------------------------------------------
71 protected:
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;
78 bool m_needsUpdate;
79 inline bool _WxCocoa_GetNeedsUpdate();
80 inline void _WxCocoa_SetNeedsUpdate(bool needsUpdate);
81 virtual void OnInternalIdle();
82 // ------------------------------------------------------------------------
83 // Implementation
84 // ------------------------------------------------------------------------
85 public:
86 virtual wxSize DoGetBestSize() const;
87 // pure virtuals from wxListBoxBase
88 virtual bool IsSelected(int n) const;
89 virtual int GetSelections(wxArrayInt& aSelections) const;
90 protected:
91 virtual void DoSetFirstItem(int n);
92 virtual void DoSetSelection(int n, bool select);
93
94 // pure virtuals from wxItemContainer
95 public:
96 // deleting items
97 virtual void DoClear();
98 virtual void DoDeleteOneItem(unsigned int n);
99 // accessing strings
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;
104 // selection
105 virtual int GetSelection() const;
106 protected:
107 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
108 unsigned int pos,
109 void **clientData, wxClientDataType type);
110 virtual void DoSetItemClientData(unsigned int n, void* clientData);
111 virtual void* DoGetItemClientData(unsigned int n) const;
112 };
113
114 #endif // __WX_COCOA_LISTBOX_H__