]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/private/gtk2-compat.h
Add new wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED event. Implement for all backends, exten...
[wxWidgets.git] / include / wx / gtk / private / gtk2-compat.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/private/compat.h
3 // Purpose: Compatibility code for older GTK+ versions
4 // Author: Vaclav Slavik
5 // Created: 2011-03-25
6 // RCS-ID: $Id$
7 // Copyright: (c) 2011 Vaclav Slavik <vslavik@fastmail.fm>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_GTK_PRIVATE_COMPAT_H_
12 #define _WX_GTK_PRIVATE_COMPAT_H_
13
14 // ----------------------------------------------------------------------------
15 // Implementations of new accessors for older GTK+ versions
16 // ----------------------------------------------------------------------------
17
18 // GTK+ deprecated direct access to struct members and some other stuff,
19 // replacing them with simple accessor functions. These aren't available in
20 // older versions, though, so we have to provide them for compatibility.
21 //
22 // Note: wx_ prefix is used to avoid symbol conflicts at runtime
23 //
24 // Note 2: We support building against newer GTK+ version and using an older
25 // one at runtime, so we must provide our implementations of these
26 // functions even if GTK_CHECK_VERSION would indicate the function is
27 // already available in GTK+.
28
29 #if !GTK_CHECK_VERSION(3,0,0) && !(defined(GTK_DISABLE_DEPRECATED) || defined(GSEAL_ENABLE))
30
31 // ----------------------------------------------------------------------------
32 // the following were introduced in GTK+ 2.8
33
34 static inline GtkWidget* wx_gtk_scrolled_window_get_hscrollbar(GtkScrolledWindow* scrolled_window)
35 {
36 return scrolled_window->hscrollbar;
37 }
38 #define gtk_scrolled_window_get_hscrollbar wx_gtk_scrolled_window_get_hscrollbar
39
40 static inline GtkWidget* wx_gtk_scrolled_window_get_vscrollbar(GtkScrolledWindow* scrolled_window)
41 {
42 return scrolled_window->vscrollbar;
43 }
44 #define gtk_scrolled_window_get_vscrollbar wx_gtk_scrolled_window_get_vscrollbar
45
46 // ----------------------------------------------------------------------------
47 // the following were introduced in GLib 2.10
48
49 static inline gpointer wx_g_object_ref_sink(gpointer object)
50 {
51 g_object_ref(object);
52 gtk_object_sink(GTK_OBJECT(object));
53 return object;
54 }
55 #define g_object_ref_sink wx_g_object_ref_sink
56
57 // ----------------------------------------------------------------------------
58 // the following were introduced in GTK+ 2.12
59
60 static inline void wx_gtk_about_dialog_set_program_name(GtkAboutDialog* about, const gchar* name)
61 {
62 gtk_about_dialog_set_name(about, name);
63 }
64 #define gtk_about_dialog_set_program_name wx_gtk_about_dialog_set_program_name
65
66 // ----------------------------------------------------------------------------
67 // the following were introduced in GTK+ 2.14
68
69 static inline gdouble wx_gtk_adjustment_get_lower(GtkAdjustment* adjustment)
70 {
71 return adjustment->lower;
72 }
73 #define gtk_adjustment_get_lower wx_gtk_adjustment_get_lower
74
75 static inline gdouble wx_gtk_adjustment_get_page_increment(GtkAdjustment* adjustment)
76 {
77 return adjustment->page_increment;
78 }
79 #define gtk_adjustment_get_page_increment wx_gtk_adjustment_get_page_increment
80
81 static inline gdouble wx_gtk_adjustment_get_page_size(GtkAdjustment* adjustment)
82 {
83 return adjustment->page_size;
84 }
85 #define gtk_adjustment_get_page_size wx_gtk_adjustment_get_page_size
86
87 static inline gdouble wx_gtk_adjustment_get_step_increment(GtkAdjustment* adjustment)
88 {
89 return adjustment->step_increment;
90 }
91 #define gtk_adjustment_get_step_increment wx_gtk_adjustment_get_step_increment
92
93 static inline gdouble wx_gtk_adjustment_get_upper(GtkAdjustment* adjustment)
94 {
95 return adjustment->upper;
96 }
97 #define gtk_adjustment_get_upper wx_gtk_adjustment_get_upper
98
99 static inline void wx_gtk_adjustment_set_page_size(GtkAdjustment* adjustment, gdouble page_size)
100 {
101 adjustment->page_size = page_size;
102 }
103 #define gtk_adjustment_set_page_size wx_gtk_adjustment_set_page_size
104
105 static inline GtkWidget* wx_gtk_color_selection_dialog_get_color_selection(GtkColorSelectionDialog* csd)
106 {
107 return csd->colorsel;
108 }
109 #define gtk_color_selection_dialog_get_color_selection wx_gtk_color_selection_dialog_get_color_selection
110
111 static inline GtkWidget* wx_gtk_dialog_get_content_area(GtkDialog* dialog)
112 {
113 return dialog->vbox;
114 }
115 #define gtk_dialog_get_content_area wx_gtk_dialog_get_content_area
116
117 static inline GtkWidget* wx_gtk_dialog_get_action_area(GtkDialog* dialog)
118 {
119 return dialog->action_area;
120 }
121 #define gtk_dialog_get_action_area wx_gtk_dialog_get_action_area
122
123 static inline guint16 wx_gtk_entry_get_text_length(GtkEntry* entry)
124 {
125 return entry->text_length;
126 }
127 #define gtk_entry_get_text_length wx_gtk_entry_get_text_length
128
129 static inline GtkWidget* wx_gtk_font_selection_dialog_get_cancel_button(GtkFontSelectionDialog* fsd)
130 {
131 return fsd->cancel_button;
132 }
133 #define gtk_font_selection_dialog_get_cancel_button wx_gtk_font_selection_dialog_get_cancel_button
134
135 static inline GtkWidget* wx_gtk_font_selection_dialog_get_ok_button(GtkFontSelectionDialog* fsd)
136 {
137 return fsd->ok_button;
138 }
139 #define gtk_font_selection_dialog_get_ok_button wx_gtk_font_selection_dialog_get_ok_button
140
141 static inline const guchar* wx_gtk_selection_data_get_data(GtkSelectionData* selection_data)
142 {
143 return selection_data->data;
144 }
145 #define gtk_selection_data_get_data wx_gtk_selection_data_get_data
146
147 static inline GdkAtom wx_gtk_selection_data_get_data_type(GtkSelectionData* selection_data)
148 {
149 return selection_data->type;
150 }
151 #define gtk_selection_data_get_data_type wx_gtk_selection_data_get_data_type
152
153 static inline gint wx_gtk_selection_data_get_format(GtkSelectionData* selection_data)
154 {
155 return selection_data->format;
156 }
157 #define gtk_selection_data_get_format wx_gtk_selection_data_get_format
158
159 static inline gint wx_gtk_selection_data_get_length(GtkSelectionData* selection_data)
160 {
161 return selection_data->length;
162 }
163 #define gtk_selection_data_get_length wx_gtk_selection_data_get_length
164
165 static inline GdkAtom wx_gtk_selection_data_get_target(GtkSelectionData* selection_data)
166 {
167 return selection_data->target;
168 }
169 #define gtk_selection_data_get_target wx_gtk_selection_data_get_target
170
171 static inline GdkWindow* wx_gtk_widget_get_window(GtkWidget* widget)
172 {
173 return widget->window;
174 }
175 #define gtk_widget_get_window wx_gtk_widget_get_window
176
177 static inline GtkWidget* wx_gtk_window_get_default_widget(GtkWindow* window)
178 {
179 return window->default_widget;
180 }
181 #define gtk_window_get_default_widget wx_gtk_window_get_default_widget
182
183 // ----------------------------------------------------------------------------
184 // the following were introduced in GTK+ 2.16
185
186 static inline GdkAtom wx_gtk_selection_data_get_selection(GtkSelectionData* selection_data)
187 {
188 return selection_data->selection;
189 }
190 #define gtk_selection_data_get_selection wx_gtk_selection_data_get_selection
191
192 // ----------------------------------------------------------------------------
193 // the following were introduced in GTK+ 2.18
194
195 static inline void wx_gtk_cell_renderer_get_alignment(GtkCellRenderer* cell, gfloat* xalign, gfloat* yalign)
196 {
197 *xalign = cell->xalign;
198 *yalign = cell->yalign;
199 }
200 #define gtk_cell_renderer_get_alignment wx_gtk_cell_renderer_get_alignment
201
202 static inline void wx_gtk_cell_renderer_get_padding(GtkCellRenderer* cell, gint* xpad, gint* ypad)
203 {
204 *xpad = cell->xpad;
205 *ypad = cell->ypad;
206 }
207 #define gtk_cell_renderer_get_padding wx_gtk_cell_renderer_get_padding
208
209 static inline void wx_gtk_widget_get_allocation(GtkWidget* widget, GtkAllocation* allocation)
210 {
211 *allocation = widget->allocation;
212 }
213 #define gtk_widget_get_allocation wx_gtk_widget_get_allocation
214
215 inline gboolean wx_gtk_widget_get_has_window(GtkWidget *widget)
216 {
217 return !GTK_WIDGET_NO_WINDOW(widget);
218 }
219 #define gtk_widget_get_has_window wx_gtk_widget_get_has_window
220
221
222 inline gboolean wx_gtk_widget_get_has_grab(GtkWidget *widget)
223 {
224 return GTK_WIDGET_HAS_GRAB(widget);
225 }
226 #define gtk_widget_get_has_grab wx_gtk_widget_get_has_grab
227
228
229 inline gboolean wx_gtk_widget_get_visible(GtkWidget *widget)
230 {
231 return GTK_WIDGET_VISIBLE(widget);
232 }
233 #define gtk_widget_get_visible wx_gtk_widget_get_visible
234
235
236 inline gboolean wx_gtk_widget_get_sensitive(GtkWidget *widget)
237 {
238 return GTK_WIDGET_SENSITIVE(widget);
239 }
240 #define gtk_widget_get_sensitive wx_gtk_widget_get_sensitive
241
242
243 inline gboolean wx_gtk_widget_is_drawable(GtkWidget *widget)
244 {
245 return GTK_WIDGET_DRAWABLE(widget);
246 }
247 #define gtk_widget_is_drawable wx_gtk_widget_is_drawable
248
249
250 inline gboolean wx_gtk_widget_get_can_focus(GtkWidget *widget)
251 {
252 return GTK_WIDGET_CAN_FOCUS(widget);
253 }
254 #define gtk_widget_get_can_focus wx_gtk_widget_get_can_focus
255
256 inline void wx_gtk_widget_set_can_focus(GtkWidget *widget, gboolean can)
257 {
258 if ( can )
259 GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
260 else
261 GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS);
262 }
263 #define gtk_widget_set_can_focus wx_gtk_widget_set_can_focus
264
265
266 inline gboolean wx_gtk_widget_get_can_default(GtkWidget *widget)
267 {
268 return GTK_WIDGET_CAN_DEFAULT(widget);
269 }
270 #define gtk_widget_get_can_default wx_gtk_widget_get_can_default
271
272 inline void wx_gtk_widget_set_can_default(GtkWidget *widget, gboolean can)
273 {
274 if ( can )
275 GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_DEFAULT);
276 else
277 GTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_DEFAULT);
278 }
279 #define gtk_widget_set_can_default wx_gtk_widget_set_can_default
280
281
282 inline gboolean wx_gtk_widget_has_default(GtkWidget *widget)
283 {
284 return GTK_WIDGET_HAS_DEFAULT(widget);
285 }
286 #define gtk_widget_has_default wx_gtk_widget_has_default
287
288
289 inline GtkStateType wx_gtk_widget_get_state(GtkWidget *widget)
290 {
291 return (GtkStateType)GTK_WIDGET_STATE(widget);
292 }
293 #define gtk_widget_get_state wx_gtk_widget_get_state
294
295
296 inline gboolean wx_gtk_widget_get_double_buffered(GtkWidget *widget)
297 {
298 return GTK_WIDGET_DOUBLE_BUFFERED(widget);
299 }
300 #define gtk_widget_get_double_buffered wx_gtk_widget_get_double_buffered
301
302 static inline gboolean wx_gtk_widget_has_grab(GtkWidget* widget)
303 {
304 return GTK_WIDGET_HAS_GRAB(widget);
305 }
306 #define gtk_widget_has_grab wx_gtk_widget_has_grab
307
308 static inline void wx_gtk_widget_set_allocation(GtkWidget* widget, const GtkAllocation* allocation)
309 {
310 widget->allocation = *allocation;
311 }
312 #define gtk_widget_set_allocation wx_gtk_widget_set_allocation
313
314 // ----------------------------------------------------------------------------
315 // the following were introduced in GTK+ 2.20
316
317 inline gboolean wx_gtk_widget_get_realized(GtkWidget *widget)
318 {
319 return GTK_WIDGET_REALIZED(widget);
320 }
321 #define gtk_widget_get_realized wx_gtk_widget_get_realized
322
323
324 inline gboolean wx_gtk_widget_get_mapped(GtkWidget *widget)
325 {
326 return GTK_WIDGET_MAPPED(widget);
327 }
328 #define gtk_widget_get_mapped wx_gtk_widget_get_mapped
329
330 static inline void wx_gtk_widget_get_requisition(GtkWidget* widget, GtkRequisition* requisition)
331 {
332 *requisition = widget->requisition;
333 }
334 #define gtk_widget_get_requisition wx_gtk_widget_get_requisition
335
336 static inline GdkWindow* wx_gtk_entry_get_text_window(GtkEntry* entry)
337 {
338 return entry->text_area;
339 }
340 #define gtk_entry_get_text_window wx_gtk_entry_get_text_window
341
342 #endif // !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
343
344
345 #endif // _WX_GTK_PRIVATE_COMPAT_H_
346