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 //-----------------------------------------------------------------------------
16 //-----------------------------------------------------------------------------
18 class WXDLLIMPEXP_CORE wxComboBox
: public wxControl
,
22 wxComboBox() { m_strings
= NULL
; }
23 wxComboBox(wxWindow
*parent
,
25 const wxString
& value
= wxEmptyString
,
26 const wxPoint
& pos
= wxDefaultPosition
,
27 const wxSize
& size
= wxDefaultSize
,
28 int n
= 0, const wxString choices
[] = NULL
,
30 const wxValidator
& validator
= wxDefaultValidator
,
31 const wxString
& name
= wxComboBoxNameStr
)
33 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
36 wxComboBox(wxWindow
*parent
, wxWindowID id
,
37 const wxString
& value
,
40 const wxArrayString
& choices
,
42 const wxValidator
& validator
= wxDefaultValidator
,
43 const wxString
& name
= wxComboBoxNameStr
)
45 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
48 virtual ~wxComboBox();
50 bool Create(wxWindow
*parent
, wxWindowID id
,
51 const wxString
& value
= wxEmptyString
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
,
54 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
56 const wxValidator
& validator
= wxDefaultValidator
,
57 const wxString
& name
= wxComboBoxNameStr
);
58 bool Create(wxWindow
*parent
, wxWindowID id
,
59 const wxString
& value
,
62 const wxArrayString
& choices
,
64 const wxValidator
& validator
= wxDefaultValidator
,
65 const wxString
& name
= wxComboBoxNameStr
);
67 // From wxItemContainerImmutable:
68 virtual unsigned int GetCount() const;
69 virtual wxString
GetString(unsigned int n
) const;
70 virtual void SetString(unsigned int n
, const wxString
&text
);
71 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
72 virtual void SetSelection(int n
);
73 virtual int GetSelection() const;
75 // from wxTextEntry: we need to override them to avoid virtual function
77 virtual void SetSelection(long from
, long to
)
79 wxTextEntry::SetSelection(from
, to
);
82 virtual void GetSelection(long *from
, long *to
) const
84 return wxTextEntry::GetSelection(from
, to
);
87 virtual wxString
GetStringSelection() const
89 return wxItemContainer::GetStringSelection();
92 // From wxComboBoxBase:
93 virtual int GetCurrentSelection() const;
95 virtual void SetFocus();
97 void OnSize( wxSizeEvent
&event
);
98 void OnChar( wxKeyEvent
&event
);
100 // Standard event handling
101 void OnCut(wxCommandEvent
& event
);
102 void OnCopy(wxCommandEvent
& event
);
103 void OnPaste(wxCommandEvent
& event
);
104 void OnUndo(wxCommandEvent
& event
);
105 void OnRedo(wxCommandEvent
& event
);
106 void OnDelete(wxCommandEvent
& event
);
107 void OnSelectAll(wxCommandEvent
& event
);
109 void OnUpdateCut(wxUpdateUIEvent
& event
);
110 void OnUpdateCopy(wxUpdateUIEvent
& event
);
111 void OnUpdatePaste(wxUpdateUIEvent
& event
);
112 void OnUpdateUndo(wxUpdateUIEvent
& event
);
113 void OnUpdateRedo(wxUpdateUIEvent
& event
);
114 void OnUpdateDelete(wxUpdateUIEvent
& event
);
115 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
117 bool m_ignoreNextUpdate
:1;
118 wxArrayPtrVoid m_clientData
;
121 void DisableEvents();
123 GtkWidget
* GetConnectWidget();
125 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
127 static wxVisualAttributes
128 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
130 virtual bool IsSorted() const { return HasFlag(wxCB_SORT
); }
134 virtual void DoApplyWidgetStyle(GtkRcStyle
*style
);
135 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
137 // From wxItemContainer:
138 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
140 void **clientData
, wxClientDataType type
);
141 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
142 virtual void* DoGetItemClientData(unsigned int n
) const;
143 virtual void DoClear();
144 virtual void DoDeleteOneItem(unsigned int n
);
147 virtual wxSize
DoGetBestSize() const;
149 // Widgets that use the style->base colour for the BG colour should
150 // override this and return true.
151 virtual bool UseGTKStyleBase() const { return true; }
155 virtual const wxWindow
*GetEditableWindow() const { return this; }
156 virtual GtkEditable
*GetEditable() const;
157 virtual void EnableTextChangedEvents(bool enable
)
165 // this array is only used for controls with wxCB_SORT style, so only
166 // allocate it if it's needed (hence using pointer)
167 wxSortedArrayString
*m_strings
;
169 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
170 DECLARE_EVENT_TABLE()
173 #endif // _WX_GTK_COMBOBOX_H_