X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7beba2fc73283f5b750227459da57e66bcd475f5..b8aa1680f21faef698d39a2bce9c09e45a5bbf7a:/samples/font/font.cpp diff --git a/samples/font/font.cpp b/samples/font/font.cpp index acc320e270..56e5a565b6 100644 --- a/samples/font/font.cpp +++ b/samples/font/font.cpp @@ -296,29 +296,44 @@ bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly, if ( fontEnumerator.GotAny() ) { - int n, nFacenames = fontEnumerator.GetFacenames().GetCount(); - wxLogStatus(this, "Found %d %sfonts", - nFacenames, fixedWidthOnly ? "fixed width " : ""); - - wxString *facenames = new wxString[nFacenames]; - for ( n = 0; n < nFacenames; n++ ) - facenames[n] = fontEnumerator.GetFacenames().Item(n); + int nFacenames = fontEnumerator.GetFacenames().GetCount(); + if ( !silent ) + { + wxLogStatus(this, "Found %d %sfonts", + nFacenames, fixedWidthOnly ? "fixed width " : ""); + } + wxString facename; if ( silent ) - n = 1; + { + // choose the first + facename = fontEnumerator.GetFacenames().Item(0); + } else + { + // let the user choose + wxString *facenames = new wxString[nFacenames]; + int n; + for ( n = 0; n < nFacenames; n++ ) + facenames[n] = fontEnumerator.GetFacenames().Item(n); + n = wxGetSingleChoiceIndex("Choose a facename", "Font demo", nFacenames, facenames, this); - if ( n != -1 ) + + if ( n != -1 ) + facename = facenames[n]; + + delete [] facenames; + } + + if ( !facename.IsEmpty() ) { - wxFont font(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, FALSE, facenames[n], encoding); + wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_NORMAL, FALSE, facename, encoding); DoChangeFont(font); } - delete [] facenames; - return TRUE; } else if ( !silent ) @@ -477,7 +492,7 @@ void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event)) // and now create the correct font if ( !DoEnumerateFamilies(FALSE, fontenc, TRUE /* silent */) ) { - wxFont font(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, + wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, FALSE /* !underlined */, wxEmptyString /* facename */, fontenc); if ( font.Ok() ) @@ -542,10 +557,9 @@ BEGIN_EVENT_TABLE(MyCanvas, wxWindow) END_EVENT_TABLE() MyCanvas::MyCanvas( wxWindow *parent ) - : wxWindow( parent, -1 ) + : wxWindow( parent, -1 ), + m_colour(*wxRED), m_font(*wxNORMAL_FONT) { - m_font = *wxNORMAL_FONT; - m_colour = *wxRED; } MyCanvas::~MyCanvas()