]>
Commit | Line | Data |
---|---|---|
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$ | |
77ffb593 | 8 | // Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org> |
65571936 | 9 | // Licence: wxWindows licence |
9e691f46 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_GTK_PRIVATE_H_ | |
13 | #define _WX_GTK_PRIVATE_H_ | |
14 | ||
9e691f46 VZ |
15 | #include <gtk/gtk.h> |
16 | ||
17 | #include "wx/event.h" | |
18 | ||
19 | // fail all version tests if the GTK+ version is so ancient that it doesn't | |
20 | // even have GTK_CHECK_VERSION | |
21 | #ifndef GTK_CHECK_VERSION | |
22 | #define GTK_CHECK_VERSION(a, b, c) 0 | |
23 | #endif | |
24 | ||
dd398cd0 RR |
25 | #if wxUSE_UNICODE |
26 | #define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s) | |
27 | #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s) | |
28 | #else | |
29 | #define wxGTK_CONV(s) wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC(s) ) | |
30 | #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX( (wxConvUTF8.cMB2WC( s ) ) ) | |
31 | #endif | |
dd398cd0 | 32 | |
1efb5db8 MR |
33 | // Some deprecated GTK+ prototypes we still use often |
34 | // FIXME: Don't use them if possible. | |
35 | G_BEGIN_DECLS | |
36 | ||
37 | // Should use gtk_image_new, but the mask seems to be handled different, | |
38 | // and we need to migrate | |
39 | GtkWidget* gtk_pixmap_new (GdkPixmap *pixmap, | |
40 | GdkBitmap *mask); | |
41 | ||
42 | // Deprecated since GTK+-1.3.7: | |
43 | // Trivial wrapper around gtk_window_move, with some side effects we seem to rely on | |
44 | void gtk_widget_set_uposition (GtkWidget *widget, | |
45 | gint x, | |
46 | gint y); | |
47 | ||
48 | // We rely on the allow_shrink parameter in one place | |
49 | void gtk_window_set_policy (GtkWindow *window, | |
50 | gint allow_shrink, | |
51 | gint allow_grow, | |
52 | gint auto_shrink); | |
53 | ||
54 | G_END_DECLS | |
55 | ||
84833214 VZ |
56 | //----------------------------------------------------------------------------- |
57 | // idle system | |
58 | //----------------------------------------------------------------------------- | |
59 | ||
60 | extern void wxapp_install_idle_handler(); | |
61 | extern bool g_isIdle; | |
62 | ||
35a489dd MR |
63 | //----------------------------------------------------------------------------- |
64 | // Convenience class for g_freeing a gchar* on scope exit automatically | |
65 | //----------------------------------------------------------------------------- | |
66 | ||
67 | class wxGtkString | |
68 | { | |
69 | public: | |
70 | explicit wxGtkString(gchar *s) : m_str(s) { } | |
71 | ~wxGtkString() { g_free(m_str); } | |
72 | ||
73 | operator gchar *() const { return m_str; } | |
74 | ||
75 | private: | |
76 | gchar *m_str; | |
77 | ||
78 | DECLARE_NO_COPY_CLASS(wxGtkString) | |
79 | }; | |
80 | ||
84833214 VZ |
81 | //----------------------------------------------------------------------------- |
82 | // GTK+ scroll types -> wxEventType | |
83 | //----------------------------------------------------------------------------- | |
84 | ||
9e691f46 VZ |
85 | // translate a GTK+ scroll type to a wxEventType |
86 | inline wxEventType GtkScrollTypeToWx(guint scrollType) | |
87 | { | |
88 | wxEventType command; | |
89 | switch ( scrollType ) | |
90 | { | |
91 | case GTK_SCROLL_STEP_BACKWARD: | |
92 | command = wxEVT_SCROLL_LINEUP; | |
93 | break; | |
94 | ||
95 | case GTK_SCROLL_STEP_FORWARD: | |
96 | command = wxEVT_SCROLL_LINEDOWN; | |
97 | break; | |
98 | ||
99 | case GTK_SCROLL_PAGE_BACKWARD: | |
100 | command = wxEVT_SCROLL_PAGEUP; | |
101 | break; | |
102 | ||
103 | case GTK_SCROLL_PAGE_FORWARD: | |
104 | command = wxEVT_SCROLL_PAGEDOWN; | |
105 | break; | |
106 | ||
107 | default: | |
108 | command = wxEVT_SCROLL_THUMBTRACK; | |
109 | } | |
110 | ||
111 | return command; | |
112 | } | |
113 | ||
114 | inline wxEventType GtkScrollWinTypeToWx(guint scrollType) | |
115 | { | |
116 | // GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need | |
117 | return GtkScrollTypeToWx(scrollType) + | |
118 | wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP; | |
119 | } | |
120 | ||
84833214 VZ |
121 | |
122 | //----------------------------------------------------------------------------- | |
123 | // Misc. functions | |
124 | //----------------------------------------------------------------------------- | |
125 | ||
224016a8 JS |
126 | // Needed for implementing e.g. combobox on wxGTK within a modal dialog. |
127 | void wxAddGrab(wxWindow* window); | |
128 | void wxRemoveGrab(wxWindow* window); | |
129 | ||
66bd83b4 | 130 | // Escapes string so that it is valid Pango markup XML string: |
20123d49 | 131 | WXDLLIMPEXP_CORE wxString wxEscapeStringForPangoMarkup(const wxString& str); |
66bd83b4 | 132 | |
abc736fd MW |
133 | // The declaration for gtk_icon_size_lookup was accidentally ifdefed out in |
134 | // GTK+ 2.1.0 which Sun seem to have shipped with some versions of JDS | |
135 | // for Solaris 9 x86. | |
18720210 | 136 | #ifdef NEED_GTK_ICON_SIZE_LOOKUP |
abc736fd MW |
137 | extern "C" gboolean gtk_icon_size_lookup (GtkIconSize size, |
138 | gint *width, | |
139 | gint *height); | |
140 | #endif | |
141 | ||
9e691f46 VZ |
142 | #endif // _WX_GTK_PRIVATE_H_ |
143 |