diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 7068b1ab12..aaf018626c 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -1084,7 +1084,7 @@ void DnDFrame::OnPaint(wxPaintEvent& WXUNUSED(event)) GetClientSize( &w, &h ); wxPaintDC dc(this); - dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL, false, wxT("charter") ) ); + dc.SetFont( wxFontInfo(24).Family(wxFONTFAMILY_DECORATIVE).FaceName("charter") ); dc.DrawText( wxT("Drag text from here!"), 100, h-50 ); } diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 2d3c6c7316..8ce1eeec2f 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -774,7 +774,7 @@ void MyCanvas::DrawDefault(wxDC& dc) void MyCanvas::DrawText(wxDC& dc) { // set underlined font for testing - dc.SetFont( wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, true) ); + dc.SetFont( wxFontInfo(12).Family(wxFONTFAMILY_MODERN).Underlined() ); dc.DrawText( wxT("This is text"), 110, 10 ); dc.DrawRotatedText( wxT("That is text"), 20, 10, -45 ); @@ -791,7 +791,7 @@ void MyCanvas::DrawText(wxDC& dc) dc.DrawRotatedText(text , 400, 400, n); } - dc.SetFont( wxFont( 18, wxSWISS, wxNORMAL, wxNORMAL ) ); + dc.SetFont( wxFontInfo(18).Family(wxFONTFAMILY_SWISS) ); dc.DrawText( wxT("This is Swiss 18pt text."), 110, 40 ); @@ -1232,7 +1232,7 @@ void MyCanvas::DrawSplines(wxDC& dc) letters[m][n].y = center.y + h[ letters[m][n].y ]; } - dc.SetPen( wxPen( *wxBLUE, 1, wxDOT) ); + dc.SetPen( wxPen( *wxBLUE, 1, wxPENSTYLE_DOT) ); dc.DrawLines(5, letters[m]); dc.SetPen( wxPen( *wxBLACK, 4) ); dc.DrawSpline(5, letters[m]); diff --git a/samples/image/canvas.cpp b/samples/image/canvas.cpp index cf8433caaf..b3fa2caf75 100644 --- a/samples/image/canvas.cpp +++ b/samples/image/canvas.cpp @@ -666,7 +666,7 @@ void MyCanvas::CreateAntiAliasedBitmap() dc.Clear(); - dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL) ); + dc.SetFont( wxFontInfo(24).Family(wxFONTFAMILY_DECORATIVE) ); dc.SetTextForeground( wxT("RED") ); dc.DrawText( wxT("This is anti-aliased Text."), 20, 5 ); dc.DrawText( wxT("And a Rectangle."), 20, 45 ); diff --git a/samples/ownerdrw/ownerdrw.cpp b/samples/ownerdrw/ownerdrw.cpp index a9dd840fd3..bbecdcce2e 100644 --- a/samples/ownerdrw/ownerdrw.cpp +++ b/samples/ownerdrw/ownerdrw.cpp @@ -110,11 +110,11 @@ void OwnerDrawnFrame::InitMenu() wxMenu *sub_menu = new wxMenu; // vars used for menu construction - wxFont fontLarge(18, wxROMAN, wxNORMAL, wxBOLD, false), - fontUlined(12, wxDEFAULT, wxNORMAL, wxNORMAL, true), - fontItalic(12, wxMODERN, wxITALIC, wxBOLD, false), + wxFont fontLarge(wxFontInfo(18).Family(wxFONTFAMILY_ROMAN).Bold()), + fontUlined(wxFontInfo(12).Underlined()), + fontItalic(wxFontInfo(12).Italic().Bold()), // should be at least of the size of bitmaps - fontBmp(14, wxDEFAULT, wxNORMAL, wxNORMAL, false); + fontBmp(wxFontInfo(14)); // sorry for my artistic skills... wxBitmap bmpBell(wxT("bell")), diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index 9a40b10078..327cd72642 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -698,9 +698,8 @@ void MyPrintout::DrawPageTwo() wxT("testing "), wxT("string. "), wxT("Enjoy "), wxT("it!") }; wxCoord w, h; long x = 200, y= 250; - wxFont fnt(15, wxSWISS, wxNORMAL, wxNORMAL); - dc->SetFont(fnt); + dc->SetFont(wxFontInfo(15).Family(wxFONTFAMILY_SWISS)); for (int i = 0; i < 7; i++) { @@ -746,15 +745,6 @@ void MyPrintout::DrawPageTwo() // Writes a header on a page. Margin units are in millimetres. bool MyPrintout::WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString&text, float mmToLogical) { -#if 0 - static wxFont *headerFont = (wxFont *) NULL; - if (!headerFont) - { - headerFont = wxTheFontList->FindOrCreateFont(16, wxSWISS, wxNORMAL, wxBOLD); - } - dc->SetFont(headerFont); -#endif - int pageWidthMM, pageHeightMM; printout->GetPageSizeMM(&pageWidthMM, &pageHeightMM); diff --git a/samples/propgrid/sampleprops.cpp b/samples/propgrid/sampleprops.cpp index 20778a9673..cc7e8eae06 100644 --- a/samples/propgrid/sampleprops.cpp +++ b/samples/propgrid/sampleprops.cpp @@ -113,7 +113,7 @@ void wxFontDataProperty::OnSetValue() wxFont font = fontData.GetChosenFont(); if ( !font.IsOk() ) - font = wxFont(10,wxSWISS,wxNORMAL,wxNORMAL); + font = wxFontInfo(10).Family(wxFONTFAMILY_SWISS); m_value = WXVARIANT(font); } diff --git a/samples/richtext/richtext.cpp b/samples/richtext/richtext.cpp index 3609e3c3fc..d4a07d266b 100644 --- a/samples/richtext/richtext.cpp +++ b/samples/richtext/richtext.cpp @@ -594,8 +594,8 @@ void MyApp::CreateStyles() { // Paragraph styles - wxFont romanFont(12, wxROMAN, wxNORMAL, wxNORMAL); - wxFont swissFont(12, wxSWISS, wxNORMAL, wxNORMAL); + wxFont romanFont(wxFontInfo(12).Family(wxFONTFAMILY_ROMAN)); + wxFont swissFont(wxFontInfo(12).Family(wxFONTFAMILY_SWISS)); wxRichTextParagraphStyleDefinition* normalPara = new wxRichTextParagraphStyleDefinition(wxT("Normal")); wxRichTextAttr normalAttr; @@ -915,14 +915,14 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE); sizer->Add(splitter, 1, wxEXPAND); - wxFont textFont = wxFont(12, wxROMAN, wxNORMAL, wxNORMAL); - wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD); - wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL); + wxFont textFont = wxFont(wxFontInfo(12).Family(wxFONTFAMILY_ROMAN)); + wxFont boldFont = wxFont(wxFontInfo(12).Family(wxFONTFAMILY_ROMAN)); + wxFont italicFont = wxFont(wxFontInfo(12).Family(wxFONTFAMILY_ROMAN).Italic()); m_richTextCtrl = new MyRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxHSCROLL/*|wxWANTS_CHARS*/); wxASSERT(!m_richTextCtrl->GetBuffer().GetAttributes().HasFontPixelSize()); - wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL); + wxFont font(wxFontInfo(12).Family(wxFONTFAMILY_ROMAN)); m_richTextCtrl->SetFont(font); diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index d3b4349f08..b852e698ea 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -145,7 +145,7 @@ Edit::Edit (wxWindow *parent, wxWindowID id, SetReadOnly (g_CommonPrefs.readOnlyInitial); SetWrapMode (g_CommonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); - wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL); + wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN)); StyleSetFont (wxSTC_STYLE_DEFAULT, font); StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK); StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE); @@ -529,7 +529,7 @@ bool Edit::InitializePrefs (const wxString &name) { // default fonts for all styles! int Nr; for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) { - wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL); + wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN)); StyleSetFont (Nr, font); } @@ -543,8 +543,9 @@ bool Edit::InitializePrefs (const wxString &name) { for (Nr = 0; Nr < STYLE_TYPES_COUNT; Nr++) { if (curInfo->styles[Nr].type == -1) continue; const StyleInfo &curType = g_StylePrefs [curInfo->styles[Nr].type]; - wxFont font (curType.fontsize, wxMODERN, wxNORMAL, wxNORMAL, false, - curType.fontname); + wxFont font(wxFontInfo(curType.fontsize) + .Family(wxFONTFAMILY_MODERN) + .FaceName(curType.fontname)); StyleSetFont (Nr, font); if (curType.foreground) { StyleSetForeground (Nr, wxColour (curType.foreground)); diff --git a/samples/stc/stctest.cpp b/samples/stc/stctest.cpp index b42bda52d8..18ba366ecb 100644 --- a/samples/stc/stctest.cpp +++ b/samples/stc/stctest.cpp @@ -648,7 +648,7 @@ AppAbout::AppAbout (wxWindow *parent, wxBoxSizer *totalpane = new wxBoxSizer (wxVERTICAL); totalpane->Add (0, 20); wxStaticText *appname = new wxStaticText(this, wxID_ANY, *g_appname); - appname->SetFont (wxFont (24, wxDEFAULT, wxNORMAL, wxBOLD)); + appname->SetFont (wxFontInfo(24).Bold()); totalpane->Add (appname, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 40); totalpane->Add (0, 10); totalpane->Add (aboutpane, 0, wxEXPAND | wxALL, 4); diff --git a/samples/svg/svgtest.cpp b/samples/svg/svgtest.cpp index c19be16039..7caa9473f7 100644 --- a/samples/svg/svgtest.cpp +++ b/samples/svg/svgtest.cpp @@ -336,7 +336,6 @@ void MyCanvas::OnDraw(wxDC& dc) wxBrush wB; wxPoint points[6]; wxColour wC; - wxFont wF; dc.SetFont(*wxSWISS_FONT); dc.SetPen(*wxGREEN_PEN); @@ -399,8 +398,10 @@ void MyCanvas::OnDraw(wxDC& dc) dc.DrawText(wxT("This is a Red string"), 50, 200); dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45); dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90); - wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman")); - dc.SetFont(wF); + dc.SetFont(wxFontInfo(18) + .FaceName("Times New Roman") + .Family(wxFONTFAMILY_ROMAN) + .Italic().Bold()); dc.SetTextForeground (wC); dc.DrawText(wxT("This is a Times-style string"), 50, 60); #if wxUSE_STATUSBAR @@ -455,8 +456,10 @@ void MyCanvas::OnDraw(wxDC& dc) break; case 5: - wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman")); - dc.SetFont(wF); + dc.SetFont(wxFontInfo(18) + .FaceName("Times New Roman") + .Family(wxFONTFAMILY_ROMAN) + .Italic().Bold()); dc.DrawLine(0, 0, 200, 200); dc.DrawLine(200, 0, 0, 200); dc.DrawText(wxT("This is an 18pt string"), 50, 60); diff --git a/samples/text/text.cpp b/samples/text/text.cpp index e0e5ede53b..f7733e57e5 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -1098,23 +1098,23 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) switch ( (wxChar)wxTheApp->argv[1][0] ) { case '2': - m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL, - false, wxT(""), - wxFONTENCODING_ISO8859_2)); + m_horizontal->SetFont(wxFontInfo(18) + .Family(wxFONTFAMILY_SWISS) + .Encoding(wxFONTENCODING_ISO8859_2)); m_horizontal->AppendText(wxT("\256lu\273ou\350k\375 k\371\362 zb\354sile \350e\271tina \253\273")); break; case '1': - m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL, - false, wxT(""), - wxFONTENCODING_CP1251)); + m_horizontal->SetFont(wxFontInfo(18) + .Family(wxFONTFAMILY_SWISS) + .Encoding(wxFONTENCODING_CP1251)); m_horizontal->AppendText(wxT("\317\360\350\342\345\362!")); break; case '8': - m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL, - false, wxT(""), - wxFONTENCODING_CP1251)); + m_horizontal->SetFont(wxFontInfo(18) + .Family(wxFONTFAMILY_SWISS) + .Encoding(wxFONTENCODING_CP1251)); #if wxUSE_UNICODE m_horizontal->AppendText(L"\x0412\x0430\x0434\x0438\x043c \x0426"); #else @@ -1923,12 +1923,12 @@ void RichTextFrame::OnIdle(wxIdleEvent& WXUNUSED(event)) if (attr.HasFont()) { - if (attr.GetFont().GetWeight() == wxBOLD) + if (attr.GetFont().GetWeight() == wxFONTWEIGHT_BOLD) msg += wxT(" BOLD"); - else if (attr.GetFont().GetWeight() == wxNORMAL) + else if (attr.GetFont().GetWeight() == wxFONTWEIGHT_NORMAL) msg += wxT(" NORMAL"); - if (attr.GetFont().GetStyle() == wxITALIC) + if (attr.GetFont().GetStyle() == wxFONTSTYLE_ITALIC) msg += wxT(" ITALIC"); if (attr.GetFont().GetUnderlined()) diff --git a/samples/xti/classlist.cpp b/samples/xti/classlist.cpp index 7c7a1b58cd..92aeda9fd9 100644 --- a/samples/xti/classlist.cpp +++ b/samples/xti/classlist.cpp @@ -111,7 +111,7 @@ void ClassListDialog::CreateControls() m_pClassCountText = new wxStaticText( this, wxID_STATIC, wxT("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), wxDefaultPosition, wxDefaultSize, 0 ); - m_pClassCountText->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); + m_pClassCountText->SetFont(wxFontInfo(8).Family(wxFONTFAMILY_SWISS).Bold()); itemBoxSizer2->Add(m_pClassCountText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); diff --git a/src/common/fontmgrcmn.cpp b/src/common/fontmgrcmn.cpp index 9dd64f859a..1559d0ad7d 100644 --- a/src/common/fontmgrcmn.cpp +++ b/src/common/fontmgrcmn.cpp @@ -118,13 +118,14 @@ wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const int type = FaceType_Regular; - if ( font.GetWeight() == wxBOLD ) + if ( font.GetWeight() == wxFONTWEIGHT_BOLD ) type |= FaceType_Bold; - // FIXME -- this should read "if ( font->GetStyle() == wxITALIC )", + // FIXME -- this should read "if ( font->GetStyle() == wxFONTSTYLE_ITALIC )", // but since DFB doesn't support slant, we try to display it with italic // face (better than nothing...) - if ( font.GetStyle() == wxITALIC || font.GetStyle() == wxSLANT ) + if ( font.GetStyle() == wxFONTSTYLE_ITALIC + || font.GetStyle() == wxFONTSTYLE_SLANT ) { if ( HasFace((FaceType)(type | FaceType_Italic)) ) type |= FaceType_Italic; diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index b5c493b0f4..143d22de75 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1041,8 +1041,8 @@ void wxPostScriptDCImpl::SetFont( const wxFont& font ) m_font = font; - int Style = m_font.GetStyle(); - int Weight = m_font.GetWeight(); + wxFontStyle Style = m_font.GetStyle(); + wxFontWeight Weight = m_font.GetWeight(); const char *name; switch (m_font.GetFamily()) @@ -1050,16 +1050,16 @@ void wxPostScriptDCImpl::SetFont( const wxFont& font ) case wxTELETYPE: case wxMODERN: { - if (Style == wxITALIC) + if (Style == wxFONTSTYLE_ITALIC) { - if (Weight == wxBOLD) + if (Weight == wxFONTWEIGHT_BOLD) name = "/Courier-BoldOblique"; else name = "/Courier-Oblique"; } else { - if (Weight == wxBOLD) + if (Weight == wxFONTWEIGHT_BOLD) name = "/Courier-Bold"; else name = "/Courier"; @@ -1068,16 +1068,16 @@ void wxPostScriptDCImpl::SetFont( const wxFont& font ) } case wxROMAN: { - if (Style == wxITALIC) + if (Style == wxFONTSTYLE_ITALIC) { - if (Weight == wxBOLD) + if (Weight == wxFONTWEIGHT_BOLD) name = "/Times-BoldItalic"; else name = "/Times-Italic"; } else { - if (Weight == wxBOLD) + if (Weight == wxFONTWEIGHT_BOLD) name = "/Times-Bold"; else name = "/Times-Roman"; @@ -1092,16 +1092,16 @@ void wxPostScriptDCImpl::SetFont( const wxFont& font ) case wxSWISS: default: { - if (Style == wxITALIC) + if (Style == wxFONTSTYLE_ITALIC) { - if (Weight == wxBOLD) + if (Weight == wxFONTWEIGHT_BOLD) name = "/Helvetica-BoldOblique"; else name = "/Helvetica-Oblique"; } else { - if (Weight == wxBOLD) + if (Weight == wxFONTWEIGHT_BOLD) name = "/Helvetica-Bold"; else name = "/Helvetica"; @@ -2092,7 +2092,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, / dc.StartDoc("Test"); / dc.StartPage(); / wxCoord w,h; - / dc.SetFont(new wxFont(10, wxROMAN, wxNORMAL, wxNORMAL)); + / dc.SetFont(new wxFontInfo(10).Family(wxFONTFAMILY_ROMAN)); / dc.GetTextExtent("Hallo",&w,&h); / dc.EndPage(); / dc.EndDoc(); @@ -2135,17 +2135,17 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, case wxMODERN: case wxTELETYPE: { - if ((Style == wxITALIC) && (Weight == wxBOLD)) name = wxT("CourBoO.afm"); - else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = wxT("CourBo.afm"); - else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = wxT("CourO.afm"); + if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("CourBoO.afm"); + else if ((Style != wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("CourBo.afm"); + else if ((Style == wxFONTSTYLE_ITALIC) && (Weight != wxFONTWEIGHT_BOLD)) name = wxT("CourO.afm"); else name = wxT("Cour.afm"); break; } case wxROMAN: { - if ((Style == wxITALIC) && (Weight == wxBOLD)) name = wxT("TimesBoO.afm"); - else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = wxT("TimesBo.afm"); - else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = wxT("TimesO.afm"); + if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("TimesBoO.afm"); + else if ((Style != wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("TimesBo.afm"); + else if ((Style == wxFONTSTYLE_ITALIC) && (Weight != wxFONTWEIGHT_BOLD)) name = wxT("TimesO.afm"); else name = wxT("TimesRo.afm"); break; } @@ -2157,9 +2157,9 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, case wxSWISS: default: { - if ((Style == wxITALIC) && (Weight == wxBOLD)) name = wxT("HelvBoO.afm"); - else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = wxT("HelvBo.afm"); - else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = wxT("HelvO.afm"); + if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("HelvBoO.afm"); + else if ((Style != wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("HelvBo.afm"); + else if ((Style == wxFONTSTYLE_ITALIC) && (Weight != wxFONTWEIGHT_BOLD)) name = wxT("HelvO.afm"); else name = wxT("Helv.afm"); break; } diff --git a/src/generic/fontdlgg.cpp b/src/generic/fontdlgg.cpp index 58a7835c96..d7b2aed416 100644 --- a/src/generic/fontdlgg.cpp +++ b/src/generic/fontdlgg.cpp @@ -94,11 +94,11 @@ static const wxChar *wxFontWeightIntToString(int weight) { switch (weight) { - case wxLIGHT: + case wxFONTWEIGHT_LIGHT: return wxT("Light"); - case wxBOLD: + case wxFONTWEIGHT_BOLD: return wxT("Bold"); - case wxNORMAL: + case wxFONTWEIGHT_NORMAL: default: return wxT("Normal"); } @@ -108,11 +108,11 @@ static const wxChar *wxFontStyleIntToString(int style) { switch (style) { - case wxITALIC: + case wxFONTSTYLE_ITALIC: return wxT("Italic"); - case wxSLANT: + case wxFONTSTYLE_SLANT: return wxT("Slant"); - case wxNORMAL: + case wxFONTSTYLE_NORMAL: default: return wxT("Normal"); } @@ -122,62 +122,62 @@ static const wxChar *wxFontFamilyIntToString(int family) { switch (family) { - case wxROMAN: + case wxFONTFAMILY_ROMAN: return wxT("Roman"); - case wxDECORATIVE: + case wxFONTFAMILY_DECORATIVE: return wxT("Decorative"); - case wxMODERN: + case wxFONTFAMILY_MODERN: return wxT("Modern"); - case wxSCRIPT: + case wxFONTFAMILY_SCRIPT: return wxT("Script"); - case wxTELETYPE: + case wxFONTFAMILY_TELETYPE: return wxT("Teletype"); - case wxSWISS: + case wxFONTFAMILY_SWISS: default: return wxT("Swiss"); } } -static int wxFontFamilyStringToInt(const wxString& family) +static wxFontFamily wxFontFamilyStringToInt(const wxString& family) { if (family.empty()) - return wxSWISS; + return wxFONTFAMILY_SWISS; if (wxStrcmp(family, wxT("Roman")) == 0) - return wxROMAN; + return wxFONTFAMILY_ROMAN; else if (wxStrcmp(family, wxT("Decorative")) == 0) - return wxDECORATIVE; + return wxFONTFAMILY_DECORATIVE; else if (wxStrcmp(family, wxT("Modern")) == 0) - return wxMODERN; + return wxFONTFAMILY_MODERN; else if (wxStrcmp(family, wxT("Script")) == 0) - return wxSCRIPT; + return wxFONTFAMILY_SCRIPT; else if (wxStrcmp(family, wxT("Teletype")) == 0) - return wxTELETYPE; - else return wxSWISS; + return wxFONTFAMILY_TELETYPE; + else return wxFONTFAMILY_SWISS; } -static int wxFontStyleStringToInt(const wxString& style) +static wxFontStyle wxFontStyleStringToInt(const wxString& style) { if (style.empty()) - return wxNORMAL; + return wxFONTSTYLE_NORMAL; if (wxStrcmp(style, wxT("Italic")) == 0) - return wxITALIC; + return wxFONTSTYLE_ITALIC; else if (wxStrcmp(style, wxT("Slant")) == 0) - return wxSLANT; + return wxFONTSTYLE_SLANT; else - return wxNORMAL; + return wxFONTSTYLE_NORMAL; } -static int wxFontWeightStringToInt(const wxString& weight) +static wxFontWeight wxFontWeightStringToInt(const wxString& weight) { if (weight.empty()) - return wxNORMAL; + return wxFONTWEIGHT_NORMAL; if (wxStrcmp(weight, wxT("Bold")) == 0) - return wxBOLD; + return wxFONTWEIGHT_BOLD; else if (wxStrcmp(weight, wxT("Light")) == 0) - return wxLIGHT; + return wxFONTWEIGHT_LIGHT; else - return wxNORMAL; + return wxFONTWEIGHT_NORMAL; } //----------------------------------------------------------------------------- @@ -543,9 +543,9 @@ void wxGenericFontDialog::CreateWidgets() void wxGenericFontDialog::InitializeFont() { - int fontFamily = wxSWISS; - int fontWeight = wxNORMAL; - int fontStyle = wxNORMAL; + wxFontFamily fontFamily = wxFONTFAMILY_SWISS; + wxFontWeight fontWeight = wxFONTWEIGHT_NORMAL; + wxFontStyle fontStyle = wxFONTSTYLE_NORMAL; int fontSize = 12; bool fontUnderline = false; @@ -574,9 +574,9 @@ void wxGenericFontDialog::DoChangeFont() { if (!m_useEvents) return; - int fontFamily = wxFontFamilyStringToInt(m_familyChoice->GetStringSelection()); - int fontWeight = wxFontWeightStringToInt(m_weightChoice->GetStringSelection()); - int fontStyle = wxFontStyleStringToInt(m_styleChoice->GetStringSelection()); + wxFontFamily fontFamily = wxFontFamilyStringToInt(m_familyChoice->GetStringSelection()); + wxFontWeight fontWeight = wxFontWeightStringToInt(m_weightChoice->GetStringSelection()); + wxFontStyle fontStyle = wxFontStyleStringToInt(m_styleChoice->GetStringSelection()); #if USE_SPINCTRL_FOR_POINT_SIZE wxSpinCtrl* fontSizeCtrl = wxDynamicCast(FindWindow(wxID_FONT_SIZE), wxSpinCtrl); int fontSize = fontSizeCtrl->GetValue(); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 14065dd42e..b1cf580d12 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -7254,9 +7254,9 @@ void wxGrid::SetColLabelAlignment( int horiz, int vert ) // Note: under MSW, the default column label font must be changed because it // does not support vertical printing // -// Example: wxFont font(9, wxSWISS, wxNORMAL, wxBOLD); -// pGrid->SetLabelFont(font); -// pGrid->SetColLabelTextOrientation(wxVERTICAL); +// Example: +// pGrid->SetLabelFont(wxFontInfo(9).Family(wxFONTFAMILY_SWISS)); +// pGrid->SetColLabelTextOrientation(wxVERTICAL); // void wxGrid::SetColLabelTextOrientation( int textOrientation ) { diff --git a/src/osx/carbon/fontdlg.cpp b/src/osx/carbon/fontdlg.cpp index b2a4013620..0c54a9e57a 100644 --- a/src/osx/carbon/fontdlg.cpp +++ b/src/osx/carbon/fontdlg.cpp @@ -279,8 +279,8 @@ int wxFontDialog::ShowModal() // wxFontDialog stub for mac OS's without a native font dialog // --------------------------------------------------------------------------- -static const wxChar *FontFamilyIntToString(int family); -static int FontFamilyStringToInt(const wxChar *family); +static const wxChar *FontFamilyIntToString(wxFontFamily family); +static wxFontFamily FontFamilyStringToInt(const wxChar *family); //----------------------------------------------------------------------------- @@ -689,9 +689,9 @@ bool wxFontDialog::ShowToolTips() void wxFontDialog::InitializeFont() { - int fontFamily = wxSWISS; - int fontWeight = wxNORMAL; - int fontStyle = wxNORMAL; + wxFontFamily fontFamily = wxFONTFAMILY_SWISS; + wxFontWeight fontWeight = wxFONTWEIGHT_NORMAL; + wxFontStyle fontStyle = wxFONTSTYLE_NORMAL; int fontSize = 12; bool fontUnderline = false; wxString fontName; @@ -723,8 +723,8 @@ void wxFontDialog::InitializeControls() if (m_underlinedCtrl) m_underlinedCtrl->SetValue(m_dialogFont.GetUnderlined()); - m_boldCtrl->SetValue(m_dialogFont.GetWeight() == wxBOLD); - m_italicCtrl->SetValue(m_dialogFont.GetStyle() == wxITALIC); + m_boldCtrl->SetValue(m_dialogFont.GetWeight() == wxFONTWEIGHT_BOLD); + m_italicCtrl->SetValue(m_dialogFont.GetStyle() == wxFONTSTYLE_ITALIC); m_sizeCtrl->SetValue(m_dialogFont.GetPointSize()); wxString facename = m_dialogFont.GetFaceName(); @@ -755,14 +755,13 @@ void wxFontDialog::ChangeFont() int size = m_sizeCtrl->GetValue(); wxString facename = m_facenameCtrl->GetStringSelection(); - int family = FontFamilyStringToInt(facename); - if (family == -1) - family = wxDEFAULT; - else + wxFontFamily family = FontFamilyStringToInt(facename); + if (family != wxFONTFAMILY_DEFAULT) facename = wxEmptyString; - m_dialogFont = wxFont(size, family, italic ? wxITALIC : wxNORMAL, bold ? wxBOLD : wxNORMAL, - underlined, facename); + m_dialogFont = wxFontInfo(size) + .Family(family).FaceName(facename) + .Italic(italic).Bold(bold).Underlined(underlined); m_fontData.SetChosenFont(m_dialogFont); @@ -789,44 +788,44 @@ void wxFontDialog::OnPanelClose() { } -const wxChar *FontFamilyIntToString(int family) +const wxChar *FontFamilyIntToString(wxFontFamily family) { switch (family) { - case wxROMAN: + case wxFONTFAMILY_ROMAN: return _(""); - case wxDECORATIVE: + case wxFONTFAMILY_DECORATIVE: return _(""); - case wxMODERN: + case wxFONTFAMILY_MODERN: return _(""); - case wxSCRIPT: + case wxFONTFAMILY_SCRIPT: return _(""); - case wxTELETYPE: + case wxFONTFAMILY_TELETYPE: return _(""); - case wxSWISS: + case wxFONTFAMILY_SWISS: default: return _(""); } } -int FontFamilyStringToInt(const wxChar *family) +wxFontFamily FontFamilyStringToInt(const wxChar *family) { if (!family) - return wxSWISS; + return wxFONTFAMILY_SWISS; if (wxStrcmp(family, _("")) == 0) - return wxROMAN; + return wxFONTFAMILY_ROMAN; else if (wxStrcmp(family, _("")) == 0) - return wxDECORATIVE; + return wxFONTFAMILY_DECORATIVE; else if (wxStrcmp(family, _("")) == 0) - return wxMODERN; + return wxFONTFAMILY_MODERN; else if (wxStrcmp(family, _("")) == 0) - return wxSCRIPT; + return wxFONTFAMILY_SCRIPT; else if (wxStrcmp(family, _("")) == 0) - return wxTELETYPE; + return wxFONTFAMILY_TELETYPE; else if (wxStrcmp(family, _("")) == 0) - return wxSWISS; - else return -1; + return wxFONTFAMILY_SWISS; + else return wxFONTFAMILY_DEFAULT; } #endif // !USE_NATIVE_FONT_DIALOG_FOR_MACOSX diff --git a/src/osx/carbon/fontdlgosx.mm b/src/osx/carbon/fontdlgosx.mm index 2129527f3e..53df02df32 100644 --- a/src/osx/carbon/fontdlgosx.mm +++ b/src/osx/carbon/fontdlgosx.mm @@ -402,8 +402,8 @@ bool wxFontDialog::Create(wxWindow *parent) [[NSFontManager sharedFontManager] fontWithFamily: wxNSStringWithWxString(thewxfont.GetFaceName()) traits:theMask - weight:thewxfont.GetWeight() == wxBOLD ? 9 : - thewxfont.GetWeight() == wxLIGHT ? 0 : 5 + weight:thewxfont.GetWeight() == wxFONTWEIGHT_BOLD ? 9 : + thewxfont.GetWeight() == wxFONTWEIGHT_LIGHT ? 0 : 5 size: (float)(thewxfont.GetPointSize()) ]; @@ -530,8 +530,8 @@ int wxFontDialog::ShowModal() m_fontData.m_chosenFont.SetFaceName(wxStringWithNSString([theFont familyName])); m_fontData.m_chosenFont.SetPointSize(theFontSize); m_fontData.m_chosenFont.SetStyle(theTraits & NSItalicFontMask ? wxFONTSTYLE_ITALIC : 0); - m_fontData.m_chosenFont.SetWeight(theFontWeight < 5 ? wxLIGHT : - theFontWeight >= 9 ? wxBOLD : wxNORMAL); + m_fontData.m_chosenFont.SetWeight(theFontWeight < 5 ? wxFONTWEIGHT_LIGHT : + theFontWeight >= 9 ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); //Get the shared color panel along with the chosen color and set the chosen color NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 19295211fb..7adc3127c7 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -583,9 +583,9 @@ static const wxChar* const gs_fp_es_style_labels[] = { }; static const long gs_fp_es_style_values[] = { - wxNORMAL, - wxSLANT, - wxITALIC + wxFONTSTYLE_NORMAL, + wxFONTSTYLE_SLANT, + wxFONTSTYLE_ITALIC }; static const wxChar* const gs_fp_es_weight_labels[] = { @@ -596,9 +596,9 @@ static const wxChar* const gs_fp_es_weight_labels[] = { }; static const long gs_fp_es_weight_values[] = { - wxNORMAL, - wxLIGHT, - wxBOLD + wxFONTWEIGHT_NORMAL, + wxFONTWEIGHT_LIGHT, + wxFONTWEIGHT_BOLD }; // Class body is in advprops.h @@ -806,9 +806,7 @@ void wxFontProperty::OnCustomPaint(wxDC& dc, dc.DrawRectangle( rect ); wxFont oldFont = dc.GetFont(); - wxFont drawFont(oldFont.GetPointSize(), - wxDEFAULT,wxNORMAL,wxBOLD,false,drawFace); - dc.SetFont(drawFont); + dc.SetFont(wxFontInfo(oldFont.GetPointSize().Bold().FaceName(drawFace)); dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT) ); dc.DrawText( wxT("Aa"), rect.x+2, rect.y+1 ); diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 6b5e34d486..d0f0ac8a8a 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -355,8 +355,8 @@ void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) { #endif int size = font.GetPointSize(); wxString faceName = font.GetFaceName(); - bool bold = font.GetWeight() == wxBOLD; - bool italic = font.GetStyle() != wxNORMAL; + bool bold = font.GetWeight() == wxFONTWEIGHT_BOLD; + bool italic = font.GetStyle() != wxFONTSTYLE_NORMAL; bool under = font.GetUnderlined(); wxFontEncoding encoding = font.GetEncoding(); diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 4eecb5009a..e61dbae125 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -517,9 +517,9 @@ static wxHashTable *g_fontHash = NULL; static bool wxTestFontSpec(const wxString& fontspec); static wxNativeFont wxLoadQueryFont(int pointSize, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool underlined, const wxString& facename, const wxString& xregistry, @@ -1000,9 +1000,9 @@ bool wxTestFontEncoding(const wxNativeEncodingInfo& info) // ---------------------------------------------------------------------------- wxNativeFont wxLoadQueryNearestFont(int pointSize, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool underlined, const wxString &facename, wxFontEncoding encoding, @@ -1087,9 +1087,9 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, // second round: use normal weight if ( round == 1 ) { - if ( testweight != wxNORMAL ) + if ( testweight != wxFONTWEIGHT_NORMAL ) { - testweight = wxNORMAL; + testweight = wxFONTWEIGHT_NORMAL; } else { @@ -1100,9 +1100,9 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, // third round: ... and use normal style if ( round == 2 ) { - if ( teststyle != wxNORMAL ) + if ( teststyle != wxFONTSTYLE_NORMAL ) { - teststyle = wxNORMAL; + teststyle = wxFONTSTYLE_NORMAL; } else { @@ -1127,9 +1127,9 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, } // Try default family - if ( !font && family != wxDEFAULT ) + if ( !font && family != wxFONTFAMILY_DEFAULT ) { - font = wxLoadQueryFont(pointSize, wxDEFAULT, style, weight, + font = wxLoadQueryFont(pointSize, wxFONTFAMILY_DEFAULT, style, weight, underlined, facename, info.xregistry, info.xencoding, xFontName ); @@ -1139,7 +1139,8 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, // given facename and encoding if ( !font ) { - font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, + font = wxLoadQueryFont(120, wxFONTFAMILY_DEFAULT, + wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, underlined, facename, info.xregistry, info.xencoding, xFontName); @@ -1147,7 +1148,8 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, // ignore family as well if ( !font ) { - font = wxLoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, + font = wxLoadQueryFont(120, wxFONTFAMILY_DEFAULT, + wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, underlined, wxEmptyString, info.xregistry, info.xencoding, xFontName); @@ -1158,7 +1160,8 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, // different from 120 if ( !font ) { - font = wxLoadQueryFont(-1, wxDEFAULT, wxNORMAL, wxNORMAL, + font = wxLoadQueryFont(-1, wxFONTFAMILY_DEFAULT, + wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString, info.xregistry, info.xencoding, xFontName); @@ -1170,8 +1173,8 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, { wxFAIL_MSG( wxT("this encoding should be available!") ); - font = wxLoadQueryFont(-1, - wxDEFAULT, wxNORMAL, wxNORMAL, + font = wxLoadQueryFont(-1, wxFONTFAMILY_DEFAULT, + wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString, wxT("*"), wxT("*"), xFontName); @@ -1220,41 +1223,40 @@ static bool wxTestFontSpec(const wxString& fontspec) } static wxNativeFont wxLoadQueryFont(int pointSize, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool WXUNUSED(underlined), const wxString& facename, const wxString& xregistry, const wxString& xencoding, wxString* xFontName) { - wxString xfamily; + wxString xfamily("*"); switch (family) { - case wxDECORATIVE: xfamily = wxT("lucida"); break; - case wxROMAN: xfamily = wxT("times"); break; - case wxMODERN: xfamily = wxT("courier"); break; - case wxSWISS: xfamily = wxT("helvetica"); break; - case wxTELETYPE: xfamily = wxT("lucidatypewriter"); break; - case wxSCRIPT: xfamily = wxT("utopia"); break; - default: xfamily = wxT("*"); + case wxFONTFAMILY_DECORATIVE: xfamily = wxT("lucida"); break; + case wxFONTFAMILY_ROMAN: xfamily = wxT("times"); break; + case wxFONTFAMILY_MODERN: xfamily = wxT("courier"); break; + case wxFONTFAMILY_SWISS: xfamily = wxT("helvetica"); break; + case wxFONTFAMILY_TELETYPE: xfamily = wxT("lucidatypewriter"); break; + case wxFONTFAMILY_SCRIPT: xfamily = wxT("utopia"); break; } #if wxUSE_NANOX int xweight; switch (weight) { - case wxBOLD: + case wxFONTWEIGHT_BOLD: { xweight = MWLF_WEIGHT_BOLD; break; } - case wxLIGHT: + case wxFONTWEIGHT_LIGHT: { xweight = MWLF_WEIGHT_LIGHT; break; } - case wxNORMAL: + case wxFONTWEIGHT_NORMAL: { xweight = MWLF_WEIGHT_NORMAL; break; @@ -1289,7 +1291,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize, logFont.lfEscapement = 0; logFont.lfOrientation = 0; logFont.lfWeight = xweight; - logFont.lfItalic = (style == wxNORMAL ? 0 : 1) ; + logFont.lfItalic = (style == wxFONTSTYLE_ITALIC ? 0 : 1) ; logFont.lfUnderline = 0; logFont.lfStrikeOut = 0; logFont.lfCharSet = MWLF_CHARSET_DEFAULT; // TODO: select appropriate one @@ -1327,7 +1329,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize, wxString xstyle; switch (style) { - case wxSLANT: + case wxFONTSTYLE_SLANT: fontSpec.Printf(wxT("-*-%s-*-o-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) @@ -1335,18 +1337,18 @@ static wxNativeFont wxLoadQueryFont(int pointSize, xstyle = wxT("o"); break; } - // fall through - try wxITALIC now + // fall through - try wxFONTSTYLE_ITALIC now - case wxITALIC: + case wxFONTSTYLE_ITALIC: fontSpec.Printf(wxT("-*-%s-*-i-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xstyle = wxT("i"); } - else if ( style == wxITALIC ) // and not wxSLANT + else if ( style == wxFONTSTYLE_ITALIC ) // and not wxFONTSTYLE_SLANT { - // try wxSLANT + // try wxFONTSTYLE_SLANT fontSpec.Printf(wxT("-*-%s-*-o-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) @@ -1365,7 +1367,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize, wxFAIL_MSG(wxT("unknown font style")); // fall back to normal - case wxNORMAL: + case wxFONTSTYLE_NORMAL: xstyle = wxT("r"); break; } @@ -1373,7 +1375,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize, wxString xweight; switch (weight) { - case wxBOLD: + case wxFONTWEIGHT_BOLD: { fontSpec.Printf(wxT("-*-%s-bold-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); @@ -1419,7 +1421,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize, } } break; - case wxLIGHT: + case wxFONTWEIGHT_LIGHT: { fontSpec.Printf(wxT("-*-%s-light-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); @@ -1437,7 +1439,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize, } } break; - case wxNORMAL: + case wxFONTWEIGHT_NORMAL: { fontSpec.Printf(wxT("-*-%s-medium-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str());