]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
853dcc57 | 2 | // Name: wx/gtk/combobox.h |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
5ebd1fb2 | 6 | // Id: $Id$ |
dbf858b5 | 7 | // Copyright: (c) 1998 Robert Roebling |
7d8268a1 | 8 | // Licence: wxWindows licence |
c801d85f KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
0416c418 PC |
11 | #ifndef _WX_GTK_COMBOBOX_H_ |
12 | #define _WX_GTK_COMBOBOX_H_ | |
7f4dc78d | 13 | |
ff654490 VZ |
14 | typedef struct _GtkEntry GtkEntry; |
15 | ||
c801d85f KB |
16 | //----------------------------------------------------------------------------- |
17 | // wxComboBox | |
18 | //----------------------------------------------------------------------------- | |
19 | ||
0ec1179b VZ |
20 | class WXDLLIMPEXP_CORE wxComboBox : public wxControl, |
21 | public wxComboBoxBase | |
7f4dc78d | 22 | { |
fd0eed64 | 23 | public: |
0ec1179b VZ |
24 | wxComboBox() { m_strings = NULL; } |
25 | wxComboBox(wxWindow *parent, | |
26 | wxWindowID id, | |
27 | const wxString& value = wxEmptyString, | |
28 | const wxPoint& pos = wxDefaultPosition, | |
29 | const wxSize& size = wxDefaultSize, | |
30 | int n = 0, const wxString choices[] = NULL, | |
31 | long style = 0, | |
32 | const wxValidator& validator = wxDefaultValidator, | |
33 | const wxString& name = wxComboBoxNameStr) | |
738f9e5a RR |
34 | { |
35 | Create(parent, id, value, pos, size, n, choices, style, validator, name); | |
36 | } | |
0ec1179b VZ |
37 | |
38 | wxComboBox(wxWindow *parent, wxWindowID id, | |
39 | const wxString& value, | |
40 | const wxPoint& pos, | |
41 | const wxSize& size, | |
42 | const wxArrayString& choices, | |
43 | long style = 0, | |
44 | const wxValidator& validator = wxDefaultValidator, | |
45 | const wxString& name = wxComboBoxNameStr) | |
584ad2a3 MB |
46 | { |
47 | Create(parent, id, value, pos, size, choices, style, validator, name); | |
48 | } | |
6f6f938f | 49 | |
d3c7fc99 | 50 | virtual ~wxComboBox(); |
6f6f938f | 51 | |
738f9e5a | 52 | bool Create(wxWindow *parent, wxWindowID id, |
0ec1179b VZ |
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, | |
57 | long style = 0, | |
58 | const wxValidator& validator = wxDefaultValidator, | |
59 | const wxString& name = wxComboBoxNameStr); | |
584ad2a3 | 60 | bool Create(wxWindow *parent, wxWindowID id, |
0ec1179b VZ |
61 | const wxString& value, |
62 | const wxPoint& pos, | |
63 | const wxSize& size, | |
64 | const wxArrayString& choices, | |
65 | long style = 0, | |
66 | const wxValidator& validator = wxDefaultValidator, | |
67 | const wxString& name = wxComboBoxNameStr); | |
7f4dc78d | 68 | |
d95c5149 | 69 | // From wxItemContainerImmutable: |
aa61d352 | 70 | virtual unsigned int GetCount() const; |
d95c5149 | 71 | virtual wxString GetString(unsigned int n) const; |
aa61d352 | 72 | virtual void SetString(unsigned int n, const wxString &text); |
d95c5149 MR |
73 | virtual int FindString(const wxString& s, bool bCase = false) const; |
74 | virtual void SetSelection(int n); | |
75 | virtual int GetSelection() const; | |
d95c5149 | 76 | |
0ec1179b VZ |
77 | // from wxTextEntry: we need to override them to avoid virtual function |
78 | // hiding | |
79 | virtual void SetSelection(long from, long to) | |
80 | { | |
81 | wxTextEntry::SetSelection(from, to); | |
82 | } | |
d95c5149 | 83 | |
0ec1179b VZ |
84 | virtual void GetSelection(long *from, long *to) const |
85 | { | |
86 | return wxTextEntry::GetSelection(from, to); | |
87 | } | |
88 | ||
89 | virtual wxString GetStringSelection() const | |
90 | { | |
91 | return wxItemContainer::GetStringSelection(); | |
92 | } | |
93 | ||
94 | // From wxComboBoxBase: | |
95 | virtual int GetCurrentSelection() const; | |
30ed6e5c | 96 | |
2b5f62a0 | 97 | virtual void SetFocus(); |
30ed6e5c | 98 | |
738f9e5a | 99 | void OnChar( wxKeyEvent &event ); |
30ed6e5c | 100 | |
150e31d2 JS |
101 | // Standard event handling |
102 | void OnCut(wxCommandEvent& event); | |
103 | void OnCopy(wxCommandEvent& event); | |
104 | void OnPaste(wxCommandEvent& event); | |
105 | void OnUndo(wxCommandEvent& event); | |
106 | void OnRedo(wxCommandEvent& event); | |
107 | void OnDelete(wxCommandEvent& event); | |
108 | void OnSelectAll(wxCommandEvent& event); | |
109 | ||
110 | void OnUpdateCut(wxUpdateUIEvent& event); | |
111 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
112 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
113 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
114 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
115 | void OnUpdateDelete(wxUpdateUIEvent& event); | |
116 | void OnUpdateSelectAll(wxUpdateUIEvent& event); | |
117 | ||
a236aa20 VZ |
118 | bool m_ignoreNextUpdate:1; |
119 | wxArrayPtrVoid m_clientData; | |
120 | int m_prevSelection; | |
738f9e5a RR |
121 | |
122 | void DisableEvents(); | |
123 | void EnableEvents(); | |
738f9e5a | 124 | GtkWidget* GetConnectWidget(); |
30ed6e5c | 125 | |
6f6f938f VZ |
126 | wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST |
127 | ||
9d522606 RD |
128 | static wxVisualAttributes |
129 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
150e31d2 | 130 | |
3c75d8ba PC |
131 | virtual bool IsSorted() const { return HasFlag(wxCB_SORT); } |
132 | ||
f68586e5 | 133 | protected: |
d95c5149 | 134 | // From wxWindowGTK: |
ef5c70f9 | 135 | virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; |
d95c5149 MR |
136 | |
137 | // From wxItemContainer: | |
a236aa20 VZ |
138 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, |
139 | unsigned int pos, | |
140 | void **clientData, wxClientDataType type); | |
aa61d352 VZ |
141 | virtual void DoSetItemClientData(unsigned int n, void* clientData); |
142 | virtual void* DoGetItemClientData(unsigned int n) const; | |
0ec1179b VZ |
143 | virtual void DoClear(); |
144 | virtual void DoDeleteOneItem(unsigned int n); | |
6f6f938f | 145 | |
d95c5149 | 146 | // From wxControl: |
f68586e5 VZ |
147 | virtual wxSize DoGetBestSize() const; |
148 | ||
3c75d8ba PC |
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; } | |
152 | ||
ff654490 VZ |
153 | // return the GtkEntry part of the combobox |
154 | GtkEntry *GetEntry() const; | |
155 | ||
3c75d8ba | 156 | private: |
0ec1179b VZ |
157 | // From wxTextEntry: |
158 | virtual const wxWindow *GetEditableWindow() const { return this; } | |
159 | virtual GtkEditable *GetEditable() const; | |
160 | virtual void EnableTextChangedEvents(bool enable) | |
161 | { | |
162 | if ( enable ) | |
163 | EnableEvents(); | |
164 | else | |
165 | DisableEvents(); | |
166 | } | |
167 | ||
a236aa20 VZ |
168 | // this array is only used for controls with wxCB_SORT style, so only |
169 | // allocate it if it's needed (hence using pointer) | |
170 | wxSortedArrayString *m_strings; | |
171 | ||
6f6f938f | 172 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox) |
738f9e5a | 173 | DECLARE_EVENT_TABLE() |
7f4dc78d RR |
174 | }; |
175 | ||
0416c418 | 176 | #endif // _WX_GTK_COMBOBOX_H_ |