void MyFrame::DoResizeFont(int diff) { wxFont font = m_canvas->GetTextFont(); font.SetPointSize(font.GetPointSize() + diff); 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 = *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::OnSlant(wxCommandEvent& event) { wxFont font = m_canvas->GetTextFont(); font.SetStyle(event.IsChecked() ? wxFONTSTYLE_SLANT : wxFONTSTYLE_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::OnSetFamily(wxCommandEvent& WXUNUSED(event)) { wxFontFamily f = GetFamilyFromUser(); wxFont font = m_canvas->GetTextFont(); font.SetFamily(f); DoChangeFont(font); }
void MyFrame::OnSetEncoding(wxCommandEvent& WXUNUSED(event)) { wxFontEncoding enc = GetEncodingFromUser(); if ( enc == wxFONTENCODING_SYSTEM ) return; wxFont font = m_canvas->GetTextFont(); font.SetEncoding(enc); DoChangeFont(font); }
void MyFrame::OnSelectFont(wxCommandEvent& WXUNUSED(event)) { wxFontData data; data.SetInitialFont(m_canvas->GetTextFont()); data.SetColour(m_canvas->GetColour()); wxFontDialog dialog(this, data); if ( dialog.ShowModal() == wxID_OK ) { wxFontData retData = dialog.GetFontData(); wxFont font = retData.GetChosenFont(); wxColour colour = retData.GetColour(); DoChangeFont(font, colour); } }
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.IsOk(), wxT("The font should now be valid")); DoChangeFont(font); } else { wxASSERT_MSG(!font.IsOk(), wxT("The font should now be invalid")); wxMessageBox(wxT("Error trying to create a font with such description...")); } }
bool _HYChartWindow::_ProcessMenuSelection (long msel) { switch (msel) { case HY_CHART_WIN32_MENU_BASE: { // chart menu HandleChartOptions (); return true; } case HY_WINDOW_MENU_ID_FILE+1: // save menu case HY_WINDOW_MENU_ID_FILE+3: // save menu case HY_WINDOW_MENU_ID_FILE+4: { // save menu DoSave ((msel==HY_WINDOW_MENU_ID_FILE-1)?0:msel-HY_WINDOW_MENU_ID_FILE-2); return true; } case HY_WINDOW_MENU_ID_FILE+2: // print menu case HY_WINDOW_MENU_ID_FILE+5: { // print menu DoPrint ((msel==HY_WINDOW_MENU_ID_FILE+2)?0:-1); return true; } case HY_CHART_WIN32_MENU_BASE+1: // font menu case HY_CHART_WIN32_MENU_BASE+2: // font menu case HY_CHART_WIN32_MENU_BASE+3: { // font menu DoChangeFont (msel-HY_CHART_WIN32_MENU_BASE-1); return true; } case HY_CHART_WIN32_MENU_BASE+4: { // chart name RenameChartWindow (); return true; } default: { // proc menu if (msel>=HY_CHART_WIN32_MENU_BASE+5) { ExecuteProcessor (msel-HY_CHART_WIN32_MENU_BASE-5); return true; } } } return _HYTWindow::_ProcessMenuSelection(msel); }
void MyFrame::OnSetNativeDesc(wxCommandEvent& WXUNUSED(event)) { wxString fontInfo = wxGetTextFromUser ( wxT("Enter native font string"), wxT("Input font description"), m_canvas->GetTextFont().GetNativeFontInfoDesc(), this ); if ( fontInfo.empty() ) return; // user clicked "Cancel" - do nothing wxFont font; font.SetNativeFontInfo(fontInfo); if ( !font.IsOk() ) { wxLogError(wxT("Font info string \"%s\" is invalid."), fontInfo.c_str()); return; } DoChangeFont(font); }
void MyFrame::OnSetFaceName(wxCommandEvent& WXUNUSED(event)) { wxString facename = GetCanvas()->GetTextFont().GetFaceName(); wxString newFaceName = wxGetTextFromUser( wxT("Here you can edit current font face name."), wxT("Input font facename"), facename, this); if (newFaceName.IsEmpty()) return; // user clicked "Cancel" - do nothing wxFont font(GetCanvas()->GetTextFont()); if (font.SetFaceName(newFaceName)) // change facename only { wxASSERT_MSG(font.IsOk(), wxT("The font should now be valid")); DoChangeFont(font); } else { wxASSERT_MSG(!font.IsOk(), wxT("The font should now be invalid")); wxMessageBox(wxT("There is no font with such face name..."), wxT("Invalid face name"), wxOK|wxICON_ERROR, this); } }
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::OnViewMsg(wxCommandEvent& WXUNUSED(event)) { #if wxUSE_FILEDLG // first, choose the file static wxString s_dir, s_file; wxFileDialog dialog(this, wxT("Open an email message file"), s_dir, s_file); if ( dialog.ShowModal() != wxID_OK ) return; // save for the next time s_dir = dialog.GetDirectory(); s_file = dialog.GetFilename(); wxString filename = dialog.GetPath(); // load it and search for Content-Type header wxTextFile file(filename); if ( !file.Open() ) return; wxString charset; static const wxChar *prefix = wxT("Content-Type: text/plain; charset="); const size_t len = wxStrlen(prefix); size_t n, count = file.GetLineCount(); for ( n = 0; n < count; n++ ) { wxString line = file[n]; if ( !line ) { // if it is an email message, headers are over, no need to parse // all the file break; } if ( line.Left(len) == prefix ) { // found! const wxChar *pc = line.c_str() + len; if ( *pc == wxT('"') ) pc++; while ( *pc && *pc != wxT('"') ) { charset += *pc++; } break; } } if ( !charset ) { wxLogError(wxT("The file '%s' doesn't contain charset information."), filename.c_str()); return; } // ok, now get the corresponding encoding wxFontEncoding fontenc = wxFontMapper::Get()->CharsetToEncoding(charset); if ( fontenc == wxFONTENCODING_SYSTEM ) { wxLogError(wxT("Charset '%s' is unsupported."), charset.c_str()); return; } m_textctrl->LoadFile(filename); if ( fontenc == wxFONTENCODING_UTF8 || !wxFontMapper::Get()->IsEncodingAvailable(fontenc) ) { // try to find some similar encoding: wxFontEncoding encAlt; if ( wxFontMapper::Get()->GetAltForEncoding(fontenc, &encAlt) ) { wxEncodingConverter conv; if (conv.Init(fontenc, encAlt)) { fontenc = encAlt; m_textctrl -> SetValue(conv.Convert(m_textctrl -> GetValue())); } else { wxLogWarning(wxT("Cannot convert from '%s' to '%s'."), wxFontMapper::GetEncodingDescription(fontenc).c_str(), wxFontMapper::GetEncodingDescription(encAlt).c_str()); } } else wxLogWarning(wxT("No fonts for encoding '%s' on this system."), wxFontMapper::GetEncodingDescription(fontenc).c_str()); } // and now create the correct font if ( !DoEnumerateFamilies(false, fontenc, true /* silent */) ) { wxFont font(wxFontInfo(wxNORMAL_FONT->GetPointSize()).Encoding(fontenc)); if ( font.IsOk() ) { DoChangeFont(font); } else { wxLogWarning(wxT("No fonts for encoding '%s' on this system."), wxFontMapper::GetEncodingDescription(fontenc).c_str()); } } #endif // wxUSE_FILEDLG }
void MyFrame::OnFontDefault(wxCommandEvent& WXUNUSED(event)) { DoChangeFont(wxFont(wxFontInfo())); }
void MyFrame::OnStrikethrough(wxCommandEvent& event) { wxFont font = m_canvas->GetTextFont(); font.SetStrikethrough(event.IsChecked()); DoChangeFont(font); }
bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly, wxFontEncoding encoding, bool silent) { MyFontEnumerator fontEnumerator; fontEnumerator.EnumerateFacenames(encoding, fixedWidthOnly); if ( fontEnumerator.GotAny() ) { int nFacenames = fontEnumerator.GetFacenames().GetCount(); if ( !silent ) { wxLogStatus(this, wxT("Found %d %sfonts"), nFacenames, fixedWidthOnly ? wxT("fixed width ") : wxT("")); } wxString facename; if ( silent ) { // choose the first facename = fontEnumerator.GetFacenames().Item(0); } else { // let the user choose wxString *facenames = new wxString[nFacenames]; int n; for ( n = 0; n < nFacenames; n++ ) facenames[n] = fontEnumerator.GetFacenames().Item(n); n = wxGetSingleChoiceIndex ( wxT("Choose a facename"), SAMPLE_TITLE, nFacenames, facenames, this ); if ( n != -1 ) facename = facenames[n]; delete [] facenames; } if ( !facename.empty() ) { wxFont font(wxFontInfo().FaceName(facename).Encoding(encoding)); DoChangeFont(font); } return true; } else if ( !silent ) { wxLogWarning(wxT("No such fonts found.")); } return false; }