aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-03-25 11:16:04 +1100
committerNeil <nyamatongwe@gmail.com>2021-03-25 11:16:04 +1100
commit3d45c4bf974b6fdcce9712bbd3f0071a9618b89f (patch)
tree0e648f92f248247953cc6e0e4bed30e83c443765
parent921df6efca5b385790a2806f8b8844becb36e773 (diff)
downloadscintilla-mirror-3d45c4bf974b6fdcce9712bbd3f0071a9618b89f.tar.gz
Translucent text.
-rw-r--r--cocoa/PlatCocoa.h20
-rw-r--r--cocoa/PlatCocoa.mm30
-rwxr-xr-xgtk/PlatGTK.cxx32
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp31
-rw-r--r--qt/ScintillaEditBase/PlatQt.h13
-rw-r--r--src/Platform.h12
-rw-r--r--win32/PlatWin.cxx129
7 files changed, 127 insertions, 140 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index f8a941f95..d11b52336 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -124,19 +124,19 @@ public:
void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource) override;
std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
- void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidths(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthText(const Font *font_, std::string_view text) override;
- void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidthsUTF8(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthTextUTF8(const Font *font_, std::string_view text) override;
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 4020c3f09..aba1fa810 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -1454,7 +1454,7 @@ std::unique_ptr<IScreenLineLayout> SurfaceImpl::Layout(const IScreenLine *screen
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
DrawTextTransparent(rc, font_, ybase, text, fore);
}
@@ -1462,7 +1462,7 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION yb
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
CGContextSaveGState(gc);
CGContextClipToRect(gc, PRectangleToCGRect(rc));
DrawTextNoClip(rc, font_, ybase, text, fore, back);
@@ -1527,14 +1527,17 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) {
}
void SurfaceImpl::DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
QuartzTextStyle *style = TextStyleFromFont(font_);
if (!style) {
return;
}
CFStringEncoding encoding = EncodingFromCharacterSet(UnicodeMode(), style->getCharacterSet());
- ColourDesired colour(fore.AsInteger());
- CGColorRef color = CGColorCreateGenericRGB(colour.GetRed()/255.0, colour.GetGreen()/255.0, colour.GetBlue()/255.0, 1.0);
+
+ CGColorRef color = CGColorCreateGenericRGB(fore.GetRedComponent(),
+ fore.GetGreenComponent(),
+ fore.GetBlueComponent(),
+ fore.GetAlphaComponent());
style->setCTStyleColour(color);
@@ -1623,32 +1626,35 @@ XYPOSITION SurfaceImpl::WidthText(const Font *font_, std::string_view text) {
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
- DrawTextTransparent(rc, font_, ybase, text, fore);
+ DrawTextTransparentUTF8(rc, font_, ybase, text, fore);
}
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
CGContextSaveGState(gc);
CGContextClipToRect(gc, PRectangleToCGRect(rc));
- DrawTextNoClip(rc, font_, ybase, text, fore, back);
+ DrawTextNoClipUTF8(rc, font_, ybase, text, fore, back);
CGContextRestoreGState(gc);
}
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
QuartzTextStyle *style = TextStyleFromFont(font_);
if (!style) {
return;
}
const CFStringEncoding encoding = kCFStringEncodingUTF8;
- ColourDesired colour(fore.AsInteger());
- CGColorRef color = CGColorCreateGenericRGB(colour.GetRed()/255.0, colour.GetGreen()/255.0, colour.GetBlue()/255.0, 1.0);
+
+ CGColorRef color = CGColorCreateGenericRGB(fore.GetRedComponent(),
+ fore.GetGreenComponent(),
+ fore.GetBlueComponent(),
+ fore.GetAlphaComponent());
style->setCTStyleColour(color);
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 8be8b6bf3..60b47c88c 100755
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -193,17 +193,17 @@ public:
std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
- void DrawTextBase(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore);
- void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextBase(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore);
+ void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidths(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthText(const Font *font_, std::string_view text) override;
- void DrawTextBaseUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore);
- void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextBaseUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore);
+ void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidthsUTF8(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthTextUTF8(const Font *font_, std::string_view text) override;
@@ -949,7 +949,7 @@ size_t MultiByteLenFromIconv(const Converter &conv, const char *s, size_t len) n
}
void SurfaceImpl::DrawTextBase(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
PenColour(fore);
if (context) {
const XYPOSITION xText = rc.left;
@@ -975,20 +975,20 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, const Font *font_, XYPOSITION ybas
}
void SurfaceImpl::DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
DrawTextBase(rc, font_, ybase, text, fore);
}
// On GTK+, exactly same as DrawTextNoClip
void SurfaceImpl::DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
DrawTextBase(rc, font_, ybase, text, fore);
}
void SurfaceImpl::DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
// Avoid drawing spaces in transparent mode
for (size_t i=0; i<text.length(); i++) {
if (text[i] != ' ') {
@@ -1165,7 +1165,7 @@ XYPOSITION SurfaceImpl::WidthText(const Font *font_, std::string_view text) {
}
void SurfaceImpl::DrawTextBaseUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
PenColour(fore);
if (context) {
const XYPOSITION xText = rc.left;
@@ -1181,20 +1181,20 @@ void SurfaceImpl::DrawTextBaseUTF8(PRectangle rc, const Font *font_, XYPOSITION
}
void SurfaceImpl::DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
DrawTextBaseUTF8(rc, font_, ybase, text, fore);
}
// On GTK+, exactly same as DrawTextNoClip
void SurfaceImpl::DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
DrawTextBaseUTF8(rc, font_, ybase, text, fore);
}
void SurfaceImpl::DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
// Avoid drawing spaces in transparent mode
for (size_t i = 0; i < text.length(); i++) {
if (text[i] != ' ') {
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index d61abf7b2..248fcf194 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -249,6 +249,13 @@ void SurfaceImpl::PenColour(ColourDesired fore)
GetPainter()->setPen(penOutline);
}
+void SurfaceImpl::PenColour(ColourAlpha fore)
+{
+ QPen penOutline(QColorFromColourAlpha(fore));
+ penOutline.setCapStyle(Qt::FlatCap);
+ GetPainter()->setPen(penOutline);
+}
+
void SurfaceImpl::PenColourWidth(ColourAlpha fore, XYPOSITION strokeWidth) {
QPen penOutline(QColorFromColourAlpha(fore));
penOutline.setCapStyle(Qt::FlatCap);
@@ -639,13 +646,13 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc,
const Font *font,
XYPOSITION ybase,
std::string_view text,
- ColourDesired fore,
- ColourDesired back)
+ ColourAlpha fore,
+ ColourAlpha back)
{
SetFont(font);
PenColour(fore);
- GetPainter()->setBackground(QColorFromCA(back));
+ GetPainter()->setBackground(QColorFromColourAlpha(back));
GetPainter()->setBackgroundMode(Qt::OpaqueMode);
QString su = UnicodeFromText(codec, text);
GetPainter()->drawText(QPointF(rc.left, ybase), su);
@@ -655,8 +662,8 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc,
const Font *font,
XYPOSITION ybase,
std::string_view text,
- ColourDesired fore,
- ColourDesired back)
+ ColourAlpha fore,
+ ColourAlpha back)
{
SetClip(rc);
DrawTextNoClip(rc, font, ybase, text, fore, back);
@@ -667,7 +674,7 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc,
const Font *font,
XYPOSITION ybase,
std::string_view text,
- ColourDesired fore)
+ ColourAlpha fore)
{
SetFont(font);
PenColour(fore);
@@ -751,13 +758,13 @@ void SurfaceImpl::DrawTextNoClipUTF8(PRectangle rc,
const Font *font,
XYPOSITION ybase,
std::string_view text,
- ColourDesired fore,
- ColourDesired back)
+ ColourAlpha fore,
+ ColourAlpha back)
{
SetFont(font);
PenColour(fore);
- GetPainter()->setBackground(QColorFromCA(back));
+ GetPainter()->setBackground(QColorFromColourAlpha(back));
GetPainter()->setBackgroundMode(Qt::OpaqueMode);
QString su = QString::fromUtf8(text.data(), static_cast<int>(text.length()));
GetPainter()->drawText(QPointF(rc.left, ybase), su);
@@ -767,8 +774,8 @@ void SurfaceImpl::DrawTextClippedUTF8(PRectangle rc,
const Font *font,
XYPOSITION ybase,
std::string_view text,
- ColourDesired fore,
- ColourDesired back)
+ ColourAlpha fore,
+ ColourAlpha back)
{
SetClip(rc);
DrawTextNoClip(rc, font, ybase, text, fore, back);
@@ -779,7 +786,7 @@ void SurfaceImpl::DrawTextTransparentUTF8(PRectangle rc,
const Font *font,
XYPOSITION ybase,
std::string_view text,
- ColourDesired fore)
+ ColourAlpha fore)
{
SetFont(font);
PenColour(fore);
diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h
index 1fc476129..c9424378e 100644
--- a/qt/ScintillaEditBase/PlatQt.h
+++ b/qt/ScintillaEditBase/PlatQt.h
@@ -102,6 +102,7 @@ public:
int Supports(int feature) noexcept override;
bool Initialised() override;
void PenColour(ColourDesired fore) override;
+ void PenColour(ColourAlpha fore);
void PenColourWidth(ColourAlpha fore, XYPOSITION strokeWidth);
int LogPixelsY() override;
int PixelDivisions() override;
@@ -139,21 +140,21 @@ public:
std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
void DrawTextNoClip(PRectangle rc, const Font *font, XYPOSITION ybase,
- std::string_view text, ColourDesired fore, ColourDesired back) override;
+ std::string_view text, ColourAlpha fore, ColourAlpha back) override;
void DrawTextClipped(PRectangle rc, const Font *font, XYPOSITION ybase,
- std::string_view text, ColourDesired fore, ColourDesired back) override;
+ std::string_view text, ColourAlpha fore, ColourAlpha back) override;
void DrawTextTransparent(PRectangle rc, const Font *font, XYPOSITION ybase,
- std::string_view text, ColourDesired fore) override;
+ std::string_view text, ColourAlpha fore) override;
void MeasureWidths(const Font *font, std::string_view text,
XYPOSITION *positions) override;
XYPOSITION WidthText(const Font *font, std::string_view text) override;
void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase,
- std::string_view text, ColourDesired fore, ColourDesired back) override;
+ std::string_view text, ColourAlpha fore, ColourAlpha back) override;
void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase,
- std::string_view text, ColourDesired fore, ColourDesired back) override;
+ std::string_view text, ColourAlpha fore, ColourAlpha back) override;
void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase,
- std::string_view text, ColourDesired fore) override;
+ std::string_view text, ColourAlpha fore) override;
void MeasureWidthsUTF8(const Font *font_, std::string_view text,
XYPOSITION *positions) override;
XYPOSITION WidthTextUTF8(const Font *font_, std::string_view text) override;
diff --git a/src/Platform.h b/src/Platform.h
index 5fa139189..7a07fb5e7 100644
--- a/src/Platform.h
+++ b/src/Platform.h
@@ -236,15 +236,15 @@ public:
virtual std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) = 0;
- virtual void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) = 0;
- virtual void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) = 0;
- virtual void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) = 0;
+ virtual void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) = 0;
+ virtual void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) = 0;
+ virtual void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) = 0;
virtual void MeasureWidths(const Font *font_, std::string_view text, XYPOSITION *positions) = 0;
virtual XYPOSITION WidthText(const Font *font_, std::string_view text) = 0;
- virtual void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) = 0;
- virtual void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) = 0;
- virtual void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) = 0;
+ virtual void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) = 0;
+ virtual void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) = 0;
+ virtual void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) = 0;
virtual void MeasureWidthsUTF8(const Font *font_, std::string_view text, XYPOSITION *positions) = 0;
virtual XYPOSITION WidthTextUTF8(const Font *font_, std::string_view text) = 0;
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 7d8403b9d..34f4faa49 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -516,16 +516,16 @@ public:
std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
void DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, UINT fuOptions);
- void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidths(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthText(const Font *font_, std::string_view text) override;
void DrawTextCommonUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, UINT fuOptions);
- void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidthsUTF8(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthTextUTF8(const Font *font_, std::string_view text) override;
@@ -760,7 +760,7 @@ void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired
}
void SurfaceGDI::RectangleDraw(PRectangle rc, FillStroke fillStroke) {
- FillRectangle(rc, fillStroke.stroke.colour);
+ RectangleFrame(rc, fillStroke.stroke);
FillRectangle(rc.Inset(fillStroke.stroke.width), fillStroke.fill.colour);
}
@@ -1161,25 +1161,25 @@ void SurfaceGDI::DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION yba
}
void SurfaceGDI::DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
- ::SetTextColor(hdc, fore.AsInteger());
- ::SetBkColor(hdc, back.AsInteger());
+ ColourAlpha fore, ColourAlpha back) {
+ ::SetTextColor(hdc, fore.GetColour().AsInteger());
+ ::SetBkColor(hdc, back.GetColour().AsInteger());
DrawTextCommon(rc, font_, ybase, text, ETO_OPAQUE);
}
void SurfaceGDI::DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
- ::SetTextColor(hdc, fore.AsInteger());
- ::SetBkColor(hdc, back.AsInteger());
+ ColourAlpha fore, ColourAlpha back) {
+ ::SetTextColor(hdc, fore.GetColour().AsInteger());
+ ::SetBkColor(hdc, back.GetColour().AsInteger());
DrawTextCommon(rc, font_, ybase, text, ETO_OPAQUE | ETO_CLIPPED);
}
void SurfaceGDI::DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
// Avoid drawing spaces in transparent mode
for (const char ch : text) {
if (ch != ' ') {
- ::SetTextColor(hdc, fore.AsInteger());
+ ::SetTextColor(hdc, fore.GetColour().AsInteger());
::SetBkMode(hdc, TRANSPARENT);
DrawTextCommon(rc, font_, ybase, text, 0);
::SetBkMode(hdc, OPAQUE);
@@ -1253,25 +1253,25 @@ void SurfaceGDI::DrawTextCommonUTF8(PRectangle rc, const Font *font_, XYPOSITION
}
void SurfaceGDI::DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
- ::SetTextColor(hdc, fore.AsInteger());
- ::SetBkColor(hdc, back.AsInteger());
+ ColourAlpha fore, ColourAlpha back) {
+ ::SetTextColor(hdc, fore.GetColour().AsInteger());
+ ::SetBkColor(hdc, back.GetColour().AsInteger());
DrawTextCommonUTF8(rc, font_, ybase, text, ETO_OPAQUE);
}
void SurfaceGDI::DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
- ::SetTextColor(hdc, fore.AsInteger());
- ::SetBkColor(hdc, back.AsInteger());
+ ColourAlpha fore, ColourAlpha back) {
+ ::SetTextColor(hdc, fore.GetColour().AsInteger());
+ ::SetBkColor(hdc, back.GetColour().AsInteger());
DrawTextCommonUTF8(rc, font_, ybase, text, ETO_OPAQUE | ETO_CLIPPED);
}
void SurfaceGDI::DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
// Avoid drawing spaces in transparent mode
for (const char ch : text) {
if (ch != ' ') {
- ::SetTextColor(hdc, fore.AsInteger());
+ ::SetTextColor(hdc, fore.GetColour().AsInteger());
::SetBkMode(hdc, TRANSPARENT);
DrawTextCommonUTF8(rc, font_, ybase, text, 0);
::SetBkMode(hdc, OPAQUE);
@@ -1497,17 +1497,17 @@ public:
std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
- void DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, UINT fuOptions);
- void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, int codePageDraw, UINT fuOptions);
+
+ void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidths(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthText(const Font *font_, std::string_view text) override;
- void DrawTextCommonUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, UINT fuOptions);
- void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) override;
- void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore, ColourAlpha back) override;
+ void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidthsUTF8(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthTextUTF8(const Font *font_, std::string_view text) override;
@@ -2646,11 +2646,11 @@ std::unique_ptr<IScreenLineLayout> SurfaceD2D::Layout(const IScreenLine *screenL
return std::make_unique<ScreenLineLayout>(screenLine);
}
-void SurfaceD2D::DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, UINT fuOptions) {
+void SurfaceD2D::DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, int codePageDraw, UINT fuOptions) {
SetFont(font_);
// Use Unicode calls
- const TextWide tbuf(text, codePageText);
+ const TextWide tbuf(text, codePageDraw);
if (pRenderTarget && pTextFormat && pBrush) {
if (fuOptions & ETO_CLIPPED) {
const D2D1_RECT_F rcClip = RectangleFromPRectangle(rc);
@@ -2674,31 +2674,31 @@ void SurfaceD2D::DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION yba
}
void SurfaceD2D::DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
if (pRenderTarget) {
FillRectangle(rc, back);
- D2DPenColour(fore);
- DrawTextCommon(rc, font_, ybase, text, ETO_OPAQUE);
+ D2DPenColourAlpha(fore);
+ DrawTextCommon(rc, font_, ybase, text, codePageText, ETO_OPAQUE);
}
}
void SurfaceD2D::DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
if (pRenderTarget) {
FillRectangle(rc, back);
- D2DPenColour(fore);
- DrawTextCommon(rc, font_, ybase, text, ETO_OPAQUE | ETO_CLIPPED);
+ D2DPenColourAlpha(fore);
+ DrawTextCommon(rc, font_, ybase, text, codePageText, ETO_OPAQUE | ETO_CLIPPED);
}
}
void SurfaceD2D::DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
// Avoid drawing spaces in transparent mode
for (const char ch : text) {
if (ch != ' ') {
if (pRenderTarget) {
- D2DPenColour(fore);
- DrawTextCommon(rc, font_, ybase, text, 0);
+ D2DPenColourAlpha(fore);
+ DrawTextCommon(rc, font_, ybase, text, codePageText, 0);
}
return;
}
@@ -2804,59 +2804,32 @@ XYPOSITION SurfaceD2D::WidthText(const Font *font_, std::string_view text) {
return width;
}
-void SurfaceD2D::DrawTextCommonUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, UINT fuOptions) {
- SetFont(font_);
-
- // Use Unicode calls
- const TextWide tbuf(text, SC_CP_UTF8);
- if (pRenderTarget && pTextFormat && pBrush) {
- if (fuOptions & ETO_CLIPPED) {
- D2D1_RECT_F rcClip = { rc.left, rc.top, rc.right, rc.bottom };
- pRenderTarget->PushAxisAlignedClip(rcClip, D2D1_ANTIALIAS_MODE_ALIASED);
- }
-
- // Explicitly creating a text layout appears a little faster
- IDWriteTextLayout *pTextLayout = nullptr;
- const HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat,
- rc.Width(), rc.Height(), &pTextLayout);
- if (SUCCEEDED(hr)) {
- D2D1_POINT_2F origin = {rc.left, ybase-yAscent};
- pRenderTarget->DrawTextLayout(origin, pTextLayout, pBrush, d2dDrawTextOptions);
- ReleaseUnknown(pTextLayout);
- }
-
- if (fuOptions & ETO_CLIPPED) {
- pRenderTarget->PopAxisAlignedClip();
- }
- }
-}
-
void SurfaceD2D::DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
if (pRenderTarget) {
FillRectangle(rc, back);
- D2DPenColour(fore);
- DrawTextCommonUTF8(rc, font_, ybase, text, ETO_OPAQUE);
+ D2DPenColourAlpha(fore);
+ DrawTextCommon(rc, font_, ybase, text, SC_CP_UTF8, ETO_OPAQUE);
}
}
void SurfaceD2D::DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
if (pRenderTarget) {
FillRectangle(rc, back);
- D2DPenColour(fore);
- DrawTextCommonUTF8(rc, font_, ybase, text, ETO_OPAQUE | ETO_CLIPPED);
+ D2DPenColourAlpha(fore);
+ DrawTextCommon(rc, font_, ybase, text, SC_CP_UTF8, ETO_OPAQUE | ETO_CLIPPED);
}
}
void SurfaceD2D::DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
// Avoid drawing spaces in transparent mode
for (const char ch : text) {
if (ch != ' ') {
if (pRenderTarget) {
- D2DPenColour(fore);
- DrawTextCommonUTF8(rc, font_, ybase, text, 0);
+ D2DPenColourAlpha(fore);
+ DrawTextCommon(rc, font_, ybase, text, SC_CP_UTF8, 0);
}
return;
}