1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/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_FWD_CORE wxComboBox
;
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr
[];
31 extern WXDLLIMPEXP_BASE
const wxChar
* wxEmptyString
;
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 class WXDLLIMPEXP_CORE wxComboBox
:
38 public wxWindowWithItems
<wxControl
, wxComboBoxBase
>
41 inline wxComboBox() {}
42 inline wxComboBox(wxWindow
*parent
, wxWindowID id
,
43 const wxString
& value
= wxEmptyString
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
46 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
48 const wxValidator
& validator
= wxDefaultValidator
,
49 const wxString
& name
= wxComboBoxNameStr
)
51 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
53 inline wxComboBox(wxWindow
*parent
, wxWindowID id
,
54 const wxString
& value
,
57 const wxArrayString
& choices
,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxComboBoxNameStr
)
62 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
65 virtual ~wxComboBox();
67 bool Create(wxWindow
*parent
, wxWindowID id
,
68 const wxString
& value
= wxEmptyString
,
69 const wxPoint
& pos
= wxDefaultPosition
,
70 const wxSize
& size
= wxDefaultSize
,
71 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
73 const wxValidator
& validator
= wxDefaultValidator
,
74 const wxString
& name
= wxComboBoxNameStr
);
75 bool Create(wxWindow
*parent
, wxWindowID id
,
76 const wxString
& value
,
79 const wxArrayString
& choices
,
81 const wxValidator
& validator
= wxDefaultValidator
,
82 const wxString
& name
= wxComboBoxNameStr
);
85 void DoDeleteOneItem(unsigned int n
);
87 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
88 int GetSelection() const;
89 int GetCurrentSelection() const;
90 virtual wxString
GetString(unsigned int n
) const;
91 wxString
GetStringSelection() const;
92 virtual unsigned int GetCount() const;
93 virtual void SetSelection(int n
);
94 virtual void SetString(unsigned int n
, const wxString
&text
);
96 wxString
GetValue() const { return DoGetValue(); }
97 void SetValue(const wxString
& value
);
98 void WriteText(const wxString
& value
);
103 bool CanCopy() const;
105 bool CanPaste() const;
106 void SetInsertionPoint( long pos
);
107 void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
108 long GetInsertionPoint() const;
109 virtual wxTextPos
GetLastPosition() const;
110 void Remove(long from
, long to
) { Replace(from
, to
, wxEmptyString
); }
111 void Replace( long from
, long to
, const wxString
& value
);
112 void SetSelection( long from
, long to
);
113 void GetSelection( long* from
, long* to
) const;
114 void SetEditable( bool editable
);
117 bool CanUndo() const;
118 bool CanRedo() const;
120 bool IsEditable() const ;
121 bool HasSelection() const ;
125 virtual void SetFocus();
127 void OnSize( wxSizeEvent
&event
);
128 void OnChar( wxKeyEvent
&event
);
130 // Standard event handling
131 void OnCut(wxCommandEvent
& event
);
132 void OnCopy(wxCommandEvent
& event
);
133 void OnPaste(wxCommandEvent
& event
);
134 void OnUndo(wxCommandEvent
& event
);
135 void OnRedo(wxCommandEvent
& event
);
136 void OnDelete(wxCommandEvent
& event
);
137 void OnSelectAll(wxCommandEvent
& event
);
139 void OnUpdateCut(wxUpdateUIEvent
& event
);
140 void OnUpdateCopy(wxUpdateUIEvent
& event
);
141 void OnUpdatePaste(wxUpdateUIEvent
& event
);
142 void OnUpdateUndo(wxUpdateUIEvent
& event
);
143 void OnUpdateRedo(wxUpdateUIEvent
& event
);
144 void OnUpdateDelete(wxUpdateUIEvent
& event
);
145 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
147 bool m_ignoreNextUpdate
:1;
148 wxList m_clientDataList
;
149 wxList m_clientObjectList
;
152 void DisableEvents();
154 GtkWidget
* GetConnectWidget();
155 bool IsOwnGtkWindow( GdkWindow
*window
);
156 void DoApplyWidgetStyle(GtkRcStyle
*style
);
158 static wxVisualAttributes
159 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
162 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
164 void **clientData
, wxClientDataType type
);
166 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
167 virtual void* DoGetItemClientData(unsigned int n
) const;
169 virtual wxSize
DoGetBestSize() const;
171 // implement wxTextEntry pure virtual methods
172 virtual wxString
DoGetValue() const;
173 virtual wxWindow
*GetEditableWindow() { return this; }
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()