]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/gtk1/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_FWD_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 | virtual ~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 | void DoClear(); | |
84 | void DoDeleteOneItem(unsigned int n); | |
85 | ||
86 | virtual int FindString(const wxString& s, bool bCase = false) const; | |
87 | int GetSelection() const; | |
88 | int GetCurrentSelection() const; | |
89 | virtual wxString GetString(unsigned int n) const; | |
90 | wxString GetStringSelection() const; | |
91 | virtual unsigned int GetCount() const; | |
92 | virtual void SetSelection(int n); | |
93 | virtual void SetString(unsigned int n, const wxString &text); | |
94 | ||
95 | wxString GetValue() const; | |
96 | void SetValue(const wxString& value); | |
97 | ||
98 | void Copy(); | |
99 | void Cut(); | |
100 | void Paste(); | |
101 | bool CanCopy() const; | |
102 | bool CanCut() const; | |
103 | bool CanPaste() const; | |
104 | void SetInsertionPoint( long pos ); | |
105 | void SetInsertionPointEnd() { SetInsertionPoint( -1 ); } | |
106 | long GetInsertionPoint() const; | |
107 | virtual wxTextPos GetLastPosition() const; | |
108 | void Remove(long from, long to) { Replace(from, to, wxEmptyString); } | |
109 | void Replace( long from, long to, const wxString& value ); | |
110 | void SetSelection( long from, long to ); | |
111 | void GetSelection( long* from, long* to ) const; | |
112 | void SetEditable( bool editable ); | |
113 | void Undo() ; | |
114 | void Redo() ; | |
115 | bool CanUndo() const; | |
116 | bool CanRedo() const; | |
117 | void SelectAll(); | |
118 | bool IsEditable() const ; | |
119 | bool HasSelection() const ; | |
120 | ||
121 | // implementation | |
122 | ||
123 | virtual void SetFocus(); | |
124 | ||
125 | void OnSize( wxSizeEvent &event ); | |
126 | void OnChar( wxKeyEvent &event ); | |
127 | ||
128 | // Standard event handling | |
129 | void OnCut(wxCommandEvent& event); | |
130 | void OnCopy(wxCommandEvent& event); | |
131 | void OnPaste(wxCommandEvent& event); | |
132 | void OnUndo(wxCommandEvent& event); | |
133 | void OnRedo(wxCommandEvent& event); | |
134 | void OnDelete(wxCommandEvent& event); | |
135 | void OnSelectAll(wxCommandEvent& event); | |
136 | ||
137 | void OnUpdateCut(wxUpdateUIEvent& event); | |
138 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
139 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
140 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
141 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
142 | void OnUpdateDelete(wxUpdateUIEvent& event); | |
143 | void OnUpdateSelectAll(wxUpdateUIEvent& event); | |
144 | ||
145 | bool m_ignoreNextUpdate:1; | |
146 | wxList m_clientDataList; | |
147 | wxList m_clientObjectList; | |
148 | int m_prevSelection; | |
149 | ||
150 | void DisableEvents(); | |
151 | void EnableEvents(); | |
152 | GtkWidget* GetConnectWidget(); | |
153 | bool IsOwnGtkWindow( GdkWindow *window ); | |
154 | void DoApplyWidgetStyle(GtkRcStyle *style); | |
155 | ||
156 | wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST | |
157 | ||
158 | static wxVisualAttributes | |
159 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
160 | ||
161 | protected: | |
162 | virtual int DoInsertItems(const wxArrayStringsAdapter& items, | |
163 | unsigned int pos, | |
164 | void **clientData, wxClientDataType type); | |
165 | ||
166 | virtual void DoSetItemClientData(unsigned int n, void* clientData); | |
167 | virtual void* DoGetItemClientData(unsigned int n) const; | |
168 | ||
169 | virtual wxSize DoGetBestSize() const; | |
170 | ||
171 | // Widgets that use the style->base colour for the BG colour should | |
172 | // override this and return true. | |
173 | virtual bool UseGTKStyleBase() const { return true; } | |
174 | ||
175 | private: | |
176 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox) | |
177 | DECLARE_EVENT_TABLE() | |
178 | }; | |
179 | ||
180 | #endif | |
181 | ||
182 | #endif | |
183 | ||
184 | // __GTKCOMBOBOXH__ |