aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/PlatCocoa.mm6
-rw-r--r--gtk/PlatGTK.cxx6
-rw-r--r--include/Platform.h79
-rw-r--r--qt/ScintillaEditBase/PlatQt.h2
-rw-r--r--src/Editor.cxx56
-rw-r--r--src/ScintillaBase.cxx6
-rw-r--r--src/ViewStyle.h4
-rw-r--r--src/XPM.cxx29
-rw-r--r--win32/PlatWin.cxx24
9 files changed, 101 insertions, 111 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index bdf0d3997..704645cb6 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -255,7 +255,7 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID
void SurfaceImpl::PenColour(ColourDesired fore) {
if (gc) {
- ColourDesired colour(fore.AsLong());
+ ColourDesired colour(fore.AsInteger());
// Set the Stroke color to match
CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,
@@ -267,7 +267,7 @@ void SurfaceImpl::PenColour(ColourDesired fore) {
void SurfaceImpl::FillColour(const ColourDesired &back) {
if (gc) {
- ColourDesired colour(back.AsLong());
+ ColourDesired colour(back.AsInteger());
// Set the Fill color to match
CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,
@@ -854,7 +854,7 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) {
void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
ColourDesired fore) {
CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_));
- ColourDesired colour(fore.AsLong());
+ ColourDesired colour(fore.AsInteger());
CGColorRef color = CGColorCreateGenericRGB(colour.GetRed()/255.0, colour.GetGreen()/255.0, colour.GetBlue()/255.0, 1.0);
QuartzTextStyle *style = TextStyleFromFont(font_);
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index bb8f7575c..622936877 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -362,7 +362,7 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID
void SurfaceImpl::PenColour(ColourDesired fore) {
if (context) {
- ColourDesired cdFore(fore.AsLong());
+ ColourDesired cdFore(fore.AsInteger());
cairo_set_source_rgb(context,
cdFore.GetRed() / 255.0,
cdFore.GetGreen() / 255.0,
@@ -520,7 +520,7 @@ static void PathRoundRectangle(cairo_t *context, double left, double top, double
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
ColourDesired outline, int alphaOutline, int /*flags*/) {
if (context && rc.Width() > 0) {
- ColourDesired cdFill(fill.AsLong());
+ ColourDesired cdFill(fill.AsInteger());
cairo_set_source_rgba(context,
cdFill.GetRed() / 255.0,
cdFill.GetGreen() / 255.0,
@@ -532,7 +532,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fi
cairo_rectangle(context, rc.left + 1.0, rc.top + 1.0, rc.right - rc.left - 2.0, rc.bottom - rc.top - 2.0);
cairo_fill(context);
- ColourDesired cdOutline(outline.AsLong());
+ ColourDesired cdOutline(outline.AsInteger());
cairo_set_source_rgba(context,
cdOutline.GetRed() / 255.0,
cdOutline.GetGreen() / 255.0,
diff --git a/include/Platform.h b/include/Platform.h
index fdf41e6e7..d020db883 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -75,9 +75,6 @@ namespace Scintilla {
typedef float XYPOSITION;
typedef double XYACCUMULATOR;
-inline int RoundXYPosition(XYPOSITION xyPos) {
- return static_cast<int>(xyPos + 0.5);
-}
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
@@ -99,10 +96,10 @@ public:
XYPOSITION x;
XYPOSITION y;
- constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) {
+ constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) noexcept : x(x_), y(y_) {
}
- static Point FromInts(int x_, int y_) {
+ static Point FromInts(int x_, int y_) noexcept {
return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_));
}
@@ -111,7 +108,7 @@ public:
/**
* A geometric rectangle class.
- * PRectangle is similar to the Win32 RECT.
+ * PRectangle is similar to Win32 RECT.
* PRectangles contain their top and left sides, but not their right and bottom sides.
*/
class PRectangle {
@@ -121,47 +118,47 @@ public:
XYPOSITION right;
XYPOSITION bottom;
- explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
+ constexpr explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) noexcept :
left(left_), top(top_), right(right_), bottom(bottom_) {
}
- static PRectangle FromInts(int left_, int top_, int right_, int bottom_) {
+ static PRectangle FromInts(int left_, int top_, int right_, int bottom_) noexcept {
return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_),
static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_));
}
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
- bool operator==(const PRectangle &rc) const {
+ bool operator==(const PRectangle &rc) const noexcept {
return (rc.left == left) && (rc.right == right) &&
(rc.top == top) && (rc.bottom == bottom);
}
- bool Contains(Point pt) const {
+ bool Contains(Point pt) const noexcept {
return (pt.x >= left) && (pt.x <= right) &&
(pt.y >= top) && (pt.y <= bottom);
}
- bool ContainsWholePixel(Point pt) const {
+ bool ContainsWholePixel(Point pt) const noexcept {
// Does the rectangle contain all of the pixel to left/below the point
return (pt.x >= left) && ((pt.x+1) <= right) &&
(pt.y >= top) && ((pt.y+1) <= bottom);
}
- bool Contains(PRectangle rc) const {
+ bool Contains(PRectangle rc) const noexcept {
return (rc.left >= left) && (rc.right <= right) &&
(rc.top >= top) && (rc.bottom <= bottom);
}
- bool Intersects(PRectangle other) const {
+ bool Intersects(PRectangle other) const noexcept {
return (right > other.left) && (left < other.right) &&
(bottom > other.top) && (top < other.bottom);
}
- void Move(XYPOSITION xDelta, XYPOSITION yDelta) {
+ void Move(XYPOSITION xDelta, XYPOSITION yDelta) noexcept {
left += xDelta;
top += yDelta;
right += xDelta;
bottom += yDelta;
}
- XYPOSITION Width() const { return right - left; }
- XYPOSITION Height() const { return bottom - top; }
- bool Empty() const {
+ XYPOSITION Width() const noexcept { return right - left; }
+ XYPOSITION Height() const noexcept { return bottom - top; }
+ bool Empty() const noexcept {
return (Height() <= 0) || (Width() <= 0);
}
};
@@ -170,62 +167,32 @@ public:
* Holds a desired RGB colour.
*/
class ColourDesired {
- long co;
+ int co;
public:
- ColourDesired(long lcol=0) {
- co = lcol;
+ ColourDesired(int co_=0) noexcept : co(co_) {
}
- ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
- Set(red, green, blue);
+ ColourDesired(unsigned int red, unsigned int green, unsigned int blue) noexcept :
+ co(red | (green << 8) | (blue << 16)) {
}
- bool operator==(const ColourDesired &other) const {
+ bool operator==(const ColourDesired &other) const noexcept {
return co == other.co;
}
- void Set(long lcol) {
- co = lcol;
- }
-
- void Set(unsigned int red, unsigned int green, unsigned int blue) {
- co = red | (green << 8) | (blue << 16);
- }
-
- static inline unsigned int ValueOfHex(const char ch) {
- if (ch >= '0' && ch <= '9')
- return ch - '0';
- else if (ch >= 'A' && ch <= 'F')
- return ch - 'A' + 10;
- else if (ch >= 'a' && ch <= 'f')
- return ch - 'a' + 10;
- else
- return 0;
- }
-
- void Set(const char *val) {
- if (*val == '#') {
- val++;
- }
- unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]);
- unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]);
- unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]);
- Set(r, g, b);
- }
-
- long AsLong() const {
+ int AsInteger() const noexcept {
return co;
}
- unsigned char GetRed() const {
+ unsigned char GetRed() const noexcept {
return co & 0xff;
}
- unsigned char GetGreen() const {
+ unsigned char GetGreen() const noexcept {
return (co >> 8) & 0xff;
}
- unsigned char GetBlue() const {
+ unsigned char GetBlue() const noexcept {
return (co >> 16) & 0xff;
}
};
diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h
index 95a84eaf8..00a9645ef 100644
--- a/qt/ScintillaEditBase/PlatQt.h
+++ b/qt/ScintillaEditBase/PlatQt.h
@@ -26,7 +26,7 @@ const char *CharacterSetID(int characterSet);
inline QColor QColorFromCA(ColourDesired ca)
{
- long c = ca.AsLong();
+ long c = ca.AsInteger();
return QColor(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
}
diff --git a/src/Editor.cxx b/src/Editor.cxx
index c89f3b6b8..80cdbc97a 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5593,10 +5593,10 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
vs.EnsureStyle(wParam);
switch (iMessage) {
case SCI_STYLESETFORE:
- vs.styles[wParam].fore = ColourDesired(static_cast<long>(lParam));
+ vs.styles[wParam].fore = ColourDesired(static_cast<int>(lParam));
break;
case SCI_STYLESETBACK:
- vs.styles[wParam].back = ColourDesired(static_cast<long>(lParam));
+ vs.styles[wParam].back = ColourDesired(static_cast<int>(lParam));
break;
case SCI_STYLESETBOLD:
vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL;
@@ -5648,9 +5648,9 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar
vs.EnsureStyle(wParam);
switch (iMessage) {
case SCI_STYLEGETFORE:
- return vs.styles[wParam].fore.AsLong();
+ return vs.styles[wParam].fore.AsInteger();
case SCI_STYLEGETBACK:
- return vs.styles[wParam].back.AsLong();
+ return vs.styles[wParam].back.AsInteger();
case SCI_STYLEGETBOLD:
return vs.styles[wParam].weight > SC_WEIGHT_NORMAL;
case SCI_STYLEGETWEIGHT:
@@ -6790,13 +6790,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_MARKERSETFORE:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].fore = ColourDesired(static_cast<long>(lParam));
+ vs.markers[wParam].fore = ColourDesired(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_MARKERSETBACKSELECTED:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].backSelected = ColourDesired(static_cast<long>(lParam));
+ vs.markers[wParam].backSelected = ColourDesired(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
@@ -6806,7 +6806,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_MARKERSETBACK:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].back = ColourDesired(static_cast<long>(lParam));
+ vs.markers[wParam].back = ColourDesired(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
@@ -6945,14 +6945,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETMARGINBACKN:
if (ValidMargin(wParam)) {
- vs.ms[wParam].back = ColourDesired(static_cast<long>(lParam));
+ vs.ms[wParam].back = ColourDesired(static_cast<int>(lParam));
InvalidateStyleRedraw();
}
break;
case SCI_GETMARGINBACKN:
if (ValidMargin(wParam))
- return vs.ms[wParam].back.AsLong();
+ return vs.ms[wParam].back.AsInteger();
else
return 0;
@@ -7047,9 +7047,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleRedraw();
break;
case SCI_GETCARETLINEBACK:
- return vs.caretLineBackground.AsLong();
+ return vs.caretLineBackground.AsInteger();
case SCI_SETCARETLINEBACK:
- vs.caretLineBackground = ColourDesired(static_cast<long>(wParam));
+ vs.caretLineBackground = ColourDesired(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
case SCI_GETCARETLINEBACKALPHA:
@@ -7197,13 +7197,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETSELFORE:
vs.selColours.fore = ColourOptional(wParam, lParam);
- vs.selAdditionalForeground = ColourDesired(static_cast<long>(lParam));
+ vs.selAdditionalForeground = ColourDesired(static_cast<int>(lParam));
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
vs.selColours.back = ColourOptional(wParam, lParam);
- vs.selAdditionalBackground = ColourDesired(static_cast<long>(lParam));
+ vs.selAdditionalBackground = ColourDesired(static_cast<int>(lParam));
InvalidateStyleRedraw();
break;
@@ -7235,12 +7235,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETCARETFORE:
- vs.caretcolour = ColourDesired(static_cast<long>(wParam));
+ vs.caretcolour = ColourDesired(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
case SCI_GETCARETFORE:
- return vs.caretcolour.AsLong();
+ return vs.caretcolour.AsInteger();
case SCI_SETCARETSTYLE:
if (wParam <= CARETSTYLE_BLOCK)
@@ -7289,14 +7289,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].sacNormal.fore = ColourDesired(static_cast<long>(lParam));
- vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
+ vs.indicators[wParam].sacNormal.fore = ColourDesired(static_cast<int>(lParam));
+ vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<int>(lParam));
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETFORE:
- return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.fore.AsLong() : 0;
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.fore.AsInteger() : 0;
case SCI_INDICSETHOVERSTYLE:
if (wParam <= INDIC_MAX) {
@@ -7310,13 +7310,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETHOVERFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<long>(lParam));
+ vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast<int>(lParam));
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETHOVERFORE:
- return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsLong() : 0;
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsInteger() : 0;
case SCI_INDICSETFLAGS:
if (wParam <= INDIC_MAX) {
@@ -7547,10 +7547,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETEDGECOLOUR:
- return vs.theEdge.colour.AsLong();
+ return vs.theEdge.colour.AsInteger();
case SCI_SETEDGECOLOUR:
- vs.theEdge.colour = ColourDesired(static_cast<long>(wParam));
+ vs.theEdge.colour = ColourDesired(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
@@ -7782,7 +7782,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETHOTSPOTACTIVEFORE:
- return vs.hotspotColours.fore.AsLong();
+ return vs.hotspotColours.fore.AsInteger();
case SCI_SETHOTSPOTACTIVEBACK:
vs.hotspotColours.back = ColourOptional(wParam, lParam);
@@ -7790,7 +7790,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETHOTSPOTACTIVEBACK:
- return vs.hotspotColours.back.AsLong();
+ return vs.hotspotColours.back.AsInteger();
case SCI_SETHOTSPOTACTIVEUNDERLINE:
vs.hotspotUnderline = wParam != 0;
@@ -8114,12 +8114,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return virtualSpaceOptions;
case SCI_SETADDITIONALSELFORE:
- vs.selAdditionalForeground = ColourDesired(static_cast<long>(wParam));
+ vs.selAdditionalForeground = ColourDesired(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
case SCI_SETADDITIONALSELBACK:
- vs.selAdditionalBackground = ColourDesired(static_cast<long>(wParam));
+ vs.selAdditionalBackground = ColourDesired(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
@@ -8132,12 +8132,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.selAdditionalAlpha;
case SCI_SETADDITIONALCARETFORE:
- vs.additionalCaretColour = ColourDesired(static_cast<long>(wParam));
+ vs.additionalCaretColour = ColourDesired(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
case SCI_GETADDITIONALCARETFORE:
- return vs.additionalCaretColour.AsLong();
+ return vs.additionalCaretColour.AsInteger();
case SCI_ROTATESELECTION:
sel.RotateMain();
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 71f42d856..824bcdfeb 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -1013,19 +1013,19 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
break;
case SCI_CALLTIPSETBACK:
- ct.colourBG = ColourDesired(static_cast<long>(wParam));
+ ct.colourBG = ColourDesired(static_cast<int>(wParam));
vs.styles[STYLE_CALLTIP].back = ct.colourBG;
InvalidateStyleRedraw();
break;
case SCI_CALLTIPSETFORE:
- ct.colourUnSel = ColourDesired(static_cast<long>(wParam));
+ ct.colourUnSel = ColourDesired(static_cast<int>(wParam));
vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel;
InvalidateStyleRedraw();
break;
case SCI_CALLTIPSETFOREHLT:
- ct.colourSel = ColourDesired(static_cast<long>(wParam));
+ ct.colourSel = ColourDesired(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 2a4e7329a..800d8cb67 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -68,7 +68,7 @@ public:
bool isSet;
ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) : ColourDesired(colour_), isSet(isSet_) {
}
- ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(static_cast<long>(lParam)), isSet(wParam != 0) {
+ ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(static_cast<int>(lParam)), isSet(wParam != 0) {
}
};
@@ -84,7 +84,7 @@ struct EdgeProperties {
column(column_), colour(colour_) {
}
EdgeProperties(uptr_t wParam, sptr_t lParam) :
- column(static_cast<int>(wParam)), colour(static_cast<long>(lParam)) {
+ column(static_cast<int>(wParam)), colour(static_cast<int>(lParam)) {
}
};
diff --git a/src/XPM.cxx b/src/XPM.cxx
index 65099a8b3..0d4a2a068 100644
--- a/src/XPM.cxx
+++ b/src/XPM.cxx
@@ -22,7 +22,9 @@
using namespace Scintilla;
-static const char *NextField(const char *s) {
+namespace {
+
+const char *NextField(const char *s) {
// In case there are leading spaces in the string
while (*s == ' ') {
s++;
@@ -37,13 +39,34 @@ static const char *NextField(const char *s) {
}
// Data lines in XPM can be terminated either with NUL or "
-static size_t MeasureLength(const char *s) {
+size_t MeasureLength(const char *s) {
size_t i = 0;
while (s[i] && (s[i] != '\"'))
i++;
return i;
}
+unsigned int ValueOfHex(const char ch) noexcept {
+ if (ch >= '0' && ch <= '9')
+ return ch - '0';
+ else if (ch >= 'A' && ch <= 'F')
+ return ch - 'A' + 10;
+ else if (ch >= 'a' && ch <= 'f')
+ return ch - 'a' + 10;
+ else
+ return 0;
+}
+
+ColourDesired ColourFromHex(const char *val) noexcept {
+ unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]);
+ unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]);
+ unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]);
+ return ColourDesired(r, g, b);
+}
+
+}
+
+
ColourDesired XPM::ColourFromCode(int ch) const {
return colourCodeTable[ch];
}
@@ -110,7 +133,7 @@ void XPM::Init(const char *const *linesForm) {
colourDef += 4;
ColourDesired colour(0xff, 0xff, 0xff);
if (*colourDef == '#') {
- colour.Set(colourDef);
+ colour = ColourFromHex(colourDef+1);
} else {
codeTransparent = code;
}
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 43b27cf7b..4c57fd133 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -675,7 +675,7 @@ void SurfaceGDI::PenColour(ColourDesired fore) {
pen = 0;
penOld = 0;
}
- pen = ::CreatePen(0,1,fore.AsLong());
+ pen = ::CreatePen(0,1,fore.AsInteger());
penOld = static_cast<HPEN>(::SelectObject(hdc, pen));
}
@@ -687,8 +687,8 @@ void SurfaceGDI::BrushColor(ColourDesired back) {
brushOld = 0;
}
// Only ever want pure, non-dithered brushes
- const ColourDesired colourNearest = ColourDesired(::GetNearestColor(hdc, back.AsLong()));
- brush = ::CreateSolidBrush(colourNearest.AsLong());
+ const ColourDesired colourNearest = ColourDesired(::GetNearestColor(hdc, back.AsInteger()));
+ brush = ::CreateSolidBrush(colourNearest.AsInteger());
brushOld = SelectBrush(hdc, brush);
}
void SurfaceGDI::SetFont(Font &font_) {
@@ -742,7 +742,7 @@ void SurfaceGDI::FillRectangle(PRectangle rc, ColourDesired back) {
// Using ExtTextOut rather than a FillRect ensures that no dithering occurs.
// There is no need to allocate a brush either.
const RECT rcw = RectFromPRectangle(rc);
- ::SetBkColor(hdc, back.AsLong());
+ ::SetBkColor(hdc, back.AsInteger());
::ExtTextOut(hdc, rcw.left, rcw.top, ETO_OPAQUE, &rcw, TEXT(""), 0, NULL);
}
@@ -930,15 +930,15 @@ void SurfaceGDI::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, co
void SurfaceGDI::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
ColourDesired fore, ColourDesired back) {
- ::SetTextColor(hdc, fore.AsLong());
- ::SetBkColor(hdc, back.AsLong());
+ ::SetTextColor(hdc, fore.AsInteger());
+ ::SetBkColor(hdc, back.AsInteger());
DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE);
}
void SurfaceGDI::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
ColourDesired fore, ColourDesired back) {
- ::SetTextColor(hdc, fore.AsLong());
- ::SetBkColor(hdc, back.AsLong());
+ ::SetTextColor(hdc, fore.AsInteger());
+ ::SetBkColor(hdc, back.AsInteger());
DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE | ETO_CLIPPED);
}
@@ -947,7 +947,7 @@ void SurfaceGDI::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybas
// Avoid drawing spaces in transparent mode
for (int i=0; i<len; i++) {
if (s[i] != ' ') {
- ::SetTextColor(hdc, fore.AsLong());
+ ::SetTextColor(hdc, fore.AsInteger());
::SetBkMode(hdc, TRANSPARENT);
DrawTextCommon(rc, font_, ybase, s, len, 0);
::SetBkMode(hdc, OPAQUE);
@@ -1261,9 +1261,9 @@ void SurfaceD2D::PenColour(ColourDesired fore) {
void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) {
if (pRenderTarget) {
D2D_COLOR_F col;
- col.r = (fore.AsLong() & 0xff) / 255.0f;
- col.g = ((fore.AsLong() & 0xff00) >> 8) / 255.0f;
- col.b = (fore.AsLong() >> 16) / 255.0f;
+ col.r = (fore.AsInteger() & 0xff) / 255.0f;
+ col.g = ((fore.AsInteger() & 0xff00) >> 8) / 255.0f;
+ col.b = (fore.AsInteger() >> 16) / 255.0f;
col.a = alpha / 255.0f;
if (pBrush) {
pBrush->SetColor(col);