]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/private.h
Committing in .
[wxWidgets.git] / include / wx / gtk / private.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/private.h
3 // Purpose: wxGTK private macros, functions &c
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 12.03.02
7 // RCS-ID: $Id$
8 // Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GTK_PRIVATE_H_
13 #define _WX_GTK_PRIVATE_H_
14
15 #include <gdk/gdk.h>
16 #include <gtk/gtk.h>
17
18 #include "wx/event.h"
19
20 // fail all version tests if the GTK+ version is so ancient that it doesn't
21 // even have GTK_CHECK_VERSION
22 #ifndef GTK_CHECK_VERSION
23 #define GTK_CHECK_VERSION(a, b, c) 0
24 #endif
25
26 // GTK+ 2.0 compatibility define is broken when used from C++ as it casts enum
27 // to int implicitly
28 #ifdef __WXGTK20__
29 #undef gtk_signal_disconnect_by_func
30 #define gtk_signal_disconnect_by_func(object,func,data) \
31 gtk_signal_compat_matched((object), (func), (data), \
32 (GSignalMatchType)(G_SIGNAL_MATCH_FUNC | \
33 G_SIGNAL_MATCH_DATA), 0)
34 #endif
35
36 // child is not a member of GTK_BUTTON() any more in GTK+ 2.0
37 #ifdef __WXGTK20__
38 #define BUTTON_CHILD(w) GTK_BIN((w))->child
39 #else
40 #define BUTTON_CHILD(w) GTK_BUTTON((w))->child
41 #endif
42
43 // event_window has disappeared from GtkToggleButton in GTK+ 2.0
44 #ifdef __WXGTK20__
45 #define TOGGLE_BUTTON_EVENT_WIN(w) GTK_BUTTON((w))->event_window
46 #else
47 #define TOGGLE_BUTTON_EVENT_WIN(w) GTK_TOGGLE_BUTTON((w))->event_window
48 #endif
49
50 // get the font from a style
51 //
52 // TODO: GdkFont has been replaced by PangoFontDescription in GTK+ 2.0
53 // and we really should use it instead of GdkFont (see also dclient.cpp)
54 #ifdef __WXGTK20__
55 #define GET_STYLE_FONT(style) gtk_style_get_font(style)
56 #define SET_STYLE_FONT(style, font) gtk_style_set_font(style, font)
57 #else
58 #define GET_STYLE_FONT(style) ((style)->font)
59 #define SET_STYLE_FONT(style, fnt) \
60 gdk_font_unref( style->font ); \
61 style->font = gdk_font_ref( fnt )
62 #endif
63
64 // gtk_editable_{copy|cut|paste}_clipboard() had an extra argument under
65 // previous GTK+ versions but no more
66 #if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
67 #define DUMMY_CLIPBOARD_ARG
68 #else
69 #define DUMMY_CLIPBOARD_ARG ,0
70 #endif
71
72 // _GtkEditable is now private
73 #ifdef __WXGTK20__
74 #define GET_EDITABLE_POS(w) gtk_editable_get_position(GTK_EDITABLE(w))
75 #define SET_EDITABLE_POS(w, pos) \
76 gtk_editable_set_position(GTK_EDITABLE(w), (pos))
77 #else
78 #define GET_EDITABLE_POS(w) GTK_EDITABLE((w))->current_pos
79 #define SET_EDITABLE_POS(w, pos) \
80 GTK_EDITABLE((w))->current_pos = (pos)
81 #endif
82
83 // this GtkNotebook struct field has been renamed
84 #ifdef __WXGTK20__
85 #define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->event_window
86 #else
87 #define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->panel
88 #endif
89
90 // VZ: I _think_ that in GTK+ 2.0 the scroll type is passed to the
91 // value_changed callback as a 2nd argument but I'm not at all sure about
92 // it, if this is false all occurences of this macro must be changed!
93 #ifdef __WXGTK20__
94 #define SCROLLBAR_CBACK_ARG GtkScrollType scrollType,
95 #define GET_SCROLL_TYPE(w) scrollType
96 #else
97 #define SCROLLBAR_CBACK_ARG
98 #define GET_SCROLL_TYPE(w) GTK_RANGE((w))->scroll_type
99 #endif
100
101 // translate a GTK+ scroll type to a wxEventType
102 inline wxEventType GtkScrollTypeToWx(guint scrollType)
103 {
104 wxEventType command;
105 switch ( scrollType )
106 {
107 case GTK_SCROLL_STEP_BACKWARD:
108 command = wxEVT_SCROLL_LINEUP;
109 break;
110
111 case GTK_SCROLL_STEP_FORWARD:
112 command = wxEVT_SCROLL_LINEDOWN;
113 break;
114
115 case GTK_SCROLL_PAGE_BACKWARD:
116 command = wxEVT_SCROLL_PAGEUP;
117 break;
118
119 case GTK_SCROLL_PAGE_FORWARD:
120 command = wxEVT_SCROLL_PAGEDOWN;
121 break;
122
123 default:
124 command = wxEVT_SCROLL_THUMBTRACK;
125 }
126
127 return command;
128 }
129
130 inline wxEventType GtkScrollWinTypeToWx(guint scrollType)
131 {
132 // GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need
133 return GtkScrollTypeToWx(scrollType) +
134 wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP;
135 }
136
137 #endif // _WX_GTK_PRIVATE_H_
138