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
27 #define wxGTK_CONV(s) wxConvUTF8.cWX2MB((s))
28 #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
29 #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
30 #define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
32 #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX((s))
33 #define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s)
34 #define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s)
35 #define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s)
39 // convert the text between the given encoding and UTF-8 used by wxGTK
41 wxConvertToGTK(const wxString
& s
,
42 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
);
45 wxConvertFromGTK(const wxString
& s
,
46 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
);
48 // helper: use the encoding of the given font if it's valid
49 inline wxCharBuffer
wxConvertToGTK(const wxString
& s
, const wxFont
& font
)
51 return wxConvertToGTK(s
, font
.Ok() ? font
.GetEncoding()
52 : wxFONTENCODING_SYSTEM
);
55 inline wxCharBuffer
wxConvertFromGTK(const wxString
& s
, const wxFont
& font
)
57 return wxConvertFromGTK(s
, font
.Ok() ? font
.GetEncoding()
58 : wxFONTENCODING_SYSTEM
);
61 // more helpers: allow passing GTK+ strings directly
63 wxConvertFromGTK(const wxGtkString
& gs
,
64 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
)
66 return wxConvertFromGTK(gs
.c_str(), enc
);
70 wxConvertFromGTK(const wxGtkString
& gs
, const wxFont
& font
)
72 return wxConvertFromGTK(gs
.c_str(), font
);
75 #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font)
76 #define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc))
77 #define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font))
78 #define wxGTK_CONV_SYS(s) wxConvertToGTK((s))
80 #define wxGTK_CONV_BACK(s) wxConvertFromGTK((s), m_font)
81 #define wxGTK_CONV_BACK_ENC(s, enc) wxConvertFromGTK((s), (enc))
82 #define wxGTK_CONV_BACK_FONT(s, font) wxConvertFromGTK((s), (font))
83 #define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s))
86 // Some deprecated GTK+ prototypes we still use often
87 // FIXME: Don't use them if possible.
90 // Should use gtk_image_new, but the mask seems to be handled different,
91 // and we need to migrate
92 GtkWidget
* gtk_pixmap_new (GdkPixmap
*pixmap
,
95 // Deprecated since GTK+-1.3.7:
96 // Trivial wrapper around gtk_window_move, with some side effects we seem to rely on
97 void gtk_widget_set_uposition (GtkWidget
*widget
,
101 // We rely on the allow_shrink parameter in one place
102 void gtk_window_set_policy (GtkWindow
*window
,
109 //-----------------------------------------------------------------------------
111 //-----------------------------------------------------------------------------
113 // Needed for implementing e.g. combobox on wxGTK within a modal dialog.
114 void wxAddGrab(wxWindow
* window
);
115 void wxRemoveGrab(wxWindow
* window
);
117 // Escapes string so that it is valid Pango markup XML string:
118 WXDLLIMPEXP_CORE wxString
wxEscapeStringForPangoMarkup(const wxString
& str
);
120 // The declaration for gtk_icon_size_lookup was accidentally ifdefed out in
121 // GTK+ 2.1.0 which Sun seem to have shipped with some versions of JDS
122 // for Solaris 9 x86.
123 #ifdef NEED_GTK_ICON_SIZE_LOOKUP
124 extern "C" gboolean
gtk_icon_size_lookup (GtkIconSize size
,
130 #include <gdk/gdktypes.h>
132 // Returns stock accelerator modifier and key code for the given ID
133 WXDLLEXPORT
bool wxGetStockGtkAccelerator(const char *id
, GdkModifierType
*mod
, guint
*key
);
136 #endif // _WX_GTK_PRIVATE_H_