void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
{
- wxFontData data;
- data.SetInitialFont(wxGetApp().m_canvasFont);
- data.SetColour(wxGetApp().m_canvasTextColour);
+ wxFontData data;
+ data.SetInitialFont(wxGetApp().m_canvasFont);
+ data.SetColour(wxGetApp().m_canvasTextColour);
- wxFontDialog *dialog = new wxFontDialog(this, &data);
- if (dialog->ShowModal() == wxID_OK)
- {
- wxFontData retData = dialog->GetFontData();
+ // you might also do this:
+ //
+ // wxFontDialog dialog;
+ // if ( !dialog.Create(this, data) { ... error ... }
+ //
+ wxFontDialog dialog(this, data);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxFontData retData = dialog.GetFontData();
wxGetApp().m_canvasFont = retData.GetChosenFont();
wxGetApp().m_canvasTextColour = retData.GetColour();
myCanvas->Refresh();
- }
- dialog->Destroy();
+ }
+ //else: cancelled by the user, don't change the font
}
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
switch ( dialog.ShowModal() )
{
case wxID_YES:
- wxLogStatus("You pressed \"Yes\"");
+ wxLogStatus(wxT("You pressed \"Yes\""));
break;
case wxID_NO:
- wxLogStatus("You pressed \"No\"");
+ wxLogStatus(wxT("You pressed \"No\""));
break;
case wxID_CANCEL:
- wxLogStatus("You pressed \"Cancel\"");
+ wxLogStatus(wxT("You pressed \"Cancel\""));
break;
default:
- wxLogError("Unexpected wxMessageDialog return code!");
+ wxLogError(wxT("Unexpected wxMessageDialog return code!"));
}
}