]>
Commit | Line | Data |
---|---|---|
421a8431 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/cocoa/combobox.h | |
3 | // Purpose: wxComboBox class | |
8f248607 | 4 | // Author: Ryan Norton |
421a8431 | 5 | // Modified by: |
8f248607 | 6 | // Created: 2005/02/16 |
421a8431 DE |
7 | // RCS-ID: $Id$ |
8 | // Copyright: (c) 2003 David Elliott | |
7d8268a1 | 9 | // Licence: wxWindows licence |
421a8431 DE |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef __WX_COCOA_COMBOBOX_H__ | |
13 | #define __WX_COCOA_COMBOBOX_H__ | |
14 | ||
8f248607 RN |
15 | //Begin NSComboBox.h |
16 | ||
17 | #include "wx/hashmap.h" | |
18 | #include "wx/cocoa/ObjcAssociate.h" | |
19 | ||
e960ba59 DE |
20 | #include "wx/textctrl.h" |
21 | ||
8f248607 RN |
22 | DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox); |
23 | ||
24 | WX_DECLARE_OBJC_HASHMAP(NSComboBox); | |
25 | class wxCocoaNSComboBox | |
26 | { | |
27 | WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSComboBox) | |
28 | public: | |
29 | void AssociateNSComboBox(WX_NSComboBox cocoaNSComboBox); | |
30 | void DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox); | |
853dcc57 | 31 | |
8f248607 | 32 | virtual void doWxEvent(int nEvent) = 0; |
31e57091 | 33 | virtual ~wxCocoaNSComboBox() { } |
8f248607 RN |
34 | }; |
35 | ||
36 | //begin combobox.h | |
37 | ||
38 | #include "wx/dynarray.h" | |
421a8431 DE |
39 | |
40 | // ======================================================================== | |
41 | // wxComboBox | |
42 | // ======================================================================== | |
53a2db12 | 43 | class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase, protected wxCocoaNSComboBox, protected wxCocoaNSTextField |
421a8431 DE |
44 | { |
45 | DECLARE_DYNAMIC_CLASS(wxComboBox) | |
46 | DECLARE_EVENT_TABLE() | |
8f248607 | 47 | WX_DECLARE_COCOA_OWNER(NSComboBox,NSTextField,NSView) |
e960ba59 | 48 | WX_DECLARE_COCOA_OWNER(NSTextField,NSControl,NSView) |
421a8431 DE |
49 | // ------------------------------------------------------------------------ |
50 | // initialization | |
51 | // ------------------------------------------------------------------------ | |
52 | public: | |
53 | wxComboBox() { } | |
54 | wxComboBox(wxWindow *parent, wxWindowID winid, | |
55 | const wxString& value = wxEmptyString, | |
56 | const wxPoint& pos = wxDefaultPosition, | |
57 | const wxSize& size = wxDefaultSize, | |
58 | int n = 0, const wxString choices[] = NULL, | |
59 | long style = 0, | |
60 | const wxValidator& validator = wxDefaultValidator, | |
61 | const wxString& name = wxComboBoxNameStr) | |
62 | { | |
63 | Create(parent, winid, value, pos, size, n, choices, style, validator, name); | |
64 | } | |
584ad2a3 MB |
65 | wxComboBox(wxWindow *parent, wxWindowID winid, |
66 | const wxString& value, | |
67 | const wxPoint& pos, | |
68 | const wxSize& size, | |
69 | const wxArrayString& choices, | |
70 | long style = 0, | |
71 | const wxValidator& validator = wxDefaultValidator, | |
72 | const wxString& name = wxComboBoxNameStr) | |
73 | { | |
74 | Create(parent, winid, value, pos, size, choices, style, | |
75 | validator, name); | |
76 | } | |
421a8431 DE |
77 | |
78 | bool Create(wxWindow *parent, wxWindowID winid, | |
79 | const wxString& value = wxEmptyString, | |
80 | const wxPoint& pos = wxDefaultPosition, | |
81 | const wxSize& size = wxDefaultSize, | |
82 | int n = 0, const wxString choices[] = NULL, | |
83 | long style = 0, | |
84 | const wxValidator& validator = wxDefaultValidator, | |
85 | const wxString& name = wxComboBoxNameStr); | |
584ad2a3 MB |
86 | bool Create(wxWindow *parent, wxWindowID winid, |
87 | const wxString& value, | |
88 | const wxPoint& pos, | |
89 | const wxSize& size, | |
90 | const wxArrayString& choices, | |
91 | long style = 0, | |
92 | const wxValidator& validator = wxDefaultValidator, | |
93 | const wxString& name = wxComboBoxNameStr); | |
421a8431 DE |
94 | virtual ~wxComboBox(); |
95 | ||
96 | // ------------------------------------------------------------------------ | |
97 | // Cocoa callbacks | |
98 | // ------------------------------------------------------------------------ | |
99 | protected: | |
8f248607 RN |
100 | wxArrayPtrVoid m_Datas; |
101 | virtual void doWxEvent(int nEvent); | |
102 | ||
e960ba59 DE |
103 | virtual void Cocoa_didChangeText() |
104 | {} | |
421a8431 DE |
105 | // ------------------------------------------------------------------------ |
106 | // Implementation | |
107 | // ------------------------------------------------------------------------ | |
108 | public: | |
05ef417f DE |
109 | void Clear() // HACK |
110 | { wxComboBoxBase::Clear(); } | |
111 | ||
421a8431 | 112 | // wxCombobox methods |
aa61d352 | 113 | virtual void SetSelection(int pos); |
421a8431 DE |
114 | // Overlapping methods |
115 | virtual wxString GetStringSelection(); | |
421a8431 | 116 | // wxItemContainer |
a236aa20 VZ |
117 | virtual void DoClear(); |
118 | virtual void DoDeleteOneItem(unsigned int n); | |
aa61d352 VZ |
119 | virtual unsigned int GetCount() const; |
120 | virtual wxString GetString(unsigned int) const; | |
121 | virtual void SetString(unsigned int pos, const wxString&); | |
853dcc57 | 122 | virtual int FindString(const wxString& s, bool bCase = false) const; |
421a8431 | 123 | virtual int GetSelection() const; |
a236aa20 VZ |
124 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, |
125 | unsigned int pos, | |
126 | void **clientData, wxClientDataType type); | |
aa61d352 VZ |
127 | virtual void DoSetItemClientData(unsigned int, void*); |
128 | virtual void* DoGetItemClientData(unsigned int) const; | |
a236aa20 | 129 | virtual bool IsSorted() const { return HasFlag(wxCB_SORT); } |
e960ba59 DE |
130 | |
131 | // ------------------------------------------------------------------------ | |
132 | // wxTextEntryBase virtual implementations: | |
133 | // ------------------------------------------------------------------------ | |
134 | // FIXME: This needs to be moved to some sort of common code. | |
135 | virtual void WriteText(const wxString&); | |
136 | virtual wxString GetValue() const; | |
137 | virtual void Remove(long, long); | |
138 | virtual void Cut(); | |
139 | virtual void Copy(); | |
140 | virtual void Paste(); | |
141 | virtual void Undo(); | |
142 | virtual void Redo(); | |
143 | virtual bool CanUndo() const; | |
144 | virtual bool CanRedo() const; | |
145 | virtual void SetInsertionPoint(long pos); | |
146 | virtual long GetInsertionPoint() const; | |
147 | virtual wxTextPos GetLastPosition() const; | |
148 | virtual void SetSelection(long from, long to); | |
149 | virtual void GetSelection(long *from, long *to) const; | |
150 | virtual bool IsEditable() const; | |
151 | virtual void SetEditable(bool editable); | |
63f7d502 VZ |
152 | |
153 | private: | |
154 | // implement wxTextEntry pure virtual method | |
155 | virtual wxWindow *GetEditableWindow() { return this; } | |
421a8431 DE |
156 | }; |
157 | ||
158 | #endif // __WX_COCOA_COMBOBOX_H__ |