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 // FIXME: Quit deriving from wxTextCtrl
106 { wxComboBoxBase::Clear(); }
108 // wxCombobox methods
109 virtual void SetSelection(int pos
);
110 // Overlapping methods
111 virtual wxString
GetStringSelection();
113 virtual void DoClear();
114 virtual void DoDeleteOneItem(unsigned int n
);
115 virtual unsigned int GetCount() const;
116 virtual wxString
GetString(unsigned int) const;
117 virtual void SetString(unsigned int pos
, const wxString
&);
118 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
119 virtual int GetSelection() const;
120 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
122 void **clientData
, wxClientDataType type
);
123 virtual void DoSetItemClientData(unsigned int, void*);
124 virtual void* DoGetItemClientData(unsigned int) const;
125 virtual bool IsSorted() const { return HasFlag(wxCB_SORT
); }
126 // wxComboBoxBase pure virtuals
127 virtual wxString
GetValue() const
128 { return wxTextCtrl::GetValue(); }
129 virtual void SetValue(const wxString
& value
)
130 { return wxTextCtrl::SetValue(value
); }
131 virtual void Cut() { wxTextCtrl::Cut(); }
132 virtual void Copy() { wxTextCtrl::Copy(); }
133 virtual void Paste() { wxTextCtrl::Paste(); }
134 virtual void SetInsertionPoint(long pos
)
135 { wxTextCtrl::SetInsertionPoint(pos
); }
136 virtual void SetInsertionPointEnd()
137 { wxTextCtrl::SetInsertionPointEnd(); }
138 virtual long GetInsertionPoint() const
139 { return wxTextCtrl::GetInsertionPoint(); }
140 virtual wxTextPos
GetLastPosition() const
141 { return wxTextCtrl::GetLastPosition(); }
142 virtual void Replace(long from
, long to
, const wxString
& value
)
143 { wxTextCtrl::Replace(from
,to
,value
); }
144 virtual void SetSelection(long from
, long to
)
145 { wxTextCtrl::SetSelection(from
,to
); }
146 virtual void SetEditable(bool editable
)
147 { wxTextCtrl::SetEditable(editable
); }
148 virtual bool IsEditable() const
149 { return !HasFlag(wxCB_READONLY
); }
151 { wxTextCtrl::Undo(); }
153 { wxTextCtrl::Redo(); }
154 virtual void SelectAll()
155 { wxTextCtrl::SelectAll(); }
156 virtual bool CanCopy() const
157 { return wxTextCtrl::CanCopy(); }
158 virtual bool CanCut() const
159 { return wxTextCtrl::CanCut(); }
160 virtual bool CanPaste() const
161 { return wxTextCtrl::CanPaste(); }
162 virtual bool CanUndo() const
163 { return wxTextCtrl::CanUndo(); }
164 virtual bool CanRedo() const
165 { return wxTextCtrl::CanRedo(); }
168 #endif // __WX_COCOA_COMBOBOX_H__