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_
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
26 #define wxGTK_CONV(s) wxConvUTF8.cWX2MB((s))
27 #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
28 #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
29 #define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
30 #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX((s))
34 // convert the text in given encoding to UTF-8 used by wxGTK
36 wxConvertToGTK(const wxString
& s
,
37 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
);
39 // helper: use the encoding of the given font if it's valid
40 inline wxCharBuffer
wxConvertToGTK(const wxString
& s
, const wxFont
& font
)
42 return wxConvertToGTK(s
, font
.Ok() ? font
.GetEncoding()
43 : wxFONTENCODING_SYSTEM
);
46 #define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc))
47 #define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font))
48 #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font)
49 #define wxGTK_CONV_SYS(s) wxConvertToGTK((s))
50 #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX(wxConvUTF8.cMB2WC((s)))
53 // Some deprecated GTK+ prototypes we still use often
54 // FIXME: Don't use them if possible.
57 // Should use gtk_image_new, but the mask seems to be handled different,
58 // and we need to migrate
59 GtkWidget
* gtk_pixmap_new (GdkPixmap
*pixmap
,
62 // Deprecated since GTK+-1.3.7:
63 // Trivial wrapper around gtk_window_move, with some side effects we seem to rely on
64 void gtk_widget_set_uposition (GtkWidget
*widget
,
68 // We rely on the allow_shrink parameter in one place
69 void gtk_window_set_policy (GtkWindow
*window
,
76 //-----------------------------------------------------------------------------
78 //-----------------------------------------------------------------------------
80 extern void wxapp_install_idle_handler();
83 //-----------------------------------------------------------------------------
84 // Convenience class for g_freeing a gchar* on scope exit automatically
85 //-----------------------------------------------------------------------------
90 explicit wxGtkString(gchar
*s
) : m_str(s
) { }
91 ~wxGtkString() { g_free(m_str
); }
93 const gchar
*c_str() const { return m_str
; }
95 operator gchar
*() const { return m_str
; }
100 DECLARE_NO_COPY_CLASS(wxGtkString
)
103 //-----------------------------------------------------------------------------
104 // GTK+ scroll types -> wxEventType
105 //-----------------------------------------------------------------------------
107 // translate a GTK+ scroll type to a wxEventType
108 inline wxEventType
GtkScrollTypeToWx(guint scrollType
)
111 switch ( scrollType
)
113 case GTK_SCROLL_STEP_BACKWARD
:
114 command
= wxEVT_SCROLL_LINEUP
;
117 case GTK_SCROLL_STEP_FORWARD
:
118 command
= wxEVT_SCROLL_LINEDOWN
;
121 case GTK_SCROLL_PAGE_BACKWARD
:
122 command
= wxEVT_SCROLL_PAGEUP
;
125 case GTK_SCROLL_PAGE_FORWARD
:
126 command
= wxEVT_SCROLL_PAGEDOWN
;
130 command
= wxEVT_SCROLL_THUMBTRACK
;
136 inline wxEventType
GtkScrollWinTypeToWx(guint scrollType
)
138 // GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need
139 return GtkScrollTypeToWx(scrollType
) +
140 wxEVT_SCROLLWIN_TOP
- wxEVT_SCROLL_TOP
;
144 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
148 // Needed for implementing e.g. combobox on wxGTK within a modal dialog.
149 void wxAddGrab(wxWindow
* window
);
150 void wxRemoveGrab(wxWindow
* window
);
152 // Escapes string so that it is valid Pango markup XML string:
153 WXDLLIMPEXP_CORE wxString
wxEscapeStringForPangoMarkup(const wxString
& str
);
155 // The declaration for gtk_icon_size_lookup was accidentally ifdefed out in
156 // GTK+ 2.1.0 which Sun seem to have shipped with some versions of JDS
157 // for Solaris 9 x86.
158 #ifdef NEED_GTK_ICON_SIZE_LOOKUP
159 extern "C" gboolean
gtk_icon_size_lookup (GtkIconSize size
,
164 #endif // _WX_GTK_PRIVATE_H_