mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Finish removing QDState
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "UnsafePascalStr.h"
|
||||
|
||||
class PLPasStr;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
template<size_t TSize>
|
||||
class PascalStr : public UnsafePascalStr<TSize, true>
|
||||
{
|
||||
public:
|
||||
PascalStr();
|
||||
class PLPasStr;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
template<size_t TSize>
|
||||
class PascalStr : public UnsafePascalStr<TSize, true>
|
||||
{
|
||||
public:
|
||||
PascalStr();
|
||||
PascalStr(size_t size, const char *str);
|
||||
explicit PascalStr(const PLPasStr &pstr);
|
||||
};
|
||||
}
|
||||
|
||||
explicit PascalStr(const PLPasStr &pstr);
|
||||
};
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
#include "PLPasStr.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
template<size_t TSize>
|
||||
inline PascalStr<TSize>::PascalStr()
|
||||
: UnsafePascalStr<TSize, true>(0, nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<size_t TSize>
|
||||
PascalStr<TSize>::PascalStr(size_t size, const char *str)
|
||||
: UnsafePascalStr<TSize, true>(size, str)
|
||||
{
|
||||
}
|
||||
|
||||
template<size_t TSize>
|
||||
PascalStr<TSize>::PascalStr(const PLPasStr &pstr)
|
||||
: UnsafePascalStr<TSize, true>(pstr.Length(), pstr.Chars())
|
||||
{
|
||||
}
|
||||
}
|
||||
#include "PLPasStr.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
template<size_t TSize>
|
||||
inline PascalStr<TSize>::PascalStr()
|
||||
: UnsafePascalStr<TSize, true>(0, nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<size_t TSize>
|
||||
PascalStr<TSize>::PascalStr(size_t size, const char *str)
|
||||
: UnsafePascalStr<TSize, true>(size, str)
|
||||
{
|
||||
}
|
||||
|
||||
template<size_t TSize>
|
||||
PascalStr<TSize>::PascalStr(const PLPasStr &pstr)
|
||||
: UnsafePascalStr<TSize, true>(pstr.Length(), pstr.Chars())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user