Don't use deprecated wxBOLD, wxNORMAL and similar constants.

Replace them with wxFONTWEIGHT_BOLD, wxFONTSTYLE_NORMAL or wxFONTWEIGHT_NORMAL
and equivalents in the code of the library itself and in the samples.

Also simplify font construction using wxFontInfo where possible to avoid
specifying these constants at all if they are not needed.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75590 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-01-11 14:25:30 +00:00
parent 7696081c90
commit d66e7af9aa
21 changed files with 192 additions and 198 deletions

View File

@@ -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());