1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/combobox.h
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_COMBOBOX_H_
11 #define _WX_GTK_COMBOBOX_H_
13 #include "wx/choice.h"
15 typedef struct _GtkEntry GtkEntry
;
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 class WXDLLIMPEXP_CORE wxComboBox
: public wxChoice
,
26 : wxChoice(), wxTextEntry()
30 wxComboBox(wxWindow
*parent
,
32 const wxString
& value
= wxEmptyString
,
33 const wxPoint
& pos
= wxDefaultPosition
,
34 const wxSize
& size
= wxDefaultSize
,
35 int n
= 0, const wxString choices
[] = NULL
,
37 const wxValidator
& validator
= wxDefaultValidator
,
38 const wxString
& name
= wxComboBoxNameStr
)
39 : wxChoice(), wxTextEntry()
42 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
45 wxComboBox(wxWindow
*parent
, wxWindowID id
,
46 const wxString
& value
,
49 const wxArrayString
& choices
,
51 const wxValidator
& validator
= wxDefaultValidator
,
52 const wxString
& name
= wxComboBoxNameStr
)
53 : wxChoice(), wxTextEntry()
56 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
60 bool Create(wxWindow
*parent
, wxWindowID id
,
61 const wxString
& value
= wxEmptyString
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
64 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxComboBoxNameStr
);
68 bool Create(wxWindow
*parent
, wxWindowID id
,
69 const wxString
& value
,
72 const wxArrayString
& choices
,
74 const wxValidator
& validator
= wxDefaultValidator
,
75 const wxString
& name
= wxComboBoxNameStr
);
77 // Set/GetSelection() from wxTextEntry and wxChoice
79 virtual void SetSelection(int n
) { wxChoice::SetSelection(n
); }
80 virtual void SetSelection(long from
, long to
)
81 { wxTextEntry::SetSelection(from
, to
); }
83 virtual int GetSelection() const { return wxChoice::GetSelection(); }
84 virtual void GetSelection(long *from
, long *to
) const
85 { return wxTextEntry::GetSelection(from
, to
); }
87 virtual wxString
GetStringSelection() const
89 return wxItemContainer::GetStringSelection();
92 virtual void SetString(unsigned int n
, const wxString
& string
);
95 virtual void Dismiss();
100 wxItemContainer::Clear();
103 // See wxComboBoxBase discussion of IsEmpty().
104 bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
105 bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
107 void OnChar( wxKeyEvent
&event
);
109 virtual void SetValue(const wxString
& value
);
111 // Standard event handling
112 void OnCut(wxCommandEvent
& event
);
113 void OnCopy(wxCommandEvent
& event
);
114 void OnPaste(wxCommandEvent
& event
);
115 void OnUndo(wxCommandEvent
& event
);
116 void OnRedo(wxCommandEvent
& event
);
117 void OnDelete(wxCommandEvent
& event
);
118 void OnSelectAll(wxCommandEvent
& event
);
120 void OnUpdateCut(wxUpdateUIEvent
& event
);
121 void OnUpdateCopy(wxUpdateUIEvent
& event
);
122 void OnUpdatePaste(wxUpdateUIEvent
& event
);
123 void OnUpdateUndo(wxUpdateUIEvent
& event
);
124 void OnUpdateRedo(wxUpdateUIEvent
& event
);
125 void OnUpdateDelete(wxUpdateUIEvent
& event
);
126 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
128 virtual void GTKDisableEvents();
129 virtual void GTKEnableEvents();
130 GtkWidget
* GetConnectWidget();
132 static wxVisualAttributes
133 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
137 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
139 // Widgets that use the style->base colour for the BG colour should
140 // override this and return true.
141 virtual bool UseGTKStyleBase() const { return true; }
143 // Override in derived classes to create combo box widgets with
144 // custom list stores.
145 virtual void GTKCreateComboBoxWidget();
147 virtual wxSize
DoGetSizeFromTextSize(int xlen
, int ylen
= -1) const;
149 virtual GtkEntry
*GetEntry() const
156 virtual wxWindow
*GetEditableWindow() { return this; }
157 virtual GtkEditable
*GetEditable() const;
158 virtual void EnableTextChangedEvents(bool enable
);
162 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
163 DECLARE_EVENT_TABLE()
166 #endif // _WX_GTK_COMBOBOX_H_