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 typedef struct _GtkEntry GtkEntry
;
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 class WXDLLIMPEXP_CORE wxComboBox
: public wxControl
,
24 wxComboBox() { m_strings
= NULL
; }
25 wxComboBox(wxWindow
*parent
,
27 const wxString
& value
= wxEmptyString
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
30 int n
= 0, const wxString choices
[] = NULL
,
32 const wxValidator
& validator
= wxDefaultValidator
,
33 const wxString
& name
= wxComboBoxNameStr
)
35 Create(parent
, id
, value
, pos
, size
, n
, choices
, style
, validator
, name
);
38 wxComboBox(wxWindow
*parent
, wxWindowID id
,
39 const wxString
& value
,
42 const wxArrayString
& choices
,
44 const wxValidator
& validator
= wxDefaultValidator
,
45 const wxString
& name
= wxComboBoxNameStr
)
47 Create(parent
, id
, value
, pos
, size
, choices
, style
, validator
, name
);
50 virtual ~wxComboBox();
52 bool Create(wxWindow
*parent
, wxWindowID id
,
53 const wxString
& value
= wxEmptyString
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
56 int n
= 0, const wxString choices
[] = (const wxString
*) NULL
,
58 const wxValidator
& validator
= wxDefaultValidator
,
59 const wxString
& name
= wxComboBoxNameStr
);
60 bool Create(wxWindow
*parent
, wxWindowID id
,
61 const wxString
& value
,
64 const wxArrayString
& choices
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxComboBoxNameStr
);
69 // From wxItemContainerImmutable:
70 virtual unsigned int GetCount() const;
71 virtual wxString
GetString(unsigned int n
) const;
72 virtual void SetString(unsigned int n
, const wxString
&text
);
73 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
74 virtual void SetSelection(int n
);
75 virtual int GetSelection() const;
77 // from wxTextEntry: we need to override them to avoid virtual function
79 virtual void SetSelection(long from
, long to
)
81 wxTextEntry::SetSelection(from
, to
);
84 virtual void GetSelection(long *from
, long *to
) const
86 return wxTextEntry::GetSelection(from
, to
);
89 virtual wxString
GetStringSelection() const
91 return wxItemContainer::GetStringSelection();
94 // From wxComboBoxBase:
95 virtual int GetCurrentSelection() const;
97 void OnChar( wxKeyEvent
&event
);
99 // Standard event handling
100 void OnCut(wxCommandEvent
& event
);
101 void OnCopy(wxCommandEvent
& event
);
102 void OnPaste(wxCommandEvent
& event
);
103 void OnUndo(wxCommandEvent
& event
);
104 void OnRedo(wxCommandEvent
& event
);
105 void OnDelete(wxCommandEvent
& event
);
106 void OnSelectAll(wxCommandEvent
& event
);
108 void OnUpdateCut(wxUpdateUIEvent
& event
);
109 void OnUpdateCopy(wxUpdateUIEvent
& event
);
110 void OnUpdatePaste(wxUpdateUIEvent
& event
);
111 void OnUpdateUndo(wxUpdateUIEvent
& event
);
112 void OnUpdateRedo(wxUpdateUIEvent
& event
);
113 void OnUpdateDelete(wxUpdateUIEvent
& event
);
114 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
116 bool m_ignoreNextUpdate
:1;
117 wxArrayPtrVoid m_clientData
;
120 void DisableEvents();
122 GtkWidget
* GetConnectWidget();
124 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
126 static wxVisualAttributes
127 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
129 virtual bool IsSorted() const { return HasFlag(wxCB_SORT
); }
133 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
135 // From wxItemContainer:
136 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
138 void **clientData
, wxClientDataType type
);
139 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
140 virtual void* DoGetItemClientData(unsigned int n
) const;
141 virtual void DoClear();
142 virtual void DoDeleteOneItem(unsigned int n
);
145 virtual wxSize
DoGetBestSize() const;
147 // Widgets that use the style->base colour for the BG colour should
148 // override this and return true.
149 virtual bool UseGTKStyleBase() const { return true; }
151 // return the GtkEntry part of the combobox
152 GtkEntry
*GetEntry() const;
156 virtual const wxWindow
*GetEditableWindow() const { return this; }
157 virtual GtkEditable
*GetEditable() const;
158 virtual void EnableTextChangedEvents(bool enable
)
166 // this array is only used for controls with wxCB_SORT style, so only
167 // allocate it if it's needed (hence using pointer)
168 wxSortedArrayString
*m_strings
;
170 DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox
)
171 DECLARE_EVENT_TABLE()
174 #endif // _WX_GTK_COMBOBOX_H_