]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/private.h
compilation fix for cygwin
[wxWidgets.git] / include / wx / gtk / private.h
CommitLineData
9e691f46
VZ
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
dd398cd0
RR
26#ifdef __WXGTK20__
27#if wxUSE_UNICODE
28 #define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s)
29 #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s)
30#else
31 #define wxGTK_CONV(s) wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC(s) )
32 #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX( (wxConvUTF8.cMB2WC( s ) ) )
33#endif
34#else
35 #define wxGTK_CONV(s) s.c_str()
36 #define wxGTK_CONV_BACK(s) s
37#endif
38
39
40// GTK+ 2.0 compatibility define is broken when used from C++ as it
41// casts enum to int implicitly
9e691f46
VZ
42#ifdef __WXGTK20__
43 #undef gtk_signal_disconnect_by_func
44 #define gtk_signal_disconnect_by_func(object,func,data) \
45 gtk_signal_compat_matched((object), (func), (data), \
46 (GSignalMatchType)(G_SIGNAL_MATCH_FUNC | \
47 G_SIGNAL_MATCH_DATA), 0)
48#endif
49
50// child is not a member of GTK_BUTTON() any more in GTK+ 2.0
51#ifdef __WXGTK20__
52 #define BUTTON_CHILD(w) GTK_BIN((w))->child
53#else
54 #define BUTTON_CHILD(w) GTK_BUTTON((w))->child
55#endif
56
57// event_window has disappeared from GtkToggleButton in GTK+ 2.0
58#ifdef __WXGTK20__
59 #define TOGGLE_BUTTON_EVENT_WIN(w) GTK_BUTTON((w))->event_window
60#else
61 #define TOGGLE_BUTTON_EVENT_WIN(w) GTK_TOGGLE_BUTTON((w))->event_window
62#endif
63
64// get the font from a style
65//
66// TODO: GdkFont has been replaced by PangoFontDescription in GTK+ 2.0
67// and we really should use it instead of GdkFont (see also dclient.cpp)
68#ifdef __WXGTK20__
69 #define GET_STYLE_FONT(style) gtk_style_get_font(style)
70 #define SET_STYLE_FONT(style, font) gtk_style_set_font(style, font)
71#else
72 #define GET_STYLE_FONT(style) ((style)->font)
73 #define SET_STYLE_FONT(style, fnt) \
74 gdk_font_unref( style->font ); \
75 style->font = gdk_font_ref( fnt )
76#endif
77
78// gtk_editable_{copy|cut|paste}_clipboard() had an extra argument under
79// previous GTK+ versions but no more
80#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0)
81 #define DUMMY_CLIPBOARD_ARG
82#else
83 #define DUMMY_CLIPBOARD_ARG ,0
84#endif
85
86// _GtkEditable is now private
87#ifdef __WXGTK20__
88 #define GET_EDITABLE_POS(w) gtk_editable_get_position(GTK_EDITABLE(w))
89 #define SET_EDITABLE_POS(w, pos) \
90 gtk_editable_set_position(GTK_EDITABLE(w), (pos))
91#else
92 #define GET_EDITABLE_POS(w) GTK_EDITABLE((w))->current_pos
93 #define SET_EDITABLE_POS(w, pos) \
94 GTK_EDITABLE((w))->current_pos = (pos)
95#endif
96
97// this GtkNotebook struct field has been renamed
98#ifdef __WXGTK20__
99 #define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->event_window
100#else
101 #define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->panel
102#endif
103
9e691f46 104#ifdef __WXGTK20__
b5a49d4c
RR
105 #define SCROLLBAR_CBACK_ARG
106 #define GET_SCROLL_TYPE(w) GTK_SCROLL_JUMP
9e691f46
VZ
107#else
108 #define SCROLLBAR_CBACK_ARG
109 #define GET_SCROLL_TYPE(w) GTK_RANGE((w))->scroll_type
110#endif
111
112// translate a GTK+ scroll type to a wxEventType
113inline wxEventType GtkScrollTypeToWx(guint scrollType)
114{
115 wxEventType command;
116 switch ( scrollType )
117 {
118 case GTK_SCROLL_STEP_BACKWARD:
119 command = wxEVT_SCROLL_LINEUP;
120 break;
121
122 case GTK_SCROLL_STEP_FORWARD:
123 command = wxEVT_SCROLL_LINEDOWN;
124 break;
125
126 case GTK_SCROLL_PAGE_BACKWARD:
127 command = wxEVT_SCROLL_PAGEUP;
128 break;
129
130 case GTK_SCROLL_PAGE_FORWARD:
131 command = wxEVT_SCROLL_PAGEDOWN;
132 break;
133
134 default:
135 command = wxEVT_SCROLL_THUMBTRACK;
136 }
137
138 return command;
139}
140
141inline wxEventType GtkScrollWinTypeToWx(guint scrollType)
142{
143 // GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need
144 return GtkScrollTypeToWx(scrollType) +
145 wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP;
146}
147
148#endif // _WX_GTK_PRIVATE_H_
149