From fc9361e3ec5b81a7e8c32d93a03aea0b2cd3e045 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 27 Jul 2007 23:49:08 +0000 Subject: [PATCH] added wxTo/FromString() overloads for wxFont (1st part of patch 1760073) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/function.tex | 9 +++++++-- include/wx/font.h | 6 ++++++ src/common/fontcmn.cpp | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index e145da2886..5d8a4e82b6 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -3264,7 +3264,10 @@ and current pointer position in screen coordinates. \membersection{wxFromString}\label{wxfromstring} \func{bool}{wxFromString}{\param{const wxString\& }{str}, - \param{wxColourBase* }{col}} + \param{wxColour* }{col}} + +\func{bool}{wxFromString}{\param{const wxString\& }{str}, + \param{wxFont* }{col}} Converts string to the type of the second argument. Returns \true on success. See also: \helpref{wxToString}{wxtostring}. @@ -3587,7 +3590,9 @@ Notice that there should be no semicolon after this macro. \membersection{wxToString}\label{wxtostring} -\func{wxString}{wxToString}{\param{const wxColourBase\& }{col}} +\func{wxString}{wxToString}{\param{const wxColour\& }{col}} + +\func{wxString}{wxToString}{\param{const wxFont\& }{col}} Converts its argument to string. See also: \helpref{wxFromString}{wxfromstring}. diff --git a/include/wx/font.h b/include/wx/font.h index c20d2125a9..9b87cafd11 100644 --- a/include/wx/font.h +++ b/include/wx/font.h @@ -222,6 +222,12 @@ private: static wxFontEncoding ms_encodingDefault; }; +// wxFontBase <-> wxString utilities, used by wxConfig +WXDLLIMPEXP_CORE wxString wxToString(const wxFontBase& font); +WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font); + + + // include the real class declaration #if defined(__WXPALMOS__) #include "wx/palmos/font.h" diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index 20b8c303d0..8a9063f5b3 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -799,3 +799,26 @@ bool wxNativeFontInfo::FromUserString(const wxString& s) } #endif // generic or wxMSW or wxOS2 + + +// wxFont <-> wxString utilities, used by wxConfig +wxString wxToString(const wxFontBase& font) +{ + return font.IsOk() ? font.GetNativeFontInfoDesc() + : wxString(); +} + +bool wxFromString(const wxString& str, wxFontBase *font) +{ + wxCHECK_MSG( font, false, _T("NULL output parameter") ); + + if ( str.empty() ) + { + *font = wxNullFont; + return true; + } + + return font->SetNativeFontInfo(str); +} + + -- 2.45.2