+void MyFrame::OnSetNativeUserDesc(wxCommandEvent& WXUNUSED(event))
+{
+ wxString fontdesc = GetCanvas()->GetTextFont().GetNativeFontInfoUserDesc();
+ wxString fontUserInfo = wxGetTextFromUser(
+ wxT("Here you can edit current font description"),
+ wxT("Input font description"), fontdesc,
+ this);
+ if (fontUserInfo.IsEmpty())
+ return; // user clicked "Cancel" - do nothing
+
+ wxFont font;
+ if (font.SetNativeFontInfoUserDesc(fontUserInfo))
+ {
+ wxASSERT_MSG(font.Ok(), wxT("The font should now be valid"));
+ DoChangeFont(font);
+ }
+ else
+ {
+ wxASSERT_MSG(!font.Ok(), wxT("The font should now be invalid"));
+ wxMessageBox(wxT("Error trying to create a font with such description..."));
+ }
+}
+
+void MyFrame::OnSetEncoding(wxCommandEvent& WXUNUSED(event))
+{
+ wxFontEncoding enc = GetEncodingFromUser();
+ if ( enc == wxFONTENCODING_SYSTEM )
+ return;
+
+ wxFont font = m_canvas->GetTextFont();
+ font.SetEncoding(enc);
+ DoChangeFont(font);
+}
+
+wxFontEncoding MyFrame::GetEncodingFromUser()
+{
+ wxArrayString names;
+ wxArrayInt encodings;
+
+ const size_t count = wxFontMapper::GetSupportedEncodingsCount();
+ names.reserve(count);
+ encodings.reserve(count);
+
+ for ( size_t n = 0; n < count; n++ )
+ {
+ wxFontEncoding enc = wxFontMapper::GetEncoding(n);
+ encodings.push_back(enc);
+ names.push_back(wxFontMapper::GetEncodingName(enc));
+ }
+
+ int i = wxGetSingleChoiceIndex
+ (
+ wxT("Choose the encoding"),
+ SAMPLE_TITLE,
+ names,
+ this
+ );
+
+ return i == -1 ? wxFONTENCODING_SYSTEM : (wxFontEncoding)encodings[i];
+}
+
+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)