1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKCOMBOBOXH__
12 #define __GTKCOMBOBOXH__
18 #include "wx/object.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class WXDLLIMPEXP_CORE wxComboBox
;
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 extern WXDLLIMPEXP_CORE
const wxChar
* wxComboBoxNameStr
;
31 extern WXDLLIMPEXP_BASE
const wxChar
* wxEmptyString
;
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 class WXDLLIMPEXP_CORE wxComboBox
: public wxControl
, public wxComboBoxBase
40 inline wxComboBox() {}
41 inline wxComboBox(wxWindow
*parent
, wxWindowID id
,
42 const wxString
& value
= wxEmptyString
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
45 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxComboBoxNameStr
)
50 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
52 inline wxComboBox(wxWindow
*parent
, wxWindowID id
,
53 const wxString
& value
,
56 const wxArrayString
& choices
,
58 const wxValidator
& validator
= wxDefaultValidator
,
59 const wxString
& name
= wxComboBoxNameStr
)
61 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
66 bool Create(wxWindow
*parent
, wxWindowID id
,
67 const wxString
& value
= wxEmptyString
,
68 const wxPoint
& pos
= wxDefaultPosition
,
69 const wxSize
& size
= wxDefaultSize
,
70 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
72 const wxValidator
& validator
= wxDefaultValidator
,
73 const wxString
& name
= wxComboBoxNameStr
);
74 bool Create(wxWindow
*parent
, wxWindowID id
,
75 const wxString
& value
,
78 const wxArrayString
& choices
,
80 const wxValidator
& validator
= wxDefaultValidator
,
81 const wxString
& name
= wxComboBoxNameStr
);
86 virtual int FindString( const wxString
&item
) const;
87 int GetSelection() const;
88 #if wxABI_VERSION >= 20602
89 int GetCurrentSelection() const;
91 wxString
GetString( int n
) const;
92 wxString
GetStringSelection() const;
94 int Number() const { return GetCount(); }
95 void SetSelection( int n
);
96 void SetString(int n
, const wxString
&text
);
98 wxString
GetValue() const;
99 void SetValue(const wxString
& value
);
104 bool CanCopy() const;
106 bool CanPaste() const;
107 void SetInsertionPoint( long pos
);
108 void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
109 long GetInsertionPoint() const;
110 virtual wxTextPos
GetLastPosition() const;
111 void Remove(long from
, long to
) { Replace(from
, to
, wxEmptyString
); }
112 void Replace( long from
, long to
, const wxString
& value
);
113 void SetSelection( long from
, long to
);
114 void GetSelection( long* from
, long* to
) const;
115 void SetEditable( bool editable
);
118 bool CanUndo() const;
119 bool CanRedo() const;
121 bool IsEditable() const ;
122 bool HasSelection() const ;
126 virtual void SetFocus();
128 void OnSize( wxSizeEvent
&event
);
129 void OnChar( wxKeyEvent
&event
);
131 // Standard event handling
132 void OnCut(wxCommandEvent
& event
);
133 void OnCopy(wxCommandEvent
& event
);
134 void OnPaste(wxCommandEvent
& event
);
135 void OnUndo(wxCommandEvent
& event
);
136 void OnRedo(wxCommandEvent
& event
);
137 void OnDelete(wxCommandEvent
& event
);
138 void OnSelectAll(wxCommandEvent
& event
);
140 void OnUpdateCut(wxUpdateUIEvent
& event
);
141 void OnUpdateCopy(wxUpdateUIEvent
& event
);
142 void OnUpdatePaste(wxUpdateUIEvent
& event
);
143 void OnUpdateUndo(wxUpdateUIEvent
& event
);
144 void OnUpdateRedo(wxUpdateUIEvent
& event
);
145 void OnUpdateDelete(wxUpdateUIEvent
& event
);
146 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
148 bool m_ignoreNextUpdate
:1;
149 wxList m_clientDataList
;
150 wxList m_clientObjectList
;
153 void DisableEvents();
155 GtkWidget
* GetConnectWidget();
156 bool IsOwnGtkWindow( GdkWindow
*window
);
157 void DoApplyWidgetStyle(GtkRcStyle
*style
);
159 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
161 static wxVisualAttributes
162 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
165 virtual int DoAppend(const wxString
& item
);
166 virtual int DoInsert(const wxString
& item
, int pos
);
168 virtual void DoSetItemClientData( int n
, void* clientData
);
169 virtual void* DoGetItemClientData( int n
) const;
170 virtual void DoSetItemClientObject( int n
, wxClientData
* clientData
);
171 virtual wxClientData
* DoGetItemClientObject( int n
) const;
173 virtual wxSize
DoGetBestSize() const;
175 // Widgets that use the style->base colour for the BG colour should
176 // override this and return true.
177 virtual bool UseGTKStyleBase() const { return true; }
180 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
181 DECLARE_EVENT_TABLE()