fontdlg.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/fontdlg.h
  3. // Purpose: common interface for different wxFontDialog classes
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 12.05.02
  7. // Copyright: (c) 1997-2002 wxWidgets team
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_FONTDLG_H_BASE_
  11. #define _WX_FONTDLG_H_BASE_
  12. #include "wx/defs.h" // for wxUSE_FONTDLG
  13. #if wxUSE_FONTDLG
  14. #include "wx/dialog.h" // the base class
  15. #include "wx/fontdata.h"
  16. // ----------------------------------------------------------------------------
  17. // wxFontDialog interface
  18. // ----------------------------------------------------------------------------
  19. class WXDLLIMPEXP_CORE wxFontDialogBase : public wxDialog
  20. {
  21. public:
  22. // create the font dialog
  23. wxFontDialogBase() { }
  24. wxFontDialogBase(wxWindow *parent) { m_parent = parent; }
  25. wxFontDialogBase(wxWindow *parent, const wxFontData& data)
  26. { m_parent = parent; InitFontData(&data); }
  27. bool Create(wxWindow *parent)
  28. { return DoCreate(parent); }
  29. bool Create(wxWindow *parent, const wxFontData& data)
  30. { InitFontData(&data); return Create(parent); }
  31. // retrieve the font data
  32. const wxFontData& GetFontData() const { return m_fontData; }
  33. wxFontData& GetFontData() { return m_fontData; }
  34. #if WXWIN_COMPATIBILITY_2_6
  35. // deprecated interface, for compatibility only, don't use
  36. wxDEPRECATED( wxFontDialogBase(wxWindow *parent, const wxFontData *data) );
  37. wxDEPRECATED( bool Create(wxWindow *parent, const wxFontData *data) );
  38. #endif // WXWIN_COMPATIBILITY_2_6
  39. protected:
  40. virtual bool DoCreate(wxWindow *parent) { m_parent = parent; return true; }
  41. void InitFontData(const wxFontData *data = NULL)
  42. { if ( data ) m_fontData = *data; }
  43. wxFontData m_fontData;
  44. wxDECLARE_NO_COPY_CLASS(wxFontDialogBase);
  45. };
  46. #if WXWIN_COMPATIBILITY_2_6
  47. // deprecated interface, for compatibility only, don't use
  48. inline wxFontDialogBase::wxFontDialogBase(wxWindow *parent, const wxFontData *data)
  49. { m_parent = parent; InitFontData(data); }
  50. inline bool wxFontDialogBase::Create(wxWindow *parent, const wxFontData *data)
  51. { InitFontData(data); return Create(parent); }
  52. #endif // WXWIN_COMPATIBILITY_2_6
  53. // ----------------------------------------------------------------------------
  54. // platform-specific wxFontDialog implementation
  55. // ----------------------------------------------------------------------------
  56. #if defined( __WXOSX_MAC__ )
  57. //set to 1 to use native mac font and color dialogs
  58. #define USE_NATIVE_FONT_DIALOG_FOR_MACOSX 1
  59. #else
  60. //not supported on these platforms, leave 0
  61. #define USE_NATIVE_FONT_DIALOG_FOR_MACOSX 0
  62. #endif
  63. #if defined(__WXUNIVERSAL__) || \
  64. defined(__WXMOTIF__) || \
  65. defined(__WXCOCOA__) || \
  66. defined(__WXWINCE__) || \
  67. defined(__WXGPE__)
  68. #include "wx/generic/fontdlgg.h"
  69. #define wxFontDialog wxGenericFontDialog
  70. #elif defined(__WXMSW__)
  71. #include "wx/msw/fontdlg.h"
  72. #elif defined(__WXGTK20__)
  73. #include "wx/gtk/fontdlg.h"
  74. #elif defined(__WXGTK__)
  75. #include "wx/gtk1/fontdlg.h"
  76. #elif defined(__WXPM__)
  77. #include "wx/os2/fontdlg.h"
  78. #elif defined(__WXMAC__)
  79. #include "wx/osx/fontdlg.h"
  80. #endif
  81. // ----------------------------------------------------------------------------
  82. // global public functions
  83. // ----------------------------------------------------------------------------
  84. // get the font from user and return it, returns wxNullFont if the dialog was
  85. // cancelled
  86. WXDLLIMPEXP_CORE wxFont wxGetFontFromUser(wxWindow *parent = NULL,
  87. const wxFont& fontInit = wxNullFont,
  88. const wxString& caption = wxEmptyString);
  89. #endif // wxUSE_FONTDLG
  90. #endif
  91. // _WX_FONTDLG_H_BASE_