From 1baec21fcef4b9787dea19e2928a057442cb4be4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 Aug 2006 10:07:35 +0000 Subject: [PATCH] allow entering font description string interactively git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/font/font.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/samples/font/font.cpp b/samples/font/font.cpp index 7fe8717618..7c6c89794d 100644 --- a/samples/font/font.cpp +++ b/samples/font/font.cpp @@ -266,9 +266,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuFont->AppendSeparator(); menuFont->Append(Font_CheckNativeToFromString, - wxT("Check Native Font Info To/From String")); + wxT("Set native font &description\tShift-Ctrl-D")); menuFont->Append(Font_CheckNativeToFromUserString, - wxT("Check Native Font Info User String")); + wxT("Set &user font description\tShift-Ctrl-U")); menuFont->Append(Font_CheckFaceName, wxT("Check font face name")); @@ -481,22 +481,26 @@ void MyFrame::OnEnumerateFamiliesForEncoding(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnCheckNativeToFromString(wxCommandEvent& WXUNUSED(event)) { - wxString fontInfo = m_canvas->GetTextFont().GetNativeFontInfoDesc(); - + wxString fontInfo = wxGetTextFromUser + ( + wxT("Enter native font string"), + wxT("Input font description"), + m_canvas->GetTextFont().GetNativeFontInfoDesc(), + this + ); if ( fontInfo.empty() ) + return; // user clicked "Cancel" - do nothing + + wxFont font; + font.SetNativeFontInfo(fontInfo); + if ( !font.Ok() ) { - wxLogError(wxT("Native font info string is empty!")); + wxLogError(wxT("Font info string \"%s\" is invalid."), + fontInfo.c_str()); + return; } - else - { - wxFont *font = wxFont::New(fontInfo); - if ( fontInfo != font->GetNativeFontInfoDesc() ) - wxLogError(wxT("wxNativeFontInfo ToString()/FromString() broken!")); - else - wxLogMessage(wxT("wxNativeFontInfo works: %s"), fontInfo.c_str()); - delete font; - } + DoChangeFont(font); } void MyFrame::OnCheckFaceName(wxCommandEvent& WXUNUSED(event)) -- 2.45.2