+void MyFrame::OnCheckNativeToFromString(wxCommandEvent& WXUNUSED(event))
+{
+ wxString fontInfo = m_canvas->GetTextFont().GetNativeFontInfoDesc();
+
+ if ( fontInfo.IsEmpty() )
+ {
+ wxLogError(wxT("Native font info string is empty!"));
+ }
+ 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;
+ }
+}
+
+void MyFrame::DoResizeFont(int diff)
+{
+ wxFont font = m_canvas->GetTextFont();
+
+ font.SetPointSize(font.GetPointSize() + diff);
+ DoChangeFont(font);
+}
+
+void MyFrame::OnBold(wxCommandEvent& event)
+{
+ wxFont font = m_canvas->GetTextFont();
+
+ font.SetWeight(event.IsChecked() ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL);
+ DoChangeFont(font);
+}
+
+void MyFrame::OnItalic(wxCommandEvent& event)
+{
+ wxFont font = m_canvas->GetTextFont();
+
+ font.SetStyle(event.IsChecked() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL);
+ DoChangeFont(font);
+}
+
+void MyFrame::OnUnderline(wxCommandEvent& event)
+{
+ wxFont font = m_canvas->GetTextFont();
+
+ font.SetUnderlined(event.IsChecked());
+ DoChangeFont(font);
+}
+
+void MyFrame::OnwxPointerFont(wxCommandEvent& event)
+{
+ wxFont font;
+
+ switch (event.GetId())
+ {
+ case Font_wxNORMAL_FONT : font = wxFont(*wxNORMAL_FONT); break;
+ case Font_wxSMALL_FONT : font = wxFont(*wxSMALL_FONT); break;
+ case Font_wxITALIC_FONT : font = wxFont(*wxITALIC_FONT); break;
+ case Font_wxSWISS_FONT : font = wxFont(*wxSWISS_FONT); break;
+ default : font = wxFont(*wxNORMAL_FONT); break;
+ }
+
+ GetMenuBar()->Check(Font_Bold, FALSE);
+ GetMenuBar()->Check(Font_Italic, FALSE);
+ GetMenuBar()->Check(Font_Underlined, FALSE);
+
+ DoChangeFont(font);
+}
+
+void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col)
+{
+ m_canvas->SetTextFont(font);
+ if ( col.Ok() )
+ m_canvas->SetColour(col);
+ m_canvas->Refresh();
+
+ m_textctrl->SetFont(font);
+ if ( col.Ok() )
+ m_textctrl->SetForegroundColour(col);
+}
+