1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/combobox.h
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
& s
, bool bCase
= false) const;
87 int GetSelection() const;
88 int GetCurrentSelection() const;
89 wxString
GetString( int n
) const;
90 wxString
GetStringSelection() const;
92 int Number() const { return GetCount(); }
93 void SetSelection( int n
);
94 void SetString(int n
, const wxString
&text
);
96 wxString
GetValue() const;
97 void SetValue(const wxString
& value
);
102 bool CanCopy() const;
104 bool CanPaste() const;
105 void SetInsertionPoint( long pos
);
106 void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
107 long GetInsertionPoint() const;
108 virtual wxTextPos
GetLastPosition() const;
109 void Remove(long from
, long to
) { Replace(from
, to
, wxEmptyString
); }
110 void Replace( long from
, long to
, const wxString
& value
);
111 void SetSelection( long from
, long to
);
112 void GetSelection( long* from
, long* to
) const;
113 void SetEditable( bool editable
);
116 bool CanUndo() const;
117 bool CanRedo() const;
119 bool IsEditable() const ;
120 bool HasSelection() const ;
124 virtual void SetFocus();
126 void OnSize( wxSizeEvent
&event
);
127 void OnChar( wxKeyEvent
&event
);
129 // Standard event handling
130 void OnCut(wxCommandEvent
& event
);
131 void OnCopy(wxCommandEvent
& event
);
132 void OnPaste(wxCommandEvent
& event
);
133 void OnUndo(wxCommandEvent
& event
);
134 void OnRedo(wxCommandEvent
& event
);
135 void OnDelete(wxCommandEvent
& event
);
136 void OnSelectAll(wxCommandEvent
& event
);
138 void OnUpdateCut(wxUpdateUIEvent
& event
);
139 void OnUpdateCopy(wxUpdateUIEvent
& event
);
140 void OnUpdatePaste(wxUpdateUIEvent
& event
);
141 void OnUpdateUndo(wxUpdateUIEvent
& event
);
142 void OnUpdateRedo(wxUpdateUIEvent
& event
);
143 void OnUpdateDelete(wxUpdateUIEvent
& event
);
144 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
146 bool m_ignoreNextUpdate
:1;
147 wxList m_clientDataList
;
148 wxList m_clientObjectList
;
151 void DisableEvents();
153 GtkWidget
* GetConnectWidget();
154 bool IsOwnGtkWindow( GdkWindow
*window
);
155 void DoApplyWidgetStyle(GtkRcStyle
*style
);
157 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
159 static wxVisualAttributes
160 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
163 virtual int DoAppend(const wxString
& item
);
164 virtual int DoInsert(const wxString
& item
, int pos
);
166 virtual void DoSetItemClientData( int n
, void* clientData
);
167 virtual void* DoGetItemClientData( int n
) const;
168 virtual void DoSetItemClientObject( int n
, wxClientData
* clientData
);
169 virtual wxClientData
* DoGetItemClientObject( int n
) const;
171 virtual wxSize
DoGetBestSize() const;
173 // Widgets that use the style->base colour for the BG colour should
174 // override this and return true.
175 virtual bool UseGTKStyleBase() const { return true; }
178 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
179 DECLARE_EVENT_TABLE()