X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a82a59f519b29a3233b0211c155b1254fc116b0a..dd71bfb9921430755a885117cc6c9843c62dafda:/samples/font/font.cpp diff --git a/samples/font/font.cpp b/samples/font/font.cpp index 4fa3fdc85d..cb036de8b7 100644 --- a/samples/font/font.cpp +++ b/samples/font/font.cpp @@ -41,7 +41,7 @@ #endif // used as title for several dialog boxes -static const wxChar SAMPLE_TITLE[] = _T("wxWidgets Font Sample"); +static const wxChar SAMPLE_TITLE[] = wxT("wxWidgets Font Sample"); // ---------------------------------------------------------------------------- // private classes @@ -302,7 +302,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) { m_fontSize = wxNORMAL_FONT->GetPointSize(); - SetIcon(wxIcon(sample_xpm)); + SetIcon(wxICON(sample)); // create a menu bar wxMenu *menuFile = new wxMenu; @@ -324,7 +324,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuFont->AppendCheckItem(Font_Light, wxT("&Light\tCtrl-L"), wxT("Toggle light state")); menuFont->AppendSeparator(); menuFont->AppendCheckItem(Font_Italic, wxT("&Oblique\tCtrl-O"), wxT("Toggle italic state")); +#ifndef __WXMSW__ + // under wxMSW slant == italic so there's no reason to provide another menu item for the same thing menuFont->AppendCheckItem(Font_Slant, wxT("&Slant\tCtrl-S"), wxT("Toggle slant state")); +#endif menuFont->AppendSeparator(); menuFont->AppendCheckItem(Font_Underlined, wxT("&Underlined\tCtrl-U"), wxT("Toggle underlined state")); @@ -820,7 +823,9 @@ void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col) 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()); } @@ -1007,6 +1012,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) // set background dc.SetBackground(wxBrush(wxT("white"), wxSOLID)); dc.Clear(); + dc.SetFont(m_font); // one text line height wxCoord hLine = dc.GetCharHeight(); @@ -1017,19 +1023,27 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) // output the font name/info wxString fontInfo; - fontInfo.Printf(wxT("Font size is %d points, family: %s, encoding: %s"), + + fontInfo.Printf(wxT("Face name: %s, family: %s"), + m_font.GetFaceName().c_str(), + m_font.GetFamilyString().c_str()); + + dc.DrawText(fontInfo, x, y); + y += hLine; + + fontInfo.Printf(wxT("Size: %d points or %d pixels; %d*%d average char size"), m_font.GetPointSize(), - m_font.GetFamilyString().c_str(), - wxFontMapper:: - GetEncodingDescription(m_font.GetEncoding()).c_str()); + m_font.GetPixelSize().y, + dc.GetCharWidth(), dc.GetCharHeight()); dc.DrawText(fontInfo, x, y); y += hLine; - fontInfo.Printf(wxT("Style: %s, weight: %s, fixed width: %s"), + fontInfo.Printf(wxT("Style: %s, weight: %s, fixed width: %s, encoding: %s"), m_font.GetStyleString().c_str(), m_font.GetWeightString().c_str(), - m_font.IsFixedWidth() ? _T("yes") : _T("no")); + m_font.IsFixedWidth() ? wxT("yes") : wxT("no"), + wxFontMapper::GetEncodingDescription(m_font.GetEncoding())); dc.DrawText(fontInfo, x, y); y += hLine; @@ -1050,7 +1064,6 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) y += hLine; // prepare to draw the font - dc.SetFont(m_font); dc.SetTextForeground(m_colour); // the size of one cell (Normally biggest char + small margin) @@ -1079,7 +1092,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) } // draw the lines between them - dc.SetPen(wxPen(wxColour(_T("blue")), 1, wxSOLID)); + dc.SetPen(wxPen(wxColour(wxT("blue")), 1, wxSOLID)); int l; // horizontal