]>
Commit | Line | Data |
---|---|---|
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/gtk/private/string.h" | |
18 | #include "wx/gtk/dc.h" | |
19 | #include "wx/gtk/dcclient.h" | |
20 | #include "wx/gtk/dcmemory.h" | |
21 | ||
22 | // pango_version_check symbol is quite recent ATM (4/2007)... so we | |
23 | // use our own wrapper which implements a smart trick. | |
24 | // Use this function as you'd use pango_version_check: | |
25 | // | |
26 | // if (!wx_pango_version_check(1,18,0)) | |
27 | // ... call to a function available only in pango >= 1.18 ... | |
28 | // | |
29 | // and use it only to test for pango versions >= 1.16.0 | |
30 | extern const gchar *wx_pango_version_check(int major, int minor, int micro); | |
31 | ||
32 | #if wxUSE_UNICODE | |
33 | #define wxGTK_CONV(s) s.utf8_str() | |
34 | #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s)) | |
35 | #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s)) | |
36 | #define wxGTK_CONV_SYS(s) wxGTK_CONV((s)) | |
37 | ||
38 | #define wxGTK_CONV_BACK(s) wxString::FromUTF8(s) | |
39 | #define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s) | |
40 | #define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s) | |
41 | #define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s) | |
42 | #else | |
43 | #include "wx/font.h" | |
44 | ||
45 | // convert the text between the given encoding and UTF-8 used by wxGTK | |
46 | extern WXDLLIMPEXP_CORE wxCharBuffer | |
47 | wxConvertToGTK(const wxString& s, | |
48 | wxFontEncoding enc = wxFONTENCODING_SYSTEM); | |
49 | ||
50 | extern WXDLLIMPEXP_CORE wxCharBuffer | |
51 | wxConvertFromGTK(const wxString& s, | |
52 | wxFontEncoding enc = wxFONTENCODING_SYSTEM); | |
53 | ||
54 | // helper: use the encoding of the given font if it's valid | |
55 | inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font) | |
56 | { | |
57 | return wxConvertToGTK(s, font.Ok() ? font.GetEncoding() | |
58 | : wxFONTENCODING_SYSTEM); | |
59 | } | |
60 | ||
61 | inline wxCharBuffer wxConvertFromGTK(const wxString& s, const wxFont& font) | |
62 | { | |
63 | return wxConvertFromGTK(s, font.Ok() ? font.GetEncoding() | |
64 | : wxFONTENCODING_SYSTEM); | |
65 | } | |
66 | ||
67 | // more helpers: allow passing GTK+ strings directly | |
68 | inline wxCharBuffer | |
69 | wxConvertFromGTK(const wxGtkString& gs, | |
70 | wxFontEncoding enc = wxFONTENCODING_SYSTEM) | |
71 | { | |
72 | return wxConvertFromGTK(gs.c_str(), enc); | |
73 | } | |
74 | ||
75 | inline wxCharBuffer | |
76 | wxConvertFromGTK(const wxGtkString& gs, const wxFont& font) | |
77 | { | |
78 | return wxConvertFromGTK(gs.c_str(), font); | |
79 | } | |
80 | ||
81 | #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font) | |
82 | #define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc)) | |
83 | #define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font)) | |
84 | #define wxGTK_CONV_SYS(s) wxConvertToGTK((s)) | |
85 | ||
86 | #define wxGTK_CONV_BACK(s) wxConvertFromGTK((s), m_font) | |
87 | #define wxGTK_CONV_BACK_ENC(s, enc) wxConvertFromGTK((s), (enc)) | |
88 | #define wxGTK_CONV_BACK_FONT(s, font) wxConvertFromGTK((s), (font)) | |
89 | #define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s)) | |
90 | #endif | |
91 | ||
92 | // Some deprecated GTK+ prototypes we still use often | |
93 | // FIXME: Don't use them if possible. | |
94 | extern "C" { | |
95 | ||
96 | // Deprecated since GTK+-1.3.7: | |
97 | // Trivial wrapper around gtk_window_move, with some side effects we seem to rely on | |
98 | void gtk_widget_set_uposition (GtkWidget *widget, | |
99 | gint x, | |
100 | gint y); | |
101 | ||
102 | // We rely on the allow_shrink parameter in one place | |
103 | void gtk_window_set_policy (GtkWindow *window, | |
104 | gint allow_shrink, | |
105 | gint allow_grow, | |
106 | gint auto_shrink); | |
107 | ||
108 | } // extern "C" | |
109 | ||
110 | #endif // _WX_GTK_PRIVATE_H_ | |
111 |