added missing export declarations for wxGTK internal functions needed outside of...
[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@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GTK_PRIVATE_H_
13 #define _WX_GTK_PRIVATE_H_
14
15 #include <gtk/gtk.h>
16
17 #include "wx/event.h"
18 #include "wx/gtk/private/string.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 // 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:
29 //
30 // if (!wx_pango_version_check(1,18,0))
31 // ... call to a function available only in pango >= 1.18 ...
32 //
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);
35
36 #if wxUSE_UNICODE
37 #define wxGTK_CONV(s) s.utf8_str()
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))
41
42 #define wxGTK_CONV_BACK(s) wxString::FromUTF8(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)
46 #else
47 #include "wx/font.h"
48
49 // convert the text between the given encoding and UTF-8 used by wxGTK
50 extern WXDLLIMPEXP_CORE wxCharBuffer
51 wxConvertToGTK(const wxString& s,
52 wxFontEncoding enc = wxFONTENCODING_SYSTEM);
53
54 extern WXDLLIMPEXP_CORE wxCharBuffer
55 wxConvertFromGTK(const wxString& s,
56 wxFontEncoding enc = wxFONTENCODING_SYSTEM);
57
58 // helper: use the encoding of the given font if it's valid
59 inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font)
60 {
61 return wxConvertToGTK(s, font.Ok() ? font.GetEncoding()
62 : wxFONTENCODING_SYSTEM);
63 }
64
65 inline wxCharBuffer wxConvertFromGTK(const wxString& s, const wxFont& font)
66 {
67 return wxConvertFromGTK(s, font.Ok() ? font.GetEncoding()
68 : wxFONTENCODING_SYSTEM);
69 }
70
71 // more helpers: allow passing GTK+ strings directly
72 inline wxCharBuffer
73 wxConvertFromGTK(const wxGtkString& gs,
74 wxFontEncoding enc = wxFONTENCODING_SYSTEM)
75 {
76 return wxConvertFromGTK(gs.c_str(), enc);
77 }
78
79 inline wxCharBuffer
80 wxConvertFromGTK(const wxGtkString& gs, const wxFont& font)
81 {
82 return wxConvertFromGTK(gs.c_str(), font);
83 }
84
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))
89
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))
94 #endif
95
96 // Some deprecated GTK+ prototypes we still use often
97 // FIXME: Don't use them if possible.
98 G_BEGIN_DECLS
99
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,
103 GdkBitmap *mask);
104
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,
108 gint x,
109 gint y);
110
111 // We rely on the allow_shrink parameter in one place
112 void gtk_window_set_policy (GtkWindow *window,
113 gint allow_shrink,
114 gint allow_grow,
115 gint auto_shrink);
116
117 G_END_DECLS
118
119 //-----------------------------------------------------------------------------
120 // Misc. functions
121 //-----------------------------------------------------------------------------
122
123 // Needed for implementing e.g. combobox on wxGTK within a modal dialog.
124 void wxAddGrab(wxWindow* window);
125 void wxRemoveGrab(wxWindow* window);
126
127 // Escapes string so that it is valid Pango markup XML string:
128 WXDLLIMPEXP_CORE wxString wxEscapeStringForPangoMarkup(const wxString& str);
129
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,
135 gint *width,
136 gint *height);
137 #endif
138
139 #ifdef __WXGTK20__
140 #include <gdk/gdktypes.h>
141
142 // Returns stock accelerator modifier and key code for the given ID
143 WXDLLEXPORT bool wxGetStockGtkAccelerator(const char *id, GdkModifierType *mod, guint *key);
144 #endif
145
146 #endif // _WX_GTK_PRIVATE_H_
147