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