1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/combobox.h
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTK_COMBOBOX_H_
12 #define _WX_GTK_COMBOBOX_H_
14 #include "wx/choice.h"
16 typedef struct _GtkEntry GtkEntry
;
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxComboBox
: public wxChoice
,
27 : wxChoice(), wxTextEntry()
31 wxComboBox(wxWindow
*parent
,
33 const wxString
& value
= wxEmptyString
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
,
36 int n
= 0, const wxString choices
[] = NULL
,
38 const wxValidator
& validator
= wxDefaultValidator
,
39 const wxString
& name
= wxComboBoxNameStr
)
40 : wxChoice(), wxTextEntry()
43 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
46 wxComboBox(wxWindow
*parent
, wxWindowID id
,
47 const wxString
& value
,
50 const wxArrayString
& choices
,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxComboBoxNameStr
)
54 : wxChoice(), wxTextEntry()
57 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
61 bool Create(wxWindow
*parent
, wxWindowID id
,
62 const wxString
& value
= wxEmptyString
,
63 const wxPoint
& pos
= wxDefaultPosition
,
64 const wxSize
& size
= wxDefaultSize
,
65 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
67 const wxValidator
& validator
= wxDefaultValidator
,
68 const wxString
& name
= wxComboBoxNameStr
);
69 bool Create(wxWindow
*parent
, wxWindowID id
,
70 const wxString
& value
,
73 const wxArrayString
& choices
,
75 const wxValidator
& validator
= wxDefaultValidator
,
76 const wxString
& name
= wxComboBoxNameStr
);
78 // Set/GetSelection() from wxTextEntry and wxChoice
80 virtual void SetSelection(int n
) { wxChoice::SetSelection(n
); }
81 virtual void SetSelection(long from
, long to
)
82 { wxTextEntry::SetSelection(from
, to
); }
84 virtual int GetSelection() const { return wxChoice::GetSelection(); }
85 virtual void GetSelection(long *from
, long *to
) const
86 { return wxTextEntry::GetSelection(from
, to
); }
88 virtual wxString
GetStringSelection() const
90 return wxItemContainer::GetStringSelection();
93 virtual void SetString(unsigned int n
, const wxString
& string
);
96 virtual void Dismiss();
100 wxTextEntry::Clear();
101 wxItemContainer::Clear();
104 // See wxComboBoxBase discussion of IsEmpty().
105 bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
106 bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
108 void OnChar( wxKeyEvent
&event
);
110 virtual void SetValue(const wxString
& value
);
112 // Standard event handling
113 void OnCut(wxCommandEvent
& event
);
114 void OnCopy(wxCommandEvent
& event
);
115 void OnPaste(wxCommandEvent
& event
);
116 void OnUndo(wxCommandEvent
& event
);
117 void OnRedo(wxCommandEvent
& event
);
118 void OnDelete(wxCommandEvent
& event
);
119 void OnSelectAll(wxCommandEvent
& event
);
121 void OnUpdateCut(wxUpdateUIEvent
& event
);
122 void OnUpdateCopy(wxUpdateUIEvent
& event
);
123 void OnUpdatePaste(wxUpdateUIEvent
& event
);
124 void OnUpdateUndo(wxUpdateUIEvent
& event
);
125 void OnUpdateRedo(wxUpdateUIEvent
& event
);
126 void OnUpdateDelete(wxUpdateUIEvent
& event
);
127 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
129 virtual void GTKDisableEvents();
130 virtual void GTKEnableEvents();
131 GtkWidget
* GetConnectWidget();
133 static wxVisualAttributes
134 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
138 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
140 // Widgets that use the style->base colour for the BG colour should
141 // override this and return true.
142 virtual bool UseGTKStyleBase() const { return true; }
144 // Override in derived classes to create combo box widgets with
145 // custom list stores.
146 virtual void GTKCreateComboBoxWidget();
148 virtual wxSize
DoGetSizeFromTextSize(int xlen
, int ylen
= -1) const;
150 virtual GtkEntry
*GetEntry() const
157 virtual wxWindow
*GetEditableWindow() { return this; }
158 virtual GtkEditable
*GetEditable() const;
159 virtual void EnableTextChangedEvents(bool enable
);
163 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
164 DECLARE_EVENT_TABLE()
167 #endif // _WX_GTK_COMBOBOX_H_