]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/gtk/combobox.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: $Id$ | |
7 | // Copyright: (c) 1998 Robert Roebling | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef __GTKCOMBOBOXH__ | |
12 | #define __GTKCOMBOBOXH__ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | ||
16 | #if wxUSE_COMBOBOX | |
17 | ||
18 | #include "wx/object.h" | |
19 | ||
20 | //----------------------------------------------------------------------------- | |
21 | // classes | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
24 | class WXDLLIMPEXP_CORE wxComboBox; | |
25 | ||
26 | //----------------------------------------------------------------------------- | |
27 | // global data | |
28 | //----------------------------------------------------------------------------- | |
29 | ||
30 | extern WXDLLEXPORT_DATA(const wxChar) wxComboBoxNameStr[]; | |
31 | extern WXDLLIMPEXP_BASE const wxChar* wxEmptyString; | |
32 | ||
33 | //----------------------------------------------------------------------------- | |
34 | // wxComboBox | |
35 | //----------------------------------------------------------------------------- | |
36 | ||
37 | class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase | |
38 | { | |
39 | public: | |
40 | inline wxComboBox() {} | |
41 | inline wxComboBox(wxWindow *parent, wxWindowID id, | |
42 | const wxString& value = wxEmptyString, | |
43 | const wxPoint& pos = wxDefaultPosition, | |
44 | const wxSize& size = wxDefaultSize, | |
45 | int n = 0, const wxString choices[] = (const wxString *) NULL, | |
46 | long style = 0, | |
47 | const wxValidator& validator = wxDefaultValidator, | |
48 | const wxString& name = wxComboBoxNameStr) | |
49 | { | |
50 | Create(parent, id, value, pos, size, n, choices, style, validator, name); | |
51 | } | |
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 | } | |
63 | ||
64 | ~wxComboBox(); | |
65 | ||
66 | bool Create(wxWindow *parent, wxWindowID id, | |
67 | const wxString& value = wxEmptyString, | |
68 | const wxPoint& pos = wxDefaultPosition, | |
69 | const wxSize& size = wxDefaultSize, | |
70 | int n = 0, const wxString choices[] = (const wxString *) NULL, | |
71 | long style = 0, | |
72 | const wxValidator& validator = wxDefaultValidator, | |
73 | const wxString& name = wxComboBoxNameStr); | |
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); | |
82 | ||
83 | // From wxItemContainerImmutable: | |
84 | virtual unsigned int GetCount() const; | |
85 | virtual wxString GetString(unsigned int n) const; | |
86 | virtual void SetString(unsigned int n, const wxString &text); | |
87 | virtual int FindString(const wxString& s, bool bCase = false) const; | |
88 | virtual void SetSelection(int n); | |
89 | virtual int GetSelection() const; | |
90 | wxString GetStringSelection() const; // not a virtual in parent class | |
91 | ||
92 | // From wxItemContainer: | |
93 | virtual void Clear(); | |
94 | virtual void Delete(unsigned int n); | |
95 | ||
96 | // From wxBomboBoxBase: | |
97 | virtual wxString GetValue() const; | |
98 | virtual void SetValue(const wxString& value); | |
99 | virtual void Copy(); | |
100 | virtual void Cut(); | |
101 | virtual void Paste(); | |
102 | virtual void SetInsertionPoint( long pos ); | |
103 | virtual long GetInsertionPoint() const; | |
104 | virtual wxTextPos GetLastPosition() const; | |
105 | virtual void Replace( long from, long to, const wxString& value ); | |
106 | virtual void SetSelection( long from, long to ); | |
107 | virtual void SetEditable( bool editable ); | |
108 | virtual void SetInsertionPointEnd() { SetInsertionPoint( -1 ); } | |
109 | virtual void Remove(long from, long to) { Replace(from, to, wxEmptyString); } | |
110 | virtual bool IsEditable() const; | |
111 | virtual void Undo(); | |
112 | virtual void Redo(); | |
113 | virtual void SelectAll(); | |
114 | virtual bool CanCopy() const; | |
115 | virtual bool CanCut() const; | |
116 | virtual bool CanPaste() const; | |
117 | virtual bool CanUndo() const; | |
118 | virtual bool CanRedo() const; | |
119 | ||
120 | // implementation | |
121 | bool HasSelection() const; | |
122 | void GetSelection( long* from, long* to ) const; | |
123 | int GetCurrentSelection() const; | |
124 | ||
125 | virtual void SetFocus(); | |
126 | ||
127 | void OnSize( wxSizeEvent &event ); | |
128 | void OnChar( wxKeyEvent &event ); | |
129 | ||
130 | // Standard event handling | |
131 | void OnCut(wxCommandEvent& event); | |
132 | void OnCopy(wxCommandEvent& event); | |
133 | void OnPaste(wxCommandEvent& event); | |
134 | void OnUndo(wxCommandEvent& event); | |
135 | void OnRedo(wxCommandEvent& event); | |
136 | void OnDelete(wxCommandEvent& event); | |
137 | void OnSelectAll(wxCommandEvent& event); | |
138 | ||
139 | void OnUpdateCut(wxUpdateUIEvent& event); | |
140 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
141 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
142 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
143 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
144 | void OnUpdateDelete(wxUpdateUIEvent& event); | |
145 | void OnUpdateSelectAll(wxUpdateUIEvent& event); | |
146 | ||
147 | bool m_ignoreNextUpdate:1; | |
148 | wxList m_clientDataList; | |
149 | wxList m_clientObjectList; | |
150 | int m_prevSelection; | |
151 | ||
152 | void DisableEvents(); | |
153 | void EnableEvents(); | |
154 | GtkWidget* GetConnectWidget(); | |
155 | bool IsOwnGtkWindow( GdkWindow *window ); | |
156 | ||
157 | wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST | |
158 | ||
159 | static wxVisualAttributes | |
160 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
161 | ||
162 | protected: | |
163 | // From wxWindowGTK: | |
164 | void DoApplyWidgetStyle(GtkRcStyle *style); | |
165 | ||
166 | // From wxItemContainer: | |
167 | virtual int DoAppend(const wxString& item); | |
168 | virtual int DoInsert(const wxString& item, unsigned int pos); | |
169 | ||
170 | virtual void DoSetItemClientData(unsigned int n, void* clientData); | |
171 | virtual void* DoGetItemClientData(unsigned int n) const; | |
172 | virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData); | |
173 | virtual wxClientData* DoGetItemClientObject(unsigned int n) const; | |
174 | ||
175 | // From wxControl: | |
176 | virtual wxSize DoGetBestSize() const; | |
177 | ||
178 | // Widgets that use the style->base colour for the BG colour should | |
179 | // override this and return true. | |
180 | virtual bool UseGTKStyleBase() const { return true; } | |
181 | ||
182 | private: | |
183 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox) | |
184 | DECLARE_EVENT_TABLE() | |
185 | }; | |
186 | ||
187 | #endif | |
188 | ||
189 | #endif | |
190 | ||
191 | // __GTKCOMBOBOXH__ |