1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __GTKCOMBOBOXH__
13 #define __GTKCOMBOBOXH__
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "combobox.h"
23 #include "wx/object.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 class WXDLLIMPEXP_CORE wxComboBox
;
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 extern WXDLLIMPEXP_CORE
const wxChar
* wxComboBoxNameStr
;
36 extern WXDLLIMPEXP_BASE
const wxChar
* wxEmptyString
;
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 class WXDLLIMPEXP_CORE wxComboBox
: public wxControl
, public wxComboBoxBase
45 inline wxComboBox() {}
46 inline wxComboBox(wxWindow
*parent
, wxWindowID id
,
47 const wxString
& value
= wxEmptyString
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
,
50 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxComboBoxNameStr
)
55 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
57 inline wxComboBox(wxWindow
*parent
, wxWindowID id
,
58 const wxString
& value
,
61 const wxArrayString
& choices
,
63 const wxValidator
& validator
= wxDefaultValidator
,
64 const wxString
& name
= wxComboBoxNameStr
)
66 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
71 bool Create(wxWindow
*parent
, wxWindowID id
,
72 const wxString
& value
= wxEmptyString
,
73 const wxPoint
& pos
= wxDefaultPosition
,
74 const wxSize
& size
= wxDefaultSize
,
75 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
77 const wxValidator
& validator
= wxDefaultValidator
,
78 const wxString
& name
= wxComboBoxNameStr
);
79 bool Create(wxWindow
*parent
, wxWindowID id
,
80 const wxString
& value
,
83 const wxArrayString
& choices
,
85 const wxValidator
& validator
= wxDefaultValidator
,
86 const wxString
& name
= wxComboBoxNameStr
);
91 virtual int FindString( const wxString
&item
) const;
92 int GetSelection() const;
93 #if wxABI_VERSION >= 20602
94 int GetCurrentSelection() const;
96 wxString
GetString( int n
) const;
97 wxString
GetStringSelection() const;
99 int Number() const { return GetCount(); }
100 void SetSelection( int n
);
101 void SetString(int n
, const wxString
&text
);
103 wxString
GetValue() const;
104 void SetValue(const wxString
& value
);
109 bool CanCopy() const;
111 bool CanPaste() const;
112 void SetInsertionPoint( long pos
);
113 void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
114 long GetInsertionPoint() const;
115 virtual wxTextPos
GetLastPosition() const;
116 void Remove(long from
, long to
) { Replace(from
, to
, wxEmptyString
); }
117 void Replace( long from
, long to
, const wxString
& value
);
118 void SetSelection( long from
, long to
);
119 void GetSelection( long* from
, long* to
) const;
120 void SetEditable( bool editable
);
123 bool CanUndo() const;
124 bool CanRedo() const;
126 bool IsEditable() const ;
127 bool HasSelection() const ;
131 virtual void SetFocus();
133 void OnSize( wxSizeEvent
&event
);
134 void OnChar( wxKeyEvent
&event
);
136 // Standard event handling
137 void OnCut(wxCommandEvent
& event
);
138 void OnCopy(wxCommandEvent
& event
);
139 void OnPaste(wxCommandEvent
& event
);
140 void OnUndo(wxCommandEvent
& event
);
141 void OnRedo(wxCommandEvent
& event
);
142 void OnDelete(wxCommandEvent
& event
);
143 void OnSelectAll(wxCommandEvent
& event
);
145 void OnUpdateCut(wxUpdateUIEvent
& event
);
146 void OnUpdateCopy(wxUpdateUIEvent
& event
);
147 void OnUpdatePaste(wxUpdateUIEvent
& event
);
148 void OnUpdateUndo(wxUpdateUIEvent
& event
);
149 void OnUpdateRedo(wxUpdateUIEvent
& event
);
150 void OnUpdateDelete(wxUpdateUIEvent
& event
);
151 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
153 bool m_ignoreNextUpdate
:1;
154 wxList m_clientDataList
;
155 wxList m_clientObjectList
;
158 void DisableEvents();
160 GtkWidget
* GetConnectWidget();
161 bool IsOwnGtkWindow( GdkWindow
*window
);
162 void DoApplyWidgetStyle(GtkRcStyle
*style
);
164 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
166 static wxVisualAttributes
167 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
170 virtual int DoAppend(const wxString
& item
);
171 virtual int DoInsert(const wxString
& item
, int pos
);
173 virtual void DoSetItemClientData( int n
, void* clientData
);
174 virtual void* DoGetItemClientData( int n
) const;
175 virtual void DoSetItemClientObject( int n
, wxClientData
* clientData
);
176 virtual wxClientData
* DoGetItemClientObject( int n
) const;
178 virtual wxSize
DoGetBestSize() const;
180 // Widgets that use the style->base colour for the BG colour should
181 // override this and return true.
182 virtual bool UseGTKStyleBase() const { return true; }
185 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
186 DECLARE_EVENT_TABLE()