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 #include "wx/textctrl.h"
22 DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox
);
24 WX_DECLARE_OBJC_HASHMAP(NSComboBox
);
25 class wxCocoaNSComboBox
27 WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSComboBox
)
29 void AssociateNSComboBox(WX_NSComboBox cocoaNSComboBox
);
30 void DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox
);
32 virtual void doWxEvent(int nEvent
) = 0;
33 virtual ~wxCocoaNSComboBox() { }
38 #include "wx/dynarray.h"
40 // ========================================================================
42 // ========================================================================
43 class WXDLLIMPEXP_CORE wxComboBox
: public wxControl
, public wxComboBoxBase
, protected wxCocoaNSComboBox
, protected wxCocoaNSTextField
45 DECLARE_DYNAMIC_CLASS(wxComboBox
)
47 WX_DECLARE_COCOA_OWNER(NSComboBox
,NSTextField
,NSView
)
48 WX_DECLARE_COCOA_OWNER(NSTextField
,NSControl
,NSView
)
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
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
,
60 const wxValidator
& validator
= wxDefaultValidator
,
61 const wxString
& name
= wxComboBoxNameStr
)
63 Create(parent
, winid
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
65 wxComboBox(wxWindow
*parent
, wxWindowID winid
,
66 const wxString
& value
,
69 const wxArrayString
& choices
,
71 const wxValidator
& validator
= wxDefaultValidator
,
72 const wxString
& name
= wxComboBoxNameStr
)
74 Create(parent
, winid
, value
, pos
, size
, choices
, style
,
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
,
84 const wxValidator
& validator
= wxDefaultValidator
,
85 const wxString
& name
= wxComboBoxNameStr
);
86 bool Create(wxWindow
*parent
, wxWindowID winid
,
87 const wxString
& value
,
90 const wxArrayString
& choices
,
92 const wxValidator
& validator
= wxDefaultValidator
,
93 const wxString
& name
= wxComboBoxNameStr
);
94 virtual ~wxComboBox();
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
100 wxArrayPtrVoid m_Datas
;
101 virtual void doWxEvent(int nEvent
);
103 virtual void Cocoa_didChangeText()
105 // ------------------------------------------------------------------------
107 // ------------------------------------------------------------------------
110 { wxComboBoxBase::Clear(); }
112 // wxCombobox methods
113 virtual void SetSelection(int pos
);
114 // Overlapping methods
115 virtual wxString
GetStringSelection();
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
,
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
); }
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);
140 virtual void Paste();
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
);
154 // implement wxTextEntry pure virtual method
155 virtual wxWindow
*GetEditableWindow() { return this; }
158 #endif // __WX_COCOA_COMBOBOX_H__