+ 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];
+}
+
+wxFontFamily MyFrame::GetFamilyFromUser()
+{
+ wxArrayString names;
+ wxArrayInt families;
+
+ families.push_back(wxFONTFAMILY_DECORATIVE);
+ families.push_back(wxFONTFAMILY_ROMAN);
+ families.push_back(wxFONTFAMILY_SCRIPT);
+ families.push_back(wxFONTFAMILY_SWISS);
+ families.push_back(wxFONTFAMILY_MODERN);
+ families.push_back(wxFONTFAMILY_TELETYPE);
+
+ names.push_back("DECORATIVE");
+ names.push_back("ROMAN");
+ names.push_back("SCRIPT");
+ names.push_back("SWISS");
+ names.push_back("MODERN");
+ names.push_back("TELETYPE");
+
+ int i = wxGetSingleChoiceIndex
+ (
+ wxT("Choose the family"),
+ SAMPLE_TITLE,
+ names,
+ this
+ );
+
+ return i == -1 ? wxFONTFAMILY_DEFAULT : (wxFontFamily)families[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::OnLight(wxCommandEvent& event)
+{
+ wxFont font = m_canvas->GetTextFont();
+
+ font.SetWeight(event.IsChecked() ? wxFONTWEIGHT_LIGHT : 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::OnSlant(wxCommandEvent& event)
+{
+ wxFont font = m_canvas->GetTextFont();
+
+ font.SetStyle(event.IsChecked() ? wxFONTSTYLE_SLANT : wxFONTSTYLE_NORMAL);
+ DoChangeFont(font);
+}
+
+void MyFrame::OnUnderline(wxCommandEvent& event)
+{
+ wxFont font = m_canvas->GetTextFont();
+
+ font.SetUnderlined(event.IsChecked());
+ DoChangeFont(font);
+}
+
+void MyFrame::OnStrikethrough(wxCommandEvent& event)
+{
+ wxFont font = m_canvas->GetTextFont();
+ font.SetStrikethrough(event.IsChecked());
+ DoChangeFont(font);
+}
+
+void MyFrame::OnwxPointerFont(wxCommandEvent& event)
+{
+ wxFont font;
+
+ switch ( event.GetId() )
+ {
+ case Font_wxNORMAL_FONT:
+ font = *wxNORMAL_FONT;
+ break;
+
+ case Font_wxSMALL_FONT:
+ font = *wxSMALL_FONT;
+ break;
+
+ case Font_wxITALIC_FONT:
+ font = *wxITALIC_FONT;
+ break;
+
+ case Font_wxSWISS_FONT:
+ font = *wxSWISS_FONT;
+ break;
+
+ default:
+ wxFAIL_MSG( wxT("unknown standard font") );
+ return;
+ }
+
+ DoChangeFont(font);
+}
+
+void MyFrame::OnwxSystemSettingsFont(wxCommandEvent& event)
+{
+ wxFont font;
+
+ switch ( event.GetId() )
+ {
+ case Font_wxSYS_OEM_FIXED_FONT:
+ font = wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT);
+ break;
+
+ case Font_wxSYS_ANSI_FIXED_FONT:
+ font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
+ break;
+
+ case Font_wxSYS_ANSI_VAR_FONT:
+ font = wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT);
+ break;
+
+ case Font_wxSYS_SYSTEM_FONT:
+ font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
+ break;
+
+ case Font_wxSYS_DEVICE_DEFAULT_FONT:
+ font = wxSystemSettings::GetFont(wxSYS_DEVICE_DEFAULT_FONT);
+ break;
+
+ case Font_wxSYS_DEFAULT_GUI_FONT:
+ font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+ break;
+
+ default:
+ wxFAIL_MSG( wxT("unknown standard font") );
+ return;
+ }
+
+ DoChangeFont(font);
+}
+
+void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col)
+{
+ m_canvas->SetTextFont(font);
+ if ( col.IsOk() )
+ m_canvas->SetColour(col);
+ m_canvas->Refresh();
+
+ m_textctrl->SetFont(font);
+ if ( col.IsOk() )
+ m_textctrl->SetForegroundColour(col);
+ m_textctrl->Refresh();
+
+ // update the state of the bold/italic/underlined menu items
+ wxMenuBar *mbar = GetMenuBar();
+ if ( mbar )
+ {
+ mbar->Check(Font_Light, font.GetWeight() == wxFONTWEIGHT_LIGHT);
+ mbar->Check(Font_Bold, font.GetWeight() == wxFONTWEIGHT_BOLD);
+
+ mbar->Check(Font_Italic, font.GetStyle() == wxFONTSTYLE_ITALIC);
+#ifndef __WXMSW__
+ mbar->Check(Font_Slant, font.GetStyle() == wxFONTSTYLE_SLANT);
+#endif
+
+ mbar->Check(Font_Underlined, font.GetUnderlined());
+ mbar->Check(Font_Strikethrough, font.GetStrikethrough());