Finish removing QDState

This commit is contained in:
elasota
2020-05-21 05:01:16 -04:00
parent 432cdbcc3a
commit 5869571747
35 changed files with 253 additions and 407 deletions

View File

@@ -14,6 +14,8 @@
#include "FontManager.h"
#include "MainWindow.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "Room.h"
#include "Utilities.h"
@@ -120,16 +122,15 @@ void DrawBannerMessage (Point topLeft)
PasStringCopy((*thisHouse)->banner, bannerStr);
workSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
count = 0;
do
{
GetLineOfText(bannerStr, count, subStr);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 32 + (count * 20)), subStr, true, blackColor);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 32 + (count * 20)), subStr, blackColor, appFont);
count++;
}
while (subStr[0] > 0);
@@ -151,10 +152,10 @@ void DrawBannerMessage (Point topLeft)
PasStringConcat(bannerStr, subStr);
PortabilityLayer::ResolveCachingColor redColor = StdColors::Red();
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 164), bannerStr, true, redColor);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 164), bannerStr, redColor, appFont);
GetLocalizedString(5, subStr);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 180), subStr, true, redColor);
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 180), subStr, redColor, appFont);
}
SetGraphicsPort(wasGWorld);
@@ -226,7 +227,7 @@ void DisplayStarsRemaining(void)
DrawSurface *surface = starsWindow->GetDrawSurface();
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
NumToString((long)numStarsRemaining, theStr);
@@ -235,8 +236,8 @@ void DisplayStarsRemaining(void)
else
{
LoadScaledGraphic(surface, kStarsRemainingPICT, &bounds);
const Point textPoint = Point::Create(bounds.left + 102 - (surface->MeasureString(theStr) / 2), bounds.top + 23);
ColorText(surface, textPoint, theStr, 4L);
const Point textPoint = Point::Create(bounds.left + 102 - (appFont->MeasurePStr(theStr) / 2), bounds.top + 23);
ColorText(surface, textPoint, theStr, 4L, appFont);
}
if (doZooms)

View File

@@ -20,11 +20,11 @@
// this function draws text in that color. It assumes the current port,<2C>
// the current font, the current pen location, etc.
void ColorText (DrawSurface *surface, const Point &point, StringPtr theStr, long color)
void ColorText (DrawSurface *surface, const Point &point, StringPtr theStr, long color, PortabilityLayer::RenderedFont *font)
{
PortabilityLayer::ResolveCachingColor rColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(color);
surface->DrawString(point, theStr, true, rColor);
surface->DrawString(point, theStr, rColor, font);
}
//-------------------------------------------------------------- ColorRect

View File

@@ -71,11 +71,12 @@ void UpdateCoordWindow (void)
if (coordWindow == nil)
return;
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::ResolveCachingColor blueColor = StdColors::Blue();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, 0, true);
DrawSurface *surface = coordWindow->GetDrawSurface();
surface->FillRect(coordWindowRect, whiteColor);
@@ -89,7 +90,7 @@ void UpdateCoordWindow (void)
else
PasStringConcat(tempStr, PSTR("-"));
surface->DrawString(Point::Create(5, 12), tempStr, true, blackColor);
surface->DrawString(Point::Create(5, 12), tempStr, blackColor, appFont);
PasStringCopy(PSTR("v: "), tempStr);
if (coordV != -1)
@@ -100,7 +101,7 @@ void UpdateCoordWindow (void)
else
PasStringConcat(tempStr, PSTR("-"));
surface->DrawString(Point::Create(4, 22), tempStr, true, blackColor);
surface->DrawString(Point::Create(4, 22), tempStr, blackColor, appFont);
PasStringCopy(PSTR("d: "), tempStr);
if (coordD != -1)
@@ -111,7 +112,7 @@ void UpdateCoordWindow (void)
else
PasStringConcat(tempStr, PSTR("-"));
surface->DrawString(Point::Create(5, 32), tempStr, true, blueColor);
surface->DrawString(Point::Create(5, 32), tempStr, blueColor, appFont);
#endif
}
@@ -157,8 +158,6 @@ void OpenCoordWindow (void)
coordV = -1;
coordD = -1;
coordWindow->GetDrawSurface()->SetApplicationFont(9, 0);
if (objActive != kNoObjectSelected)
{
if (ObjectHasHandle(&direction, &dist))

View File

@@ -18,6 +18,8 @@
#include "FontFamily.h"
#include "ResourceManager.h"
#include "ResolveCachingColor.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include <algorithm>
@@ -573,26 +575,26 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
PasStringCopy(text, stringCopy);
Rect iRect = dial->GetItems()[item - 1].GetWidget()->GetRect();
if ((surface->MeasureString(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
if ((appFont->MeasurePStr(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(appFont, stringCopy, iRect.right - iRect.left - 2);
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->FillRect(iRect, whiteColor);
short strWidth = surface->MeasureString(stringCopy);
short strWidth = appFont->MeasurePStr(stringCopy);
inset = ((iRect.right - iRect.left) - (strWidth + 2)) / 2;
iRect.left += inset;
iRect.right -= inset;
// Draw centered
const int32_t ascender = surface->MeasureFontAscender();
const int32_t ascender = appFont->GetMetrics().m_ascent;
PortabilityLayer::ResolveCachingColor backgroundColor;
PortabilityLayer::ResolveCachingColor textColor;
@@ -611,7 +613,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
surface->FillRect(iRect, backgroundColor);
const Point centeredDrawPoint = Point::Create((iRect.left + iRect.right - strWidth) / 2, (iRect.top + iRect.bottom + ascender) / 2);
surface->DrawString(centeredDrawPoint, stringCopy, true, textColor);
surface->DrawString(centeredDrawPoint, stringCopy, textColor, appFont);
}
//-------------------------------------------------------------- DrawDialogUserText
@@ -626,16 +628,16 @@ void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
short iType;
DrawSurface *surface = dial->GetWindow()->GetDrawSurface();
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
PasStringCopy(text, stringCopy);
const Rect iRect = dial->GetItems()[item - 1].GetWidget()->GetRect();
if ((surface->MeasureString(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
if ((appFont->MeasurePStr(stringCopy) + 2) > (iRect.right - iRect.left))
CollapseStringToWidth(appFont, stringCopy, iRect.right - iRect.left - 2);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
surface->DrawString(Point::Create(iRect.left, iRect.bottom), stringCopy, true, blackColor);
surface->DrawString(Point::Create(iRect.left, iRect.bottom), stringCopy, blackColor, appFont);
}
//-------------------------------------------------------------- LoadDialogPICT

View File

@@ -18,6 +18,7 @@ namespace PortabilityLayer
class ScanlineMask;
class ResTypeID;
struct RGBAColor;
class RenderedFont;
}
#define kPreferredDepth 8
@@ -134,7 +135,7 @@ void DecrementCursor (void);
void SpinCursor (short);
void BackSpinCursor (short);
void ColorText (DrawSurface *surface, const Point &, StringPtr, long); // --- ColorUtils.c
void ColorText (DrawSurface *surface, const Point &, StringPtr, long, PortabilityLayer::RenderedFont *font); // --- ColorUtils.c
void ColorRect (DrawSurface *surface, const Rect &, long);
void ColorOval (DrawSurface *surface, const Rect &, long);
void ColorOvalMaskPattern (DrawSurface *surface, const Rect &, long, const uint8_t *);
@@ -189,7 +190,7 @@ void PasStringConcat (StringPtr, const PLPasStr &);
void GetLineOfText (StringPtr, short, StringPtr);
void WrapText (StringPtr, short);
void GetFirstWordOfString (StringPtr, StringPtr);
void CollapseStringToWidth (DrawSurface *, StringPtr, short);
void CollapseStringToWidth (PortabilityLayer::RenderedFont *, StringPtr, short);
void GetChooserName (StringPtr);
StringPtr GetLocalizedString (short, StringPtr);

View File

@@ -19,6 +19,7 @@
#include "Objects.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
#include "Utilities.h"
@@ -108,16 +109,16 @@ void SetUpFinalScreen (void)
{
GetLineOfText(tempStr, count, subStr);
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
offset = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) -
surface->MeasureString(subStr)) / 2;
appFont->MeasurePStr(subStr)) / 2;
const Point textShadowPos = Point::Create(offset + 1, textDown + 33 + (count * 20));
surface->DrawString(textShadowPos, subStr, true, blackColor);
surface->DrawString(textShadowPos, subStr, blackColor, appFont);
const Point textPos = Point::Create(offset, textDown + 32 + (count * 20));
surface->DrawString(textPos, subStr, true, whiteColor);
surface->DrawString(textPos, subStr, whiteColor, appFont);
count++;
}
while (subStr[0] > 0);

View File

@@ -25,6 +25,7 @@
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
#include "Utilities.h"
#include "WindowManager.h"
@@ -148,29 +149,29 @@ void DrawHighScores (DrawSurface *surface)
DisposeGWorld(tempMap);
DisposeGWorld(tempMask);
surface->SetApplicationFont(14, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont14 = GetApplicationFont(14, PortabilityLayer::FontFamilyFlag_Bold, true);
PasStringCopy(PSTR("<EFBFBD> "), tempStr);
PasStringConcat(tempStr, thisHouseName);
PasStringConcat(tempStr, PSTR(" <20>"));
const Point scoreShadowPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2) - 1, dropIt - 66);
surface->DrawString(scoreShadowPoint, tempStr, true, blackColor);
const Point scoreShadowPoint = Point::Create(scoreLeft + ((kScoreWide - appFont14->MeasurePStr(tempStr)) / 2) - 1, dropIt - 66);
surface->DrawString(scoreShadowPoint, tempStr, blackColor, appFont14);
const Point scoreTextPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2), dropIt - 65);
surface->DrawString(scoreTextPoint, tempStr, true, cyanColor);
const Point scoreTextPoint = Point::Create(scoreLeft + ((kScoreWide - appFont14->MeasurePStr(tempStr)) / 2), dropIt - 65);
surface->DrawString(scoreTextPoint, tempStr, cyanColor, appFont14);
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont12 = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
thisHousePtr = *thisHouse;
// message for score #1
PasStringCopy(thisHousePtr->highScores.banner, tempStr);
bannerWidth = surface->MeasureString(tempStr);
bannerWidth = appFont12->MeasurePStr(tempStr);
const Point topScoreShadowPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted);
surface->DrawString(topScoreShadowPoint, tempStr, true, blackColor);
surface->DrawString(topScoreShadowPoint, tempStr, blackColor, appFont12);
const Point topScoreTextPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted - 1);
surface->DrawString(topScoreTextPoint, tempStr, true, yellowColor);
surface->DrawString(topScoreTextPoint, tempStr, yellowColor, appFont12);
QSetRect(&tempRect, 0, 0, bannerWidth + 8, kScoreSpacing);
QOffsetRect(&tempRect, scoreLeft - 3 + (kScoreWide - bannerWidth) / 2,
@@ -192,7 +193,7 @@ void DrawHighScores (DrawSurface *surface)
strPos = Point::Create(scoreLeft + 1, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 1, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, blackColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *scoreColor = (i == lastHighScore) ? &whiteColor : &cyanColor;
@@ -200,7 +201,7 @@ void DrawHighScores (DrawSurface *surface)
strPos = Point::Create(scoreLeft + 0, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 0, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, *scoreColor);
surface->DrawString(strPos, tempStr, *scoreColor, appFont12);
// draw high score name
PasStringCopy(thisHousePtr->highScores.names[i], tempStr);
@@ -208,7 +209,7 @@ void DrawHighScores (DrawSurface *surface)
strPos = Point::Create(scoreLeft + 31, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 31, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, blackColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *nameColor = (i == lastHighScore) ? &whiteColor : &yellowColor;
@@ -217,7 +218,7 @@ void DrawHighScores (DrawSurface *surface)
strPos = Point::Create(scoreLeft + 30, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 30, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, *nameColor);
surface->DrawString(strPos, tempStr, *nameColor, appFont12);
// draw level number
NumToString(thisHousePtr->highScores.levels[i], tempStr);
@@ -225,14 +226,14 @@ void DrawHighScores (DrawSurface *surface)
strPos = Point::Create(scoreLeft + 161, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 161, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, blackColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *levelColor = (i == lastHighScore) ? &whiteColor : &yellowColor;
if (i == 0)
strPos = Point::Create(scoreLeft + 160, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 160, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, *levelColor);
surface->DrawString(strPos, tempStr, *levelColor, appFont12);
// draw word "rooms"
if (thisHousePtr->highScores.levels[i] == 1)
GetLocalizedString(6, tempStr);
@@ -243,19 +244,19 @@ void DrawHighScores (DrawSurface *surface)
strPos = Point::Create(scoreLeft + 193, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 193, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, blackColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
if (i == 0)
strPos = Point::Create(scoreLeft + 192, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 192, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, cyanColor);
surface->DrawString(strPos, tempStr, cyanColor, appFont12);
// draw high score points
NumToString(thisHousePtr->highScores.scores[i], tempStr);
if (i == 0)
strPos = Point::Create(scoreLeft + 291, dropIt - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 291, dropIt + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, blackColor);
surface->DrawString(strPos, tempStr, blackColor, appFont12);
PortabilityLayer::ResolveCachingColor *pointsColor = (i == lastHighScore) ? &whiteColor : &yellowColor;
@@ -263,15 +264,15 @@ void DrawHighScores (DrawSurface *surface)
strPos = Point::Create(scoreLeft + 290, dropIt - 1 - kScoreSpacing - kKimsLifted);
else
strPos = Point::Create(scoreLeft + 290, dropIt - 1 + (i * kScoreSpacing));
surface->DrawString(strPos, tempStr, true, *pointsColor);
surface->DrawString(strPos, tempStr, *pointsColor, appFont12);
}
}
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont9 = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
const Point textPos = Point::Create(scoreLeft + 80, dropIt - 1 + (10 * kScoreSpacing));
GetLocalizedString(8, tempStr);
surface->DrawString(textPos, tempStr, true, blueColor);
surface->DrawString(textPos, tempStr, blueColor, appFont9);
}
//-------------------------------------------------------------- SortHighScores

View File

@@ -70,20 +70,20 @@ void DrawOnSplash(DrawSurface *surface)
if ((thisMac.hasQT) && (hasMovie))
PasStringConcat(houseLoadedStr, PSTR(" (TV)"));
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
const Point textPoint = Point::Create(splashOriginH + 436, splashOriginV + 314);
if (thisMac.isDepth == 4)
{
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
surface->DrawString(textPoint, houseLoadedStr, true, whiteColor);
surface->DrawString(textPoint, houseLoadedStr, whiteColor, appFont);
}
else
{
if (houseIsReadOnly)
ColorText(surface, textPoint, houseLoadedStr, 5L);
ColorText(surface, textPoint, houseLoadedStr, 5L, appFont);
else
ColorText(surface, textPoint, houseLoadedStr, 28L);
ColorText(surface, textPoint, houseLoadedStr, 28L, appFont);
}
#if defined(powerc) || defined(__powerc)

View File

@@ -15,6 +15,7 @@
#include "Environ.h"
#include "Objects.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
#include "ResourceManager.h"
#include "Room.h"
@@ -1061,13 +1062,13 @@ void DrawCalendar (Rect *theRect)
backSrcMap->DrawPicture(thePicture, bounds);
thePicture.Dispose();
backSrcMap->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
GetTime(&timeRec);
GetIndString(monthStr, kMonthStringID, timeRec.month);
const Point textPos = Point::Create(theRect->left + ((64 - backSrcMap->MeasureString(monthStr)) / 2), theRect->top + 55);
ColorText(backSrcMap, textPos, monthStr, kDarkFleshColor);
const Point textPos = Point::Create(theRect->left + ((64 - appFont->MeasurePStr(monthStr)) / 2), theRect->top + 55);
ColorText(backSrcMap, textPos, monthStr, kDarkFleshColor, appFont);
}
//-------------------------------------------------------------- DrawBulletin

View File

@@ -252,13 +252,13 @@ void ReadyBackground (short theID, short *theTiles)
workSrcMap->FillRect(workSrcRect, ltGrayColor);
workSrcMap->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_None, true);
const Point textPoint = Point::Create(10, 20);
if (houseUnlocked)
workSrcMap->DrawString(textPoint, PSTR("No rooms"), true, blackColor);
workSrcMap->DrawString(textPoint, PSTR("No rooms"), blackColor, appFont);
else
workSrcMap->DrawString(textPoint, PSTR("Nothing to show"), true, blackColor);
workSrcMap->DrawString(textPoint, PSTR("Nothing to show"), blackColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
(BitMap *)*GetGWorldPixMap(backSrcMap),

View File

@@ -10,11 +10,13 @@
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "FontFamily.h"
#include "MenuManager.h"
#include "PLStandardColors.h"
#include "QDPixMap.h"
#include "QDStandardPalette.h"
#include "RectUtils.h"
#include "RenderedFont.h"
#include "ResolveCachingColor.h"
@@ -164,33 +166,35 @@ void RefreshRoomTitle (short mode)
const Point strShadowPoint = Point::Create(1, 10);
const Point strPoint = Point::Create(0, 9);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
switch (mode)
{
case kEscapedTitleMode:
surface->DrawString(strShadowPoint, PSTR("Hit Delete key if unable to Follow"), true, blackColor);
surface->DrawString(strShadowPoint, PSTR("Hit Delete key if unable to Follow"), blackColor, appFont);
break;
case kSavingTitleMode:
surface->DrawString(strShadowPoint, PSTR("Saving Game<6D>"), true, blackColor);
surface->DrawString(strShadowPoint, PSTR("Saving Game<6D>"), blackColor, appFont);
break;
default:
surface->DrawString(strShadowPoint, thisRoom->name, true, blackColor);
surface->DrawString(strShadowPoint, thisRoom->name, blackColor, appFont);
break;
}
switch (mode)
{
case kEscapedTitleMode:
surface->DrawString(strPoint, PSTR("Hit Delete key if unable to Follow"), true, whiteColor);
surface->DrawString(strPoint, PSTR("Hit Delete key if unable to Follow"), whiteColor, appFont);
break;
case kSavingTitleMode:
surface->DrawString(strPoint, PSTR("Saving Game<6D>"), true, whiteColor);
surface->DrawString(strPoint, PSTR("Saving Game<6D>"), whiteColor, appFont);
break;
default:
surface->DrawString(strPoint, thisRoom->name, true, whiteColor);
surface->DrawString(strPoint, thisRoom->name, whiteColor, appFont);
break;
}
@@ -207,6 +211,8 @@ void RefreshNumGliders (void)
long displayMortals;
DrawSurface *surface = boardGSrcMap;
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
PortabilityLayer::ResolveCachingColor theRGBColor = PortabilityLayer::ResolveCachingColor::FromStandardColor(kGrayBackgroundColor);
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
@@ -221,8 +227,8 @@ void RefreshNumGliders (void)
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->DrawString(shadowPoint, nGlidersStr, true, blackColor);
surface->DrawString(textPoint, nGlidersStr, true, whiteColor);
surface->DrawString(shadowPoint, nGlidersStr, blackColor, appFont);
surface->DrawString(textPoint, nGlidersStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
(BitMap *)*GetGWorldPixMap(boardSrcMap),
@@ -240,6 +246,8 @@ void RefreshPoints (void)
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
surface->FillRect(boardPSrcRect, theRGBColor);
NumToString(theScore, scoreStr);
@@ -247,8 +255,8 @@ void RefreshPoints (void)
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->DrawString(shadowPoint, scoreStr, true, blackColor);
surface->DrawString(textPoint, scoreStr, true, whiteColor);
surface->DrawString(shadowPoint, scoreStr, blackColor, appFont);
surface->DrawString(textPoint, scoreStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
(BitMap *)*GetGWorldPixMap(boardSrcMap),
@@ -268,6 +276,8 @@ void QuickGlidersRefresh (void)
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
surface->FillRect(boardGSrcRect, theRGBColor);
NumToString((long)mortals, nGlidersStr);
@@ -275,8 +285,8 @@ void QuickGlidersRefresh (void)
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->DrawString(shadowPoint, nGlidersStr, true, blackColor);
surface->DrawString(textPoint, nGlidersStr, true, whiteColor);
surface->DrawString(shadowPoint, nGlidersStr, blackColor, appFont);
surface->DrawString(textPoint, nGlidersStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
@@ -296,6 +306,8 @@ void QuickScoreRefresh (void)
PortabilityLayer::ResolveCachingColor blackColor = StdColors::Black();
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
surface->FillRect(boardPSrcRect, theRGBColor);
NumToString(displayedScore, scoreStr);
@@ -303,8 +315,8 @@ void QuickScoreRefresh (void)
const Point shadowPoint = Point::Create(1, 10);
const Point textPoint = Point::Create(0, 9);
surface->DrawString(shadowPoint, scoreStr, true, blackColor);
surface->DrawString(textPoint, scoreStr, true, whiteColor);
surface->DrawString(shadowPoint, scoreStr, blackColor, appFont);
surface->DrawString(textPoint, scoreStr, whiteColor, appFont);
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),

View File

@@ -7,6 +7,7 @@
#include "PLPasStr.h"
#include "Externs.h"
#include "RenderedFont.h"
#include <string.h>
@@ -275,17 +276,17 @@ void GetFirstWordOfString (StringPtr stringIn, StringPtr stringOut)
// font. If the text would exceed our width limit, characters<72>
// are dropped off the end of the string and "<22>" appended.
void CollapseStringToWidth (DrawSurface *surface, StringPtr theStr, short wide)
void CollapseStringToWidth (PortabilityLayer::RenderedFont *font, StringPtr theStr, short wide)
{
short dotsWide;
Boolean tooWide;
dotsWide = surface->MeasureString(PSTR("<EFBFBD>"));
tooWide = surface->MeasureString(theStr) > wide;
while (tooWide)
dotsWide = font->MeasurePStr(PSTR("<EFBFBD>"));
tooWide = font->MeasurePStr(theStr) > wide;
while (tooWide && theStr[0] > 0)
{
theStr[0]--;
tooWide = ((surface->MeasureString(theStr) + dotsWide) > wide);
tooWide = ((font->MeasurePStr(theStr) + dotsWide) > wide);
if (!tooWide)
PasStringConcat(theStr, PSTR("<EFBFBD>"));
}

View File

@@ -105,7 +105,6 @@ void InitScoreboardMap(void)
if (!boardTSrcMap)
{
theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect, kPreferredPixelFormat);
boardTSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
}
boardTDestRect = boardTSrcRect;
QOffsetRect(&boardTDestRect, 137 + hOffset, 5);
@@ -114,7 +113,6 @@ void InitScoreboardMap(void)
if (!boardGSrcMap)
{
theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect, kPreferredPixelFormat);
boardGSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
}
boardGDestRect = boardGSrcRect;
QOffsetRect(&boardGDestRect, 526 + hOffset, 5);
@@ -124,7 +122,6 @@ void InitScoreboardMap(void)
if (!boardPSrcMap)
{
theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect, kPreferredPixelFormat);
boardPSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
}
boardPDestRect = boardPSrcRect;
QOffsetRect(&boardPDestRect, 570 + hOffset, 5); // total = 6396 pixels

View File

@@ -157,8 +157,8 @@ void DrawToolName (DrawSurface *surface)
const Point textPoint = Point::Create(toolTextRect.left + 3, toolTextRect.bottom - 6);
surface->SetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold);
ColorText(surface, textPoint, theString, 171L);
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(9, PortabilityLayer::FontFamilyFlag_Bold, true);
ColorText(surface, textPoint, theString, 171L, appFont);
}
#endif

View File

@@ -8,6 +8,7 @@
#include "PLPasStr.h"
#include "Externs.h"
#include "Environ.h"
#include "FontFamily.h"
#include "PLStandardColors.h"
#include "RectUtils.h"
#include "ResolveCachingColor.h"
@@ -125,8 +126,6 @@ void OpenMessageWindow (const PLPasStr &title)
ShowWindow(mssgWindow);
DrawSurface *surface = mssgWindow->GetDrawSurface();
surface->SetSystemFont(12, 0);
}
mssgWindowExclusiveStack = mssgWindow;
@@ -150,6 +149,8 @@ void SetMessageWindowMessage (StringPtr message, const PortabilityLayer::RGBACol
{
DrawSurface *surface = mssgWindow->GetDrawSurface();
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_None, true);
SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall);
InsetRect(&mssgWindowRect, 16, 16);
@@ -159,7 +160,7 @@ void SetMessageWindowMessage (StringPtr message, const PortabilityLayer::RGBACol
const Point textPoint = Point::Create(mssgWindowRect.left, mssgWindowRect.bottom - 6);
PortabilityLayer::ResolveCachingColor specifiedColor = color;
surface->DrawString(textPoint, message, true, specifiedColor);
surface->DrawString(textPoint, message, specifiedColor, sysFont);
}
}

View File

@@ -811,8 +811,6 @@ namespace PortabilityLayer
SetGraphicsPort(m_menuBarGraf);
PortabilityLayer::QDState *qdState = qdManager->GetState();
ResolveCachingColor barMidColor = gs_barMidColor;
graf->FillRect(menuRect, barMidColor);
@@ -894,7 +892,7 @@ namespace PortabilityLayer
// Text items
ResolveCachingColor barNormalTextColor = gs_barNormalTextColor;
m_menuBarGraf->SetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold, true);
{
Menu **menuHdl = m_firstMenu;
@@ -916,7 +914,7 @@ namespace PortabilityLayer
if (menuHdl != selectedMenuHdl)
{
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true, barNormalTextColor);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), barNormalTextColor, sysFont);
}
}
}
@@ -936,7 +934,7 @@ namespace PortabilityLayer
size_t xCoordinate = menu->cumulativeOffset + (menu->menuIndex * 2) * kMenuBarItemPadding + kMenuBarInitialPadding;
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true, barHighlightTextColor);
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), barHighlightTextColor, sysFont);
}
}
@@ -1375,8 +1373,6 @@ namespace PortabilityLayer
SetGraphicsPort(m_menuGraf);
QDState *qdState = qdManager->GetState();
ResolveCachingColor barMidColor = gs_barMidColor;
{
@@ -1394,7 +1390,7 @@ namespace PortabilityLayer
surface->FillRect(Rect::Create(menu->layoutFinalHeight - 1, 1, menu->layoutFinalHeight, menu->layoutWidth - 1), darkGrayColor);
}
m_menuGraf->SetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(kMenuFontSize, PortabilityLayer::FontFamilyFlag_Bold, true);
const uint8_t *strBlob = static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents);
@@ -1425,7 +1421,7 @@ namespace PortabilityLayer
else
itemTextAndCheckColor = gs_barDisabledTextColor;
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true, itemTextAndCheckColor);
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), itemTextAndCheckColor, sysFont);
if (item.key)
{
@@ -1433,7 +1429,7 @@ namespace PortabilityLayer
uint8_t hintText[kHintTextCapacity];
const size_t hintLength = FormatHintText(hintText, item.key);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), true, itemTextAndCheckColor);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), itemTextAndCheckColor, sysFont);
}
if (item.checked)
@@ -1465,7 +1461,7 @@ namespace PortabilityLayer
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true, barHighlightTextColor);
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), barHighlightTextColor, sysFont);
if (item.key)
{
@@ -1473,7 +1469,7 @@ namespace PortabilityLayer
uint8_t hintText[kHintTextCapacity];
const size_t hintLength = FormatHintText(hintText, item.key);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), true, barHighlightTextColor);
surface->DrawString(hintPos, PLPasStr(hintLength, reinterpret_cast<const char*>(hintText)), barHighlightTextColor, sysFont);
if (item.checked)
surface->FillRect(Rect::Create(item.layoutYOffset + kMenuItemCheckTopOffset, kMenuItemCheckLeftOffset, item.layoutYOffset + kMenuItemCheckBottomOffset, kMenuItemCheckRightOffset), barHighlightTextColor);

View File

@@ -4,7 +4,10 @@
#include "PLRegions.h"
#include "PLTimeTaggedVOSEvent.h"
#include "PLStandardColors.h"
#include "PLQDraw.h"
#include "FontFamily.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "SimpleGraphic.h"
@@ -442,10 +445,11 @@ namespace PortabilityLayer
ResolveCachingColor textCacheColor = textColor;
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
int32_t x = (m_rect.left + m_rect.right - static_cast<int32_t>(surface->MeasureString(m_text.ToShortStr()))) / 2;
int32_t y = (m_rect.top + m_rect.bottom + static_cast<int32_t>(surface->MeasureFontAscender())) / 2;
surface->DrawString(Point::Create(x, y), m_text.ToShortStr(), true, textCacheColor);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
int32_t x = (m_rect.left + m_rect.right - static_cast<int32_t>(sysFont->MeasureString(reinterpret_cast<const uint8_t*>(m_text.UnsafeCharPtr()), m_text.Length()))) / 2;
int32_t y = (m_rect.top + m_rect.bottom + static_cast<int32_t>(sysFont->GetMetrics().m_ascent)) / 2;
surface->DrawString(Point::Create(x, y), m_text.ToShortStr(), textCacheColor, sysFont);
}
void ButtonWidget::DrawAsCheck(DrawSurface *surface, bool inverted)
@@ -531,9 +535,9 @@ namespace PortabilityLayer
}
}
surface->SetSystemFont(12, FontFamilyFlag_Bold);
int32_t textV = (m_rect.top + m_rect.bottom + surface->MeasureFontAscender()) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), true, *textColor);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, FontFamilyFlag_Bold, true);
int32_t textV = (m_rect.top + m_rect.bottom + sysFont->GetMetrics().m_ascent) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), *textColor, sysFont);
}
@@ -592,9 +596,9 @@ namespace PortabilityLayer
}
}
surface->SetSystemFont(12, FontFamilyFlag_Bold);
int32_t textV = (m_rect.top + m_rect.bottom + surface->MeasureFontAscender()) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), true, *textColor);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, FontFamilyFlag_Bold, true);
int32_t textV = (m_rect.top + m_rect.bottom + sysFont->GetMetrics().m_ascent) / 2;
surface->DrawString(Point::Create(m_rect.left + checkFrameSize + 2, textV), m_text.ToShortStr(), *textColor, sysFont);
}
void ButtonWidget::DrawDefaultButtonChrome(const Rect &rectRef, DrawSurface *surface)

View File

@@ -8,6 +8,7 @@
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "PLKeyEncoding.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "ResolveCachingColor.h"
@@ -70,9 +71,9 @@ namespace PortabilityLayer
surface->FillRect(outerRect, blackColor);
surface->FillRect(innerRect, whiteColor);
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_None);
int32_t ascender = surface->MeasureFontAscender();
int32_t lineGap = surface->MeasureFontLineGap();
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_None, true);
int32_t ascender = sysFont->GetMetrics().m_ascent;
int32_t lineGap = sysFont->GetMetrics().m_linegap;
const PLPasStr str = this->GetString();
@@ -85,20 +86,20 @@ namespace PortabilityLayer
Vec2i basePoint = ResolveBasePoint();
if (m_hasFocus && m_selStartChar != m_selEndChar)
DrawSelection(surface, basePoint);
DrawSelection(surface, basePoint, sysFont);
int32_t verticalOffset = (ascender + lineGap + 1) / 2;
const Point stringBasePoint = Point::Create(basePoint.m_x, basePoint.m_y + verticalOffset);
if (m_isMultiLine)
surface->DrawStringWrap(stringBasePoint, m_rect, this->GetString(), true, blackColor);
surface->DrawStringWrap(stringBasePoint, m_rect, this->GetString(), blackColor, sysFont);
else
surface->DrawStringConstrained(stringBasePoint, this->GetString(), true, m_rect, blackColor);
surface->DrawStringConstrained(stringBasePoint, this->GetString(), m_rect, blackColor, sysFont);
if (m_hasFocus && m_selEndChar == m_selStartChar && m_caratTimer < kCaratBlinkRate)
{
PortabilityLayer::Vec2i caratPos = ResolveCaratPos(basePoint, surface->ResolveFont(true));
PortabilityLayer::Vec2i caratPos = ResolveCaratPos(basePoint, sysFont);
int32_t caratTop = caratPos.m_y;
int32_t caratBottom = caratTop + lineGap;
@@ -654,9 +655,8 @@ namespace PortabilityLayer
return WidgetHandleStates::kCaptured;
}
void EditboxWidget::DrawSelection(DrawSurface *surface, const Vec2i &basePoint) const
void EditboxWidget::DrawSelection(DrawSurface *surface, const Vec2i &basePoint, PortabilityLayer::RenderedFont *rfont) const
{
PortabilityLayer::RenderedFont *rfont = surface->ResolveFont(true);
PortabilityLayer::TextPlacer placer(basePoint, m_isMultiLine ? m_rect.Width() : -1, rfont, GetString());
#if 0

View File

@@ -59,7 +59,7 @@ namespace PortabilityLayer
WidgetHandleState_t HandleDragSelection(const TimeTaggedVOSEvent &evt);
void DrawSelection(DrawSurface *surface, const Vec2i &basePoint) const;
void DrawSelection(DrawSurface *surface, const Vec2i &basePoint, PortabilityLayer::RenderedFont *font) const;
Vec2i ResolveCaratPos(const Vec2i &basePoint, PortabilityLayer::RenderedFont *rfont) const;
Vec2i ResolveBasePoint() const;

View File

@@ -2,6 +2,8 @@
#include "PLQDraw.h"
#include "FontFamily.h"
#include "PLStandardColors.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include <algorithm>
@@ -37,11 +39,11 @@ namespace PortabilityLayer
surface->FillRect(m_rect, whiteColor);
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
const Point topLeftCorner = Point::Create(m_rect.left, m_rect.top);
const Point textStartPoint = topLeftCorner + Point::Create(0, surface->MeasureFontAscender());
const Point textStartPoint = topLeftCorner + Point::Create(0, sysFont->GetMetrics().m_ascent);
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), true, blackColor);
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), blackColor, sysFont);
}
}

View File

@@ -3,8 +3,11 @@
#include "MenuManager.h"
#include "PLMenus.h"
#include "PLPasStr.h"
#include "PLQDraw.h"
#include "PLStandardColors.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "FontFamily.h"
#include "Vec2i.h"
@@ -100,10 +103,10 @@ namespace PortabilityLayer
Rect textRect = innerRect;
textRect.right -= 11;
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
Point basePoint = Point::Create(textRect.left + 2, (textRect.top + textRect.bottom + surface->MeasureFontAscender() + 1) / 2 - 1);
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold, true);
Point basePoint = Point::Create(textRect.left + 2, (textRect.top + textRect.bottom + sysFont->GetMetrics().m_ascent + 1) / 2 - 1);
surface->DrawStringConstrained(basePoint, GetString(), true, textRect, blackColor);
surface->DrawStringConstrained(basePoint, GetString(), textRect, blackColor, sysFont);
Point arrowMidPoint = Point::Create(textRect.right + 5, (textRect.top + textRect.bottom + 1) / 2);

View File

@@ -1,6 +1,5 @@
#include "PLQDraw.h"
#include "QDManager.h"
#include "QDState.h"
#include "BitmapImage.h"
#include "DisplayDeviceManager.h"
#include "EllipsePlotter.h"
@@ -63,7 +62,7 @@ void SetPortWindowPort(WindowPtr window)
PortabilityLayer::QDManager::GetInstance()->SetPort(window->GetDrawSurface());
}
static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, const PortabilityLayer::Vec2i &pointA, const PortabilityLayer::Vec2i &pointB, PortabilityLayer::ResolveCachingColor &foreColor)
static void PlotLine(DrawSurface *surface, const PortabilityLayer::Vec2i &pointA, const PortabilityLayer::Vec2i &pointB, PortabilityLayer::ResolveCachingColor &foreColor)
{
const Rect lineRect = Rect::Create(
std::min(pointA.m_y, pointB.m_y),
@@ -84,7 +83,6 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c
Rect constrainedRect = port->GetRect();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(lineRect);
if (!constrainedRect.IsValid())
@@ -182,7 +180,7 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c
surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const Rect &rect, const Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character,
static void DrawGlyph(PixMap *pixMap, const Rect &rect, const Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character,
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor, PortabilityLayer::ResolveCachingColor &cacheColor)
{
assert(rect.IsValid());
@@ -288,35 +286,28 @@ static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const
}
}
static void DrawText(PortabilityLayer::TextPlacer &placer, PortabilityLayer::QDState *qdState, PixMap *pixMap, const Rect &rect, const PortabilityLayer::RenderedFont *rfont,
static void DrawText(PortabilityLayer::TextPlacer &placer, PixMap *pixMap, const Rect &rect, const PortabilityLayer::RenderedFont *rfont,
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor, PortabilityLayer::ResolveCachingColor &cacheColor)
{
PortabilityLayer::GlyphPlacementCharacteristics characteristics;
while (placer.PlaceGlyph(characteristics))
{
if (characteristics.m_haveGlyph)
DrawGlyph(qdState, pixMap, rect, Point::Create(characteristics.m_glyphStartPos.m_x, characteristics.m_glyphStartPos.m_y), rfont, characteristics.m_character, cachedAATable, cachedAATableColor, cacheColor);
DrawGlyph(pixMap, rect, Point::Create(characteristics.m_glyphStartPos.m_x, characteristics.m_glyphStartPos.m_y), rfont, characteristics.m_character, cachedAATable, cachedAATableColor, cacheColor);
}
}
void DrawSurface::DrawString(const Point &point, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor)
void DrawSurface::DrawString(const Point &point, const PLPasStr &str, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font)
{
DrawStringConstrained(point, str, aa, Rect::CreateLargest(), cacheColor);
DrawStringConstrained(point, str, Rect::CreateLargest(), cacheColor, font);
}
void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str, bool aa, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor)
void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *rfont)
{
PortabilityLayer::QDPort *port = &m_port;
PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
const int fontSize = qdState->m_fontSize;
const int fontVariationFlags = qdState->m_fontVariationFlags;
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
PixMap *pixMap = *port->GetPixMap();
const Rect rect = pixMap->m_rect.Intersect(constraintRect);
@@ -326,25 +317,17 @@ void DrawSurface::DrawStringConstrained(const Point &point, const PLPasStr &str,
PortabilityLayer::TextPlacer placer(PortabilityLayer::Vec2i(point.h, point.v), -1, rfont, str);
DrawText(placer, qdState, pixMap, rect, rfont, m_cachedAATable, m_cachedAAColor, cacheColor);
DrawText(placer, pixMap, rect, rfont, m_cachedAATable, m_cachedAAColor, cacheColor);
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor)
void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *rfont)
{
PortabilityLayer::QDPort *port = &m_port;
PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
const int fontSize = qdState->m_fontSize;
const int fontVariationFlags = qdState->m_fontVariationFlags;
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
Point penPos = point;
const size_t len = str.Length();
const uint8_t *chars = str.UChars();
@@ -359,70 +342,11 @@ void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect,
PortabilityLayer::TextPlacer placer(PortabilityLayer::Vec2i(point.h, point.v), areaRect.Width(), rfont, str);
DrawText(placer, qdState, pixMap, limitRect, rfont, m_cachedAATable, m_cachedAAColor, cacheColor);
DrawText(placer, pixMap, limitRect, rfont, m_cachedAATable, m_cachedAAColor, cacheColor);
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
size_t DrawSurface::MeasureString(const PLPasStr &str)
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
if (!fontFamily)
return 0;
const int variationFlags = qdState->m_fontVariationFlags;
const int fontSize = qdState->m_fontSize;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
if (!rfont)
return 0;
return rfont->MeasureString(str.UChars(), str.Length());
}
int32_t DrawSurface::MeasureFontAscender()
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
if (!fontFamily)
return 0;
const int variationFlags = qdState->m_fontVariationFlags;
const int fontSize = qdState->m_fontSize;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
if (!rfont)
return 0;
return rfont->GetMetrics().m_ascent;
}
int32_t DrawSurface::MeasureFontLineGap()
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
if (!fontFamily)
return 0;
const int variationFlags = qdState->m_fontVariationFlags;
const int fontSize = qdState->m_fontSize;
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
if (!rfont)
return 0;
return rfont->GetMetrics().m_linegap;
}
void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
{
@@ -732,19 +656,6 @@ void DrawSurface::DrawPicture(THandle<BitmapImage> pictHdl, const Rect &bounds)
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
PortabilityLayer::RenderedFont *DrawSurface::ResolveFont(bool aa) const
{
const PortabilityLayer::QDState *qdState = m_port.GetState();
PortabilityLayer::FontManager *fontManager = PortabilityLayer::FontManager::GetInstance();
const int fontSize = qdState->m_fontSize;
const int fontVariationFlags = qdState->m_fontVariationFlags;
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
return fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
}
void DrawSurface::FillRect(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid())
@@ -756,8 +667,6 @@ void DrawSurface::FillRect(const Rect &rect, PortabilityLayer::ResolveCachingCol
Rect constrainedRect = rect;
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(qdPort->GetRect());
if (!constrainedRect.IsValid())
@@ -805,8 +714,6 @@ void DrawSurface::FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pa
Rect constrainedRect = rect;
const Rect portRect = qdPort->GetRect();
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(qdPort->GetRect());
if (!constrainedRect.IsValid())
@@ -854,32 +761,6 @@ void DrawSurface::FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pa
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
void DrawSurface::SetApplicationFont(int size, int variationFlags)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetApplicationFont(size, variationFlags);
if (!fontFamily)
return;
PortabilityLayer::QDState *qdState = m_port.GetState();
qdState->m_fontFamily = fontFamily;
qdState->m_fontSize = size;
qdState->m_fontVariationFlags = variationFlags;
}
void DrawSurface::SetSystemFont(int size, int variationFlags)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetSystemFont(size, variationFlags);
if (!fontFamily)
return;
PortabilityLayer::QDState *qdState = m_port.GetState();
qdState->m_fontFamily = fontFamily;
qdState->m_fontSize = size;
qdState->m_fontVariationFlags = variationFlags;
}
void DrawSurface::FillEllipse(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
{
if (!rect.IsValid() || rect.Width() < 1 || rect.Height() < 1)
@@ -935,8 +816,6 @@ void DrawSurface::FrameEllipse(const Rect &rect, PortabilityLayer::ResolveCachin
const Rect portRect = qdPort->GetRect();
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(portRect);
if (!constrainedRect.IsValid())
@@ -1013,7 +892,6 @@ void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::Scanli
return;
PortabilityLayer::QDPort *port = &m_port;
PortabilityLayer::QDState *qdState = port->GetState();
PixMap *pixMap = *port->GetPixMap();
const Rect portRect = port->GetRect();
@@ -1157,22 +1035,7 @@ void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::Scanli
void DrawSurface::DrawLine(const Point &a, const Point &b, PortabilityLayer::ResolveCachingColor &cacheColor)
{
PlotLine(m_port.GetState(), this, PortabilityLayer::Vec2i(a.h, a.v), PortabilityLayer::Vec2i(b.h, b.v), cacheColor);
}
void GetClip(Rect *rect)
{
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
*rect = qdState->m_clipRect;
}
void ClipRect(const Rect *rect)
{
if (!rect->IsValid())
return;
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
qdState->m_clipRect = *rect;
PlotLine(this, PortabilityLayer::Vec2i(a.h, a.v), PortabilityLayer::Vec2i(b.h, b.v), cacheColor);
}
void DrawSurface::FrameRect(const Rect &rect, PortabilityLayer::ResolveCachingColor &cacheColor)
@@ -1247,8 +1110,6 @@ void DrawSurface::InvertFillRect(const Rect &rect, const uint8_t *pattern)
Rect constrainedRect = rect;
const Rect portRect = qdPort->GetRect();
PortabilityLayer::QDState *qdState = qdPort->GetState();
constrainedRect = constrainedRect.Intersect(qdState->m_clipRect);
constrainedRect = constrainedRect.Intersect(qdPort->GetRect());
if (!constrainedRect.IsValid())
@@ -1628,11 +1489,6 @@ Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection)
}
void RestoreDeviceClut(void *unknown)
{
PL_NotYetImplemented();
}
void BitMap::Init(const Rect &rect, GpPixelFormat_t pixelFormat, size_t pitch, void *dataPtr)
{
m_rect = rect;
@@ -1641,6 +1497,25 @@ void BitMap::Init(const Rect &rect, GpPixelFormat_t pixelFormat, size_t pitch, v
m_data = dataPtr;
}
PortabilityLayer::RenderedFont *GetApplicationFont(int size, int variationFlags, bool aa)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetApplicationFont(size, variationFlags);
if (!fontFamily)
return nullptr;
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
}
PortabilityLayer::RenderedFont *GetSystemFont(int size, int variationFlags, bool aa)
{
PortabilityLayer::FontFamily *fontFamily = PortabilityLayer::FontManager::GetInstance()->GetSystemFont(size, variationFlags);
if (!fontFamily)
return nullptr;
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, size, aa, variationFlags);
}
#include "stb_image_write.h"
void DebugPixMap(PixMap **pixMapH, const char *outName)
@@ -1652,3 +1527,4 @@ void DebugPixMap(PixMap **pixMapH, const char *outName)
stbi_write_png(outPath, pixMap->m_rect.right - pixMap->m_rect.left, pixMap->m_rect.bottom - pixMap->m_rect.top, 1, pixMap->m_data, pixMap->m_pitch);
}

View File

@@ -7,6 +7,7 @@
namespace PortabilityLayer
{
class ScanlineMask;
class RenderedFont;
}
struct Dialog;
@@ -94,7 +95,8 @@ PixMap *GetPortBitMapForCopyBits(DrawSurface *grafPtr);
Boolean SectRect(const Rect *rectA, const Rect *rectB, Rect *outIntersection);
void RestoreDeviceClut(void *unknown);
PortabilityLayer::RenderedFont *GetApplicationFont(int size, int variationFlags, bool aa);
PortabilityLayer::RenderedFont *GetSystemFont(int size, int variationFlags, bool aa);
inline RGBColor::RGBColor(uint8_t r, uint8_t g, uint8_t b)

View File

@@ -257,7 +257,6 @@
<ClInclude Include="QDPort.h" />
<ClInclude Include="QDRegion.h" />
<ClInclude Include="QDStandardPalette.h" />
<ClInclude Include="QDState.h" />
<ClInclude Include="RandomNumberGenerator.h" />
<ClInclude Include="Rect2i.h" />
<ClInclude Include="RenderedFont.h" />
@@ -379,7 +378,6 @@
<ClCompile Include="QDPixMap.cpp" />
<ClCompile Include="QDPort.cpp" />
<ClCompile Include="QDStandardPalette.cpp" />
<ClCompile Include="QDState.cpp" />
<ClCompile Include="RandomNumberGenerator.cpp" />
<ClCompile Include="ResourceCompiledRef.cpp" />
<ClCompile Include="ResourceFile.cpp" />

View File

@@ -243,9 +243,6 @@
<ClInclude Include="QDRegion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="QDState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ResourceCompiledTypeList.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -605,9 +602,6 @@
<ClCompile Include="QDPictHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="QDState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="QDPictDecoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>

View File

@@ -4,8 +4,8 @@
#include "GpPixelFormat.h"
#include "PLHandle.h"
#include "QDState.h"
#include "QDPort.h"
#include "RGBAColor.h"
namespace PortabilityLayer
{
@@ -15,6 +15,7 @@ namespace PortabilityLayer
class RenderedFont;
class ResolveCachingColor;
class ScanlineMask;
class FontSpec;
}
struct PixMap;
@@ -76,20 +77,12 @@ struct DrawSurface
void DrawLine(const Point &a, const Point &b, PortabilityLayer::ResolveCachingColor &cacheColor);
void SetApplicationFont(int size, int variationFlags);
void SetSystemFont(int size, int variationFlags);
void DrawString(const Point &point, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor);
void DrawStringConstrained(const Point &point, const PLPasStr &str, bool aa, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor);
void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa, PortabilityLayer::ResolveCachingColor &cacheColor);
size_t MeasureString(const PLPasStr &str);
int32_t MeasureFontAscender();
int32_t MeasureFontLineGap();
void DrawString(const Point &point, const PLPasStr &str, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font);
void DrawStringConstrained(const Point &point, const PLPasStr &str, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font);
void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font);
void DrawPicture(THandle<BitmapImage> pictHandle, const Rect &rect);
PortabilityLayer::RenderedFont *ResolveFont(bool aa) const;
IGpDisplayDriverSurface *m_ddSurface;
PortabilityLayer::AntiAliasTable *m_cachedAATable;

View File

@@ -4,7 +4,6 @@
#include "PLCore.h"
#include "PLQDOffscreen.h"
#include "QDGraf.h"
#include "QDState.h"
#include <assert.h>
@@ -20,7 +19,6 @@ namespace PortabilityLayer
void SetPort(DrawSurface *gw) override;
PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) override;
void DisposeGWorld(DrawSurface *gw) override;
QDState *GetState() override;
static QDManagerImpl *GetInstance();
@@ -81,11 +79,6 @@ namespace PortabilityLayer
MemoryManager::GetInstance()->Release(gw);
}
QDState *QDManagerImpl::GetState()
{
return m_port->m_port.GetState();
}
QDManagerImpl *QDManagerImpl::GetInstance()
{
return &ms_instance;

View File

@@ -10,7 +10,6 @@ struct Rect;
namespace PortabilityLayer
{
class QDPort;
struct QDState;
class QDManager
{
@@ -21,8 +20,6 @@ namespace PortabilityLayer
virtual PLError_t NewGWorld(DrawSurface **gw, GpPixelFormat_t pixelFormat, const Rect &bounds, ColorTable **colorTable) = 0;
virtual void DisposeGWorld(DrawSurface *gw) = 0;
virtual QDState *GetState() = 0;
static QDManager *GetInstance();
};
}

View File

@@ -102,16 +102,6 @@ namespace PortabilityLayer
return m_pixMap.ImplicitCast<PixMap>();
}
const QDState *QDPort::GetState() const
{
return &m_state;
}
QDState *QDPort::GetState()
{
return &m_state;
}
GpPixelFormat_t QDPort::GetPixelFormat() const
{
return m_pixelFormat;

View File

@@ -4,7 +4,6 @@
#include "GpPixelFormat.h"
#include "PLErrorCodes.h"
#include "PLHandle.h"
#include "QDState.h"
struct PixMap;
struct Rect;
@@ -37,8 +36,6 @@ namespace PortabilityLayer
QDPortType GetPortType() const;
THandle<PixMap> GetPixMap() const;
const QDState *GetState() const;
QDState *GetState();
GpPixelFormat_t GetPixelFormat() const;
Rect GetRect() const;
@@ -61,7 +58,6 @@ namespace PortabilityLayer
QDPortType m_portType;
QDState m_state;
THandle<PixMapImpl> m_pixMap;
int16_t m_left;

View File

@@ -1,15 +0,0 @@
#include "QDState.h"
#include "PLQDraw.h"
#include "QDStandardPalette.h"
namespace PortabilityLayer
{
QDState::QDState()
: m_fontFamily(nullptr)
, m_fontSize(12)
, m_fontVariationFlags(0)
, m_clipRect(Rect::Create(INT16_MIN, INT16_MIN, INT16_MAX, INT16_MAX))
{
}
}

View File

@@ -1,19 +0,0 @@
#pragma once
#include "RGBAColor.h"
#include "SharedTypes.h"
namespace PortabilityLayer
{
class FontFamily;
struct QDState
{
QDState();
FontFamily *m_fontFamily;
int m_fontVariationFlags;
int m_fontSize;
Rect m_clipRect;
};
}

View File

@@ -2,6 +2,8 @@
#include <stdint.h>
class PLPasStr;
namespace PortabilityLayer
{
struct RenderedFontMetrics;
@@ -17,5 +19,20 @@ namespace PortabilityLayer
virtual bool IsAntiAliased() const = 0;
virtual void Destroy() = 0;
size_t MeasureCharStr(const char *str, size_t len) const;
size_t MeasurePStr(const PLPasStr &pstr) const;
};
}
#include "PLPasStr.h"
inline size_t PortabilityLayer::RenderedFont::MeasurePStr(const PLPasStr &pstr) const
{
return this->MeasureString(pstr.UChars(), pstr.Length());
}
inline size_t PortabilityLayer::RenderedFont::MeasureCharStr(const char *str, size_t len) const
{
return this->MeasureString(reinterpret_cast<const uint8_t*>(str), len);
}

View File

@@ -16,6 +16,8 @@
#include "QDPixMap.h"
#include "PLTimeTaggedVOSEvent.h"
#include "Rect2i.h"
#include "RenderedFont.h"
#include "RenderedFontMetrics.h"
#include "ResolveCachingColor.h"
#include "Vec2i.h"
#include "WindowDef.h"
@@ -447,16 +449,16 @@ namespace PortabilityLayer
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
RenderChromeCloseBox(surface, rect, false);
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold);
int32_t ascender = surface->MeasureFontAscender();
PortabilityLayer::RenderedFont *sysFont = GetSystemFont(12, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
int32_t ascender = sysFont->GetMetrics().m_ascent;
const PLPasStr titlePStr = window->GetTitle().ToShortStr();
size_t titleWidth = surface->MeasureString(titlePStr);
size_t titleWidth = sysFont->MeasureString(titlePStr.UChars(), titlePStr.Length());
int32_t titleH = (rect.left + rect.right - static_cast<int32_t>(titleWidth) + 1) / 2;
int32_t titleV = (rect.top + rect.bottom + ascender + 1) / 2;
surface->DrawString(Point::Create(titleH, titleV), titlePStr, true, blackColor);
surface->DrawString(Point::Create(titleH, titleV), titlePStr, blackColor, sysFont);
}
void GenericWindowChromeTheme::RenderChromeLeft(WindowImpl *window, DrawSurface *surface) const
@@ -551,16 +553,16 @@ namespace PortabilityLayer
if (window->GetStyleFlags() & WindowStyleFlags::kCloseBox)
RenderChromeCloseBox(surface, rect, false);
surface->SetApplicationFont(10, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold);
int32_t ascender = surface->MeasureFontAscender();
PortabilityLayer::RenderedFont *appFont = GetApplicationFont(10, PortabilityLayer::FontFamilyFlags::FontFamilyFlag_Bold, true);
int32_t ascender = appFont->GetMetrics().m_ascent;
const PLPasStr titlePStr = window->GetTitle().ToShortStr();
size_t titleWidth = surface->MeasureString(titlePStr);
size_t titleWidth = appFont->MeasureString(titlePStr.UChars(), titlePStr.Length());
int32_t titleH = (rect.left + rect.right - static_cast<int32_t>(titleWidth) + 1) / 2;
int32_t titleV = (rect.top + rect.bottom + ascender + 1) / 2;
surface->DrawString(Point::Create(titleH, titleV), titlePStr, true, blackColor);
surface->DrawString(Point::Create(titleH, titleV), titlePStr, blackColor, appFont);
}
void GenericWindowChromeTheme::RenderChromeLeftMini(WindowImpl *window, DrawSurface *surface) const