]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/private/gtk2-compat.h
051f9360d1d866f9edd930bb828815c07b43748b
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/private/compat.h
3 // Purpose: Compatibility code for older GTK+ versions
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2011 Vaclav Slavik <vslavik@fastmail.fm>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTK_PRIVATE_COMPAT_H_
12 #define _WX_GTK_PRIVATE_COMPAT_H_
14 // ----------------------------------------------------------------------------
15 // Implementations of new accessors for older GTK+ versions
16 // ----------------------------------------------------------------------------
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.
22 // Note: wx_ prefix is used to avoid symbol conflicts at runtime
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+.
29 #if !GTK_CHECK_VERSION(3,0,0) && !(defined(GTK_DISABLE_DEPRECATED) || defined(GSEAL_ENABLE))
31 // ----------------------------------------------------------------------------
32 // the following were introduced in GTK+ 2.8
34 static inline GtkWidget
* wx_gtk_scrolled_window_get_hscrollbar(GtkScrolledWindow
* scrolled_window
)
36 return scrolled_window
->hscrollbar
;
38 #define gtk_scrolled_window_get_hscrollbar wx_gtk_scrolled_window_get_hscrollbar
40 static inline GtkWidget
* wx_gtk_scrolled_window_get_vscrollbar(GtkScrolledWindow
* scrolled_window
)
42 return scrolled_window
->vscrollbar
;
44 #define gtk_scrolled_window_get_vscrollbar wx_gtk_scrolled_window_get_vscrollbar
46 // ----------------------------------------------------------------------------
47 // the following were introduced in GLib 2.10
49 static inline gpointer
wx_g_object_ref_sink(gpointer object
)
52 gtk_object_sink(GTK_OBJECT(object
));
55 #define g_object_ref_sink wx_g_object_ref_sink
57 // ----------------------------------------------------------------------------
58 // the following were introduced in GTK+ 2.14
60 static inline gdouble
wx_gtk_adjustment_get_lower(GtkAdjustment
* adjustment
)
62 return adjustment
->lower
;
64 #define gtk_adjustment_get_lower wx_gtk_adjustment_get_lower
66 static inline gdouble
wx_gtk_adjustment_get_page_increment(GtkAdjustment
* adjustment
)
68 return adjustment
->page_increment
;
70 #define gtk_adjustment_get_page_increment wx_gtk_adjustment_get_page_increment
72 static inline gdouble
wx_gtk_adjustment_get_page_size(GtkAdjustment
* adjustment
)
74 return adjustment
->page_size
;
76 #define gtk_adjustment_get_page_size wx_gtk_adjustment_get_page_size
78 static inline gdouble
wx_gtk_adjustment_get_step_increment(GtkAdjustment
* adjustment
)
80 return adjustment
->step_increment
;
82 #define gtk_adjustment_get_step_increment wx_gtk_adjustment_get_step_increment
84 static inline gdouble
wx_gtk_adjustment_get_upper(GtkAdjustment
* adjustment
)
86 return adjustment
->upper
;
88 #define gtk_adjustment_get_upper wx_gtk_adjustment_get_upper
90 static inline GtkWidget
* wx_gtk_color_selection_dialog_get_color_selection(GtkColorSelectionDialog
* csd
)
94 #define gtk_color_selection_dialog_get_color_selection wx_gtk_color_selection_dialog_get_color_selection
96 static inline GtkWidget
* wx_gtk_dialog_get_content_area(GtkDialog
* dialog
)
100 #define gtk_dialog_get_content_area wx_gtk_dialog_get_content_area
102 static inline GtkWidget
* wx_gtk_dialog_get_action_area(GtkDialog
* dialog
)
104 return dialog
->action_area
;
106 #define gtk_dialog_get_action_area wx_gtk_dialog_get_action_area
108 static inline GtkWidget
* wx_gtk_font_selection_dialog_get_cancel_button(GtkFontSelectionDialog
* fsd
)
110 return fsd
->cancel_button
;
112 #define gtk_font_selection_dialog_get_cancel_button wx_gtk_font_selection_dialog_get_cancel_button
114 static inline GtkWidget
* wx_gtk_font_selection_dialog_get_ok_button(GtkFontSelectionDialog
* fsd
)
116 return fsd
->ok_button
;
118 #define gtk_font_selection_dialog_get_ok_button wx_gtk_font_selection_dialog_get_ok_button
120 static inline GdkAtom
wx_gtk_selection_data_get_data_type(GtkSelectionData
* selection_data
)
122 return selection_data
->type
;
124 #define gtk_selection_data_get_data_type wx_gtk_selection_data_get_data_type
126 static inline gint
wx_gtk_selection_data_get_format(GtkSelectionData
* selection_data
)
128 return selection_data
->format
;
130 #define gtk_selection_data_get_format wx_gtk_selection_data_get_format
132 static inline gint
wx_gtk_selection_data_get_length(GtkSelectionData
* selection_data
)
134 return selection_data
->length
;
136 #define gtk_selection_data_get_length wx_gtk_selection_data_get_length
138 static inline GdkAtom
wx_gtk_selection_data_get_target(GtkSelectionData
* selection_data
)
140 return selection_data
->target
;
142 #define gtk_selection_data_get_target wx_gtk_selection_data_get_target
144 static inline GdkWindow
* wx_gtk_widget_get_window(GtkWidget
* widget
)
146 return widget
->window
;
148 #define gtk_widget_get_window wx_gtk_widget_get_window
150 // ----------------------------------------------------------------------------
151 // the following were introduced in GTK+ 2.16
153 static inline GdkAtom
wx_gtk_selection_data_get_selection(GtkSelectionData
* selection_data
)
155 return selection_data
->selection
;
157 #define gtk_selection_data_get_selection wx_gtk_selection_data_get_selection
159 // ----------------------------------------------------------------------------
160 // the following were introduced in GTK+ 2.18
162 static inline void wx_gtk_widget_get_allocation(GtkWidget
* widget
, GtkAllocation
* allocation
)
164 *allocation
= widget
->allocation
;
166 #define gtk_widget_get_allocation wx_gtk_widget_get_allocation
168 inline gboolean
wx_gtk_widget_get_has_window(GtkWidget
*widget
)
170 return !GTK_WIDGET_NO_WINDOW(widget
);
172 #define gtk_widget_get_has_window wx_gtk_widget_get_has_window
175 inline gboolean
wx_gtk_widget_get_has_grab(GtkWidget
*widget
)
177 return GTK_WIDGET_HAS_GRAB(widget
);
179 #define gtk_widget_get_has_grab wx_gtk_widget_get_has_grab
182 inline gboolean
wx_gtk_widget_get_visible(GtkWidget
*widget
)
184 return GTK_WIDGET_VISIBLE(widget
);
186 #define gtk_widget_get_visible wx_gtk_widget_get_visible
189 inline gboolean
wx_gtk_widget_get_sensitive(GtkWidget
*widget
)
191 return GTK_WIDGET_VISIBLE(widget
);
193 #define gtk_widget_get_sensitive wx_gtk_widget_get_sensitive
196 inline gboolean
wx_gtk_widget_is_drawable(GtkWidget
*widget
)
198 return GTK_WIDGET_DRAWABLE(widget
);
200 #define gtk_widget_is_drawable wx_gtk_widget_is_drawable
203 inline gboolean
wx_gtk_widget_get_can_focus(GtkWidget
*widget
)
205 return GTK_WIDGET_CAN_FOCUS(widget
);
207 #define gtk_widget_get_can_focus wx_gtk_widget_get_can_focus
209 inline void wx_gtk_widset_set_can_focus(GtkWidget
*widget
, gboolean can
)
212 GTK_WIDGET_SET_FLAGS(widget
, GTK_CAN_FOCUS
);
214 GTK_WIDGET_UNSET_FLAGS(widget
, GTK_CAN_FOCUS
);
216 #define gtk_widset_set_can_focus wx_gtk_widset_set_can_focus
219 inline gboolean
wx_gtk_widget_get_can_default(GtkWidget
*widget
)
221 return GTK_WIDGET_CAN_DEFAULT(widget
);
223 #define gtk_widget_get_can_default wx_gtk_widget_get_can_default
225 inline void wx_gtk_widget_set_can_default(GtkWidget
*widget
, gboolean can
)
228 GTK_WIDGET_SET_FLAGS(widget
, GTK_CAN_DEFAULT
);
230 GTK_WIDGET_UNSET_FLAGS(widget
, GTK_CAN_DEFAULT
);
232 #define gtk_widget_set_can_default wx_gtk_widget_set_can_default
235 inline gboolean
wx_gtk_widget_has_default(GtkWidget
*widget
)
237 return GTK_WIDGET_HAS_DEFAULT(widget
);
239 #define gtk_widget_has_default wx_gtk_widget_has_default
242 inline GtkStateType
wx_gtk_widget_get_state(GtkWidget
*widget
)
244 return (GtkStateType
)GTK_WIDGET_STATE(widget
);
246 #define gtk_widget_get_state wx_gtk_widget_get_state
249 inline gboolean
wx_gtk_widget_get_double_buffered(GtkWidget
*widget
)
251 return GTK_WIDGET_DOUBLE_BUFFERED(widget
);
253 #define gtk_widget_get_double_buffered wx_gtk_widget_get_double_buffered
255 static inline gboolean
wx_gtk_widget_has_grab(GtkWidget
* widget
)
257 return GTK_WIDGET_HAS_GRAB(widget
);
259 #define gtk_widget_has_grab wx_gtk_widget_has_grab
261 static inline void wx_gtk_widget_set_allocation(GtkWidget
* widget
, const GtkAllocation
* allocation
)
263 widget
->allocation
= *allocation
;
265 #define gtk_widget_set_allocation wx_gtk_widget_set_allocation
267 // ----------------------------------------------------------------------------
268 // the following were introduced in GTK+ 2.20
270 inline gboolean
wx_gtk_widget_get_realized(GtkWidget
*widget
)
272 return GTK_WIDGET_REALIZED(widget
);
274 #define gtk_widget_get_realized wx_gtk_widget_get_realized
277 inline gboolean
wx_gtk_widget_get_mapped(GtkWidget
*widget
)
279 return GTK_WIDGET_MAPPED(widget
);
281 #define gtk_widget_get_mapped wx_gtk_widget_get_mapped
283 static inline GdkWindow
* wx_gtk_entry_get_text_window(GtkEntry
* entry
)
285 return entry
->text_area
;
287 #define gtk_entry_get_text_window wx_gtk_entry_get_text_window
289 #endif // !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
292 #endif // _WX_GTK_PRIVATE_COMPAT_H_