X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c2c59b22862f9537c18f4d4c16b68056d86493f9..dd360466a517259013e9874b32b2a0bfc7affb57:/src/generic/fontdlgg.cpp diff --git a/src/generic/fontdlgg.cpp b/src/generic/fontdlgg.cpp index 6ca1b71e4c..63b8abcfd4 100644 --- a/src/generic/fontdlgg.cpp +++ b/src/generic/fontdlgg.cpp @@ -5,8 +5,8 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -74,14 +74,14 @@ void wxFontPreviewer::OnPaint(wxPaintEvent& WXUNUSED(event)) if ( font.Ok() ) { - dc.SetFont(GetFont()); + dc.SetFont(font); // Calculate vertical centre long w, h; - dc.GetTextExtent("X", &w, &h); + dc.GetTextExtent( wxT("X"), &w, &h); dc.SetTextForeground(GetForegroundColour()); dc.SetClippingRegion(2, 2, size.x-4, size.y-4); dc.DrawText(_("ABCDEFGabcdefg12345"), - 10, h/2 + size.y/2); + 10, size.y/2 - h/2); dc.DestroyClippingRegion(); } } @@ -167,6 +167,7 @@ void wxGenericFontDialog::Init() { m_useEvents = FALSE; m_previewer = NULL; + Create( m_parent ) ; } wxGenericFontDialog::~wxGenericFontDialog() @@ -180,15 +181,26 @@ void wxGenericFontDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) bool wxGenericFontDialog::DoCreate(wxWindow *parent) { + if ( !wxDialog::Create( parent , -1 , _T("Choose Font") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, + _T("fontdialog") ) ) + { + wxFAIL_MSG( wxT("wxFontDialog creation failed") ); + return FALSE; + } + InitializeFont(); CreateWidgets(); + // sets initial font in preview area + wxCommandEvent dummy; + OnChangeFont(dummy); + return TRUE; } int wxGenericFontDialog::ShowModal() { - int ret = wxDialog::ShowModal(); + int ret = wxDialog::ShowModal(); if (ret != wxID_CANCEL) { @@ -229,8 +241,8 @@ void wxGenericFontDialog::CreateWidgets() int i; for ( i = 0; i < 40; i++) { - char buf[5]; - sprintf(buf, "%d", i + 1); + wxChar buf[5]; + wxSprintf(buf, wxT("%d"), i + 1); pointSizes[i] = buf; } @@ -240,7 +252,7 @@ void wxGenericFontDialog::CreateWidgets() m_previewer = new wxFontPreviewer(this); wxButton *okButton = new wxButton(this, wxID_OK, _("OK")); - wxButton *cancelButton = new wxButton(this, wxID_OK, _("Cancel")); + wxButton *cancelButton = new wxButton(this, wxID_CANCEL, _("Cancel")); familyChoice->SetStringSelection( wxFontFamilyIntToString(dialogFont.GetFamily()) ); styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle()));