]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
8ef94bfc | 2 | // Name: wx/gtk1/combobox.h |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
dbf858b5 | 6 | // Copyright: (c) 1998 Robert Roebling |
7d8268a1 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
c801d85f KB |
10 | #ifndef __GTKCOMBOBOXH__ |
11 | #define __GTKCOMBOBOXH__ | |
12 | ||
c801d85f | 13 | #include "wx/defs.h" |
ac57418f | 14 | |
dcf924a3 RR |
15 | #if wxUSE_COMBOBOX |
16 | ||
c801d85f | 17 | #include "wx/object.h" |
c801d85f KB |
18 | |
19 | //----------------------------------------------------------------------------- | |
20 | // classes | |
21 | //----------------------------------------------------------------------------- | |
22 | ||
b5dbe15d | 23 | class WXDLLIMPEXP_FWD_CORE wxComboBox; |
c801d85f | 24 | |
7f4dc78d RR |
25 | //----------------------------------------------------------------------------- |
26 | // global data | |
27 | //----------------------------------------------------------------------------- | |
28 | ||
53a2db12 | 29 | extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[]; |
20123d49 | 30 | extern WXDLLIMPEXP_BASE const wxChar* wxEmptyString; |
7f4dc78d | 31 | |
c801d85f KB |
32 | //----------------------------------------------------------------------------- |
33 | // wxComboBox | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
bf8f1022 VZ |
36 | class WXDLLIMPEXP_CORE wxComboBox : |
37 | public wxWindowWithItems<wxControl, wxComboBoxBase> | |
7f4dc78d | 38 | { |
fd0eed64 | 39 | public: |
738f9e5a RR |
40 | inline wxComboBox() {} |
41 | inline wxComboBox(wxWindow *parent, wxWindowID id, | |
7f4dc78d RR |
42 | const wxString& value = wxEmptyString, |
43 | const wxPoint& pos = wxDefaultPosition, | |
44 | const wxSize& size = wxDefaultSize, | |
c67daf87 | 45 | int n = 0, const wxString choices[] = (const wxString *) NULL, |
debe6624 | 46 | long style = 0, |
6de97a3b | 47 | const wxValidator& validator = wxDefaultValidator, |
7f4dc78d | 48 | const wxString& name = wxComboBoxNameStr) |
738f9e5a RR |
49 | { |
50 | Create(parent, id, value, pos, size, n, choices, style, validator, name); | |
51 | } | |
584ad2a3 MB |
52 | inline wxComboBox(wxWindow *parent, wxWindowID id, |
53 | const wxString& value, | |
54 | const wxPoint& pos, | |
55 | const wxSize& size, | |
56 | const wxArrayString& choices, | |
57 | long style = 0, | |
58 | const wxValidator& validator = wxDefaultValidator, | |
59 | const wxString& name = wxComboBoxNameStr) | |
60 | { | |
61 | Create(parent, id, value, pos, size, choices, style, validator, name); | |
62 | } | |
6f6f938f | 63 | |
d3c7fc99 | 64 | virtual ~wxComboBox(); |
6f6f938f | 65 | |
738f9e5a | 66 | bool Create(wxWindow *parent, wxWindowID id, |
7f4dc78d RR |
67 | const wxString& value = wxEmptyString, |
68 | const wxPoint& pos = wxDefaultPosition, | |
69 | const wxSize& size = wxDefaultSize, | |
c67daf87 | 70 | int n = 0, const wxString choices[] = (const wxString *) NULL, |
debe6624 | 71 | long style = 0, |
6de97a3b | 72 | const wxValidator& validator = wxDefaultValidator, |
7f4dc78d | 73 | const wxString& name = wxComboBoxNameStr); |
584ad2a3 MB |
74 | bool Create(wxWindow *parent, wxWindowID id, |
75 | const wxString& value, | |
76 | const wxPoint& pos, | |
77 | const wxSize& size, | |
78 | const wxArrayString& choices, | |
79 | long style = 0, | |
80 | const wxValidator& validator = wxDefaultValidator, | |
81 | const wxString& name = wxComboBoxNameStr); | |
7f4dc78d | 82 | |
a236aa20 VZ |
83 | void DoClear(); |
84 | void DoDeleteOneItem(unsigned int n); | |
30ed6e5c | 85 | |
853dcc57 | 86 | virtual int FindString(const wxString& s, bool bCase = false) const; |
738f9e5a | 87 | int GetSelection() const; |
40eb3606 | 88 | int GetCurrentSelection() const; |
aa61d352 | 89 | virtual wxString GetString(unsigned int n) const; |
738f9e5a | 90 | wxString GetStringSelection() const; |
aa61d352 VZ |
91 | virtual unsigned int GetCount() const; |
92 | virtual void SetSelection(int n); | |
93 | virtual void SetString(unsigned int n, const wxString &text); | |
738f9e5a | 94 | |
55410bb4 | 95 | wxString GetValue() const { return DoGetValue(); } |
738f9e5a | 96 | void SetValue(const wxString& value); |
c282ec44 | 97 | void WriteText(const wxString& value); |
738f9e5a RR |
98 | |
99 | void Copy(); | |
100 | void Cut(); | |
101 | void Paste(); | |
150e31d2 JS |
102 | bool CanCopy() const; |
103 | bool CanCut() const; | |
104 | bool CanPaste() const; | |
738f9e5a | 105 | void SetInsertionPoint( long pos ); |
6f6f938f | 106 | void SetInsertionPointEnd() { SetInsertionPoint( -1 ); } |
738f9e5a | 107 | long GetInsertionPoint() const; |
7d8268a1 | 108 | virtual wxTextPos GetLastPosition() const; |
6f6f938f | 109 | void Remove(long from, long to) { Replace(from, to, wxEmptyString); } |
738f9e5a | 110 | void Replace( long from, long to, const wxString& value ); |
738f9e5a | 111 | void SetSelection( long from, long to ); |
150e31d2 | 112 | void GetSelection( long* from, long* to ) const; |
738f9e5a | 113 | void SetEditable( bool editable ); |
150e31d2 JS |
114 | void Undo() ; |
115 | void Redo() ; | |
116 | bool CanUndo() const; | |
117 | bool CanRedo() const; | |
118 | void SelectAll(); | |
4e324a3f | 119 | bool IsEditable() const ; |
150e31d2 | 120 | bool HasSelection() const ; |
30ed6e5c | 121 | |
738f9e5a | 122 | // implementation |
30ed6e5c | 123 | |
2b5f62a0 | 124 | virtual void SetFocus(); |
30ed6e5c | 125 | |
738f9e5a RR |
126 | void OnSize( wxSizeEvent &event ); |
127 | void OnChar( wxKeyEvent &event ); | |
30ed6e5c | 128 | |
150e31d2 JS |
129 | // Standard event handling |
130 | void OnCut(wxCommandEvent& event); | |
131 | void OnCopy(wxCommandEvent& event); | |
132 | void OnPaste(wxCommandEvent& event); | |
133 | void OnUndo(wxCommandEvent& event); | |
134 | void OnRedo(wxCommandEvent& event); | |
135 | void OnDelete(wxCommandEvent& event); | |
136 | void OnSelectAll(wxCommandEvent& event); | |
137 | ||
138 | void OnUpdateCut(wxUpdateUIEvent& event); | |
139 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
140 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
141 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
142 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
143 | void OnUpdateDelete(wxUpdateUIEvent& event); | |
144 | void OnUpdateSelectAll(wxUpdateUIEvent& event); | |
145 | ||
78b3b018 | 146 | bool m_ignoreNextUpdate:1; |
738f9e5a RR |
147 | wxList m_clientDataList; |
148 | wxList m_clientObjectList; | |
159b66c0 | 149 | int m_prevSelection; |
738f9e5a RR |
150 | |
151 | void DisableEvents(); | |
152 | void EnableEvents(); | |
738f9e5a RR |
153 | GtkWidget* GetConnectWidget(); |
154 | bool IsOwnGtkWindow( GdkWindow *window ); | |
f40fdaa3 | 155 | void DoApplyWidgetStyle(GtkRcStyle *style); |
30ed6e5c | 156 | |
9d522606 RD |
157 | static wxVisualAttributes |
158 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
150e31d2 | 159 | |
f68586e5 | 160 | protected: |
a236aa20 VZ |
161 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, |
162 | unsigned int pos, | |
163 | void **clientData, wxClientDataType type); | |
6f6f938f | 164 | |
aa61d352 VZ |
165 | virtual void DoSetItemClientData(unsigned int n, void* clientData); |
166 | virtual void* DoGetItemClientData(unsigned int n) const; | |
6f6f938f | 167 | |
f68586e5 VZ |
168 | virtual wxSize DoGetBestSize() const; |
169 | ||
55410bb4 VZ |
170 | // implement wxTextEntry pure virtual methods |
171 | virtual wxString DoGetValue() const; | |
63f7d502 VZ |
172 | virtual wxWindow *GetEditableWindow() { return this; } |
173 | ||
9d522606 RD |
174 | // Widgets that use the style->base colour for the BG colour should |
175 | // override this and return true. | |
176 | virtual bool UseGTKStyleBase() const { return true; } | |
177 | ||
30ed6e5c | 178 | private: |
6f6f938f | 179 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox) |
738f9e5a | 180 | DECLARE_EVENT_TABLE() |
7f4dc78d RR |
181 | }; |
182 | ||
dcf924a3 RR |
183 | #endif |
184 | ||
ac57418f RR |
185 | #endif |
186 | ||
187 | // __GTKCOMBOBOXH__ |