private.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. // Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GTK_PRIVATE_H_
  11. #define _WX_GTK_PRIVATE_H_
  12. #include <gtk/gtk.h>
  13. #include "wx/gtk/private/string.h"
  14. #include "wx/gtk/private/gtk2-compat.h"
  15. #ifndef G_VALUE_INIT
  16. // introduced in GLib 2.30
  17. #define G_VALUE_INIT { 0, { { 0 } } }
  18. #endif
  19. // pango_version_check symbol is quite recent ATM (4/2007)... so we
  20. // use our own wrapper which implements a smart trick.
  21. // Use this function as you'd use pango_version_check:
  22. //
  23. // if (!wx_pango_version_check(1,18,0))
  24. // ... call to a function available only in pango >= 1.18 ...
  25. //
  26. // and use it only to test for pango versions >= 1.16.0
  27. extern const gchar *wx_pango_version_check(int major, int minor, int micro);
  28. #if wxUSE_UNICODE
  29. #define wxGTK_CONV(s) (s).utf8_str()
  30. #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
  31. #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
  32. #define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
  33. #define wxGTK_CONV_BACK(s) wxString::FromUTF8Unchecked(s)
  34. #define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s)
  35. #define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s)
  36. #define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s)
  37. #else
  38. #include "wx/font.h"
  39. // convert the text between the given encoding and UTF-8 used by wxGTK
  40. extern WXDLLIMPEXP_CORE wxCharBuffer
  41. wxConvertToGTK(const wxString& s,
  42. wxFontEncoding enc = wxFONTENCODING_SYSTEM);
  43. extern WXDLLIMPEXP_CORE wxCharBuffer
  44. wxConvertFromGTK(const wxString& s,
  45. wxFontEncoding enc = wxFONTENCODING_SYSTEM);
  46. // helper: use the encoding of the given font if it's valid
  47. inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font)
  48. {
  49. return wxConvertToGTK(s, font.IsOk() ? font.GetEncoding()
  50. : wxFONTENCODING_SYSTEM);
  51. }
  52. inline wxCharBuffer wxConvertFromGTK(const wxString& s, const wxFont& font)
  53. {
  54. return wxConvertFromGTK(s, font.IsOk() ? font.GetEncoding()
  55. : wxFONTENCODING_SYSTEM);
  56. }
  57. // more helpers: allow passing GTK+ strings directly
  58. inline wxCharBuffer
  59. wxConvertFromGTK(const wxGtkString& gs,
  60. wxFontEncoding enc = wxFONTENCODING_SYSTEM)
  61. {
  62. return wxConvertFromGTK(gs.c_str(), enc);
  63. }
  64. inline wxCharBuffer
  65. wxConvertFromGTK(const wxGtkString& gs, const wxFont& font)
  66. {
  67. return wxConvertFromGTK(gs.c_str(), font);
  68. }
  69. #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font)
  70. #define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc))
  71. #define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font))
  72. #define wxGTK_CONV_SYS(s) wxConvertToGTK((s))
  73. #define wxGTK_CONV_BACK(s) wxConvertFromGTK((s), m_font)
  74. #define wxGTK_CONV_BACK_ENC(s, enc) wxConvertFromGTK((s), (enc))
  75. #define wxGTK_CONV_BACK_FONT(s, font) wxConvertFromGTK((s), (font))
  76. #define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s))
  77. #endif
  78. // Define a macro for converting wxString to char* in appropriate encoding for
  79. // the file names.
  80. #ifdef G_OS_WIN32
  81. // Under MSW, UTF-8 file name encodings are always used.
  82. #define wxGTK_CONV_FN(s) (s).utf8_str()
  83. #else
  84. // Under Unix use GLib file name encoding (which is also UTF-8 by default
  85. // but may be different from it).
  86. #define wxGTK_CONV_FN(s) (s).fn_str()
  87. #endif
  88. // ----------------------------------------------------------------------------
  89. // various private helper functions
  90. // ----------------------------------------------------------------------------
  91. namespace wxGTKPrivate
  92. {
  93. // these functions create the GTK widgets of the specified types which can then
  94. // used to retrieve their styles, pass them to drawing functions &c
  95. //
  96. // the returned widgets shouldn't be destroyed, this is done automatically on
  97. // shutdown
  98. WXDLLIMPEXP_CORE GtkWidget *GetButtonWidget();
  99. WXDLLIMPEXP_CORE GtkWidget *GetCheckButtonWidget();
  100. WXDLLIMPEXP_CORE GtkWidget *GetComboBoxWidget();
  101. WXDLLIMPEXP_CORE GtkWidget *GetEntryWidget();
  102. WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidgetFirst();
  103. WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidgetLast();
  104. WXDLLIMPEXP_CORE GtkWidget *GetHeaderButtonWidget();
  105. WXDLLIMPEXP_CORE GtkWidget *GetNotebookWidget();
  106. WXDLLIMPEXP_CORE GtkWidget *GetRadioButtonWidget();
  107. WXDLLIMPEXP_CORE GtkWidget *GetSplitterWidget(wxOrientation orient = wxHORIZONTAL);
  108. WXDLLIMPEXP_CORE GtkWidget *GetTextEntryWidget();
  109. WXDLLIMPEXP_CORE GtkWidget *GetTreeWidget();
  110. } // wxGTKPrivate
  111. #endif // _WX_GTK_PRIVATE_H_