1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/combobox.h
3 // Purpose: wxComboBox class
7 // Copyright: (c) 2003 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __WX_COCOA_COMBOBOX_H__
12 #define __WX_COCOA_COMBOBOX_H__
16 #include "wx/hashmap.h"
17 #include "wx/cocoa/ObjcAssociate.h"
19 #include "wx/textctrl.h"
21 DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox
);
23 WX_DECLARE_OBJC_HASHMAP(NSComboBox
);
24 class wxCocoaNSComboBox
26 WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSComboBox
)
28 void AssociateNSComboBox(WX_NSComboBox cocoaNSComboBox
);
29 void DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox
);
31 virtual void doWxEvent(int nEvent
) = 0;
32 virtual ~wxCocoaNSComboBox() { }
37 #include "wx/dynarray.h"
39 // ========================================================================
41 // ========================================================================
42 class WXDLLIMPEXP_CORE wxComboBox
: public wxControl
, public wxComboBoxBase
, protected wxCocoaNSComboBox
, protected wxCocoaNSTextField
44 DECLARE_DYNAMIC_CLASS(wxComboBox
)
46 WX_DECLARE_COCOA_OWNER(NSComboBox
,NSTextField
,NSView
)
47 WX_DECLARE_COCOA_OWNER(NSTextField
,NSControl
,NSView
)
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
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
,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxComboBoxNameStr
)
62 Create(parent
, winid
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
64 wxComboBox(wxWindow
*parent
, wxWindowID winid
,
65 const wxString
& value
,
68 const wxArrayString
& choices
,
70 const wxValidator
& validator
= wxDefaultValidator
,
71 const wxString
& name
= wxComboBoxNameStr
)
73 Create(parent
, winid
, value
, pos
, size
, choices
, style
,
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
,
83 const wxValidator
& validator
= wxDefaultValidator
,
84 const wxString
& name
= wxComboBoxNameStr
);
85 bool Create(wxWindow
*parent
, wxWindowID winid
,
86 const wxString
& value
,
89 const wxArrayString
& choices
,
91 const wxValidator
& validator
= wxDefaultValidator
,
92 const wxString
& name
= wxComboBoxNameStr
);
93 virtual ~wxComboBox();
95 // ------------------------------------------------------------------------
97 // ------------------------------------------------------------------------
99 wxArrayPtrVoid m_Datas
;
100 virtual void doWxEvent(int nEvent
);
102 virtual void Cocoa_didChangeText()
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
109 { wxComboBoxBase::Clear(); }
111 // wxCombobox methods
112 virtual void SetSelection(int pos
);
113 // Overlapping methods
114 virtual wxString
GetStringSelection();
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
,
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
); }
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);
139 virtual void Paste();
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
);
153 // implement wxTextEntry pure virtual method
154 virtual wxWindow
*GetEditableWindow() { return this; }
157 #endif // __WX_COCOA_COMBOBOX_H__