1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/combobox.h
3 // Purpose: wxComboBox class
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_COCOA_COMBOBOX_H__
13 #define __WX_COCOA_COMBOBOX_H__
17 #include "wx/hashmap.h"
18 #include "wx/cocoa/ObjcAssociate.h"
20 DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox
);
22 WX_DECLARE_OBJC_HASHMAP(NSComboBox
);
23 class wxCocoaNSComboBox
25 WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSComboBox
)
27 void AssociateNSComboBox(WX_NSComboBox cocoaNSComboBox
);
28 void DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox
);
30 virtual void doWxEvent(int nEvent
) = 0;
31 virtual ~wxCocoaNSComboBox() { }
36 #include "wx/dynarray.h"
38 // ========================================================================
40 // ========================================================================
41 class WXDLLEXPORT wxComboBox
: public wxTextCtrl
, public wxComboBoxBase
, protected wxCocoaNSComboBox
43 DECLARE_DYNAMIC_CLASS(wxComboBox
)
45 WX_DECLARE_COCOA_OWNER(NSComboBox
,NSTextField
,NSView
)
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
51 wxComboBox(wxWindow
*parent
, wxWindowID winid
,
52 const wxString
& value
= wxEmptyString
,
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
= wxComboBoxNameStr
)
60 Create(parent
, winid
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
62 wxComboBox(wxWindow
*parent
, wxWindowID winid
,
63 const wxString
& value
,
66 const wxArrayString
& choices
,
68 const wxValidator
& validator
= wxDefaultValidator
,
69 const wxString
& name
= wxComboBoxNameStr
)
71 Create(parent
, winid
, value
, pos
, size
, choices
, style
,
75 bool Create(wxWindow
*parent
, wxWindowID winid
,
76 const wxString
& value
= wxEmptyString
,
77 const wxPoint
& pos
= wxDefaultPosition
,
78 const wxSize
& size
= wxDefaultSize
,
79 int n
= 0, const wxString choices
[] = NULL
,
81 const wxValidator
& validator
= wxDefaultValidator
,
82 const wxString
& name
= wxComboBoxNameStr
);
83 bool Create(wxWindow
*parent
, wxWindowID winid
,
84 const wxString
& value
,
87 const wxArrayString
& choices
,
89 const wxValidator
& validator
= wxDefaultValidator
,
90 const wxString
& name
= wxComboBoxNameStr
);
91 virtual ~wxComboBox();
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
97 wxArrayPtrVoid m_Datas
;
98 virtual void doWxEvent(int nEvent
);
100 // ------------------------------------------------------------------------
102 // ------------------------------------------------------------------------
104 // wxCombobox methods
105 virtual void SetSelection(int);
106 // Overlapping methods
107 virtual wxString
GetStringSelection();
109 virtual void Clear();
110 virtual void Delete(int);
111 virtual size_t GetCount() const;
112 virtual wxString
GetString(int) const;
113 virtual void SetString(int, const wxString
&);
114 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
115 virtual int GetSelection() const;
116 virtual int DoAppend(const wxString
&);
117 virtual int DoInsert(const wxString
&, int);
118 virtual void DoSetItemClientData(int, void*);
119 virtual void* DoGetItemClientData(int) const;
120 virtual void DoSetItemClientObject(int, wxClientData
*);
121 virtual wxClientData
* DoGetItemClientObject(int) const;
122 // wxComboBoxBase pure virtuals
123 virtual wxString
GetValue() const
124 { return wxTextCtrl::GetValue(); }
125 virtual void SetValue(const wxString
& value
)
126 { return wxTextCtrl::SetValue(value
); }
127 virtual void Cut() { wxTextCtrl::Cut(); }
128 virtual void Copy() { wxTextCtrl::Copy(); }
129 virtual void Paste() { wxTextCtrl::Paste(); }
130 virtual void SetInsertionPoint(long pos
)
131 { wxTextCtrl::SetInsertionPoint(pos
); }
132 virtual void SetInsertionPointEnd()
133 { wxTextCtrl::SetInsertionPointEnd(); }
134 virtual long GetInsertionPoint() const
135 { return wxTextCtrl::GetInsertionPoint(); }
136 virtual wxTextPos
GetLastPosition() const
137 { return wxTextCtrl::GetLastPosition(); }
138 virtual void Replace(long from
, long to
, const wxString
& value
)
139 { wxTextCtrl::Replace(from
,to
,value
); }
140 virtual void SetSelection(long from
, long to
)
141 { wxTextCtrl::SetSelection(from
,to
); }
142 virtual void SetEditable(bool editable
)
143 { wxTextCtrl::SetEditable(editable
); }
144 virtual bool IsEditable() const
145 { return !HasFlag(wxCB_READONLY
); }
147 { wxTextCtrl::Undo(); }
149 { wxTextCtrl::Redo(); }
150 virtual void SelectAll()
151 { wxTextCtrl::SelectAll(); }
152 virtual bool CanCopy() const
153 { return wxTextCtrl::CanCopy(); }
154 virtual bool CanCut() const
155 { return wxTextCtrl::CanCut(); }
156 virtual bool CanPaste() const
157 { return wxTextCtrl::CanPaste(); }
158 virtual bool CanUndo() const
159 { return wxTextCtrl::CanUndo(); }
160 virtual bool CanRedo() const
161 { return wxTextCtrl::CanRedo(); }
164 #endif // __WX_COCOA_COMBOBOX_H__