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