]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/private.h
reverted wxHVScrolledWindow patch (rev 1.19/1.21 of vscroll.h/.cpp) because not only...
[wxWidgets.git] / include / wx / gtk / private.h
CommitLineData
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)
1cef1b4a 27 #define wxGTK_CONV_SYS(s) wxGTK_CONV(s)
dd398cd0
RR
28 #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s)
29#else
5851053a
VZ
30 #include "wx/font.h"
31
5f11fef5
VZ
32 // convert the text in given encoding to UTF-8 used by wxGTK
33 extern wxCharBuffer
34 wxConvertToGTK(const wxString& s,
35 wxFontEncoding enc = wxFONTENCODING_SYSTEM);
36
37 // helper: use the encoding of the given font if it's valid
38 inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font)
39 {
40 return wxConvertToGTK(s, font.Ok() ? font.GetEncoding()
41 : wxFONTENCODING_SYSTEM);
42 }
43
44 #define wxGTK_CONV(s) wxConvertToGTK((s), m_font)
45 #define wxGTK_CONV_SYS(s) wxConvertToGTK(s)
46 #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC((s)) )
dd398cd0 47#endif
dd398cd0 48
1efb5db8
MR
49// Some deprecated GTK+ prototypes we still use often
50// FIXME: Don't use them if possible.
51G_BEGIN_DECLS
52
53// Should use gtk_image_new, but the mask seems to be handled different,
54// and we need to migrate
55GtkWidget* gtk_pixmap_new (GdkPixmap *pixmap,
56 GdkBitmap *mask);
57
58// Deprecated since GTK+-1.3.7:
59// Trivial wrapper around gtk_window_move, with some side effects we seem to rely on
60void gtk_widget_set_uposition (GtkWidget *widget,
61 gint x,
62 gint y);
63
64// We rely on the allow_shrink parameter in one place
65void gtk_window_set_policy (GtkWindow *window,
66 gint allow_shrink,
67 gint allow_grow,
68 gint auto_shrink);
69
70G_END_DECLS
71
84833214
VZ
72//-----------------------------------------------------------------------------
73// idle system
74//-----------------------------------------------------------------------------
75
76extern void wxapp_install_idle_handler();
77extern bool g_isIdle;
78
35a489dd
MR
79//-----------------------------------------------------------------------------
80// Convenience class for g_freeing a gchar* on scope exit automatically
81//-----------------------------------------------------------------------------
82
83class wxGtkString
84{
85public:
86 explicit wxGtkString(gchar *s) : m_str(s) { }
87 ~wxGtkString() { g_free(m_str); }
88
46cb4b3f
VZ
89 const gchar *c_str() const { return m_str; }
90
35a489dd
MR
91 operator gchar *() const { return m_str; }
92
93private:
94 gchar *m_str;
95
96 DECLARE_NO_COPY_CLASS(wxGtkString)
97};
98
84833214
VZ
99//-----------------------------------------------------------------------------
100// GTK+ scroll types -> wxEventType
101//-----------------------------------------------------------------------------
102
9e691f46
VZ
103// translate a GTK+ scroll type to a wxEventType
104inline wxEventType GtkScrollTypeToWx(guint scrollType)
105{
106 wxEventType command;
107 switch ( scrollType )
108 {
109 case GTK_SCROLL_STEP_BACKWARD:
110 command = wxEVT_SCROLL_LINEUP;
111 break;
112
113 case GTK_SCROLL_STEP_FORWARD:
114 command = wxEVT_SCROLL_LINEDOWN;
115 break;
116
117 case GTK_SCROLL_PAGE_BACKWARD:
118 command = wxEVT_SCROLL_PAGEUP;
119 break;
120
121 case GTK_SCROLL_PAGE_FORWARD:
122 command = wxEVT_SCROLL_PAGEDOWN;
123 break;
124
125 default:
126 command = wxEVT_SCROLL_THUMBTRACK;
127 }
128
129 return command;
130}
131
132inline wxEventType GtkScrollWinTypeToWx(guint scrollType)
133{
134 // GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need
135 return GtkScrollTypeToWx(scrollType) +
136 wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP;
137}
138
84833214
VZ
139
140//-----------------------------------------------------------------------------
141// Misc. functions
142//-----------------------------------------------------------------------------
143
224016a8
JS
144// Needed for implementing e.g. combobox on wxGTK within a modal dialog.
145void wxAddGrab(wxWindow* window);
146void wxRemoveGrab(wxWindow* window);
147
66bd83b4 148// Escapes string so that it is valid Pango markup XML string:
20123d49 149WXDLLIMPEXP_CORE wxString wxEscapeStringForPangoMarkup(const wxString& str);
66bd83b4 150
abc736fd
MW
151// The declaration for gtk_icon_size_lookup was accidentally ifdefed out in
152// GTK+ 2.1.0 which Sun seem to have shipped with some versions of JDS
153// for Solaris 9 x86.
18720210 154#ifdef NEED_GTK_ICON_SIZE_LOOKUP
abc736fd
MW
155extern "C" gboolean gtk_icon_size_lookup (GtkIconSize size,
156 gint *width,
157 gint *height);
158#endif
159
9e691f46
VZ
160#endif // _WX_GTK_PRIVATE_H_
161