]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/combobox.h
further routing into wxApp
[wxWidgets.git] / include / wx / gtk1 / combobox.h
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 WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[];
31 extern WXDLLIMPEXP_BASE const wxChar* wxEmptyString;
32
33 //-----------------------------------------------------------------------------
34 // wxComboBox
35 //-----------------------------------------------------------------------------
36
37 class WXDLLIMPEXP_CORE wxComboBox :
38 public wxWindowWithItems<wxControl, wxComboBoxBase>
39 {
40 public:
41 inline wxComboBox() {}
42 inline wxComboBox(wxWindow *parent, wxWindowID id,
43 const wxString& value = wxEmptyString,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 int n = 0, const wxString choices[] = (const wxString *) NULL,
47 long style = 0,
48 const wxValidator& validator = wxDefaultValidator,
49 const wxString& name = wxComboBoxNameStr)
50 {
51 Create(parent, id, value, pos, size, n, choices, style, validator, name);
52 }
53 inline wxComboBox(wxWindow *parent, wxWindowID id,
54 const wxString& value,
55 const wxPoint& pos,
56 const wxSize& size,
57 const wxArrayString& choices,
58 long style = 0,
59 const wxValidator& validator = wxDefaultValidator,
60 const wxString& name = wxComboBoxNameStr)
61 {
62 Create(parent, id, value, pos, size, choices, style, validator, name);
63 }
64
65 virtual ~wxComboBox();
66
67 bool Create(wxWindow *parent, wxWindowID id,
68 const wxString& value = wxEmptyString,
69 const wxPoint& pos = wxDefaultPosition,
70 const wxSize& size = wxDefaultSize,
71 int n = 0, const wxString choices[] = (const wxString *) NULL,
72 long style = 0,
73 const wxValidator& validator = wxDefaultValidator,
74 const wxString& name = wxComboBoxNameStr);
75 bool Create(wxWindow *parent, wxWindowID id,
76 const wxString& value,
77 const wxPoint& pos,
78 const wxSize& size,
79 const wxArrayString& choices,
80 long style = 0,
81 const wxValidator& validator = wxDefaultValidator,
82 const wxString& name = wxComboBoxNameStr);
83
84 void DoClear();
85 void DoDeleteOneItem(unsigned int n);
86
87 virtual int FindString(const wxString& s, bool bCase = false) const;
88 int GetSelection() const;
89 int GetCurrentSelection() const;
90 virtual wxString GetString(unsigned int n) const;
91 wxString GetStringSelection() const;
92 virtual unsigned int GetCount() const;
93 virtual void SetSelection(int n);
94 virtual void SetString(unsigned int n, const wxString &text);
95
96 wxString GetValue() const { return DoGetValue(); }
97 void SetValue(const wxString& value);
98 void WriteText(const wxString& value);
99
100 void Copy();
101 void Cut();
102 void Paste();
103 bool CanCopy() const;
104 bool CanCut() const;
105 bool CanPaste() const;
106 void SetInsertionPoint( long pos );
107 void SetInsertionPointEnd() { SetInsertionPoint( -1 ); }
108 long GetInsertionPoint() const;
109 virtual wxTextPos GetLastPosition() const;
110 void Remove(long from, long to) { Replace(from, to, wxEmptyString); }
111 void Replace( long from, long to, const wxString& value );
112 void SetSelection( long from, long to );
113 void GetSelection( long* from, long* to ) const;
114 void SetEditable( bool editable );
115 void Undo() ;
116 void Redo() ;
117 bool CanUndo() const;
118 bool CanRedo() const;
119 void SelectAll();
120 bool IsEditable() const ;
121 bool HasSelection() const ;
122
123 // implementation
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 void DoApplyWidgetStyle(GtkRcStyle *style);
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 // implement wxTextEntry pure virtual methods
172 virtual wxString DoGetValue() const;
173 virtual wxWindow *GetEditableWindow() { return this; }
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__