1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/private.h
3 // Purpose: wxGTK private macros, functions &c
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GTK_PRIVATE_H_
13 #define _WX_GTK_PRIVATE_H_
18 #include "wx/gtk/private/string.h"
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
26 // pango_version_check symbol is quite recent ATM (4/2007)... so we
27 // use our own wrapper which implements a smart trick.
28 // Use this function as you'd use pango_version_check:
30 // if (!wx_pango_version_check(1,18,0))
31 // ... call to a function available only in pango >= 1.18 ...
33 // and use it only to test for pango versions >= 1.16.0
34 extern const gchar
*wx_pango_version_check(int major
, int minor
, int micro
);
37 #define wxGTK_CONV(s) wxConvUTF8.cWX2MB((s))
38 #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
39 #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
40 #define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
42 #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX((s))
43 #define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s)
44 #define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s)
45 #define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s)
49 // convert the text between the given encoding and UTF-8 used by wxGTK
51 wxConvertToGTK(const wxString
& s
,
52 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
);
55 wxConvertFromGTK(const wxString
& s
,
56 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
);
58 // helper: use the encoding of the given font if it's valid
59 inline wxCharBuffer
wxConvertToGTK(const wxString
& s
, const wxFont
& font
)
61 return wxConvertToGTK(s
, font
.Ok() ? font
.GetEncoding()
62 : wxFONTENCODING_SYSTEM
);
65 inline wxCharBuffer
wxConvertFromGTK(const wxString
& s
, const wxFont
& font
)
67 return wxConvertFromGTK(s
, font
.Ok() ? font
.GetEncoding()
68 : wxFONTENCODING_SYSTEM
);
71 // more helpers: allow passing GTK+ strings directly
73 wxConvertFromGTK(const wxGtkString
& gs
,
74 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
)
76 return wxConvertFromGTK(gs
.c_str(), enc
);
80 wxConvertFromGTK(const wxGtkString
& gs
, const wxFont
& font
)
82 return wxConvertFromGTK(gs
.c_str(), font
);
85 #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font)
86 #define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc))
87 #define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font))
88 #define wxGTK_CONV_SYS(s) wxConvertToGTK((s))
90 #define wxGTK_CONV_BACK(s) wxConvertFromGTK((s), m_font)
91 #define wxGTK_CONV_BACK_ENC(s, enc) wxConvertFromGTK((s), (enc))
92 #define wxGTK_CONV_BACK_FONT(s, font) wxConvertFromGTK((s), (font))
93 #define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s))
96 // Some deprecated GTK+ prototypes we still use often
97 // FIXME: Don't use them if possible.
100 // Should use gtk_image_new, but the mask seems to be handled different,
101 // and we need to migrate
102 GtkWidget
* gtk_pixmap_new (GdkPixmap
*pixmap
,
105 // Deprecated since GTK+-1.3.7:
106 // Trivial wrapper around gtk_window_move, with some side effects we seem to rely on
107 void gtk_widget_set_uposition (GtkWidget
*widget
,
111 // We rely on the allow_shrink parameter in one place
112 void gtk_window_set_policy (GtkWindow
*window
,
119 //-----------------------------------------------------------------------------
121 //-----------------------------------------------------------------------------
123 // Needed for implementing e.g. combobox on wxGTK within a modal dialog.
124 void wxAddGrab(wxWindow
* window
);
125 void wxRemoveGrab(wxWindow
* window
);
127 // Escapes string so that it is valid Pango markup XML string:
128 WXDLLIMPEXP_CORE wxString
wxEscapeStringForPangoMarkup(const wxString
& str
);
130 // The declaration for gtk_icon_size_lookup was accidentally ifdefed out in
131 // GTK+ 2.1.0 which Sun seem to have shipped with some versions of JDS
132 // for Solaris 9 x86.
133 #ifdef NEED_GTK_ICON_SIZE_LOOKUP
134 extern "C" gboolean
gtk_icon_size_lookup (GtkIconSize size
,
140 #include <gdk/gdktypes.h>
142 // Returns stock accelerator modifier and key code for the given ID
143 WXDLLEXPORT
bool wxGetStockGtkAccelerator(const char *id
, GdkModifierType
*mod
, guint
*key
);
146 #endif // _WX_GTK_PRIVATE_H_