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_
17 #include "wx/gtk/private/string.h"
18 #include "wx/gtk/private/gtk2-compat.h"
20 class WXDLLIMPEXP_FWD_CORE wxFont
;
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:
26 // if (!wx_pango_version_check(1,18,0))
27 // ... call to a function available only in pango >= 1.18 ...
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
);
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))
38 #define wxGTK_CONV_BACK(s) wxString::FromUTF8Unchecked(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)
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
);
50 extern WXDLLIMPEXP_CORE wxCharBuffer
51 wxConvertFromGTK(const wxString
& s
,
52 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
);
54 // helper: use the encoding of the given font if it's valid
55 inline wxCharBuffer
wxConvertToGTK(const wxString
& s
, const wxFont
& font
)
57 return wxConvertToGTK(s
, font
.IsOk() ? font
.GetEncoding()
58 : wxFONTENCODING_SYSTEM
);
61 inline wxCharBuffer
wxConvertFromGTK(const wxString
& s
, const wxFont
& font
)
63 return wxConvertFromGTK(s
, font
.IsOk() ? font
.GetEncoding()
64 : wxFONTENCODING_SYSTEM
);
67 // more helpers: allow passing GTK+ strings directly
69 wxConvertFromGTK(const wxGtkString
& gs
,
70 wxFontEncoding enc
= wxFONTENCODING_SYSTEM
)
72 return wxConvertFromGTK(gs
.c_str(), enc
);
76 wxConvertFromGTK(const wxGtkString
& gs
, const wxFont
& font
)
78 return wxConvertFromGTK(gs
.c_str(), font
);
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))
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))
92 // ----------------------------------------------------------------------------
93 // various private helper functions
94 // ----------------------------------------------------------------------------
96 namespace wxGTKPrivate
99 // these functions create the GTK widgets of the specified types which can then
100 // used to retrieve their styles, pass them to drawing functions &c
102 // the returned widgets shouldn't be destroyed, this is done automatically on
104 GtkWidget
*GetButtonWidget();
105 GtkWidget
*GetCheckButtonWidget();
106 GtkWidget
*GetComboBoxWidget();
107 GtkWidget
*GetEntryWidget();
108 GtkWidget
*GetHeaderButtonWidgetFirst();
109 GtkWidget
*GetHeaderButtonWidgetLast();
110 GtkWidget
*GetHeaderButtonWidget();
111 GtkWidget
*GetRadioButtonWidget();
112 GtkWidget
*GetSplitterWidget();
113 GtkWidget
*GetTextEntryWidget();
114 GtkWidget
*GetTreeWidget();
116 // Set Pango attributes corresponding to the given font for the span 0..len (or
117 // without any bounds if len == 0) in the specified layout. Currently only
118 // underlined and strike-through attributes are handled by this function.
120 // Special "addDummyAttrs" parameter is used to work around a bug in old Pango
121 // versions in wxWindowDCImpl::DoDrawText(), see comment there.
123 // If neither of them is specified, returns false, otherwise sets up the
124 // attributes and returns true.
126 // This function is implemented in src/gtk/dcclient.cpp.
128 SetPangoAttrsForFont(const wxFont
& font
, PangoLayout
* layout
, size_t len
= 0,
129 bool addDummyAttrs
= false);
133 #endif // _WX_GTK_PRIVATE_H_