]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/combobox.h
6c73810879f814a175d720fb0584692b08966317
[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
12 #ifndef __GTKCOMBOBOXH__
13 #define __GTKCOMBOBOXH__
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "combobox.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_COMBOBOX
22
23 #include "wx/object.h"
24
25 //-----------------------------------------------------------------------------
26 // classes
27 //-----------------------------------------------------------------------------
28
29 class wxComboBox;
30
31 //-----------------------------------------------------------------------------
32 // global data
33 //-----------------------------------------------------------------------------
34
35 extern const wxChar* wxComboBoxNameStr;
36 extern const wxChar* wxEmptyString;
37
38 //-----------------------------------------------------------------------------
39 // wxComboBox
40 //-----------------------------------------------------------------------------
41
42 class wxComboBox : public wxControl, public wxComboBoxBase
43 {
44 public:
45 inline wxComboBox() {}
46 inline wxComboBox(wxWindow *parent, wxWindowID id,
47 const wxString& value = wxEmptyString,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 int n = 0, const wxString choices[] = (const wxString *) NULL,
51 long style = 0,
52 const wxValidator& validator = wxDefaultValidator,
53 const wxString& name = wxComboBoxNameStr)
54 {
55 Create(parent, id, value, pos, size, n, choices, style, validator, name);
56 }
57 inline wxComboBox(wxWindow *parent, wxWindowID id,
58 const wxString& value,
59 const wxPoint& pos,
60 const wxSize& size,
61 const wxArrayString& choices,
62 long style = 0,
63 const wxValidator& validator = wxDefaultValidator,
64 const wxString& name = wxComboBoxNameStr)
65 {
66 Create(parent, id, value, pos, size, choices, style, validator, name);
67 }
68
69 ~wxComboBox();
70
71 bool Create(wxWindow *parent, wxWindowID id,
72 const wxString& value = wxEmptyString,
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& size = wxDefaultSize,
75 int n = 0, const wxString choices[] = (const wxString *) NULL,
76 long style = 0,
77 const wxValidator& validator = wxDefaultValidator,
78 const wxString& name = wxComboBoxNameStr);
79 bool Create(wxWindow *parent, wxWindowID id,
80 const wxString& value,
81 const wxPoint& pos,
82 const wxSize& size,
83 const wxArrayString& choices,
84 long style = 0,
85 const wxValidator& validator = wxDefaultValidator,
86 const wxString& name = wxComboBoxNameStr);
87
88 void Clear();
89 void Delete( int n );
90
91 virtual int FindString( const wxString &item ) const;
92 int GetSelection() const;
93 wxString GetString( int n ) const;
94 wxString GetStringSelection() const;
95 int GetCount() const;
96 int Number() const { return GetCount(); }
97 void SetSelection( int n );
98 void Select( int n ) { return SetSelection( n ); }
99 void SetString(int n, const wxString &text);
100
101 wxString GetValue() const;
102 void SetValue(const wxString& value);
103
104 void Copy();
105 void Cut();
106 void Paste();
107 bool CanCopy() const;
108 bool CanCut() const;
109 bool CanPaste() const;
110 void SetInsertionPoint( long pos );
111 void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
112 long GetInsertionPoint() const;
113 virtual wxTextPos GetLastPosition() const;
114 void Remove(long from, long to) { Replace(from, to, wxEmptyString); }
115 void Replace( long from, long to, const wxString& value );
116 void SetSelection( long from, long to );
117 void GetSelection( long* from, long* to ) const;
118 void SetEditable( bool editable );
119 void Undo() ;
120 void Redo() ;
121 bool CanUndo() const;
122 bool CanRedo() const;
123 void SelectAll();
124 bool IsEditable() const ;
125 bool HasSelection() const ;
126
127 // implementation
128
129 virtual void SetFocus();
130
131 void OnSize( wxSizeEvent &event );
132 void OnChar( wxKeyEvent &event );
133
134 // Standard event handling
135 void OnCut(wxCommandEvent& event);
136 void OnCopy(wxCommandEvent& event);
137 void OnPaste(wxCommandEvent& event);
138 void OnUndo(wxCommandEvent& event);
139 void OnRedo(wxCommandEvent& event);
140 void OnDelete(wxCommandEvent& event);
141 void OnSelectAll(wxCommandEvent& event);
142
143 void OnUpdateCut(wxUpdateUIEvent& event);
144 void OnUpdateCopy(wxUpdateUIEvent& event);
145 void OnUpdatePaste(wxUpdateUIEvent& event);
146 void OnUpdateUndo(wxUpdateUIEvent& event);
147 void OnUpdateRedo(wxUpdateUIEvent& event);
148 void OnUpdateDelete(wxUpdateUIEvent& event);
149 void OnUpdateSelectAll(wxUpdateUIEvent& event);
150
151 bool m_ignoreNextUpdate:1;
152 wxList m_clientDataList;
153 wxList m_clientObjectList;
154 int m_prevSelection;
155
156 void DisableEvents();
157 void EnableEvents();
158 GtkWidget* GetConnectWidget();
159 bool IsOwnGtkWindow( GdkWindow *window );
160 void DoApplyWidgetStyle(GtkRcStyle *style);
161
162 wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
163
164 static wxVisualAttributes
165 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
166
167 protected:
168 virtual int DoAppend(const wxString& item);
169 virtual int DoInsert(const wxString& item, int pos);
170
171 virtual void DoSetItemClientData( int n, void* clientData );
172 virtual void* DoGetItemClientData( int n ) const;
173 virtual void DoSetItemClientObject( int n, wxClientData* clientData );
174 virtual wxClientData* DoGetItemClientObject( int n ) const;
175
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__