]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/private.h
Use proper format in wxGTK clipboard selection handler.
[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
b098b621 17#include "wx/gtk/private/string.h"
8bffcd08 18#include "wx/gtk/private/gtk2-compat.h"
9e691f46 19
5f4d1820
VZ
20// pango_version_check symbol is quite recent ATM (4/2007)... so we
21// use our own wrapper which implements a smart trick.
22// Use this function as you'd use pango_version_check:
23//
24// if (!wx_pango_version_check(1,18,0))
25// ... call to a function available only in pango >= 1.18 ...
26//
27// and use it only to test for pango versions >= 1.16.0
28extern const gchar *wx_pango_version_check(int major, int minor, int micro);
29
dd398cd0 30#if wxUSE_UNICODE
527f168b 31 #define wxGTK_CONV(s) (s).utf8_str()
1a6c768b
VZ
32 #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
33 #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
34 #define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
30083ad8 35
cc209a51 36 #define wxGTK_CONV_BACK(s) wxString::FromUTF8Unchecked(s)
30083ad8
VZ
37 #define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s)
38 #define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s)
39 #define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s)
dd398cd0 40#else
5851053a
VZ
41 #include "wx/font.h"
42
30083ad8 43 // convert the text between the given encoding and UTF-8 used by wxGTK
be3dc331 44 extern WXDLLIMPEXP_CORE wxCharBuffer
5f11fef5
VZ
45 wxConvertToGTK(const wxString& s,
46 wxFontEncoding enc = wxFONTENCODING_SYSTEM);
47
be3dc331 48 extern WXDLLIMPEXP_CORE wxCharBuffer
30083ad8
VZ
49 wxConvertFromGTK(const wxString& s,
50 wxFontEncoding enc = wxFONTENCODING_SYSTEM);
51
5f11fef5
VZ
52 // helper: use the encoding of the given font if it's valid
53 inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font)
54 {
a1b806b9 55 return wxConvertToGTK(s, font.IsOk() ? font.GetEncoding()
5f11fef5
VZ
56 : wxFONTENCODING_SYSTEM);
57 }
58
30083ad8
VZ
59 inline wxCharBuffer wxConvertFromGTK(const wxString& s, const wxFont& font)
60 {
a1b806b9 61 return wxConvertFromGTK(s, font.IsOk() ? font.GetEncoding()
30083ad8
VZ
62 : wxFONTENCODING_SYSTEM);
63 }
64
65 // more helpers: allow passing GTK+ strings directly
66 inline wxCharBuffer
67 wxConvertFromGTK(const wxGtkString& gs,
68 wxFontEncoding enc = wxFONTENCODING_SYSTEM)
69 {
70 return wxConvertFromGTK(gs.c_str(), enc);
71 }
72
73 inline wxCharBuffer
74 wxConvertFromGTK(const wxGtkString& gs, const wxFont& font)
75 {
76 return wxConvertFromGTK(gs.c_str(), font);
77 }
78
79 #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font)
1a6c768b
VZ
80 #define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc))
81 #define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font))
1a6c768b 82 #define wxGTK_CONV_SYS(s) wxConvertToGTK((s))
30083ad8
VZ
83
84 #define wxGTK_CONV_BACK(s) wxConvertFromGTK((s), m_font)
85 #define wxGTK_CONV_BACK_ENC(s, enc) wxConvertFromGTK((s), (enc))
86 #define wxGTK_CONV_BACK_FONT(s, font) wxConvertFromGTK((s), (font))
87 #define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s))
dd398cd0 88#endif
dd398cd0 89
c282e47d
VZ
90// Define a macro for converting wxString to char* in appropriate encoding for
91// the file names.
92#ifdef G_OS_WIN32
93 // Under MSW, UTF-8 file name encodings are always used.
94 #define wxGTK_CONV_FN(s) (s).utf8_str()
95#else
96 // Under Unix use GLib file name encoding (which is also UTF-8 by default
97 // but may be different from it).
98 #define wxGTK_CONV_FN(s) (s).fn_str()
99#endif
100
e8759560
VZ
101// ----------------------------------------------------------------------------
102// various private helper functions
103// ----------------------------------------------------------------------------
104
105namespace wxGTKPrivate
106{
107
108// these functions create the GTK widgets of the specified types which can then
109// used to retrieve their styles, pass them to drawing functions &c
110//
111// the returned widgets shouldn't be destroyed, this is done automatically on
112// shutdown
5c26126c
VZ
113WXDLLIMPEXP_CORE GtkWidget *GetButtonWidget();
114WXDLLIMPEXP_CORE GtkWidget *GetCheckButtonWidget();
115WXDLLIMPEXP_CORE GtkWidget *GetComboBoxWidget();
116WXDLLIMPEXP_CORE GtkWidget *GetEntryWidget();
117WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidgetFirst();
118WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidgetLast();
119WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidget();
740dd154 120WXDLLIMPEXP_CORE GtkWidget *GetNotebookWidget();
5c26126c 121WXDLLIMPEXP_CORE GtkWidget *GetRadioButtonWidget();
9dc44eff 122WXDLLIMPEXP_CORE GtkWidget *GetSplitterWidget(wxOrientation orient = wxHORIZONTAL);
5c26126c
VZ
123WXDLLIMPEXP_CORE GtkWidget *GetTextEntryWidget();
124WXDLLIMPEXP_CORE GtkWidget *GetTreeWidget();
e8759560
VZ
125
126} // wxGTKPrivate
127
9e691f46 128#endif // _WX_GTK_PRIVATE_H_