1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/combobox.h
3 // Purpose: wxComboBox class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_COMBOBOX_H_
13 #define _WX_COMBOBOX_H_
15 #include "wx/containr.h"
16 #include "wx/choice.h"
17 #include "wx/textctrl.h"
19 WXDLLIMPEXP_DATA_CORE(extern const char) wxComboBoxNameStr
[];
21 WX_DEFINE_ARRAY( char * , wxComboBoxDataArray
) ;
23 // forward declaration of private implementation classes
26 class wxComboBoxChoice
;
27 class wxComboWidgetImpl
;
30 class WXDLLIMPEXP_CORE wxComboBox
: public wxControl
, public wxComboBoxBase
32 DECLARE_DYNAMIC_CLASS(wxComboBox
)
35 virtual ~wxComboBox();
38 // forward these functions to all subcontrols
39 virtual bool Enable(bool enable
= true);
40 virtual bool Show(bool show
= true);
44 virtual void DelegateTextChanged( const wxString
& value
);
45 virtual void DelegateChoice( const wxString
& value
);
47 wxComboBox() { Init(); }
49 wxComboBox(wxWindow
*parent
, wxWindowID id
,
50 const wxString
& value
= wxEmptyString
,
51 const wxPoint
& pos
= wxDefaultPosition
,
52 const wxSize
& size
= wxDefaultSize
,
53 int n
= 0, const wxString choices
[] = NULL
,
55 const wxValidator
& validator
= wxDefaultValidator
,
56 const wxString
& name
= wxComboBoxNameStr
)
59 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
62 wxComboBox(wxWindow
*parent
, wxWindowID id
,
63 const wxString
& value
,
66 const wxArrayString
& choices
,
68 const wxValidator
& validator
= wxDefaultValidator
,
69 const wxString
& name
= wxComboBoxNameStr
)
72 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
75 bool Create(wxWindow
*parent
, wxWindowID id
,
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
);
84 bool Create(wxWindow
*parent
, wxWindowID id
,
85 const wxString
& value
,
88 const wxArrayString
& choices
,
90 const wxValidator
& validator
= wxDefaultValidator
,
91 const wxString
& name
= wxComboBoxNameStr
);
93 virtual int GetSelection() const;
94 virtual void GetSelection(long *from
, long *to
) const;
95 virtual void SetSelection(int n
);
96 virtual void SetSelection(long from
, long to
);
97 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
98 virtual wxString
GetString(unsigned int n
) const;
99 virtual wxString
GetStringSelection() const;
100 virtual void SetString(unsigned int n
, const wxString
& s
);
102 virtual unsigned int GetCount() const;
104 // these methods are provided by wxTextEntry for the native impl.
106 // Text field functions
107 virtual void SetValue(const wxString
& value
);
108 virtual wxString
GetValue() const;
109 virtual void WriteText(const wxString
& text
);
111 // Clipboard operations
114 virtual void Paste();
115 virtual void SetInsertionPoint(long pos
);
116 virtual void SetInsertionPointEnd();
117 virtual long GetInsertionPoint() const;
118 virtual wxTextPos
GetLastPosition() const;
119 virtual void Replace(long from
, long to
, const wxString
& value
);
120 virtual void Remove(long from
, long to
);
121 virtual void SetEditable(bool editable
);
122 virtual bool IsEditable() const;
126 virtual void SelectAll();
128 virtual bool CanCopy() const;
129 virtual bool CanCut() const;
130 virtual bool CanPaste() const;
131 virtual bool CanUndo() const;
132 virtual bool CanRedo() const;
134 virtual wxClientDataType
GetClientDataType() const;
139 // osx specific event handling common for all osx-ports
141 virtual bool OSXHandleClicked( double timestampsec
);
144 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
146 WX_DECLARE_CONTROL_CONTAINER();
149 // only used by the native Cocoa combobox, but we must define it everywhere
150 // to maintain the wxTextEntry abstraction.
151 virtual wxTextWidgetImpl
* GetTextPeer() const;
154 wxComboWidgetImpl
* GetComboPeer() const;
157 // common part of all ctors
161 virtual void DoDeleteOneItem(unsigned int n
);
162 virtual void DoClear();
164 // wxTextEntry functions
166 virtual wxString
DoGetValue() const;
168 virtual wxWindow
*GetEditableWindow() { return this; }
171 // override the base class virtuals involved in geometry calculations
172 virtual wxSize
DoGetBestSize() const;
173 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
176 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
178 void **clientData
, wxClientDataType type
);
180 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
181 virtual void * DoGetItemClientData(unsigned int n
) const;
184 virtual void SetClientDataType(wxClientDataType clientDataItemsType
);
187 virtual void EnableTextChangedEvents(bool enable
);
190 wxComboBoxText
* m_text
;
191 wxComboBoxChoice
* m_choice
;
193 wxComboBoxDataArray m_datas
;
196 DECLARE_EVENT_TABLE()
200 #endif // _WX_COMBOBOX_H_