]>
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 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2003 David Elliott | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef __WX_COCOA_COMBOBOX_H__ | |
13 | #define __WX_COCOA_COMBOBOX_H__ | |
14 | ||
15 | //Begin NSComboBox.h | |
16 | ||
17 | #include "wx/hashmap.h" | |
18 | #include "wx/cocoa/ObjcAssociate.h" | |
19 | ||
20 | #include "wx/textctrl.h" | |
21 | ||
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); | |
31 | ||
32 | virtual void doWxEvent(int nEvent) = 0; | |
33 | virtual ~wxCocoaNSComboBox() { } | |
34 | }; | |
35 | ||
36 | //begin combobox.h | |
37 | ||
38 | #include "wx/dynarray.h" | |
39 | ||
40 | // ======================================================================== | |
41 | // wxComboBox | |
42 | // ======================================================================== | |
43 | class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase, protected wxCocoaNSComboBox, protected wxCocoaNSTextField | |
44 | { | |
45 | DECLARE_DYNAMIC_CLASS(wxComboBox) | |
46 | DECLARE_EVENT_TABLE() | |
47 | WX_DECLARE_COCOA_OWNER(NSComboBox,NSTextField,NSView) | |
48 | WX_DECLARE_COCOA_OWNER(NSTextField,NSControl,NSView) | |
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 | } | |
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 | } | |
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); | |
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); | |
94 | virtual ~wxComboBox(); | |
95 | ||
96 | // ------------------------------------------------------------------------ | |
97 | // Cocoa callbacks | |
98 | // ------------------------------------------------------------------------ | |
99 | protected: | |
100 | wxArrayPtrVoid m_Datas; | |
101 | virtual void doWxEvent(int nEvent); | |
102 | ||
103 | virtual void Cocoa_didChangeText() | |
104 | {} | |
105 | // ------------------------------------------------------------------------ | |
106 | // Implementation | |
107 | // ------------------------------------------------------------------------ | |
108 | public: | |
109 | void Clear() // HACK | |
110 | { wxComboBoxBase::Clear(); } | |
111 | ||
112 | // wxCombobox methods | |
113 | virtual void SetSelection(int pos); | |
114 | // Overlapping methods | |
115 | virtual wxString GetStringSelection(); | |
116 | // wxItemContainer | |
117 | virtual void DoClear(); | |
118 | virtual void DoDeleteOneItem(unsigned int n); | |
119 | virtual unsigned int GetCount() const; | |
120 | virtual wxString GetString(unsigned int) const; | |
121 | virtual void SetString(unsigned int pos, const wxString&); | |
122 | virtual int FindString(const wxString& s, bool bCase = false) const; | |
123 | virtual int GetSelection() const; | |
124 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, | |
125 | unsigned int pos, | |
126 | void **clientData, wxClientDataType type); | |
127 | virtual void DoSetItemClientData(unsigned int, void*); | |
128 | virtual void* DoGetItemClientData(unsigned int) const; | |
129 | virtual bool IsSorted() const { return HasFlag(wxCB_SORT); } | |
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); | |
152 | }; | |
153 | ||
154 | #endif // __WX_COCOA_COMBOBOX_H__ |