summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/makefile.deps.mak3
-rw-r--r--scintilla/include/Platform.h185
-rw-r--r--scintilla/include/Scintilla.h16
-rw-r--r--scintilla/include/Scintilla.iface44
-rw-r--r--scintilla/src/AutoComplete.cxx4
-rw-r--r--scintilla/src/AutoComplete.h2
-rw-r--r--scintilla/src/CallTip.cxx48
-rw-r--r--scintilla/src/CallTip.h17
-rw-r--r--scintilla/src/Document.cxx4
-rw-r--r--scintilla/src/Document.h1
-rw-r--r--scintilla/src/Editor.cxx387
-rw-r--r--scintilla/src/Editor.h22
-rw-r--r--scintilla/src/FontQuality.h3
-rw-r--r--scintilla/src/Indicator.cxx10
-rw-r--r--scintilla/src/Indicator.h2
-rw-r--r--scintilla/src/LineMarker.cxx127
-rw-r--r--scintilla/src/LineMarker.h7
-rw-r--r--scintilla/src/PerLine.cxx11
-rw-r--r--scintilla/src/PerLine.h1
-rw-r--r--scintilla/src/PositionCache.cxx14
-rw-r--r--scintilla/src/PositionCache.h10
-rw-r--r--scintilla/src/ScintillaBase.cxx8
-rw-r--r--scintilla/src/ScintillaBase.h2
-rw-r--r--scintilla/src/Style.cxx36
-rw-r--r--scintilla/src/Style.h12
-rw-r--r--scintilla/src/ViewStyle.cxx137
-rw-r--r--scintilla/src/ViewStyle.h38
-rw-r--r--scintilla/src/XPM.cxx32
-rw-r--r--scintilla/src/XPM.h10
-rw-r--r--scintilla/win32/PlatWin.cxx1366
-rw-r--r--scintilla/win32/PlatWin.h16
-rw-r--r--scintilla/win32/ScintillaWin.cxx237
-rw-r--r--src/Notepad2.vcxproj1
-rw-r--r--src/Notepad2.vcxproj.filters3
-rw-r--r--src/Notepad2_icl12.vcxproj1
-rw-r--r--src/Notepad2_icl12.vcxproj.filters3
36 files changed, 1840 insertions, 980 deletions
diff --git a/build/makefile.deps.mak b/build/makefile.deps.mak
index ae505e7..d43b958 100644
--- a/build/makefile.deps.mak
+++ b/build/makefile.deps.mak
@@ -382,7 +382,8 @@ $(SCI_WIN_OBJDIR)\ScintillaWin.obj: \
$(SCI_SRC)\Editor.h \
$(SCI_SRC)\ScintillaBase.h \
$(SCI_SRC)\Selection.h \
- $(SCI_SRC)\UniConversion.h
+ $(SCI_SRC)\UniConversion.h \
+ $(SCI_WIN)\PlatWin.h
###########
diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h
index 99a2302..46c3642 100644
--- a/scintilla/include/Platform.h
+++ b/scintilla/include/Platform.h
@@ -59,6 +59,10 @@
namespace Scintilla {
#endif
+typedef float XYPOSITION;
+typedef double XYACCUMULATOR;
+//#define XYPOSITION int
+
// 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
@@ -76,10 +80,10 @@ typedef void *IdlerID;
*/
class Point {
public:
- int x;
- int y;
+ XYPOSITION x;
+ XYPOSITION y;
- explicit Point(int x_=0, int y_=0) : x(x_), y(y_) {
+ explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) {
}
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
@@ -94,12 +98,12 @@ public:
*/
class PRectangle {
public:
- int left;
- int top;
- int right;
- int bottom;
+ XYPOSITION left;
+ XYPOSITION top;
+ XYPOSITION right;
+ XYPOSITION bottom;
- PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) :
+ PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
left(left_), top(top_), right(right_), bottom(bottom_) {
}
@@ -121,32 +125,20 @@ public:
return (right > other.left) && (left < other.right) &&
(bottom > other.top) && (top < other.bottom);
}
- void Move(int xDelta, int yDelta) {
+ void Move(XYPOSITION xDelta, XYPOSITION yDelta) {
left += xDelta;
top += yDelta;
right += xDelta;
bottom += yDelta;
}
- int Width() { return right - left; }
- int Height() { return bottom - top; }
+ XYPOSITION Width() { return right - left; }
+ XYPOSITION Height() { return bottom - top; }
bool Empty() {
return (Height() <= 0) || (Width() <= 0);
}
};
/**
- * In some circumstances, including Win32 in paletted mode and GTK+, each colour
- * must be allocated before use. The desired colours are held in the ColourDesired class,
- * and after allocation the allocation entry is stored in the ColourAllocated class. In other
- * circumstances, such as Win32 in true colour mode, the allocation process just copies
- * the RGB values from the desired to the allocated class.
- * As each desired colour requires allocation before it can be used, the ColourPair class
- * holds both a ColourDesired and a ColourAllocated
- * The Palette class is responsible for managing the palette of colours which contains a
- * list of ColourPair objects and performs the allocation.
- */
-
-/**
* Holds a desired RGB colour.
*/
class ColourDesired {
@@ -211,82 +203,39 @@ public:
};
/**
- * Holds an allocated RGB colour which may be an approximation to the desired colour.
- */
-class ColourAllocated {
- long coAllocated;
-
-public:
-
- ColourAllocated(long lcol=0) {
- coAllocated = lcol;
- }
-
- void Set(long lcol) {
- coAllocated = lcol;
- }
-
- long AsLong() const {
- return coAllocated;
- }
-};
-
-/**
- * Colour pairs hold a desired colour and an allocated colour.
+ * Font management.
*/
-struct ColourPair {
- ColourDesired desired;
- ColourAllocated allocated;
- ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
- desired = desired_;
- allocated.Set(desired.AsLong());
- }
- void Copy() {
- allocated.Set(desired.AsLong());
+struct FontParameters {
+ const char *faceName;
+ float size;
+ int weight;
+ bool italic;
+ int extraFontFlag;
+ int technology;
+ int characterSet;
+
+ FontParameters(
+ const char *faceName_,
+ float size_=10,
+ int weight_=400,
+ bool italic_=false,
+ int extraFontFlag_=0,
+ int technology_=0,
+ int characterSet_=0) :
+
+ faceName(faceName_),
+ size(size_),
+ weight(weight_),
+ italic(italic_),
+ extraFontFlag(extraFontFlag_),
+ technology(technology_),
+ characterSet(characterSet_)
+ {
}
-};
-class Window; // Forward declaration for Palette
-
-/**
- * Colour palette management.
- */
-class Palette {
- int used;
- int size;
- ColourPair *entries;
-#if PLAT_GTK
- void *allocatedPalette; // GdkColor *
- int allocatedLen;
-#endif
- // Private so Palette objects can not be copied
- Palette(const Palette &);
- Palette &operator=(const Palette &);
-public:
-#if PLAT_WIN
- void *hpal;
-#endif
- bool allowRealization;
-
- Palette();
- ~Palette();
-
- void Release();
-
- /**
- * This method either adds a colour to the list of wanted colours (want==true)
- * or retrieves the allocated colour back to the ColourPair.
- * This is one method to make it easier to keep the code for wanting and retrieving in sync.
- */
- void WantFind(ColourPair &cp, bool want);
-
- void Allocate(Window &w);
};
-/**
- * Font management.
- */
class Font {
protected:
FontID fid;
@@ -300,8 +249,7 @@ public:
Font();
virtual ~Font();
- virtual void Create(const char *faceName, int characterSet, int size,
- bool bold, bool italic, int extraFontFlag=0);
+ virtual void Create(const FontParameters &fp);
virtual void Release();
FontID GetID() { return fid; }
@@ -325,7 +273,7 @@ private:
public:
Surface() {}
virtual ~Surface() {}
- static Surface *Allocate();
+ static Surface *Allocate(int technology);
virtual void Init(WindowID wid)=0;
virtual void Init(SurfaceID sid, WindowID wid)=0;
@@ -333,36 +281,35 @@ public:
virtual void Release()=0;
virtual bool Initialised()=0;
- virtual void PenColour(ColourAllocated fore)=0;
+ virtual void PenColour(ColourDesired fore)=0;
virtual int LogPixelsY()=0;
virtual int DeviceHeightFont(int points)=0;
virtual void MoveTo(int x_, int y_)=0;
virtual void LineTo(int x_, int y_)=0;
- virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
- virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
- virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
+ virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back)=0;
+ virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
+ virtual void FillRectangle(PRectangle rc, ColourDesired back)=0;
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
- virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
- virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
- ColourAllocated outline, int alphaOutline, int flags)=0;
+ virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
+ virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+ ColourDesired outline, int alphaOutline, int flags)=0;
virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0;
- virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
+ virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
- virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
- virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
- virtual void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore)=0;
- virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
- virtual int WidthText(Font &font_, const char *s, int len)=0;
- virtual int WidthChar(Font &font_, char ch)=0;
- virtual int Ascent(Font &font_)=0;
- virtual int Descent(Font &font_)=0;
- virtual int InternalLeading(Font &font_)=0;
- virtual int ExternalLeading(Font &font_)=0;
- virtual int Height(Font &font_)=0;
- virtual int AverageCharWidth(Font &font_)=0;
-
- virtual int SetPalette(Palette *pal, bool inBackGround)=0;
+ virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
+ virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
+ virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore)=0;
+ virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0;
+ virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0;
+ virtual XYPOSITION WidthChar(Font &font_, char ch)=0;
+ virtual XYPOSITION Ascent(Font &font_)=0;
+ virtual XYPOSITION Descent(Font &font_)=0;
+ virtual XYPOSITION InternalLeading(Font &font_)=0;
+ virtual XYPOSITION ExternalLeading(Font &font_)=0;
+ virtual XYPOSITION Height(Font &font_)=0;
+ virtual XYPOSITION AverageCharWidth(Font &font_)=0;
+
virtual void SetClip(PRectangle rc)=0;
virtual void FlushCachedState()=0;
@@ -439,7 +386,7 @@ public:
static ListBox *Allocate();
virtual void SetFont(Font &font)=0;
- virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_)=0;
+ virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0;
virtual void SetAverageCharWidth(int width)=0;
virtual void SetVisibleRows(int rows)=0;
virtual int GetVisibleRows() const=0;
diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h
index 3de254d..8355551 100644
--- a/scintilla/include/Scintilla.h
+++ b/scintilla/include/Scintilla.h
@@ -92,7 +92,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETTABWIDTH 2121
#define SC_CP_UTF8 65001
#define SCI_SETCODEPAGE 2037
-#define SCI_SETUSEPALETTE 2039
#define MARKER_MAX 31
#define SC_MARK_CIRCLE 0
#define SC_MARK_ROUNDRECT 1
@@ -221,6 +220,14 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_STYLEGETCHANGEABLE 2492
#define SCI_STYLEGETHOTSPOT 2493
#define SCI_STYLESETCASE 2060
+#define SC_FONT_SIZE_MULTIPLIER 100
+#define SCI_STYLESETSIZEFRACTIONAL 2061
+#define SCI_STYLEGETSIZEFRACTIONAL 2062
+#define SC_WEIGHT_NORMAL 400
+#define SC_WEIGHT_SEMIBOLD 600
+#define SC_WEIGHT_BOLD 700
+#define SCI_STYLESETWEIGHT 2063
+#define SCI_STYLEGETWEIGHT 2064
#define SCI_STYLESETCHARACTERSET 2066
#define SCI_STYLESETHOTSPOT 2409
#define SCI_SETSELFORE 2067
@@ -329,7 +336,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETLINEENDPOSITION 2136
#define SCI_GETCODEPAGE 2137
#define SCI_GETCARETFORE 2138
-#define SCI_GETUSEPALETTE 2139
#define SCI_GETREADONLY 2140
#define SCI_SETCURRENTPOS 2141
#define SCI_SETSELECTIONSTART 2142
@@ -820,6 +826,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_REGISTERRGBAIMAGE 2627
#define SCI_SCROLLTOSTART 2628
#define SCI_SCROLLTOEND 2629
+#define SC_TECHNOLOGY_DEFAULT 0
+#define SC_TECHNOLOGY_DIRECTWRITE 1
+#define SCI_SETTECHNOLOGY 2630
+#define SCI_GETTECHNOLOGY 2631
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
@@ -1029,6 +1039,8 @@ struct SCNotification {
#ifdef INCLUDE_DEPRECATED_FEATURES
#define SC_CP_DBCS 1
+#define SCI_SETUSEPALETTE 2039
+#define SCI_GETUSEPALETTE 2139
#endif
diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface
index 1018229..3c2741c 100644
--- a/scintilla/include/Scintilla.iface
+++ b/scintilla/include/Scintilla.iface
@@ -228,10 +228,6 @@ val SC_CP_UTF8=65001
# The SC_CP_UTF8 value can be used to enter Unicode mode.
set void SetCodePage=2037(int codePage,)
-# In palette mode, Scintilla uses the environment's palette calls to display
-# more colours. This may lead to ugly displays.
-set void SetUsePalette=2039(bool usePalette,)
-
enu MarkerSymbol=SC_MARK_
val MARKER_MAX=31
val SC_MARK_CIRCLE=0
@@ -482,6 +478,25 @@ get bool StyleGetHotSpot=2493(int style,)
# Set a style to be mixed case, or to force upper or lower case.
set void StyleSetCase=2060(int style, int caseForce)
+val SC_FONT_SIZE_MULTIPLIER=100
+
+# Set the size of characters of a style. Size is in points multiplied by 100.
+set void StyleSetSizeFractional=2061(int style, int caseForce)
+
+# Get the size of characters of a style in points multiplied by 100
+get int StyleGetSizeFractional=2062(int style,)
+
+enu FontWeight=SC_WEIGHT_
+val SC_WEIGHT_NORMAL=400
+val SC_WEIGHT_SEMIBOLD=600
+val SC_WEIGHT_BOLD=700
+
+# Set the weight of characters of a style.
+set void StyleSetWeight=2063(int style, int weight)
+
+# Get the weight of characters of a style.
+get int StyleGetWeight=2064(int style,)
+
# Set the character set of the font in a style.
set void StyleSetCharacterSet=2066(int style, int characterSet)
@@ -782,9 +797,6 @@ get int GetCodePage=2137(,)
# Get the foreground colour of the caret.
get colour GetCaretFore=2138(,)
-# In palette mode?
-get bool GetUsePalette=2139(,)
-
# In read-only mode?
get bool GetReadOnly=2140(,)
@@ -2178,6 +2190,15 @@ fun void ScrollToStart=2628(,)
# Scroll to end of document.
fun void ScrollToEnd=2629(,)
+val SC_TECHNOLOGY_DEFAULT=0
+val SC_TECHNOLOGY_DIRECTWRITE=1
+
+# Set the technolgy used.
+set void SetTechnology=2630(int technology,)
+
+# Get the tech.
+get int GetTechnology=2631(,)
+
# Start notifying the container of all key presses and commands.
fun void StartRecord=3001(,)
@@ -4037,3 +4058,12 @@ cat Deprecated
# Deprecated in 2.21
# The SC_CP_DBCS value can be used to indicate a DBCS mode for GTK+.
val SC_CP_DBCS=1
+
+# Deprecated in 2.30
+
+# In palette mode?
+get bool GetUsePalette=2139(,)
+
+# In palette mode, Scintilla uses the environment's palette calls to display
+# more colours. This may lead to ugly displays.
+set void SetUsePalette=2039(bool usePalette,)
diff --git a/scintilla/src/AutoComplete.cxx b/scintilla/src/AutoComplete.cxx
index dbab356..5fef9d6 100644
--- a/scintilla/src/AutoComplete.cxx
+++ b/scintilla/src/AutoComplete.cxx
@@ -50,11 +50,11 @@ bool AutoComplete::Active() const {
void AutoComplete::Start(Window &parent, int ctrlID,
int position, Point location, int startLen_,
- int lineHeight, bool unicodeMode) {
+ int lineHeight, bool unicodeMode, int technology) {
if (active) {
Cancel();
}
- lb->Create(parent, ctrlID, location, lineHeight, unicodeMode);
+ lb->Create(parent, ctrlID, location, lineHeight, unicodeMode, technology);
lb->Clear();
active = true;
startLen = startLen_;
diff --git a/scintilla/src/AutoComplete.h b/scintilla/src/AutoComplete.h
index 258a9f5..068aabe 100644
--- a/scintilla/src/AutoComplete.h
+++ b/scintilla/src/AutoComplete.h
@@ -40,7 +40,7 @@ public:
/// Display the auto completion list positioned to be near a character position
void Start(Window &parent, int ctrlID, int position, Point location,
- int startLen_, int lineHeight, bool unicodeMode);
+ int startLen_, int lineHeight, bool unicodeMode, int technology);
/// The stop chars are characters which, when typed, cause the auto completion list to disappear
void SetStopChars(const char *stopChars_);
diff --git a/scintilla/src/CallTip.cxx b/scintilla/src/CallTip.cxx
index 5937501..04c93b0 100644
--- a/scintilla/src/CallTip.cxx
+++ b/scintilla/src/CallTip.cxx
@@ -37,15 +37,15 @@ CallTip::CallTip() {
#ifdef __APPLE__
// proper apple colours for the default
- colourBG.desired = ColourDesired(0xff, 0xff, 0xc6);
- colourUnSel.desired = ColourDesired(0, 0, 0);
+ colourBG = ColourDesired(0xff, 0xff, 0xc6);
+ colourUnSel = ColourDesired(0, 0, 0);
#else
- colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
- colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
+ colourBG = ColourDesired(0xff, 0xff, 0xff);
+ colourUnSel = ColourDesired(0x80, 0x80, 0x80);
#endif
- colourSel.desired = ColourDesired(0, 0, 0x80);
- colourShade.desired = ColourDesired(0, 0, 0);
- colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+ colourSel = ColourDesired(0, 0, 0x80);
+ colourShade = ColourDesired(0, 0, 0);
+ colourLight = ColourDesired(0xc0, 0xc0, 0xc0);
codePage = 0;
clickPlace = 0;
}
@@ -57,14 +57,6 @@ CallTip::~CallTip() {
val = 0;
}
-void CallTip::RefreshColourPalette(Palette &pal, bool want) {
- pal.WantFind(colourBG, want);
- pal.WantFind(colourUnSel, want);
- pal.WantFind(colourSel, want);
- pal.WantFind(colourShade, want);
- pal.WantFind(colourLight, want);
-}
-
// Although this test includes 0, we should never see a \0 character.
static bool IsArrowCharacter(char ch) {
return (ch == 0) || (ch == '\001') || (ch == '\002');
@@ -120,10 +112,10 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
const int halfWidth = widthArrow / 2 - 3;
const int centreX = rcClient.left + widthArrow / 2 - 1;
const int centreY = (rcClient.top + rcClient.bottom) / 2;
- surface->FillRectangle(rcClient, colourBG.allocated);
+ surface->FillRectangle(rcClient, colourBG);
PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1,
rcClient.right - 2, rcClient.bottom - 1);
- surface->FillRectangle(rcClientInner, colourUnSel.allocated);
+ surface->FillRectangle(rcClientInner, colourUnSel);
if (upArrow) { // Up arrow
Point pts[] = {
@@ -132,7 +124,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
Point(centreX, centreY - halfWidth + halfWidth / 2),
};
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
- colourBG.allocated, colourBG.allocated);
+ colourBG, colourBG);
} else { // Down arrow
Point pts[] = {
Point(centreX - halfWidth, centreY - halfWidth / 2),
@@ -140,7 +132,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
Point(centreX, centreY + halfWidth - halfWidth / 2),
};
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
- colourBG.allocated, colourBG.allocated);
+ colourBG, colourBG);
}
}
xEnd = rcClient.right;
@@ -159,7 +151,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
rcClient.right = xEnd;
surface->DrawTextTransparent(rcClient, font, ytext,
s+startSeg, endSeg - startSeg,
- highlight ? colourSel.allocated : colourUnSel.allocated);
+ highlight ? colourSel : colourUnSel);
}
}
x = xEnd;
@@ -227,7 +219,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
rcClientPos.bottom - rcClientPos.top);
PRectangle rcClient(1, 1, rcClientSize.right - 1, rcClientSize.bottom - 1);
- surfaceWindow->FillRectangle(rcClient, colourBG.allocated);
+ surfaceWindow->FillRectangle(rcClient, colourBG);
offsetMain = insetX; // initial alignment assuming no arrows
PaintContents(surfaceWindow, true);
@@ -236,10 +228,10 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
// OSX doesn't put borders on "help tags"
// Draw a raised border around the edges of the window
surfaceWindow->MoveTo(0, rcClientSize.bottom - 1);
- surfaceWindow->PenColour(colourShade.allocated);
+ surfaceWindow->PenColour(colourShade);
surfaceWindow->LineTo(rcClientSize.right - 1, rcClientSize.bottom - 1);
surfaceWindow->LineTo(rcClientSize.right - 1, 0);
- surfaceWindow->PenColour(colourLight.allocated);
+ surfaceWindow->PenColour(colourLight);
surfaceWindow->LineTo(0, 0);
surfaceWindow->LineTo(0, rcClientSize.bottom - 1);
#endif
@@ -255,14 +247,15 @@ void CallTip::MouseClick(Point pt) {
PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size,
- int codePage_, int characterSet, Window &wParent) {
+ int codePage_, int characterSet,
+ int technology, Window &wParent) {
clickPlace = 0;
delete []val;
val = 0;
val = new char[strlen(defn) + 1];
strcpy(val, defn);
codePage = codePage_;
- Surface *surfaceMeasure = Surface::Allocate();
+ Surface *surfaceMeasure = Surface::Allocate(technology);
if (!surfaceMeasure)
return PRectangle();
surfaceMeasure->Init(wParent.GetID());
@@ -273,7 +266,8 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
inCallTipMode = true;
posStartCallTip = pos;
int deviceHeight = surfaceMeasure->DeviceHeightFont(size);
- font.Create(faceName, characterSet, deviceHeight, false, false);
+ FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
+ font.Create(fp);
// Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r!
int numLines = 1;
@@ -324,7 +318,7 @@ void CallTip::SetTabSize(int tabSz) {
// It might be better to have two access functions for this and to use
// them for all settings of colours.
-void CallTip::SetForeBack(const ColourPair &fore, const ColourPair &back) {
+void CallTip::SetForeBack(const ColourDesired &fore, const ColourDesired &back) {
colourBG = back;
colourUnSel = fore;
}
diff --git a/scintilla/src/CallTip.h b/scintilla/src/CallTip.h
index 21b48ad..74cd05a 100644
--- a/scintilla/src/CallTip.h
+++ b/scintilla/src/CallTip.h
@@ -41,20 +41,17 @@ public:
Window wDraw;
bool inCallTipMode;
int posStartCallTip;
- ColourPair colourBG;
- ColourPair colourUnSel;
- ColourPair colourSel;
- ColourPair colourShade;
- ColourPair colourLight;
+ ColourDesired colourBG;
+ ColourDesired colourUnSel;
+ ColourDesired colourSel;
+ ColourDesired colourShade;
+ ColourDesired colourLight;
int codePage;
int clickPlace;
CallTip();
~CallTip();
- /// Claim or accept palette entries for the colours required to paint a calltip.
- void RefreshColourPalette(Palette &pal, bool want);
-
void PaintCT(Surface *surfaceWindow);
void MouseClick(Point pt);
@@ -62,7 +59,7 @@ public:
/// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(int pos, Point pt, const char *defn,
const char *faceName, int size, int codePage_,
- int characterSet, Window &wParent);
+ int characterSet, int technology, Window &wParent);
void CallTipCancel();
@@ -77,7 +74,7 @@ public:
bool UseStyleCallTip() const { return useStyleCallTip;}
// Modify foreground and background colours
- void SetForeBack(const ColourPair &fore, const ColourPair &back);
+ void SetForeBack(const ColourDesired &fore, const ColourDesired &back);
};
#ifdef SCI_NAMESPACE
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx
index 118daaa..9bfc8d9 100644
--- a/scintilla/src/Document.cxx
+++ b/scintilla/src/Document.cxx
@@ -185,6 +185,10 @@ int Document::GetMark(int line) {
return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkValue(line);
}
+int Document::MarkerNext(int lineStart, int mask) const {
+ return static_cast<LineMarkers *>(perLineData[ldMarkers])->MarkerNext(lineStart, mask);
+}
+
int Document::AddMark(int line, int markerNum) {
if (line >= 0 && line <= LinesTotal()) {
int prev = static_cast<LineMarkers *>(perLineData[ldMarkers])->
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h
index 1816bea..9f1cb16 100644
--- a/scintilla/src/Document.h
+++ b/scintilla/src/Document.h
@@ -323,6 +323,7 @@ public:
cb.GetStyleRange(buffer, position, lengthRetrieve);
}
int GetMark(int line);
+ int MarkerNext(int lineStart, int mask) const;
int AddMark(int line, int markerNum);
void AddMarkSet(int line, int valueSet);
void DeleteMark(int line, int markerNum);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx
index 0d37504..eb320e4 100644
--- a/scintilla/src/Editor.cxx
+++ b/scintilla/src/Editor.cxx
@@ -102,7 +102,8 @@ Editor::Editor() {
ctrlID = 0;
stylesValid = false;
-
+ technology = SC_TECHNOLOGY_DEFAULT;
+
printMagnification = 0;
printColourMode = SC_PRINT_NORMAL;
printWrapState = eWrapWord;
@@ -168,11 +169,11 @@ Editor::Editor() {
additionalCaretsVisible = true;
virtualSpaceOptions = SCVS_NONE;
- pixmapLine = Surface::Allocate();
- pixmapSelMargin = Surface::Allocate();
- pixmapSelPattern = Surface::Allocate();
- pixmapIndentGuide = Surface::Allocate();
- pixmapIndentGuideHighlight = Surface::Allocate();
+ pixmapLine = 0;
+ pixmapSelMargin = 0;
+ pixmapSelPattern = 0;
+ pixmapIndentGuide = 0;
+ pixmapIndentGuideHighlight = 0;
targetStart = 0;
targetEnd = 0;
@@ -227,12 +228,7 @@ Editor::~Editor() {
pdoc->RemoveWatcher(this, 0);
pdoc->Release();
pdoc = 0;
- DropGraphics();
- delete pixmapLine;
- delete pixmapSelMargin;
- delete pixmapSelPattern;
- delete pixmapIndentGuide;
- delete pixmapIndentGuideHighlight;
+ DropGraphics(true);
}
void Editor::Finalise() {
@@ -240,18 +236,50 @@ void Editor::Finalise() {
CancelModes();
}
-void Editor::DropGraphics() {
- pixmapLine->Release();
- pixmapSelMargin->Release();
- pixmapSelPattern->Release();
- pixmapIndentGuide->Release();
- pixmapIndentGuideHighlight->Release();
+void Editor::DropGraphics(bool freeObjects) {
+ if (freeObjects) {
+ delete pixmapLine;
+ pixmapLine = 0;
+ delete pixmapSelMargin;
+ pixmapSelMargin = 0;
+ delete pixmapSelPattern;
+ pixmapSelPattern = 0;
+ delete pixmapIndentGuide;
+ pixmapIndentGuide = 0;
+ delete pixmapIndentGuideHighlight;
+ pixmapIndentGuideHighlight = 0;
+ } else {
+ if (pixmapLine)
+ pixmapLine->Release();
+ if (pixmapSelMargin)
+ pixmapSelMargin->Release();
+ if (pixmapSelPattern)
+ pixmapSelPattern->Release();
+ if (pixmapIndentGuide)
+ pixmapIndentGuide->Release();
+ if (pixmapIndentGuideHighlight)
+ pixmapIndentGuideHighlight->Release();
+ }
+}
+
+void Editor::AllocateGraphics() {
+ if (!pixmapLine)
+ pixmapLine = Surface::Allocate(technology);
+ if (!pixmapSelMargin)
+ pixmapSelMargin = Surface::Allocate(technology);
+ if (!pixmapSelPattern)
+ pixmapSelPattern = Surface::Allocate(technology);
+ if (!pixmapIndentGuide)
+ pixmapIndentGuide = Surface::Allocate(technology);
+ if (!pixmapIndentGuideHighlight)
+ pixmapIndentGuideHighlight = Surface::Allocate(technology);
}
void Editor::InvalidateStyleData() {
stylesValid = false;
- DropGraphics();
- palette.Release();
+ vs.technology = technology;
+ DropGraphics(false);
+ AllocateGraphics();
llc.Invalidate(LineLayout::llInvalid);
posCache.Clear();
}
@@ -262,19 +290,12 @@ void Editor::InvalidateStyleRedraw() {
Redraw();
}
-void Editor::RefreshColourPalette(Palette &pal, bool want) {
- vs.RefreshColourPalette(pal, want);
-}
-
void Editor::RefreshStyleData() {
if (!stylesValid) {
stylesValid = true;
AutoSurface surface(this);
if (surface) {
vs.Refresh(*surface);
- RefreshColourPalette(palette, true);
- palette.Allocate(wMain);
- RefreshColourPalette(palette, false);
}
if (wrapIndentMode == SC_WRAPINDENT_INDENT) {
wrapAddIndent = pdoc->IndentSize() * vs.spaceWidth;
@@ -1708,8 +1729,8 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle
surface->DrawTextNoClip(rcSegment, vs.styles[style].font,
ascent, st.text + start + i,
static_cast<int>(end - i + 1),
- vs.styles[style].fore.allocated,
- vs.styles[style].back.allocated);
+ vs.styles[style].fore,
+ vs.styles[style].back);
x += width;
i = end + 1;
}
@@ -1718,8 +1739,8 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle
surface->DrawTextNoClip(rcText, vs.styles[style].font,
rcText.top + vs.maxAscent, st.text + start,
static_cast<int>(length),
- vs.styles[style].fore.allocated,
- vs.styles[style].back.allocated);
+ vs.styles[style].fore,
+ vs.styles[style].back);
}
}
@@ -1754,22 +1775,22 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
// Required because of special way brush is created for selection margin
surface->FillRectangle(rcSelMargin, *pixmapSelPattern);
else {
- ColourAllocated colour;
+ ColourDesired colour;
switch (vs.ms[margin].style) {
case SC_MARGIN_BACK:
- colour = vs.styles[STYLE_DEFAULT].back.allocated;
+ colour = vs.styles[STYLE_DEFAULT].back;
break;
case SC_MARGIN_FORE:
- colour = vs.styles[STYLE_DEFAULT].fore.allocated;
+ colour = vs.styles[STYLE_DEFAULT].fore;
break;
default:
- colour = vs.styles[STYLE_LINENUMBER].back.allocated;
+ colour = vs.styles[STYLE_LINENUMBER].back;
break;
}
surface->FillRectangle(rcSelMargin, colour);
}
} else {
- surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated);
+ surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back);
}
int visibleLine = topLine;
@@ -1933,14 +1954,14 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
rcNumber.left = xpos;
surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
rcNumber.top + vs.maxAscent, number, istrlen(number),
- vs.styles[STYLE_LINENUMBER].fore.allocated,
- vs.styles[STYLE_LINENUMBER].back.allocated);
+ vs.styles[STYLE_LINENUMBER].fore,
+ vs.styles[STYLE_LINENUMBER].back);
} else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) {
if (firstSubLine) {
const StyledText stMargin = pdoc->MarginStyledText(lineDoc);
if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) {
surface->FillRectangle(rcMarker,
- vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back.allocated);
+ vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back);
if (vs.ms[margin].style == SC_MARGIN_RTEXT) {
int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
rcMarker.left = rcMarker.right - width - 3;
@@ -1986,7 +2007,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
PRectangle rcBlankMargin = rcMargin;
rcBlankMargin.left = rcSelMargin.right;
- surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back.allocated);
+ surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back);
if (bufferedDraw) {
surfWindow->Copy(rcMargin, Point(), *pixmapSelMargin);
@@ -2220,7 +2241,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
// Layout the line, determining the position of each character,
// with an extra element at the end for the end of the line.
int startseg = 0; // Start of the current segment, in char. number
- int startsegx = 0; // Start of the current segment, in pixels
+ XYACCUMULATOR startsegx = 0; // Start of the current segment, in pixels
ll->positions[0] = 0;
unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars;
bool lastSegItalics = false;
@@ -2241,7 +2262,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
if (vstyle.styles[ll->styles[charInLine]].visible) {
if (isControl) {
if (ll->chars[charInLine] == '\t') {
- ll->positions[charInLine + 1] = ((((startsegx + 2) /
+ ll->positions[charInLine + 1] = ((((static_cast<int>(startsegx) + 2) /
tabWidth) + 1) * tabWidth) - startsegx;
} else if (controlCharSymbol < 32) {
if (ctrlCharWidth[ll->chars[charInLine]] == 0) {
@@ -2372,14 +2393,14 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
}
}
-ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw, bool main) {
+ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) {
return main ?
- (primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) :
- vsDraw.selAdditionalBackground.allocated;
+ (primarySelection ? vsDraw.selbackground : vsDraw.selbackground2) :
+ vsDraw.selAdditionalBackground;
}
-ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
- ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
+ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
+ ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
if (inSelection == 1) {
if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
return SelectionBackground(vsDraw, true);
@@ -2392,14 +2413,14 @@ ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackgroun
if ((vsDraw.edgeState == EDGE_BACKGROUND) &&
(i >= ll->edgeColumn) &&
!IsEOLChar(ll->chars[i]))
- return vsDraw.edgecolour.allocated;
+ return vsDraw.edgecolour;
if (inHotspot && vsDraw.hotspotBackgroundSet)
- return vsDraw.hotspotBackground.allocated;
+ return vsDraw.hotspotBackground;
}
if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) {
return background;
} else {
- return vsDraw.styles[styleMain].back.allocated;
+ return vsDraw.styles[styleMain].back;
}
}
@@ -2411,7 +2432,7 @@ void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight,
}
void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
- bool isEndMarker, ColourAllocated wrapColour) {
+ bool isEndMarker, ColourDesired wrapColour) {
surface->PenColour(wrapColour);
enum { xa = 1 }; // gap before start
@@ -2456,14 +2477,14 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
y - 2 * dy);
}
-static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) {
+static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourDesired fill, int alpha) {
if (alpha != SC_ALPHA_NOALPHA) {
surface->AlphaRectangle(rc, 0, fill, alpha, fill, alpha, 0);
}
}
void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment,
- const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) {
+ const char *s, ColourDesired textBack, ColourDesired textFore, bool twoPhaseDraw) {
if (!twoPhaseDraw) {
surface->FillRectangle(rcSegment, textBack);
}
@@ -2488,8 +2509,8 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment,
void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
int line, int lineEnd, int xStart, int subLine, int subLineStart,
- bool overrideBackground, ColourAllocated background,
- bool drawWrapMarkEnd, ColourAllocated wrapColour) {
+ bool overrideBackground, ColourDesired background,
+ bool drawWrapMarkEnd, ColourDesired wrapColour) {
const int posLineStart = pdoc->LineStart(line);
const int styleMask = pdoc->stylingBitsMask;
@@ -2510,7 +2531,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
if (virtualSpace) {
rcSegment.left = xEol + xStart;
rcSegment.right = xEol + xStart + virtualSpace;
- surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+ surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) {
SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line))));
for (size_t r=0; r<sel.Count(); r++) {
@@ -2545,8 +2566,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
int inSelection = 0;
bool inHotspot = false;
int styleMain = ll->styles[eolPos];
- ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, eolPos, ll);
- ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+ ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, eolPos, ll);
+ ColourDesired textFore = vsDraw.styles[styleMain].fore;
if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
if (alpha == SC_ALPHA_NOALPHA) {
surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1));
@@ -2571,11 +2592,11 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
} else if (line < pdoc->LinesTotal() - 1) {
- surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
} else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
- surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
} else {
- surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
}
if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
@@ -2594,9 +2615,9 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
if (overrideBackground) {
surface->FillRectangle(rcSegment, background);
} else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
- surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back);
} else {
- surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back);
}
if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) {
SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha);
@@ -2714,14 +2735,14 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
int annotationLine = subLine - ll->lines;
const StyledText stAnnotation = pdoc->AnnotationStyledText(line);
if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) {
- surface->FillRectangle(rcSegment, vsDraw.styles[0].back.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.styles[0].back);
if (vs.annotationVisible == ANNOTATION_BOXED) {
// Only care about calculating width if need to draw box
int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation);
widthAnnotation += vsDraw.spaceWidth * 2; // Margins
rcSegment.left = xStart + indent;
rcSegment.right = rcSegment.left + widthAnnotation;
- surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore.allocated);
+ surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore);
} else {
rcSegment.left = xStart;
}
@@ -2737,7 +2758,7 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
PRectangle rcText = rcSegment;
if (vs.annotationVisible == ANNOTATION_BOXED) {
surface->FillRectangle(rcText,
- vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back.allocated);
+ vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back);
rcText.left += vsDraw.spaceWidth;
}
DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent,
@@ -2776,17 +2797,17 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
// with the earlier taking precedence. When multiple markers cause background override,
// the color for the highest numbered one is used.
bool overrideBackground = false;
- ColourAllocated background;
+ ColourDesired background;
if (caret.active && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha == SC_ALPHA_NOALPHA) && ll->containsCaret) {
overrideBackground = true;
- background = vsDraw.caretLineBackground.allocated;
+ background = vsDraw.caretLineBackground;
}
if (!overrideBackground) {
int marks = pdoc->GetMark(line);
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) &&
(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
- background = vsDraw.markers[markBit].back.allocated;
+ background = vsDraw.markers[markBit].back;
overrideBackground = true;
}
marks >>= 1;
@@ -2800,7 +2821,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) &&
(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
overrideBackground = true;
- background = vsDraw.markers[markBit].back.allocated;
+ background = vsDraw.markers[markBit].back;
}
marksMasked >>= 1;
}
@@ -2832,9 +2853,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
}
- ColourAllocated wrapColour = vsDraw.styles[STYLE_DEFAULT].fore.allocated;
+ ColourDesired wrapColour = vsDraw.styles[STYLE_DEFAULT].fore;
if (vsDraw.whitespaceForegroundSet)
- wrapColour = vsDraw.whitespaceForeground.allocated;
+ wrapColour = vsDraw.whitespaceForeground;
bool drawWrapMarkEnd = false;
@@ -2860,12 +2881,12 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
// default bgnd here..
surface->FillRectangle(rcSegment, overrideBackground ? background :
- vsDraw.styles[STYLE_DEFAULT].back.allocated);
+ vsDraw.styles[STYLE_DEFAULT].back);
// main line style would be below but this would be inconsistent with end markers
// also would possibly not be the style at wrap point
//int styleMain = ll->styles[lineStart];
- //surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back.allocated);
+ //surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back);
if (wrapVisualFlags & SC_WRAPVISUALFLAG_START) {
@@ -2906,18 +2927,20 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
// draw strings that are completely past the right side of the window.
if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
// Clip to line rectangle, since may have a huge position which will not work with some platforms
- rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
- rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right);
+ if (rcSegment.left < rcLine.left)
+ rcSegment.left = rcLine.left;
+ if (rcSegment.right > rcLine.right)
+ rcSegment.right = rcLine.right;
int styleMain = ll->styles[i];
const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
- ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
+ ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
if (ll->chars[i] == '\t') {
// Tab display
if (drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
- textBack = vsDraw.whitespaceBackground.allocated;
+ textBack = vsDraw.whitespaceBackground;
surface->FillRectangle(rcSegment, textBack);
} else if (IsControlCharacter(ll->chars[i])) {
// Control character display
@@ -2936,7 +2959,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
rcSegment.top,
ll->positions[cpos + startseg + 1] + xStart - subLineStart,
rcSegment.bottom);
- surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated);
+ surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground);
}
} else {
inIndentation = false;
@@ -2963,7 +2986,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if ((ll->wrapIndent != 0) && (lineStart != 0))
rcSegment.left -= ll->wrapIndent;
rcSegment.right = rcSegment.left + 1;
- surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
+ surface->FillRectangle(rcSegment, vsDraw.edgecolour);
}
// Draw underline mark as part of background if not transparent
@@ -2974,7 +2997,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
PRectangle rcUnderline = rcLine;
rcUnderline.top = rcUnderline.bottom - 2;
- surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back.allocated);
+ surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back);
}
marks >>= 1;
}
@@ -2999,31 +3022,31 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
// draw strings that are completely past the right side of the window.
if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
int styleMain = ll->styles[i];
- ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+ ColourDesired textFore = vsDraw.styles[styleMain].fore;
Font &textFont = vsDraw.styles[styleMain].font;
//hotspot foreground
if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) {
if (vsDraw.hotspotForegroundSet)
- textFore = vsDraw.hotspotForeground.allocated;
+ textFore = vsDraw.hotspotForeground;
}
const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc);
if (inSelection && (vsDraw.selforeset)) {
- textFore = (inSelection == 1) ? vsDraw.selforeground.allocated : vsDraw.selAdditionalForeground.allocated;
+ textFore = (inSelection == 1) ? vsDraw.selforeground : vsDraw.selAdditionalForeground;
}
bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd);
- ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
+ ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);
if (ll->chars[i] == '\t') {
// Tab display
if (!twoPhaseDraw) {
if (drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
- textBack = vsDraw.whitespaceBackground.allocated;
+ textBack = vsDraw.whitespaceBackground;
surface->FillRectangle(rcSegment, textBack);
}
if ((vsDraw.viewWhitespace != wsInvisible) ||
(inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
if (vsDraw.whitespaceForegroundSet)
- textFore = vsDraw.whitespaceForeground.allocated;
+ textFore = vsDraw.whitespaceForeground;
surface->PenColour(textFore);
}
if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
@@ -3078,12 +3101,12 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if (ll->chars[cpos + startseg] == ' ') {
if (vsDraw.viewWhitespace != wsInvisible) {
if (vsDraw.whitespaceForegroundSet)
- textFore = vsDraw.whitespaceForeground.allocated;
+ textFore = vsDraw.whitespaceForeground;
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
if (!twoPhaseDraw && drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
- textBack = vsDraw.whitespaceBackground.allocated;
+ textBack = vsDraw.whitespaceBackground;
PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
rcSegment.top,
ll->positions[cpos + startseg + 1] + xStart - subLineStart,
@@ -3114,7 +3137,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
rcUL.bottom = rcUL.top + 1;
if (vsDraw.hotspotForegroundSet)
- surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated);
+ surface->FillRectangle(rcUL, vsDraw.hotspotForeground);
else
surface->FillRectangle(rcUL, textFore);
} else if (vsDraw.styles[styleMain].underline) {
@@ -3214,16 +3237,16 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
rcSegment.left = 0;
rcSegment.right = rcLine.right - 1;
if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) {
- SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha);
+ SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground, vsDraw.caretLineAlpha);
}
marks = pdoc->GetMark(line);
for (markBit = 0; (markBit < 32) && marks; markBit++) {
if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) {
- SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+ SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
} else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) {
PRectangle rcUnderline = rcSegment;
rcUnderline.top = rcUnderline.bottom - 2;
- SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+ SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
}
marks >>= 1;
}
@@ -3232,7 +3255,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
if (marksMasked) {
for (markBit = 0; (markBit < 32) && marksMasked; markBit++) {
if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) {
- SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+ SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
}
marksMasked >>= 1;
}
@@ -3241,7 +3264,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
}
void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
- int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour) {
+ int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) {
int lineStart = ll->LineStart(subLine);
int posBefore = posCaret;
@@ -3299,7 +3322,7 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll,
int styleMain = ll->styles[offsetFirstChar];
surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font,
rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar,
- numCharsToDraw, vsDraw.styles[styleMain].back.allocated,
+ numCharsToDraw, vsDraw.styles[styleMain].back,
caretColour);
}
@@ -3314,22 +3337,22 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
PRectangle rcPattern(0, 0, patternSize, patternSize);
// Initialize default colours based on the chrome colour scheme. Typically the highlight is white.
- ColourAllocated colourFMFill = vs.selbar.allocated;
- ColourAllocated colourFMStripes = vs.selbarlight.allocated;
+ ColourDesired colourFMFill = vs.selbar;
+ ColourDesired colourFMStripes = vs.selbarlight;
- if (!(vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff))) {
+ if (!(vs.selbarlight == ColourDesired(0xff, 0xff, 0xff))) {
// User has chosen an unusual chrome colour scheme so just use the highlight edge colour.
// (Typically, the highlight colour is white.)
- colourFMFill = vs.selbarlight.allocated;
+ colourFMFill = vs.selbarlight;
}
if (vs.foldmarginColourSet) {
// override default fold margin colour
- colourFMFill = vs.foldmarginColour.allocated;
+ colourFMFill = vs.foldmarginColour;
}
if (vs.foldmarginHighlightColourSet) {
// override default fold margin highlight colour
- colourFMStripes = vs.foldmarginHighlightColour.allocated;
+ colourFMStripes = vs.foldmarginHighlightColour;
}
pixmapSelPattern->FillRectangle(rcPattern, colourFMFill);
@@ -3346,14 +3369,14 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) {
pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID());
PRectangle rcIG(0, 0, 1, vs.lineHeight);
- pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back.allocated);
- pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore.allocated);
- pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated);
- pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated);
+ pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back);
+ pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore);
+ pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back);
+ pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore);
for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) {
PRectangle rcPixel(0, stripe, 1, stripe+1);
- pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore.allocated);
- pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore.allocated);
+ pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore);
+ pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore);
}
}
@@ -3383,7 +3406,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
const int virtualOffset = posCaret.VirtualSpace() * spaceWidth;
if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) {
- int xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)];
+ XYPOSITION xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)];
if (ll->wrapIndent != 0) {
int lineStart = ll->LineStart(subLine);
if (lineStart != 0) // Wrapped
@@ -3438,7 +3461,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
rcCaret.left = xposCaret - caretWidthOffset;
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
- ColourAllocated caretColour = mainCaret ? vsDraw.caretcolour.allocated : vsDraw.additionalCaretColour.allocated;
+ ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
if (drawBlockCaret) {
DrawBlockCaret(surface, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour);
} else {
@@ -3465,9 +3488,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
//Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n",
// rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
- surfaceWindow->SetPalette(&palette, true);
- pixmapLine->SetPalette(&palette, !hasFocus);
-
int screenLinePaintFirst = rcArea.top / vs.lineHeight;
int xStart = vs.fixedColumnWidth - xOffset;
@@ -3478,17 +3498,11 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
bool paintAbandonedByStyling = paintState == paintAbandoned;
if (needUpdateUI) {
- // Deselect palette by selecting a temporary palette
- Palette palTemp;
- surfaceWindow->SetPalette(&palTemp, true);
-
NotifyUpdateUI();
needUpdateUI = 0;
RefreshStyleData();
RefreshPixMaps(surfaceWindow);
- surfaceWindow->SetPalette(&palette, true);
- pixmapLine->SetPalette(&palette, !hasFocus);
}
// Call priority lines wrap on a window of lines which are likely
@@ -3513,7 +3527,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
PRectangle rcRightMargin = rcClient;
rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
if (rcArea.Intersects(rcRightMargin)) {
- surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back.allocated);
+ surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back);
}
}
@@ -3623,7 +3637,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
(!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.bottom = rcFoldLine.top + 1;
- surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore);
}
// Paint the line below the fold
if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED))
@@ -3631,7 +3645,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
(!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.top = rcFoldLine.bottom - 1;
- surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
+ surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore);
}
}
@@ -3668,12 +3682,12 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
rcBeyondEOF.right = rcBeyondEOF.right;
rcBeyondEOF.top = (cs.LinesDisplayed() - topLine) * vs.lineHeight;
if (rcBeyondEOF.top < rcBeyondEOF.bottom) {
- surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back.allocated);
+ surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back);
if (vs.edgeState == EDGE_LINE) {
int edgeX = theEdge * vs.spaceWidth;
rcBeyondEOF.left = edgeX + xStart;
rcBeyondEOF.right = rcBeyondEOF.left + 1;
- surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour.allocated);
+ surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour);
}
}
//Platform::DebugPrintf(
@@ -3749,21 +3763,21 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
// Set colours for printing according to users settings
for (size_t sty = 0; sty < vsPrint.stylesSize; sty++) {
if (printColourMode == SC_PRINT_INVERTLIGHT) {
- vsPrint.styles[sty].fore.desired = InvertedLight(vsPrint.styles[sty].fore.desired);
- vsPrint.styles[sty].back.desired = InvertedLight(vsPrint.styles[sty].back.desired);
+ vsPrint.styles[sty].fore = InvertedLight(vsPrint.styles[sty].fore);
+ vsPrint.styles[sty].back = InvertedLight(vsPrint.styles[sty].back);
} else if (printColourMode == SC_PRINT_BLACKONWHITE) {
- vsPrint.styles[sty].fore.desired = ColourDesired(0, 0, 0);
- vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].fore = ColourDesired(0, 0, 0);
+ vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITE) {
- vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
if (sty <= STYLE_DEFAULT) {
- vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back = ColourDesired(0xff, 0xff, 0xff);
}
}
}
// White background for the line numbers
- vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff);
+ vsPrint.styles[STYLE_LINENUMBER].back = ColourDesired(0xff, 0xff, 0xff);
vsPrint.Refresh(*surfaceMeasure);
// Determining width must hapen after fonts have been realised in Refresh
@@ -3774,9 +3788,6 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
vsPrint.Refresh(*surfaceMeasure); // Recalculate fixedColumnWidth
}
- // Ensure colours are set up
- vsPrint.RefreshColourPalette(palette, true);
- vsPrint.RefreshColourPalette(palette, false);
int linePrintStart = pdoc->LineFromPosition(pfr->chrg.cpMin);
int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1;
@@ -3856,8 +3867,8 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
surface->FlushCachedState();
surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
ypos + vsPrint.maxAscent, number, istrlen(number),
- vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
- vsPrint.styles[STYLE_LINENUMBER].back.allocated);
+ vsPrint.styles[STYLE_LINENUMBER].fore,
+ vsPrint.styles[STYLE_LINENUMBER].back);
}
// Draw the line
@@ -3928,7 +3939,7 @@ void Editor::SetScrollBars() {
}
void Editor::ChangeSize() {
- DropGraphics();
+ DropGraphics(false);
SetScrollBars();
if (wrapState != eWrapNone) {
PRectangle rcTextArea = GetClientRectangle();
@@ -6994,13 +7005,16 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
vs.EnsureStyle(wParam);
switch (iMessage) {
case SCI_STYLESETFORE:
- vs.styles[wParam].fore.desired = ColourDesired(lParam);
+ vs.styles[wParam].fore = ColourDesired(lParam);
break;
case SCI_STYLESETBACK:
- vs.styles[wParam].back.desired = ColourDesired(lParam);
+ vs.styles[wParam].back = ColourDesired(lParam);
break;
case SCI_STYLESETBOLD:
- vs.styles[wParam].bold = lParam != 0;
+ vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL;
+ break;
+ case SCI_STYLESETWEIGHT:
+ vs.styles[wParam].weight = lParam;
break;
case SCI_STYLESETITALIC:
vs.styles[wParam].italic = lParam != 0;
@@ -7009,6 +7023,9 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
vs.styles[wParam].eolFilled = lParam != 0;
break;
case SCI_STYLESETSIZE:
+ vs.styles[wParam].size = lParam * SC_FONT_SIZE_MULTIPLIER;
+ break;
+ case SCI_STYLESETSIZEFRACTIONAL:
vs.styles[wParam].size = lParam;
break;
case SCI_STYLESETFONT:
@@ -7042,16 +7059,20 @@ 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.desired.AsLong();
+ return vs.styles[wParam].fore.AsLong();
case SCI_STYLEGETBACK:
- return vs.styles[wParam].back.desired.AsLong();
+ return vs.styles[wParam].back.AsLong();
case SCI_STYLEGETBOLD:
- return vs.styles[wParam].bold ? 1 : 0;
+ return vs.styles[wParam].weight > SC_WEIGHT_NORMAL;
+ case SCI_STYLEGETWEIGHT:
+ return vs.styles[wParam].weight;
case SCI_STYLEGETITALIC:
return vs.styles[wParam].italic ? 1 : 0;
case SCI_STYLEGETEOLFILLED:
return vs.styles[wParam].eolFilled ? 1 : 0;
case SCI_STYLEGETSIZE:
+ return vs.styles[wParam].size / SC_FONT_SIZE_MULTIPLIER;
+ case SCI_STYLEGETSIZEFRACTIONAL:
return vs.styles[wParam].size;
case SCI_STYLEGETFONT:
if (!vs.styles[wParam].fontName)
@@ -7986,13 +8007,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETCODEPAGE:
return pdoc->dbcsCodePage;
+#ifdef INCLUDE_DEPRECATED_FEATURES
case SCI_SETUSEPALETTE:
- palette.allowRealization = wParam != 0;
InvalidateStyleRedraw();
break;
case SCI_GETUSEPALETTE:
- return palette.allowRealization;
+ return 0;
+#endif
// Marker definition and setting
case SCI_MARKERDEFINE:
@@ -8010,13 +8032,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.desired = ColourDesired(lParam);
+ vs.markers[wParam].fore = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_MARKERSETBACKSELECTED:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].backSelected.desired = ColourDesired(lParam);
+ vs.markers[wParam].backSelected = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_MARKERENABLEHIGHLIGHT:
@@ -8025,7 +8047,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.desired = ColourDesired(lParam);
+ vs.markers[wParam].back = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
@@ -8054,14 +8076,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_MARKERGET:
return pdoc->GetMark(wParam);
- case SCI_MARKERNEXT: {
- int lt = pdoc->LinesTotal();
- for (int iLine = wParam; iLine < lt; iLine++) {
- if ((pdoc->GetMark(iLine) & lParam) != 0)
- return iLine;
- }
- }
- return -1;
+ case SCI_MARKERNEXT:
+ return pdoc->MarkerNext(wParam, lParam);
case SCI_MARKERPREVIOUS: {
for (int iLine = wParam; iLine >= 0; iLine--) {
@@ -8169,9 +8185,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_STYLESETFORE:
case SCI_STYLESETBACK:
case SCI_STYLESETBOLD:
+ case SCI_STYLESETWEIGHT:
case SCI_STYLESETITALIC:
case SCI_STYLESETEOLFILLED:
case SCI_STYLESETSIZE:
+ case SCI_STYLESETSIZEFRACTIONAL:
case SCI_STYLESETFONT:
case SCI_STYLESETUNDERLINE:
case SCI_STYLESETCASE:
@@ -8185,9 +8203,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_STYLEGETFORE:
case SCI_STYLEGETBACK:
case SCI_STYLEGETBOLD:
+ case SCI_STYLEGETWEIGHT:
case SCI_STYLEGETITALIC:
case SCI_STYLEGETEOLFILLED:
case SCI_STYLEGETSIZE:
+ case SCI_STYLEGETSIZEFRACTIONAL:
case SCI_STYLEGETFONT:
case SCI_STYLEGETUNDERLINE:
case SCI_STYLEGETCASE:
@@ -8225,9 +8245,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleRedraw();
break;
case SCI_GETCARETLINEBACK:
- return vs.caretLineBackground.desired.AsLong();
+ return vs.caretLineBackground.AsLong();
case SCI_SETCARETLINEBACK:
- vs.caretLineBackground.desired = wParam;
+ vs.caretLineBackground = wParam;
InvalidateStyleRedraw();
break;
case SCI_GETCARETLINEBACKALPHA:
@@ -8340,15 +8360,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETSELFORE:
vs.selforeset = wParam != 0;
- vs.selforeground.desired = ColourDesired(lParam);
- vs.selAdditionalForeground.desired = ColourDesired(lParam);
+ vs.selforeground = ColourDesired(lParam);
+ vs.selAdditionalForeground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
vs.selbackset = wParam != 0;
- vs.selbackground.desired = ColourDesired(lParam);
- vs.selAdditionalBackground.desired = ColourDesired(lParam);
+ vs.selbackground = ColourDesired(lParam);
+ vs.selAdditionalBackground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
@@ -8371,23 +8391,23 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETWHITESPACEFORE:
vs.whitespaceForegroundSet = wParam != 0;
- vs.whitespaceForeground.desired = ColourDesired(lParam);
+ vs.whitespaceForeground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETWHITESPACEBACK:
vs.whitespaceBackgroundSet = wParam != 0;
- vs.whitespaceBackground.desired = ColourDesired(lParam);
+ vs.whitespaceBackground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETCARETFORE:
- vs.caretcolour.desired = ColourDesired(wParam);
+ vs.caretcolour = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_GETCARETFORE:
- return vs.caretcolour.desired.AsLong();
+ return vs.caretcolour.AsLong();
case SCI_SETCARETSTYLE:
if (wParam <= CARETSTYLE_BLOCK)
@@ -8440,13 +8460,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].fore.desired = ColourDesired(lParam);
+ vs.indicators[wParam].fore = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_INDICGETFORE:
- return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.desired.AsLong() : 0;
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.AsLong() : 0;
case SCI_INDICSETUNDER:
if (wParam <= INDIC_MAX) {
@@ -8662,10 +8682,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETEDGECOLOUR:
- return vs.edgecolour.desired.AsLong();
+ return vs.edgecolour.AsLong();
case SCI_SETEDGECOLOUR:
- vs.edgecolour.desired = ColourDesired(wParam);
+ vs.edgecolour = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
@@ -8819,33 +8839,33 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETFOLDMARGINCOLOUR:
vs.foldmarginColourSet = wParam != 0;
- vs.foldmarginColour.desired = ColourDesired(lParam);
+ vs.foldmarginColour = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETFOLDMARGINHICOLOUR:
vs.foldmarginHighlightColourSet = wParam != 0;
- vs.foldmarginHighlightColour.desired = ColourDesired(lParam);
+ vs.foldmarginHighlightColour = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETHOTSPOTACTIVEFORE:
vs.hotspotForegroundSet = wParam != 0;
- vs.hotspotForeground.desired = ColourDesired(lParam);
+ vs.hotspotForeground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_GETHOTSPOTACTIVEFORE:
- return vs.hotspotForeground.desired.AsLong();
+ return vs.hotspotForeground.AsLong();
case SCI_SETHOTSPOTACTIVEBACK:
vs.hotspotBackgroundSet = wParam != 0;
- vs.hotspotBackground.desired = ColourDesired(lParam);
+ vs.hotspotBackground = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_GETHOTSPOTACTIVEBACK:
- return vs.hotspotBackground.desired.AsLong();
+ return vs.hotspotBackground.AsLong();
case SCI_SETHOTSPOTACTIVEUNDERLINE:
vs.hotspotUnderline = wParam != 0;
@@ -9180,12 +9200,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return virtualSpaceOptions;
case SCI_SETADDITIONALSELFORE:
- vs.selAdditionalForeground.desired = ColourDesired(wParam);
+ vs.selAdditionalForeground = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_SETADDITIONALSELBACK:
- vs.selAdditionalBackground.desired = ColourDesired(wParam);
+ vs.selAdditionalBackground = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
@@ -9198,12 +9218,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.selAdditionalAlpha;
case SCI_SETADDITIONALCARETFORE:
- vs.additionalCaretColour.desired = ColourDesired(wParam);
+ vs.additionalCaretColour = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_GETADDITIONALCARETFORE:
- return vs.additionalCaretColour.desired.AsLong();
+ return vs.additionalCaretColour.AsLong();
case SCI_ROTATESELECTION:
sel.RotateMain();
@@ -9226,6 +9246,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETIDENTIFIER:
return GetCtrlID();
+ case SCI_SETTECHNOLOGY:
+ // No action by default
+ break;
+
+ case SCI_GETTECHNOLOGY:
+ return technology;
+
default:
return DefWndProc(iMessage, wParam, lParam);
}
diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h
index 518ce07..c876868 100644
--- a/scintilla/src/Editor.h
+++ b/scintilla/src/Editor.h
@@ -131,8 +131,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
* When a style attribute is changed, this cache is flushed. */
bool stylesValid;
ViewStyle vs;
+ int technology;
Point sizeRGBAImage;
- Palette palette;
int printMagnification;
int printColourMode;
@@ -278,9 +278,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
void InvalidateStyleData();
void InvalidateStyleRedraw();
- virtual void RefreshColourPalette(Palette &pal, bool want);
void RefreshStyleData();
- void DropGraphics();
+ void DropGraphics(bool freeObjects);
+ void AllocateGraphics();
virtual PRectangle GetClientRectangle();
PRectangle GetTextRectangle();
@@ -368,14 +368,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
LineLayout *RetrieveLineLayout(int lineNumber);
void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
int width=LineLayout::wrapWidthInfinite);
- ColourAllocated SelectionBackground(ViewStyle &vsDraw, bool main);
- ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
+ ColourDesired SelectionBackground(ViewStyle &vsDraw, bool main);
+ ColourDesired TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
- void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour);
+ void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour);
void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
int line, int lineEnd, int xStart, int subLine, int subLineStart,
- bool overrideBackground, ColourAllocated background,
- bool drawWrapMark, ColourAllocated wrapColour);
+ bool overrideBackground, ColourDesired background,
+ bool drawWrapMark, ColourDesired wrapColour);
void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw,
int xStart, PRectangle rcLine, LineLayout *ll, int subLine);
void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
@@ -385,7 +385,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine);
void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
- int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour);
+ int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour);
void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
PRectangle rcLine, LineLayout *ll, int subLine);
void RefreshPixMaps(Surface *surfaceWindow);
@@ -575,7 +575,7 @@ private:
public:
AutoSurface(Editor *ed) : surf(0) {
if (ed->wMain.GetID()) {
- surf = Surface::Allocate();
+ surf = Surface::Allocate(ed->technology);
if (surf) {
surf->Init(ed->wMain.GetID());
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
@@ -585,7 +585,7 @@ public:
}
AutoSurface(SurfaceID sid, Editor *ed) : surf(0) {
if (ed->wMain.GetID()) {
- surf = Surface::Allocate();
+ surf = Surface::Allocate(ed->technology);
if (surf) {
surf->Init(sid, ed->wMain.GetID());
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
diff --git a/scintilla/src/FontQuality.h b/scintilla/src/FontQuality.h
index 3ec94f0..46e2c91 100644
--- a/scintilla/src/FontQuality.h
+++ b/scintilla/src/FontQuality.h
@@ -10,3 +10,6 @@
#define SC_EFF_QUALITY_NON_ANTIALIASED 1
#define SC_EFF_QUALITY_ANTIALIASED 2
#define SC_EFF_QUALITY_LCD_OPTIMIZED 3
+
+#define SCWIN_TECH_GDI 0
+#define SCWIN_TECH_DIRECTWRITE 1
diff --git a/scintilla/src/Indicator.cxx b/scintilla/src/Indicator.cxx
index 6ab0d8a..727d408 100644
--- a/scintilla/src/Indicator.cxx
+++ b/scintilla/src/Indicator.cxx
@@ -23,7 +23,7 @@ using namespace Scintilla;
#endif
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) {
- surface->PenColour(fore.allocated);
+ surface->PenColour(fore);
int ymid = (rc.bottom + rc.top) / 2;
if (style == INDIC_SQUIGGLE) {
surface->MoveTo(rc.left, rc.top);
@@ -91,7 +91,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
rcBox.top = rcLine.top + 1;
rcBox.left = rc.left;
rcBox.right = rc.right;
- surface->AlphaRectangle(rcBox, (style == INDIC_ROUNDBOX) ? 1 : 0, fore.allocated, fillAlpha, fore.allocated, outlineAlpha, 0);
+ surface->AlphaRectangle(rcBox, (style == INDIC_ROUNDBOX) ? 1 : 0, fore, fillAlpha, fore, outlineAlpha, 0);
} else if (style == INDIC_DOTBOX) {
PRectangle rcBox = rcLine;
rcBox.top = rcLine.top + 1;
@@ -103,13 +103,13 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
// Draw horizontal lines top and bottom
for (int x=0; x<width; x++) {
for (int y=0; y<rcBox.Height(); y += rcBox.Height()-1) {
- image.SetPixel(x, y, fore.desired, ((x + y) % 2) ? outlineAlpha : fillAlpha);
+ image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
// Draw vertical lines left and right
for (int y=1; y<rcBox.Height(); y++) {
for (int x=0; x<width; x += width-1) {
- image.SetPixel(x, y, fore.desired, ((x + y) % 2) ? outlineAlpha : fillAlpha);
+ image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels());
@@ -124,7 +124,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
int x = rc.left;
while (x < rc.right) {
PRectangle rcDot(x, ymid, x+1, ymid+1);
- surface->FillRectangle(rcDot, fore.allocated);
+ surface->FillRectangle(rcDot, fore);
x += 2;
}
} else { // Either INDIC_PLAIN or unknown
diff --git a/scintilla/src/Indicator.h b/scintilla/src/Indicator.h
index f320b80..c9f1af5 100644
--- a/scintilla/src/Indicator.h
+++ b/scintilla/src/Indicator.h
@@ -18,7 +18,7 @@ class Indicator {
public:
int style;
bool under;
- ColourPair fore;
+ ColourDesired fore;
int fillAlpha;
int outlineAlpha;
Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)), fillAlpha(30), outlineAlpha(50) {
diff --git a/scintilla/src/LineMarker.cxx b/scintilla/src/LineMarker.cxx
index e8ab7f7..45d44f4 100644
--- a/scintilla/src/LineMarker.cxx
+++ b/scintilla/src/LineMarker.cxx
@@ -20,15 +20,6 @@
using namespace Scintilla;
#endif
-void LineMarker::RefreshColourPalette(Palette &pal, bool want) {
- pal.WantFind(fore, want);
- pal.WantFind(back, want);
- pal.WantFind(backSelected, want);
- if (pxpm) {
- pxpm->RefreshColourPalette(pal, want);
- }
-}
-
void LineMarker::SetXPM(const char *textForm) {
delete pxpm;
pxpm = new XPM(textForm);
@@ -47,7 +38,7 @@ void LineMarker::SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRG
markType = SC_MARK_RGBAIMAGE;
}
-static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
+static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
PRectangle rc;
rc.left = centreX - armSize;
rc.top = centreY - armSize;
@@ -56,7 +47,7 @@ static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Col
surface->RectangleDraw(rc, back, fore);
}
-static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
+static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) {
PRectangle rcCircle;
rcCircle.left = centreX - armSize;
rcCircle.top = centreY - armSize;
@@ -65,22 +56,22 @@ static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize,
surface->Ellipse(rcCircle, back, fore);
}
-static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
+static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore);
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
-static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
+static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) {
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold) {
- ColourPair head = back;
- ColourPair body = back;
- ColourPair tail = back;
+ ColourDesired head = back;
+ ColourDesired body = back;
+ ColourDesired tail = back;
switch (tFold) {
case LineMarker::head :
@@ -130,14 +121,14 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
PRectangle rcRounded = rc;
rcRounded.left = rc.left + 1;
rcRounded.right = rc.right - 1;
- surface->RoundedRectangle(rcRounded, fore.allocated, back.allocated);
+ surface->RoundedRectangle(rcRounded, fore, back);
} else if (markType == SC_MARK_CIRCLE) {
PRectangle rcCircle;
rcCircle.left = centreX - dimOn2;
rcCircle.top = centreY - dimOn2;
rcCircle.right = centreX + dimOn2;
rcCircle.bottom = centreY + dimOn2;
- surface->Ellipse(rcCircle, fore.allocated, back.allocated);
+ surface->Ellipse(rcCircle, fore, back);
} else if (markType == SC_MARK_ARROW) {
Point pts[] = {
Point(centreX - dimOn4, centreY - dimOn2),
@@ -145,7 +136,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
Point(centreX + dimOn2 - dimOn4, centreY),
};
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
- fore.allocated, back.allocated);
+ fore, back);
} else if (markType == SC_MARK_ARROWDOWN) {
Point pts[] = {
@@ -154,7 +145,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
Point(centreX, centreY + dimOn2 - dimOn4),
};
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
- fore.allocated, back.allocated);
+ fore, back);
} else if (markType == SC_MARK_PLUS) {
Point pts[] = {
@@ -172,7 +163,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
Point(centreX - armSize, centreY + 1),
};
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
- fore.allocated, back.allocated);
+ fore, back);
} else if (markType == SC_MARK_MINUS) {
Point pts[] = {
@@ -182,7 +173,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
Point(centreX - armSize, centreY + 1),
};
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
- fore.allocated, back.allocated);
+ fore, back);
} else if (markType == SC_MARK_SMALLRECT) {
PRectangle rcSmall;
@@ -190,76 +181,76 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
rcSmall.top = rc.top + 2;
rcSmall.right = rc.right - 1;
rcSmall.bottom = rc.bottom - 2;
- surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
+ surface->RectangleDraw(rcSmall, fore, back);
} else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND ||
markType == SC_MARK_UNDERLINE || markType == SC_MARK_AVAILABLE) {
// An invisible marker so don't draw anything
} else if (markType == SC_MARK_VLINE) {
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_LCORNER) {
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2);
surface->LineTo(rc.right - 2, rc.top + dimOn2);
} else if (markType == SC_MARK_TCORNER) {
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
surface->MoveTo(centreX, rc.top + dimOn2);
surface->LineTo(rc.right - 2, rc.top + dimOn2);
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2 + 1);
- surface->PenColour(head.allocated);
+ surface->PenColour(head);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_LCORNERCURVE) {
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2-3);
surface->LineTo(centreX+3, rc.top + dimOn2);
surface->LineTo(rc.right - 1, rc.top + dimOn2);
} else if (markType == SC_MARK_TCORNERCURVE) {
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
surface->MoveTo(centreX, rc.top + dimOn2-3);
surface->LineTo(centreX+3, rc.top + dimOn2);
surface->LineTo(rc.right - 1, rc.top + dimOn2);
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, rc.top + dimOn2-2);
- surface->PenColour(head.allocated);
+ surface->PenColour(head);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_BOXPLUS) {
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawBox(surface, centreX, centreY, blobSize, fore, head);
+ DrawPlus(surface, centreX, centreY, blobSize, tail);
} else if (markType == SC_MARK_BOXPLUSCONNECTED) {
if (tFold == LineMarker::headWithTail)
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
else
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawBox(surface, centreX, centreY, blobSize, fore, head);
+ DrawPlus(surface, centreX, centreY, blobSize, tail);
if (tFold == LineMarker::body) {
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
surface->MoveTo(centreX + 1, centreY + blobSize);
surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
@@ -270,27 +261,27 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
}
} else if (markType == SC_MARK_BOXMINUS) {
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawBox(surface, centreX, centreY, blobSize, fore, head);
+ DrawMinus(surface, centreX, centreY, blobSize, tail);
- surface->PenColour(head.allocated);
+ surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_BOXMINUSCONNECTED) {
- DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawBox(surface, centreX, centreY, blobSize, fore, head);
+ DrawMinus(surface, centreX, centreY, blobSize, tail);
- surface->PenColour(head.allocated);
+ surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
if (tFold == LineMarker::body) {
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
surface->MoveTo(centreX + 1, centreY + blobSize);
surface->LineTo(centreX + blobSize + 1, centreY + blobSize);
@@ -301,41 +292,41 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
surface->LineTo(centreX + blobSize + 1, centreY - blobSize);
}
} else if (markType == SC_MARK_CIRCLEPLUS) {
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+ DrawPlus(surface, centreX, centreY, blobSize, tail);
} else if (markType == SC_MARK_CIRCLEPLUSCONNECTED) {
if (tFold == LineMarker::headWithTail)
- surface->PenColour(tail.allocated);
+ surface->PenColour(tail);
else
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawPlus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+ DrawPlus(surface, centreX, centreY, blobSize, tail);
} else if (markType == SC_MARK_CIRCLEMINUS) {
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+ DrawMinus(surface, centreX, centreY, blobSize, tail);
- surface->PenColour(head.allocated);
+ surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
} else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) {
- DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated);
- DrawMinus(surface, centreX, centreY, blobSize, tail.allocated);
+ DrawCircle(surface, centreX, centreY, blobSize, fore, head);
+ DrawMinus(surface, centreX, centreY, blobSize, tail);
- surface->PenColour(head.allocated);
+ surface->PenColour(head);
surface->MoveTo(centreX, centreY + blobSize);
surface->LineTo(centreX, rcWhole.bottom);
- surface->PenColour(body.allocated);
+ surface->PenColour(body);
surface->MoveTo(centreX, rcWhole.top);
surface->LineTo(centreX, centreY - blobSize);
@@ -346,17 +337,17 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
rc.left += (rc.Width() - width) / 2;
rc.right = rc.left + width;
surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2,
- character, 1, fore.allocated, back.allocated);
+ character, 1, fore, back);
} else if (markType == SC_MARK_DOTDOTDOT) {
int right = centreX - 6;
for (int b=0; b<3; b++) {
PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2);
- surface->FillRectangle(rcBlob, fore.allocated);
+ surface->FillRectangle(rcBlob, fore);
right += 5;
}
} else if (markType == SC_MARK_ARROWS) {
- surface->PenColour(fore.allocated);
+ surface->PenColour(fore);
int right = centreX - 2;
for (int b=0; b<3; b++) {
surface->MoveTo(right - 4, centreY - 4);
@@ -376,12 +367,12 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
Point(centreX, centreY + dimOn2),
};
surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
- fore.allocated, back.allocated);
+ fore, back);
} else if (markType == SC_MARK_LEFTRECT) {
PRectangle rcLeft = rcWhole;
rcLeft.right = rcLeft.left + 4;
- surface->FillRectangle(rcLeft, back.allocated);
+ surface->FillRectangle(rcLeft, back);
} else { // SC_MARK_FULLRECT
- surface->FillRectangle(rcWhole, back.allocated);
+ surface->FillRectangle(rcWhole, back);
}
}
diff --git a/scintilla/src/LineMarker.h b/scintilla/src/LineMarker.h
index 2e28090..8607959 100644
--- a/scintilla/src/LineMarker.h
+++ b/scintilla/src/LineMarker.h
@@ -20,9 +20,9 @@ public:
enum typeOfFold { undefined, head, body, tail, headWithTail };
int markType;
- ColourPair fore;
- ColourPair back;
- ColourPair backSelected;
+ ColourDesired fore;
+ ColourDesired back;
+ ColourDesired backSelected;
int alpha;
XPM *pxpm;
RGBAImage *image;
@@ -62,7 +62,6 @@ public:
image = NULL;
return *this;
}
- void RefreshColourPalette(Palette &pal, bool want);
void SetXPM(const char *textForm);
void SetXPM(const char *const *linesForm);
void SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRGBAImage);
diff --git a/scintilla/src/PerLine.cxx b/scintilla/src/PerLine.cxx
index c7e5c99..795f628 100644
--- a/scintilla/src/PerLine.cxx
+++ b/scintilla/src/PerLine.cxx
@@ -182,6 +182,17 @@ int LineMarkers::MarkValue(int line) {
return 0;
}
+int LineMarkers::MarkerNext(int lineStart, int mask) const {
+ int length = markers.Length();
+ for (int iLine = lineStart; iLine < length; iLine++) {
+ MarkerHandleSet *onLine = markers[iLine];
+ if (onLine && ((onLine->MarkValue() & mask) != 0))
+ //if ((pdoc->GetMark(iLine) & lParam) != 0)
+ return iLine;
+ }
+ return -1;
+}
+
int LineMarkers::AddMark(int line, int markerNum, int lines) {
handleCurrent++;
if (!markers.Length()) {
diff --git a/scintilla/src/PerLine.h b/scintilla/src/PerLine.h
index 42081a8..db2f2a9 100644
--- a/scintilla/src/PerLine.h
+++ b/scintilla/src/PerLine.h
@@ -54,6 +54,7 @@ public:
virtual void RemoveLine(int line);
int MarkValue(int line);
+ int MarkerNext(int lineStart, int mask) const;
int AddMark(int line, int marker, int lines);
void MergeMarkers(int pos);
bool DeleteMark(int line, int markerNum, bool all);
diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx
index bc0d353..002dd85 100644
--- a/scintilla/src/PositionCache.cxx
+++ b/scintilla/src/PositionCache.cxx
@@ -86,7 +86,7 @@ void LineLayout::Resize(int maxLineLength_) {
indicators = new char[maxLineLength_ + 1];
// Extra position allocated as sometimes the Windows
// GetTextExtentExPoint API writes an extra element.
- positions = new int[maxLineLength_ + 1 + 1];
+ positions = new XYPOSITION[maxLineLength_ + 1 + 1];
maxLineLength = maxLineLength_;
}
}
@@ -503,15 +503,15 @@ PositionCacheEntry::PositionCacheEntry() :
}
void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
- unsigned int len_, int *positions_, unsigned int clock_) {
+ unsigned int len_, XYPOSITION *positions_, unsigned int clock_) {
Clear();
styleNumber = styleNumber_;
len = len_;
clock = clock_;
if (s_ && positions_) {
- positions = new short[len + (len + 1) / 2];
+ positions = new XYPOSITION[len + (len + 1) / 2];
for (unsigned int i=0; i<len; i++) {
- positions[i] = static_cast<short>(positions_[i]);
+ positions[i] = static_cast<XYPOSITION>(positions_[i]);
}
memcpy(reinterpret_cast<char *>(positions + len), s_, len);
}
@@ -530,7 +530,7 @@ void PositionCacheEntry::Clear() {
}
bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
- unsigned int len_, int *positions_) const {
+ unsigned int len_, XYPOSITION *positions_) const {
if ((styleNumber == styleNumber_) && (len == len_) &&
(memcmp(reinterpret_cast<char *>(positions + len), s_, len)== 0)) {
for (unsigned int i=0; i<len; i++) {
@@ -595,7 +595,7 @@ void PositionCache::SetSize(size_t size_) {
}
void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
- const char *s, unsigned int len, int *positions, Document *pdoc) {
+ const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc) {
allClear = false;
int probe = -1;
@@ -621,7 +621,7 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned
if (len > BreakFinder::lengthStartSubdivision) {
// Break up into segments
unsigned int startSegment = 0;
- int xStartSegment = 0;
+ XYPOSITION xStartSegment = 0;
while (startSegment < len) {
unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision);
surface->MeasureWidths(vstyle.styles[styleNumber].font, s + startSegment, lenSegment, positions + startSegment);
diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h
index 13436cb..3330a7a 100644
--- a/scintilla/src/PositionCache.h
+++ b/scintilla/src/PositionCache.h
@@ -41,7 +41,7 @@ public:
unsigned char *styles;
int styleBitsSet;
char *indicators;
- int *positions;
+ XYPOSITION *positions;
char bracePreviousStyles[2];
// Hotspot support
@@ -103,13 +103,13 @@ class PositionCacheEntry {
unsigned int styleNumber:8;
unsigned int len:8;
unsigned int clock:16;
- short *positions;
+ XYPOSITION *positions;
public:
PositionCacheEntry();
~PositionCacheEntry();
- void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_, unsigned int clock);
+ void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock);
void Clear();
- bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_) const;
+ bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const;
static int Hash(unsigned int styleNumber_, const char *s, unsigned int len);
bool NewerThan(const PositionCacheEntry &other) const;
void ResetClock();
@@ -155,7 +155,7 @@ public:
void SetSize(size_t size_);
size_t GetSize() const { return size; }
void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
- const char *s, unsigned int len, int *positions, Document *pdoc);
+ const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc);
};
inline bool IsSpaceOrTab(int ch) {
diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx
index 8afa6e7..27c45c5 100644
--- a/scintilla/src/ScintillaBase.cxx
+++ b/scintilla/src/ScintillaBase.cxx
@@ -65,11 +65,6 @@ void ScintillaBase::Finalise() {
popup.Destroy();
}
-void ScintillaBase::RefreshColourPalette(Palette &pal, bool want) {
- Editor::RefreshColourPalette(pal, want);
- ct.RefreshColourPalette(pal, want);
-}
-
void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
if (!isFillUp) {
@@ -222,7 +217,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
}
}
ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(),
- lenEntered, vs.lineHeight, IsUnicodeMode());
+ lenEntered, vs.lineHeight, IsUnicodeMode(), technology);
PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(sel.MainCaret() - lenEntered);
@@ -419,6 +414,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
vs.styles[ctStyle].sizeZoomed,
CodePage(),
vs.styles[ctStyle].characterSet,
+ vs.technology,
wMain);
// If the call-tip window would be out of the client
// space, adjust so it displays above the text.
diff --git a/scintilla/src/ScintillaBase.h b/scintilla/src/ScintillaBase.h
index 2d743e3..f34e04e 100644
--- a/scintilla/src/ScintillaBase.h
+++ b/scintilla/src/ScintillaBase.h
@@ -59,8 +59,6 @@ protected:
virtual void Initialise() = 0;
virtual void Finalise() = 0;
- virtual void RefreshColourPalette(Palette &pal, bool want);
-
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void Command(int cmdId);
virtual void CancelModes();
diff --git a/scintilla/src/Style.cxx b/scintilla/src/Style.cxx
index 9405c53..2efcf7f 100644
--- a/scintilla/src/Style.cxx
+++ b/scintilla/src/Style.cxx
@@ -33,7 +33,7 @@ void FontAlias::ClearFont() {
}
bool FontSpecification::EqualTo(const FontSpecification &other) const {
- return bold == other.bold &&
+ return weight == other.weight &&
italic == other.italic &&
size == other.size &&
characterSet == other.characterSet &&
@@ -56,18 +56,18 @@ void FontMeasurements::Clear() {
Style::Style() : FontSpecification() {
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
- Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
- false, false, false, false, caseMixed, true, true, false);
+ Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
+ SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
}
Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, 0,
- false, false, false, false, caseMixed, true, true, false);
- fore.desired = source.fore.desired;
- back.desired = source.back.desired;
+ SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
+ fore = source.fore;
+ back = source.back;
characterSet = source.characterSet;
- bold = source.bold;
+ weight = source.weight;
italic = source.italic;
size = source.size;
eolFilled = source.eolFilled;
@@ -86,11 +86,11 @@ Style &Style::operator=(const Style &source) {
return * this;
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, SC_CHARSET_DEFAULT,
- false, false, false, false, caseMixed, true, true, false);
- fore.desired = source.fore.desired;
- back.desired = source.back.desired;
+ SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
+ fore = source.fore;
+ back = source.back;
characterSet = source.characterSet;
- bold = source.bold;
+ weight = source.weight;
italic = source.italic;
size = source.size;
eolFilled = source.eolFilled;
@@ -103,13 +103,13 @@ Style &Style::operator=(const Style &source) {
void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
const char *fontName_, int characterSet_,
- bool bold_, bool italic_, bool eolFilled_,
+ int weight_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_,
bool visible_, bool changeable_, bool hotspot_) {
- fore.desired = fore_;
- back.desired = back_;
+ fore = fore_;
+ back = back_;
characterSet = characterSet_;
- bold = bold_;
+ weight = weight_;
italic = italic_;
size = size_;
fontName = fontName_;
@@ -125,12 +125,12 @@ void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
void Style::ClearTo(const Style &source) {
Clear(
- source.fore.desired,
- source.back.desired,
+ source.fore,
+ source.back,
source.size,
source.fontName,
source.characterSet,
- source.bold,
+ source.weight,
source.italic,
source.eolFilled,
source.underline,
diff --git a/scintilla/src/Style.h b/scintilla/src/Style.h
index 9c1bf35..1cd085f 100644
--- a/scintilla/src/Style.h
+++ b/scintilla/src/Style.h
@@ -14,16 +14,16 @@ namespace Scintilla {
struct FontSpecification {
const char *fontName;
- bool bold;
+ int weight;
bool italic;
int size;
int characterSet;
int extraFontFlag;
FontSpecification() :
fontName(0),
- bold(false),
+ weight(SC_WEIGHT_NORMAL),
italic(false),
- size(10),
+ size(10 * SC_FONT_SIZE_MULTIPLIER),
characterSet(0),
extraFontFlag(0) {
}
@@ -58,8 +58,8 @@ struct FontMeasurements {
*/
class Style : public FontSpecification, public FontMeasurements {
public:
- ColourPair fore;
- ColourPair back;
+ ColourDesired fore;
+ ColourDesired back;
bool eolFilled;
bool underline;
enum ecaseForced {caseMixed, caseUpper, caseLower};
@@ -77,7 +77,7 @@ public:
void Clear(ColourDesired fore_, ColourDesired back_,
int size_,
const char *fontName_, int characterSet_,
- bool bold_, bool italic_, bool eolFilled_,
+ int weight_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_,
bool visible_, bool changeable_, bool hotspot_);
void ClearTo(const Style &source);
diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx
index 2c20169..882decc 100644
--- a/scintilla/src/ViewStyle.cxx
+++ b/scintilla/src/ViewStyle.cxx
@@ -86,14 +86,15 @@ FontRealised::~FontRealised() {
frNext = 0;
}
-void FontRealised::Realise(Surface &surface, int zoomLevel) {
+void FontRealised::Realise(Surface &surface, int zoomLevel, int technology) {
PLATFORM_ASSERT(fontName);
- sizeZoomed = size + zoomLevel;
- if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
- sizeZoomed = 2;
+ sizeZoomed = size + zoomLevel * SC_FONT_SIZE_MULTIPLIER;
+ if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
+ sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
- int deviceHeight = surface.DeviceHeightFont(sizeZoomed);
- font.Create(fontName, characterSet, deviceHeight, bold, italic, extraFontFlag);
+ float deviceHeight = surface.DeviceHeightFont(sizeZoomed);
+ FontParameters fp(fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, weight, italic, extraFontFlag, technology, characterSet);
+ font.Create(fp);
ascent = surface.Ascent(font);
descent = surface.Descent(font);
@@ -102,7 +103,7 @@ void FontRealised::Realise(Surface &surface, int zoomLevel) {
aveCharWidth = surface.AverageCharWidth(font);
spaceWidth = surface.WidthChar(font, ' ');
if (frNext) {
- frNext->Realise(surface, zoomLevel);
+ frNext->Realise(surface, zoomLevel, technology);
}
}
@@ -149,40 +150,40 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
}
selforeset = source.selforeset;
- selforeground.desired = source.selforeground.desired;
- selAdditionalForeground.desired = source.selAdditionalForeground.desired;
+ selforeground = source.selforeground;
+ selAdditionalForeground = source.selAdditionalForeground;
selbackset = source.selbackset;
- selbackground.desired = source.selbackground.desired;
- selAdditionalBackground.desired = source.selAdditionalBackground.desired;
- selbackground2.desired = source.selbackground2.desired;
+ selbackground = source.selbackground;
+ selAdditionalBackground = source.selAdditionalBackground;
+ selbackground2 = source.selbackground2;
selAlpha = source.selAlpha;
selAdditionalAlpha = source.selAdditionalAlpha;
selEOLFilled = source.selEOLFilled;
foldmarginColourSet = source.foldmarginColourSet;
- foldmarginColour.desired = source.foldmarginColour.desired;
+ foldmarginColour = source.foldmarginColour;
foldmarginHighlightColourSet = source.foldmarginHighlightColourSet;
- foldmarginHighlightColour.desired = source.foldmarginHighlightColour.desired;
+ foldmarginHighlightColour = source.foldmarginHighlightColour;
hotspotForegroundSet = source.hotspotForegroundSet;
- hotspotForeground.desired = source.hotspotForeground.desired;
+ hotspotForeground = source.hotspotForeground;
hotspotBackgroundSet = source.hotspotBackgroundSet;
- hotspotBackground.desired = source.hotspotBackground.desired;
+ hotspotBackground = source.hotspotBackground;
hotspotUnderline = source.hotspotUnderline;
hotspotSingleLine = source.hotspotSingleLine;
whitespaceForegroundSet = source.whitespaceForegroundSet;
- whitespaceForeground.desired = source.whitespaceForeground.desired;
+ whitespaceForeground = source.whitespaceForeground;
whitespaceBackgroundSet = source.whitespaceBackgroundSet;
- whitespaceBackground.desired = source.whitespaceBackground.desired;
- selbar.desired = source.selbar.desired;
- selbarlight.desired = source.selbarlight.desired;
- caretcolour.desired = source.caretcolour.desired;
- additionalCaretColour.desired = source.additionalCaretColour.desired;
+ whitespaceBackground = source.whitespaceBackground;
+ selbar = source.selbar;
+ selbarlight = source.selbarlight;
+ caretcolour = source.caretcolour;
+ additionalCaretColour = source.additionalCaretColour;
showCaretLineBackground = source.showCaretLineBackground;
- caretLineBackground.desired = source.caretLineBackground.desired;
+ caretLineBackground = source.caretLineBackground;
caretLineAlpha = source.caretLineAlpha;
- edgecolour.desired = source.edgecolour.desired;
+ edgecolour = source.edgecolour;
edgeState = source.edgeState;
caretStyle = source.caretStyle;
caretWidth = source.caretWidth;
@@ -239,6 +240,7 @@ void ViewStyle::Init(size_t stylesSize_) {
indicators[2].under = false;
indicators[2].fore = ColourDesired(0xff, 0, 0);
+ technology = SC_TECHNOLOGY_DEFAULT;
lineHeight = 1;
maxAscent = 1;
maxDescent = 1;
@@ -246,35 +248,35 @@ void ViewStyle::Init(size_t stylesSize_) {
spaceWidth = 8;
selforeset = false;
- selforeground.desired = ColourDesired(0xff, 0, 0);
- selAdditionalForeground.desired = ColourDesired(0xff, 0, 0);
+ selforeground = ColourDesired(0xff, 0, 0);
+ selAdditionalForeground = ColourDesired(0xff, 0, 0);
selbackset = true;
- selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
- selAdditionalBackground.desired = ColourDesired(0xd7, 0xd7, 0xd7);
- selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
+ selbackground = ColourDesired(0xc0, 0xc0, 0xc0);
+ selAdditionalBackground = ColourDesired(0xd7, 0xd7, 0xd7);
+ selbackground2 = ColourDesired(0xb0, 0xb0, 0xb0);
selAlpha = SC_ALPHA_NOALPHA;
selAdditionalAlpha = SC_ALPHA_NOALPHA;
selEOLFilled = false;
foldmarginColourSet = false;
- foldmarginColour.desired = ColourDesired(0xff, 0, 0);
+ foldmarginColour = ColourDesired(0xff, 0, 0);
foldmarginHighlightColourSet = false;
- foldmarginHighlightColour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+ foldmarginHighlightColour = ColourDesired(0xc0, 0xc0, 0xc0);
whitespaceForegroundSet = false;
- whitespaceForeground.desired = ColourDesired(0, 0, 0);
+ whitespaceForeground = ColourDesired(0, 0, 0);
whitespaceBackgroundSet = false;
- whitespaceBackground.desired = ColourDesired(0xff, 0xff, 0xff);
- selbar.desired = Platform::Chrome();
- selbarlight.desired = Platform::ChromeHighlight();
- styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
- styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
- caretcolour.desired = ColourDesired(0, 0, 0);
- additionalCaretColour.desired = ColourDesired(0x7f, 0x7f, 0x7f);
+ whitespaceBackground = ColourDesired(0xff, 0xff, 0xff);
+ selbar = Platform::Chrome();
+ selbarlight = Platform::ChromeHighlight();
+ styles[STYLE_LINENUMBER].fore = ColourDesired(0, 0, 0);
+ styles[STYLE_LINENUMBER].back = Platform::Chrome();
+ caretcolour = ColourDesired(0, 0, 0);
+ additionalCaretColour = ColourDesired(0x7f, 0x7f, 0x7f);
showCaretLineBackground = false;
- caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
+ caretLineBackground = ColourDesired(0xff, 0xff, 0);
caretLineAlpha = SC_ALPHA_NOALPHA;
- edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+ edgecolour = ColourDesired(0xc0, 0xc0, 0xc0);
edgeState = EDGE_NONE;
caretStyle = CARETSTYLE_LINE;
caretWidth = 1;
@@ -282,9 +284,9 @@ void ViewStyle::Init(size_t stylesSize_) {
someStylesForceCase = false;
hotspotForegroundSet = false;
- hotspotForeground.desired = ColourDesired(0, 0, 0xff);
+ hotspotForeground = ColourDesired(0, 0, 0xff);
hotspotBackgroundSet = false;
- hotspotBackground.desired = ColourDesired(0xff, 0xff, 0xff);
+ hotspotBackground = ColourDesired(0xff, 0xff, 0xff);
hotspotUnderline = true;
hotspotSingleLine = true;
@@ -326,39 +328,6 @@ void ViewStyle::Init(size_t stylesSize_) {
braceBadLightIndicator = 0;
}
-void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
- unsigned int i;
- for (i=0; i<stylesSize; i++) {
- pal.WantFind(styles[i].fore, want);
- pal.WantFind(styles[i].back, want);
- }
- for (i=0; i<(sizeof(indicators)/sizeof(indicators[0])); i++) {
- pal.WantFind(indicators[i].fore, want);
- }
- for (i=0; i<(sizeof(markers)/sizeof(markers[0])); i++) {
- markers[i].RefreshColourPalette(pal, want);
- }
- pal.WantFind(selforeground, want);
- pal.WantFind(selAdditionalForeground, want);
- pal.WantFind(selbackground, want);
- pal.WantFind(selAdditionalBackground, want);
- pal.WantFind(selbackground2, want);
-
- pal.WantFind(foldmarginColour, want);
- pal.WantFind(foldmarginHighlightColour, want);
-
- pal.WantFind(whitespaceForeground, want);
- pal.WantFind(whitespaceBackground, want);
- pal.WantFind(selbar, want);
- pal.WantFind(selbarlight, want);
- pal.WantFind(caretcolour, want);
- pal.WantFind(additionalCaretColour, want);
- pal.WantFind(caretLineBackground, want);
- pal.WantFind(edgecolour, want);
- pal.WantFind(hotspotForeground, want);
- pal.WantFind(hotspotBackground, want);
-}
-
void ViewStyle::CreateFont(const FontSpecification &fs) {
if (fs.fontName) {
for (FontRealised *cur=frFirst; cur; cur=cur->frNext) {
@@ -376,8 +345,8 @@ void ViewStyle::CreateFont(const FontSpecification &fs) {
void ViewStyle::Refresh(Surface &surface) {
delete frFirst;
frFirst = NULL;
- selbar.desired = Platform::Chrome();
- selbarlight.desired = Platform::ChromeHighlight();
+ selbar = Platform::Chrome();
+ selbarlight = Platform::ChromeHighlight();
for (unsigned int i=0; i<stylesSize; i++) {
styles[i].extraFontFlag = extraFontFlag;
@@ -388,7 +357,7 @@ void ViewStyle::Refresh(Surface &surface) {
CreateFont(styles[j]);
}
- frFirst->Realise(surface, zoomLevel);
+ frFirst->Realise(surface, zoomLevel, technology);
for (unsigned int k=0; k<stylesSize; k++) {
FontRealised *fr = frFirst->Find(styles[k]);
@@ -457,9 +426,9 @@ void ViewStyle::EnsureStyle(size_t index) {
void ViewStyle::ResetDefaultStyle() {
styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
ColourDesired(0xff,0xff,0xff),
- Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
+ Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT,
- false, false, false, false, Style::caseMixed, true, true, false);
+ SC_WEIGHT_NORMAL, false, false, false, Style::caseMixed, true, true, false);
}
void ViewStyle::ClearStyles() {
@@ -469,11 +438,11 @@ void ViewStyle::ClearStyles() {
styles[i].ClearTo(styles[STYLE_DEFAULT]);
}
}
- styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
+ styles[STYLE_LINENUMBER].back = Platform::Chrome();
// Set call tip fore/back to match the values previously set for call tips
- styles[STYLE_CALLTIP].back.desired = ColourDesired(0xff, 0xff, 0xff);
- styles[STYLE_CALLTIP].fore.desired = ColourDesired(0x80, 0x80, 0x80);
+ styles[STYLE_CALLTIP].back = ColourDesired(0xff, 0xff, 0xff);
+ styles[STYLE_CALLTIP].fore = ColourDesired(0x80, 0x80, 0x80);
}
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h
index feaa9eb..a9370c7 100644
--- a/scintilla/src/ViewStyle.h
+++ b/scintilla/src/ViewStyle.h
@@ -48,7 +48,7 @@ public:
FontRealised *frNext;
FontRealised(const FontSpecification &fs);
virtual ~FontRealised();
- void Realise(Surface &surface, int zoomLevel);
+ void Realise(Surface &surface, int zoomLevel, int technology);
FontRealised *Find(const FontSpecification &fs);
void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent);
};
@@ -67,35 +67,36 @@ public:
Style *styles;
LineMarker markers[MARKER_MAX + 1];
Indicator indicators[INDIC_MAX + 1];
+ int technology;
int lineHeight;
unsigned int maxAscent;
unsigned int maxDescent;
unsigned int aveCharWidth;
unsigned int spaceWidth;
bool selforeset;
- ColourPair selforeground;
- ColourPair selAdditionalForeground;
+ ColourDesired selforeground;
+ ColourDesired selAdditionalForeground;
bool selbackset;
- ColourPair selbackground;
- ColourPair selAdditionalBackground;
- ColourPair selbackground2;
+ ColourDesired selbackground;
+ ColourDesired selAdditionalBackground;
+ ColourDesired selbackground2;
int selAlpha;
int selAdditionalAlpha;
bool selEOLFilled;
bool whitespaceForegroundSet;
- ColourPair whitespaceForeground;
+ ColourDesired whitespaceForeground;
bool whitespaceBackgroundSet;
- ColourPair whitespaceBackground;
- ColourPair selbar;
- ColourPair selbarlight;
+ ColourDesired whitespaceBackground;
+ ColourDesired selbar;
+ ColourDesired selbarlight;
bool foldmarginColourSet;
- ColourPair foldmarginColour;
+ ColourDesired foldmarginColour;
bool foldmarginHighlightColourSet;
- ColourPair foldmarginHighlightColour;
+ ColourDesired foldmarginHighlightColour;
bool hotspotForegroundSet;
- ColourPair hotspotForeground;
+ ColourDesired hotspotForeground;
bool hotspotBackgroundSet;
- ColourPair hotspotBackground;
+ ColourDesired hotspotBackground;
bool hotspotUnderline;
bool hotspotSingleLine;
/// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
@@ -112,12 +113,12 @@ public:
IndentView viewIndentationGuides;
bool viewEOL;
bool showMarkedLines;
- ColourPair caretcolour;
- ColourPair additionalCaretColour;
+ ColourDesired caretcolour;
+ ColourDesired additionalCaretColour;
bool showCaretLineBackground;
- ColourPair caretLineBackground;
+ ColourDesired caretLineBackground;
int caretLineAlpha;
- ColourPair edgecolour;
+ ColourDesired edgecolour;
int edgeState;
int caretStyle;
int caretWidth;
@@ -139,7 +140,6 @@ public:
~ViewStyle();
void Init(size_t stylesSize_=64);
void CreateFont(const FontSpecification &fs);
- void RefreshColourPalette(Palette &pal, bool want);
void Refresh(Surface &surface);
void AllocStyles(size_t sizeNew);
void EnsureStyle(size_t index);
diff --git a/scintilla/src/XPM.cxx b/scintilla/src/XPM.cxx
index 4ef9e3b..02d7da9 100644
--- a/scintilla/src/XPM.cxx
+++ b/scintilla/src/XPM.cxx
@@ -46,11 +46,11 @@ static size_t MeasureLength(const char *s) {
}
ColourDesired XPM::ColourDesiredFromCode(int ch) const {
- return colourCodeTable[ch]->desired;
+ return *colourCodeTable[ch];
}
-ColourAllocated XPM::ColourFromCode(int ch) const {
- return colourCodeTable[ch]->allocated;
+ColourDesired XPM::ColourFromCode(int ch) const {
+ return *colourCodeTable[ch];
#ifdef SLOW
for (int i=0; i<nColours; i++) {
if (codes[i] == ch) {
@@ -124,7 +124,7 @@ void XPM::Init(const char *const *linesForm) {
return;
}
codes = new char[nColours];
- colours = new ColourPair[nColours];
+ colours = new ColourDesired[nColours];
int strings = 1+height+nColours;
lines = new char *[strings];
@@ -151,9 +151,9 @@ void XPM::Init(const char *const *linesForm) {
codes[c] = colourDef[0];
colourDef += 4;
if (*colourDef == '#') {
- colours[c].desired.Set(colourDef);
+ colours[c].Set(colourDef);
} else {
- colours[c].desired = ColourDesired(0xff, 0xff, 0xff);
+ colours[c] = ColourDesired(0xff, 0xff, 0xff);
codeTransparent = codes[c];
}
colourCodeTable[static_cast<unsigned char>(codes[c])] = &(colours[c]);
@@ -171,24 +171,6 @@ void XPM::Clear() {
lines = 0;
}
-void XPM::RefreshColourPalette(Palette &pal, bool want) {
- if (!data || !codes || !colours || !lines) {
- return;
- }
- for (int i=0; i<nColours; i++) {
- pal.WantFind(colours[i], want);
- }
-}
-
-void XPM::CopyDesiredColours() {
- if (!data || !codes || !colours || !lines) {
- return;
- }
- for (int i=0; i<nColours; i++) {
- colours[i].Copy();
- }
-}
-
void XPM::Draw(Surface *surface, PRectangle &rc) {
if (!data || !codes || !colours || !lines) {
return;
@@ -296,7 +278,6 @@ void XPMSet::Add(int ident, const char *textForm) {
for (int i = 0; i < len; i++) {
if (set[i]->GetId() == ident) {
set[i]->Init(textForm);
- set[i]->CopyDesiredColours();
return;
}
}
@@ -305,7 +286,6 @@ void XPMSet::Add(int ident, const char *textForm) {
XPM *pxpm = new XPM(textForm);
if (pxpm) {
pxpm->SetId(ident);
- pxpm->CopyDesiredColours();
if (len == maximum) {
maximum += 64;
XPM **setNew = new XPM *[maximum];
diff --git a/scintilla/src/XPM.h b/scintilla/src/XPM.h
index d8b59dd..d32ce9a 100644
--- a/scintilla/src/XPM.h
+++ b/scintilla/src/XPM.h
@@ -23,12 +23,12 @@ class XPM {
char *data;
char codeTransparent;
char *codes;
- ColourPair *colours;
+ ColourDesired *colours;
ColourDesired ColourDesiredFromCode(int ch) const;
- ColourAllocated ColourFromCode(int ch) const;
+ ColourDesired ColourFromCode(int ch) const;
void FillRun(Surface *surface, int code, int startX, int y, int x);
char **lines;
- ColourPair *colourCodeTable[256];
+ ColourDesired *colourCodeTable[256];
public:
XPM(const char *textForm);
XPM(const char *const *linesForm);
@@ -36,10 +36,6 @@ public:
void Init(const char *textForm);
void Init(const char *const *linesForm);
void Clear();
- /// Similar to same named method in ViewStyle:
- void RefreshColourPalette(Palette &pal, bool want);
- /// No palette used, so just copy the desired colours to the allocated colours
- void CopyDesiredColours();
/// Decompose image into runs and use FillRectangle for each run
void Draw(Surface *surface, PRectangle &rc);
char **InLinesForm() { return lines; }
diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx
index e2eab19..9295d07 100644
--- a/scintilla/win32/PlatWin.cxx
+++ b/scintilla/win32/PlatWin.cxx
@@ -30,6 +30,17 @@
#include <richedit.h>
#include <windowsx.h>
+/* notepad2-mod custom code
+ D2D files are not included in WDK 7.1 */
+#if defined(_MSC_VER) && !defined(WDK_BUILD)
+#define USE_D2D 1
+#endif
+
+#if defined(USE_D2D)
+#include <d2d1.h>
+#include <dwrite.h>
+#endif
+
#include "Platform.h"
#include "UniConversion.h"
#include "XPM.h"
@@ -111,93 +122,102 @@ static RECT RectFromPRectangle(PRectangle prc) {
return rc;
}
-Palette::Palette() {
- used = 0;
- allowRealization = false;
- hpal = 0;
- size = 100;
- entries = new ColourPair[size];
-}
-
-Palette::~Palette() {
- Release();
- delete []entries;
- entries = 0;
-}
-
-void Palette::Release() {
- used = 0;
- if (hpal)
- ::DeleteObject(hpal);
- hpal = 0;
- delete []entries;
- size = 100;
- entries = new ColourPair[size];
-}
-
-/**
- * This method either adds a colour to the list of wanted colours (want==true)
- * or retrieves the allocated colour back to the ColourPair.
- * This is one method to make it easier to keep the code for wanting and retrieving in sync.
- */
-void Palette::WantFind(ColourPair &cp, bool want) {
- if (want) {
- for (int i=0; i < used; i++) {
- if (entries[i].desired == cp.desired)
- return;
- }
-
- if (used >= size) {
- int sizeNew = size * 2;
- ColourPair *entriesNew = new ColourPair[sizeNew];
- for (int j=0; j<size; j++) {
- entriesNew[j] = entries[j];
+#if defined(USE_D2D)
+IDWriteFactory *pIDWriteFactory = 0;
+ID2D1Factory *pD2DFactory = 0;
+
+bool LoadD2D() {
+ static bool triedLoadingD2D = false;
+ static HMODULE hDLLD2D = 0;
+ static HMODULE hDLLDWrite = 0;
+ if (!triedLoadingD2D) {
+ typedef HRESULT (WINAPI *D2D1CFSig)(D2D1_FACTORY_TYPE factoryType, REFIID riid,
+ CONST D2D1_FACTORY_OPTIONS *pFactoryOptions, IUnknown **factory);
+ typedef HRESULT (WINAPI *DWriteCFSig)(DWRITE_FACTORY_TYPE factoryType, REFIID iid,
+ IUnknown **factory);
+
+ hDLLD2D = ::LoadLibrary(TEXT("D2D1.DLL"));
+ if (hDLLD2D) {
+ D2D1CFSig fnD2DCF = (D2D1CFSig)::GetProcAddress(hDLLD2D, "D2D1CreateFactory");
+ if (fnD2DCF) {
+ // A single threaded factory as Scintilla always draw on the GUI thread
+ fnD2DCF(D2D1_FACTORY_TYPE_SINGLE_THREADED,
+ __uuidof(ID2D1Factory),
+ 0,
+ reinterpret_cast<IUnknown**>(&pD2DFactory));
}
- delete []entries;
- entries = entriesNew;
- size = sizeNew;
}
-
- entries[used].desired = cp.desired;
- entries[used].allocated.Set(cp.desired.AsLong());
- used++;
- } else {
- for (int i=0; i < used; i++) {
- if (entries[i].desired == cp.desired) {
- cp.allocated = entries[i].allocated;
- return;
+ hDLLDWrite = ::LoadLibrary(TEXT("DWRITE.DLL"));
+ if (hDLLDWrite) {
+ DWriteCFSig fnDWCF = (DWriteCFSig)::GetProcAddress(hDLLDWrite, "DWriteCreateFactory");
+ if (fnDWCF) {
+ fnDWCF(DWRITE_FACTORY_TYPE_SHARED,
+ __uuidof(IDWriteFactory),
+ reinterpret_cast<IUnknown**>(&pIDWriteFactory));
}
}
- cp.allocated.Set(cp.desired.AsLong());
}
+ triedLoadingD2D = true;
+ return pIDWriteFactory && pD2DFactory;
}
+#endif
-void Palette::Allocate(Window &) {
- if (hpal)
- ::DeleteObject(hpal);
- hpal = 0;
+struct FormatAndMetrics {
+ int technology;
+ HFONT hfont;
+#if defined(USE_D2D)
+ IDWriteTextFormat *pTextFormat;
+#endif
+ int extraFontFlag;
+ FLOAT yAscent;
+ FLOAT yDescent;
+ FormatAndMetrics(HFONT hfont_, int extraFontFlag_) :
+ technology(SCWIN_TECH_GDI), hfont(hfont_),
+#if defined(USE_D2D)
+ pTextFormat(0),
+#endif
+ extraFontFlag(extraFontFlag_), yAscent(2), yDescent(1) {
+ }
+#if defined(USE_D2D)
+ FormatAndMetrics(IDWriteTextFormat *pTextFormat_, int extraFontFlag_, FLOAT yAscent_, FLOAT yDescent_) :
+ technology(SCWIN_TECH_DIRECTWRITE), hfont(0), pTextFormat(pTextFormat_), extraFontFlag(extraFontFlag_), yAscent(yAscent_), yDescent(yDescent_) {
+ }
+#endif
+ ~FormatAndMetrics() {
+ if (hfont)
+ ::DeleteObject(hfont);
+#if defined(USE_D2D)
+ if (pTextFormat)
+ pTextFormat->Release();
+ pTextFormat = 0;
+#endif
+ extraFontFlag = 0;
+ yAscent = 2;
+ yDescent = 1;
+ }
+ HFONT HFont();
+};
- if (allowRealization) {
- char *pal = new char[sizeof(LOGPALETTE) + (used-1) * sizeof(PALETTEENTRY)];
- LOGPALETTE *logpal = reinterpret_cast<LOGPALETTE *>(pal);
- logpal->palVersion = 0x300;
- logpal->palNumEntries = static_cast<WORD>(used);
- for (int iPal=0;iPal<used;iPal++) {
- ColourDesired desired = entries[iPal].desired;
- logpal->palPalEntry[iPal].peRed = static_cast<BYTE>(desired.GetRed());
- logpal->palPalEntry[iPal].peGreen = static_cast<BYTE>(desired.GetGreen());
- logpal->palPalEntry[iPal].peBlue = static_cast<BYTE>(desired.GetBlue());
- entries[iPal].allocated.Set(
- PALETTERGB(desired.GetRed(), desired.GetGreen(), desired.GetBlue()));
- // PC_NOCOLLAPSE means exact colours allocated even when in background this means other windows
- // are less likely to get their colours and also flashes more when switching windows
- logpal->palPalEntry[iPal].peFlags = PC_NOCOLLAPSE;
- // 0 allows approximate colours when in background, yielding moe colours to other windows
- //logpal->palPalEntry[iPal].peFlags = 0;
+HFONT FormatAndMetrics::HFont() {
+#if defined(USE_D2D)
+ if (technology == SCWIN_TECH_GDI) {
+ return hfont;
+ } else {
+ LOGFONTW lf;
+ memset(&lf, 0, sizeof(lf));
+
+ HRESULT hr = pTextFormat->GetFontFamilyName(lf.lfFaceName, LF_FACESIZE);
+ if (SUCCEEDED(hr)) {
+ lf.lfWeight = pTextFormat->GetFontWeight();
+ lf.lfItalic = pTextFormat->GetFontStyle() == DWRITE_FONT_STYLE_ITALIC;
+ lf.lfHeight = -static_cast<int>(pTextFormat->GetFontSize());
+ return ::CreateFontIndirectW(&lf);
}
- hpal = ::CreatePalette(logpal);
- delete []pal;
}
+ return 0;
+#else
+ return hfont;
+#endif
}
#ifndef CLEARTYPE_QUALITY
@@ -221,11 +241,30 @@ static BYTE Win32MapFontQuality(int extraFontFlag) {
}
}
-static void SetLogFont(LOGFONTA &lf, const char *faceName, int characterSet, int size, bool bold, bool italic, int extraFontFlag) {
+#if defined(USE_D2D)
+static D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) {
+ switch (extraFontFlag & SC_EFF_QUALITY_MASK) {
+
+ case SC_EFF_QUALITY_NON_ANTIALIASED:
+ return D2D1_TEXT_ANTIALIAS_MODE_ALIASED;
+
+ case SC_EFF_QUALITY_ANTIALIASED:
+ return D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
+
+ case SC_EFF_QUALITY_LCD_OPTIMIZED:
+ return D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
+
+ default:
+ return D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
+ }
+}
+#endif
+
+static void SetLogFont(LOGFONTA &lf, const char *faceName, int characterSet, float size, int weight, bool italic, int extraFontFlag) {
memset(&lf, 0, sizeof(lf));
// The negative is to allow for leading
- lf.lfHeight = -(abs(size));
- lf.lfWeight = bold ? FW_BOLD : FW_NORMAL;
+ lf.lfHeight = -(abs(static_cast<int>(size + 0.5)));
+ lf.lfWeight = weight;
lf.lfItalic = static_cast<BYTE>(italic ? 1 : 0);
lf.lfCharSet = static_cast<BYTE>(characterSet);
lf.lfQuality = Win32MapFontQuality(extraFontFlag);
@@ -237,71 +276,113 @@ static void SetLogFont(LOGFONTA &lf, const char *faceName, int characterSet, int
* If one font is the same as another, its hash will be the same, but if the hash is the
* same then they may still be different.
*/
-static int HashFont(const char *faceName, int characterSet, int size, bool bold, bool italic, int extraFontFlag) {
+static int HashFont(const FontParameters &fp) {
return
- size ^
- (characterSet << 10) ^
- ((extraFontFlag & SC_EFF_QUALITY_MASK) << 9) ^
- (bold ? 0x10000000 : 0) ^
- (italic ? 0x20000000 : 0) ^
- faceName[0];
+ static_cast<int>(fp.size) ^
+ (fp.characterSet << 10) ^
+ ((fp.extraFontFlag & SC_EFF_QUALITY_MASK) << 9) ^
+ ((fp.weight/100) << 12) ^
+ (fp.italic ? 0x20000000 : 0) ^
+ (fp.technology << 15) ^
+ fp.faceName[0];
}
class FontCached : Font {
FontCached *next;
int usage;
+ float size;
LOGFONTA lf;
+ int technology;
int hash;
- FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_, int extraFontFlag_);
+ FontCached(const FontParameters &fp);
~FontCached() {}
- bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_, int extraFontFlag_);
+ bool SameAs(const FontParameters &fp);
virtual void Release();
static FontCached *first;
public:
- static FontID FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_, int extraFontFlag_);
+ static FontID FindOrCreate(const FontParameters &fp);
static void ReleaseId(FontID fid_);
};
FontCached *FontCached::first = 0;
-FontCached::FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_, int extraFontFlag_) :
- next(0), usage(0), hash(0) {
- SetLogFont(lf, faceName_, characterSet_, size_, bold_, italic_, extraFontFlag_);
- hash = HashFont(faceName_, characterSet_, size_, bold_, italic_, extraFontFlag_);
- fid = ::CreateFontIndirectA(&lf);
+FontCached::FontCached(const FontParameters &fp) :
+ next(0), usage(0), size(1.0), hash(0) {
+ SetLogFont(lf, fp.faceName, fp.characterSet, fp.size, fp.weight, fp.italic, fp.extraFontFlag);
+ technology = fp.technology;
+ hash = HashFont(fp);
+ fid = 0;
+ if (technology == SCWIN_TECH_GDI) {
+ HFONT hfont = ::CreateFontIndirectA(&lf);
+ fid = reinterpret_cast<void *>(new FormatAndMetrics(hfont, fp.extraFontFlag));
+ } else {
+#if defined(USE_D2D)
+ IDWriteTextFormat *pTextFormat;
+ const int faceSize = 200;
+ WCHAR wszFace[faceSize];
+ UTF16FromUTF8(fp.faceName, static_cast<unsigned int>(strlen(fp.faceName))+1, wszFace, faceSize);
+ FLOAT fHeight = fp.size;
+ DWRITE_FONT_STYLE style = fp.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL;
+ HRESULT hr = pIDWriteFactory->CreateTextFormat(wszFace, NULL,
+ static_cast<DWRITE_FONT_WEIGHT>(fp.weight),
+ style,
+ DWRITE_FONT_STRETCH_NORMAL, fHeight, L"en-us", &pTextFormat);
+ if (SUCCEEDED(hr)) {
+ pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
+
+ const int maxLines = 2;
+ DWRITE_LINE_METRICS lineMetrics[maxLines];
+ UINT32 lineCount = 0;
+ FLOAT yAscent = 1.0f;
+ FLOAT yDescent = 1.0f;
+ IDWriteTextLayout *pTextLayout = 0;
+ hr = pIDWriteFactory->CreateTextLayout(L"X", 1, pTextFormat,
+ 100.0f, 100.0f, &pTextLayout);
+ if (SUCCEEDED(hr)) {
+ hr = pTextLayout->GetLineMetrics(lineMetrics, maxLines, &lineCount);
+ if (SUCCEEDED(hr)) {
+ yAscent = lineMetrics[0].baseline;
+ yDescent = lineMetrics[0].height - lineMetrics[0].baseline;
+ }
+ pTextLayout->Release();
+ }
+ fid = reinterpret_cast<void *>(new FormatAndMetrics(pTextFormat, fp.extraFontFlag, yAscent, yDescent));
+ }
+#endif
+ }
usage = 1;
}
-bool FontCached::SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_, int extraFontFlag_) {
+bool FontCached::SameAs(const FontParameters &fp) {
return
- (lf.lfHeight == -(abs(size_))) &&
- (lf.lfWeight == (bold_ ? FW_BOLD : FW_NORMAL)) &&
- (lf.lfItalic == static_cast<BYTE>(italic_ ? 1 : 0)) &&
- (lf.lfCharSet == characterSet_) &&
- (lf.lfQuality == Win32MapFontQuality(extraFontFlag_)) &&
- 0 == strcmp(lf.lfFaceName,faceName_);
+ (size == fp.size) &&
+ (lf.lfWeight == fp.weight) &&
+ (lf.lfItalic == static_cast<BYTE>(fp.italic ? 1 : 0)) &&
+ (lf.lfCharSet == fp.characterSet) &&
+ (lf.lfQuality == Win32MapFontQuality(fp.extraFontFlag)) &&
+ (technology == fp.technology) &&
+ 0 == strcmp(lf.lfFaceName,fp.faceName);
}
void FontCached::Release() {
- if (fid)
- ::DeleteObject(fid);
+ delete reinterpret_cast<FormatAndMetrics *>(fid);
fid = 0;
}
-FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_, int extraFontFlag_) {
+FontID FontCached::FindOrCreate(const FontParameters &fp) {
FontID ret = 0;
::EnterCriticalSection(&crPlatformLock);
- int hashFind = HashFont(faceName_, characterSet_, size_, bold_, italic_, extraFontFlag_);
+ int hashFind = HashFont(fp);
for (FontCached *cur=first; cur; cur=cur->next) {
if ((cur->hash == hashFind) &&
- cur->SameAs(faceName_, characterSet_, size_, bold_, italic_, extraFontFlag_)) {
+ cur->SameAs(fp)) {
cur->usage++;
ret = cur->fid;
}
}
if (ret == 0) {
- FontCached *fc = new FontCached(faceName_, characterSet_, size_, bold_, italic_, extraFontFlag_);
+ FontCached *fc = new FontCached(fp);
if (fc) {
fc->next = first;
first = fc;
@@ -340,35 +421,62 @@ Font::~Font() {
#define FONTS_CACHED
-void Font::Create(const char *faceName, int characterSet, int size,
- bool bold, bool italic, int extraFontFlag) {
+void Font::Create(const FontParameters &fp) {
Release();
-#ifndef FONTS_CACHED
- LOGFONT lf;
- SetLogFont(lf, faceName, characterSet, size, bold, italic, extraFontFlag);
- fid = ::CreateFontIndirect(&lf);
-#else
- if (faceName)
- fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic, extraFontFlag);
-#endif
+ if (fp.faceName)
+ fid = FontCached::FindOrCreate(fp);
}
void Font::Release() {
-#ifndef FONTS_CACHED
- if (fid)
- ::DeleteObject(fid);
-#else
if (fid)
FontCached::ReleaseId(fid);
-#endif
fid = 0;
}
+// Buffer to hold strings and string position arrays without always allocating on heap.
+// May sometimes have string too long to allocate on stack. So use a fixed stack-allocated buffer
+// when less than safe size otherwise allocate on heap and free automatically.
+template<typename T, int lengthStandard>
+class VarBuffer {
+ T bufferStandard[lengthStandard];
+public:
+ T *buffer;
+ VarBuffer(size_t length) : buffer(0) {
+ if (length > lengthStandard) {
+ buffer = new T[length];
+ } else {
+ buffer = bufferStandard;
+ }
+ }
+ ~VarBuffer() {
+ if (buffer != bufferStandard) {
+ delete []buffer;
+ buffer = 0;
+ }
+ }
+};
+
+const int stackBufferLength = 10000;
+class TextWide : public VarBuffer<wchar_t, stackBufferLength> {
+public:
+ int tlen;
+ TextWide(const char *s, int len, bool unicodeMode, int codePage=0) :
+ VarBuffer<wchar_t, stackBufferLength>(len) {
+ if (unicodeMode) {
+ tlen = UTF16FromUTF8(s, len, buffer, len);
+ } else {
+ // Support Asian string display in 9x English
+ tlen = ::MultiByteToWideChar(codePage, 0, s, len, buffer, len);
+ }
+ }
+};
+typedef VarBuffer<XYPOSITION, stackBufferLength> TextPositions;
+
#ifdef SCI_NAMESPACE
namespace Scintilla {
#endif
-class SurfaceImpl : public Surface {
+class SurfaceGDI : public Surface {
bool unicodeMode;
HDC hdc;
bool hdcOwned;
@@ -380,7 +488,6 @@ class SurfaceImpl : public Surface {
HFONT fontOld;
HBITMAP bitmap;
HBITMAP bitmapOld;
- HPALETTE paletteOld;
int maxWidthMeasure;
int maxLenText;
@@ -388,15 +495,15 @@ class SurfaceImpl : public Surface {
// If 9x OS and current code page is same as ANSI code page.
bool win9xACPSame;
- void BrushColor(ColourAllocated back);
+ void BrushColor(ColourDesired back);
void SetFont(Font &font_);
- // Private so SurfaceImpl objects can not be copied
- SurfaceImpl(const SurfaceImpl &);
- SurfaceImpl &operator=(const SurfaceImpl &);
+ // Private so SurfaceGDI objects can not be copied
+ SurfaceGDI(const SurfaceGDI &);
+ SurfaceGDI &operator=(const SurfaceGDI &);
public:
- SurfaceImpl();
- virtual ~SurfaceImpl();
+ SurfaceGDI();
+ virtual ~SurfaceGDI();
void Init(WindowID wid);
void Init(SurfaceID sid, WindowID wid);
@@ -404,37 +511,36 @@ public:
void Release();
bool Initialised();
- void PenColour(ColourAllocated fore);
+ void PenColour(ColourDesired fore);
int LogPixelsY();
int DeviceHeightFont(int points);
void MoveTo(int x_, int y_);
void LineTo(int x_, int y_);
- void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
- void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
- void FillRectangle(PRectangle rc, ColourAllocated back);
+ void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back);
+ void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back);
+ void FillRectangle(PRectangle rc, ColourDesired back);
void FillRectangle(PRectangle rc, Surface &surfacePattern);
- void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
- void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
- ColourAllocated outline, int alphaOutline, int flags);
+ void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back);
+ void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+ ColourDesired outline, int alphaOutline, int flags);
void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage);
- void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back);
void Copy(PRectangle rc, Point from, Surface &surfaceSource);
- void DrawTextCommon(PRectangle rc, Font &font_, int ybase, const char *s, int len, UINT fuOptions);
- void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
- void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
- void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore);
- void MeasureWidths(Font &font_, const char *s, int len, int *positions);
- int WidthText(Font &font_, const char *s, int len);
- int WidthChar(Font &font_, char ch);
- int Ascent(Font &font_);
- int Descent(Font &font_);
- int InternalLeading(Font &font_);
- int ExternalLeading(Font &font_);
- int Height(Font &font_);
- int AverageCharWidth(Font &font_);
-
- int SetPalette(Palette *pal, bool inBackGround);
+ void DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, UINT fuOptions);
+ void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
+ void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
+ void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);
+ void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions);
+ XYPOSITION WidthText(Font &font_, const char *s, int len);
+ XYPOSITION WidthChar(Font &font_, char ch);
+ XYPOSITION Ascent(Font &font_);
+ XYPOSITION Descent(Font &font_);
+ XYPOSITION InternalLeading(Font &font_);
+ XYPOSITION ExternalLeading(Font &font_);
+ XYPOSITION Height(Font &font_);
+ XYPOSITION AverageCharWidth(Font &font_);
+
void SetClip(PRectangle rc);
void FlushCachedState();
@@ -446,14 +552,13 @@ public:
} //namespace Scintilla
#endif
-SurfaceImpl::SurfaceImpl() :
+SurfaceGDI::SurfaceGDI() :
unicodeMode(false),
hdc(0), hdcOwned(false),
pen(0), penOld(0),
brush(0), brushOld(0),
font(0), fontOld(0),
- bitmap(0), bitmapOld(0),
- paletteOld(0) {
+ bitmap(0), bitmapOld(0) {
// Windows 9x has only a 16 bit coordinate system so break after 30000 pixels
maxWidthMeasure = IsNT() ? INT_MAX : 30000;
// There appears to be a 16 bit string length limit in GDI on NT and a limit of
@@ -464,11 +569,11 @@ SurfaceImpl::SurfaceImpl() :
win9xACPSame = false;
}
-SurfaceImpl::~SurfaceImpl() {
+SurfaceGDI::~SurfaceGDI() {
Release();
}
-void SurfaceImpl::Release() {
+void SurfaceGDI::Release() {
if (penOld) {
::SelectObject(reinterpret_cast<HDC>(hdc), penOld);
::DeleteObject(pen);
@@ -493,12 +598,6 @@ void SurfaceImpl::Release() {
bitmapOld = 0;
}
bitmap = 0;
- if (paletteOld) {
- // Palettes are not deleted as they are owned by a Palette object
- ::SelectPalette(reinterpret_cast<HDC>(hdc),
- reinterpret_cast<HPALETTE>(paletteOld), TRUE);
- paletteOld = 0;
- }
if (hdcOwned) {
::DeleteDC(reinterpret_cast<HDC>(hdc));
hdc = 0;
@@ -506,33 +605,33 @@ void SurfaceImpl::Release() {
}
}
-bool SurfaceImpl::Initialised() {
+bool SurfaceGDI::Initialised() {
return hdc != 0;
}
-void SurfaceImpl::Init(WindowID) {
+void SurfaceGDI::Init(WindowID) {
Release();
hdc = ::CreateCompatibleDC(NULL);
hdcOwned = true;
::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);
}
-void SurfaceImpl::Init(SurfaceID sid, WindowID) {
+void SurfaceGDI::Init(SurfaceID sid, WindowID) {
Release();
hdc = reinterpret_cast<HDC>(sid);
::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);
}
-void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID) {
+void SurfaceGDI::InitPixMap(int width, int height, Surface *surface_, WindowID) {
Release();
- hdc = ::CreateCompatibleDC(static_cast<SurfaceImpl *>(surface_)->hdc);
+ hdc = ::CreateCompatibleDC(static_cast<SurfaceGDI *>(surface_)->hdc);
hdcOwned = true;
- bitmap = ::CreateCompatibleBitmap(static_cast<SurfaceImpl *>(surface_)->hdc, width, height);
+ bitmap = ::CreateCompatibleBitmap(static_cast<SurfaceGDI *>(surface_)->hdc, width, height);
bitmapOld = static_cast<HBITMAP>(::SelectObject(hdc, bitmap));
::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);
}
-void SurfaceImpl::PenColour(ColourAllocated fore) {
+void SurfaceGDI::PenColour(ColourDesired fore) {
if (pen) {
::SelectObject(hdc, penOld);
::DeleteObject(pen);
@@ -543,7 +642,7 @@ void SurfaceImpl::PenColour(ColourAllocated fore) {
penOld = static_cast<HPEN>(::SelectObject(reinterpret_cast<HDC>(hdc), pen));
}
-void SurfaceImpl::BrushColor(ColourAllocated back) {
+void SurfaceGDI::BrushColor(ColourDesired back) {
if (brush) {
::SelectObject(hdc, brushOld);
::DeleteObject(brush);
@@ -551,51 +650,53 @@ void SurfaceImpl::BrushColor(ColourAllocated back) {
brushOld = 0;
}
// Only ever want pure, non-dithered brushes
- ColourAllocated colourNearest = ::GetNearestColor(hdc, back.AsLong());
+ ColourDesired colourNearest = ::GetNearestColor(hdc, back.AsLong());
brush = ::CreateSolidBrush(colourNearest.AsLong());
brushOld = static_cast<HBRUSH>(::SelectObject(hdc, brush));
}
-void SurfaceImpl::SetFont(Font &font_) {
+void SurfaceGDI::SetFont(Font &font_) {
if (font_.GetID() != font) {
+ FormatAndMetrics *pfm = reinterpret_cast<FormatAndMetrics *>(font_.GetID());
+ PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_GDI);
if (fontOld) {
- ::SelectObject(hdc, font_.GetID());
+ ::SelectObject(hdc, pfm->hfont);
} else {
- fontOld = static_cast<HFONT>(::SelectObject(hdc, font_.GetID()));
+ fontOld = static_cast<HFONT>(::SelectObject(hdc, pfm->hfont));
}
- font = reinterpret_cast<HFONT>(font_.GetID());
+ font = reinterpret_cast<HFONT>(pfm->hfont);
}
}
-int SurfaceImpl::LogPixelsY() {
+int SurfaceGDI::LogPixelsY() {
return ::GetDeviceCaps(hdc, LOGPIXELSY);
}
-int SurfaceImpl::DeviceHeightFont(int points) {
+int SurfaceGDI::DeviceHeightFont(int points) {
return ::MulDiv(points, LogPixelsY(), 72);
}
-void SurfaceImpl::MoveTo(int x_, int y_) {
+void SurfaceGDI::MoveTo(int x_, int y_) {
::MoveToEx(hdc, x_, y_, 0);
}
-void SurfaceImpl::LineTo(int x_, int y_) {
+void SurfaceGDI::LineTo(int x_, int y_) {
::LineTo(hdc, x_, y_);
}
-void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
+void SurfaceGDI::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColor(back);
::Polygon(hdc, reinterpret_cast<POINT *>(pts), npts);
}
-void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
+void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColor(back);
::Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
}
-void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
+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.
RECT rcw = RectFromPRectangle(rc);
@@ -603,10 +704,10 @@ void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) {
::ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE, &rcw, TEXT(""), 0, NULL);
}
-void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
+void SurfaceGDI::FillRectangle(PRectangle rc, Surface &surfacePattern) {
HBRUSH br;
- if (static_cast<SurfaceImpl &>(surfacePattern).bitmap)
- br = ::CreatePatternBrush(static_cast<SurfaceImpl &>(surfacePattern).bitmap);
+ if (static_cast<SurfaceGDI &>(surfacePattern).bitmap)
+ br = ::CreatePatternBrush(static_cast<SurfaceGDI &>(surfacePattern).bitmap);
else // Something is wrong so display in red
br = ::CreateSolidBrush(RGB(0xff, 0, 0));
RECT rcw = RectFromPRectangle(rc);
@@ -614,7 +715,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
::DeleteObject(br);
}
-void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
+void SurfaceGDI::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColor(back);
::RoundRect(hdc,
@@ -650,8 +751,8 @@ static DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) {
return converter.val;
}
-void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
- ColourAllocated outline, int alphaOutline, int /* flags*/ ) {
+void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+ ColourDesired outline, int alphaOutline, int /* flags*/ ) {
if (AlphaBlendFn && rc.Width() > 0) {
HDC hMemDC = ::CreateCompatibleDC(reinterpret_cast<HDC>(hdc));
int width = rc.Width();
@@ -709,7 +810,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated
}
}
-void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {
+void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {
if (AlphaBlendFn && rc.Width() > 0) {
HDC hMemDC = ::CreateCompatibleDC(reinterpret_cast<HDC>(hdc));
if (rc.Width() > width)
@@ -748,58 +849,21 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi
}
}
-void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
+void SurfaceGDI::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColor(back);
::Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);
}
-void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
+void SurfaceGDI::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
::BitBlt(hdc,
rc.left, rc.top, rc.Width(), rc.Height(),
- static_cast<SurfaceImpl &>(surfaceSource).hdc, from.x, from.y, SRCCOPY);
+ static_cast<SurfaceGDI &>(surfaceSource).hdc, from.x, from.y, SRCCOPY);
}
-// Buffer to hold strings and string position arrays without always allocating on heap.
-// May sometimes have string too long to allocate on stack. So use a fixed stack-allocated buffer
-// when less than safe size otherwise allocate on heap and free automatically.
-template<typename T, int lengthStandard>
-class VarBuffer {
- T bufferStandard[lengthStandard];
-public:
- T *buffer;
- VarBuffer(size_t length) : buffer(0) {
- if (length > lengthStandard) {
- buffer = new T[length];
- } else {
- buffer = bufferStandard;
- }
- }
- ~VarBuffer() {
- if (buffer != bufferStandard) {
- delete []buffer;
- buffer = 0;
- }
- }
-};
-
-const int stackBufferLength = 10000;
-class TextWide : public VarBuffer<wchar_t, stackBufferLength> {
-public:
- int tlen;
- TextWide(const char *s, int len, bool unicodeMode, int codePage=0) :
- VarBuffer<wchar_t, stackBufferLength>(len) {
- if (unicodeMode) {
- tlen = UTF16FromUTF8(s, len, buffer, len);
- } else {
- // Support Asian string display in 9x English
- tlen = ::MultiByteToWideChar(codePage, 0, s, len, buffer, len);
- }
- }
-};
-typedef VarBuffer<int, stackBufferLength> TextPositions;
+typedef VarBuffer<int, stackBufferLength> TextPositionsI;
-void SurfaceImpl::DrawTextCommon(PRectangle rc, Font &font_, int ybase, const char *s, int len, UINT fuOptions) {
+void SurfaceGDI::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, UINT fuOptions) {
SetFont(font_);
RECT rcw = RectFromPRectangle(rc);
SIZE sz={0,0};
@@ -843,22 +907,22 @@ void SurfaceImpl::DrawTextCommon(PRectangle rc, Font &font_, int ybase, const ch
}
}
-void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len,
- ColourAllocated fore, ColourAllocated back) {
+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());
DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE);
}
-void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len,
- ColourAllocated fore, ColourAllocated back) {
+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());
DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE | ETO_CLIPPED);
}
-void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len,
- ColourAllocated fore) {
+void SurfaceGDI::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+ ColourDesired fore) {
// Avoid drawing spaces in transparent mode
for (int i=0;i<len;i++) {
if (s[i] != ' ') {
@@ -871,7 +935,7 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, con
}
}
-int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
+XYPOSITION SurfaceGDI::WidthText(Font &font_, const char *s, int len) {
SetFont(font_);
SIZE sz={0,0};
if ((!unicodeMode) && (IsNT() || (codePage==0) || win9xACPSame)) {
@@ -883,13 +947,13 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
return sz.cx;
}
-void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) {
+void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) {
SetFont(font_);
SIZE sz={0,0};
int fit = 0;
if (unicodeMode) {
const TextWide tbuf(s, len, unicodeMode, codePage);
- TextPositions poses(tbuf.tlen);
+ TextPositionsI poses(tbuf.tlen);
fit = tbuf.tlen;
if (!::GetTextExtentExPointW(hdc, tbuf.buffer, tbuf.tlen, maxWidthMeasure, &fit, poses.buffer, &sz)) {
// Likely to have failed because on Windows 9x where function not available
@@ -933,19 +997,19 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
int startOffset = 0;
while (len > 0) {
int lenBlock = Platform::Minimum(len, maxLenText);
- if (!::GetTextExtentExPointA(hdc, s, lenBlock, maxWidthMeasure, &fit, positions, &sz)) {
+ TextPositionsI poses(len);
+ if (!::GetTextExtentExPointA(hdc, s, lenBlock, maxWidthMeasure, &fit, poses.buffer, &sz)) {
// Eeek - a NULL DC or other foolishness could cause this.
return;
} else if (fit < lenBlock) {
// For some reason, such as an incomplete DBCS character
// Not all the positions are filled in so make them equal to end.
- for (int i=fit;i<lenBlock;i++)
- positions[i] = positions[fit-1];
- } else if (startOffset > 0) {
- for (int i=0;i<lenBlock;i++)
- positions[i] += startOffset;
+ for (int i = fit;i<lenBlock;i++)
+ poses.buffer[i] = poses.buffer[fit-1];
}
- startOffset = positions[lenBlock-1];
+ for (int i=0;i<lenBlock;i++)
+ positions[i] = poses.buffer[i] + startOffset;
+ startOffset = poses.buffer[lenBlock-1];
len -= lenBlock;
positions += lenBlock;
s += lenBlock;
@@ -953,7 +1017,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
} else {
// Support Asian string display in 9x English
const TextWide tbuf(s, len, unicodeMode, codePage);
- TextPositions poses(tbuf.tlen);
+ TextPositionsI poses(tbuf.tlen);
for (int widthSS=0; widthSS<tbuf.tlen; widthSS++) {
::GetTextExtentPoint32W(hdc, tbuf.buffer, widthSS+1, &sz);
poses.buffer[widthSS] = sz.cx;
@@ -975,91 +1039,757 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
}
}
-int SurfaceImpl::WidthChar(Font &font_, char ch) {
+XYPOSITION SurfaceGDI::WidthChar(Font &font_, char ch) {
SetFont(font_);
SIZE sz;
::GetTextExtentPoint32A(hdc, &ch, 1, &sz);
return sz.cx;
}
-int SurfaceImpl::Ascent(Font &font_) {
+XYPOSITION SurfaceGDI::Ascent(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
return tm.tmAscent;
}
-int SurfaceImpl::Descent(Font &font_) {
+XYPOSITION SurfaceGDI::Descent(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
return tm.tmDescent;
}
-int SurfaceImpl::InternalLeading(Font &font_) {
+XYPOSITION SurfaceGDI::InternalLeading(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
return tm.tmInternalLeading;
}
-int SurfaceImpl::ExternalLeading(Font &font_) {
+XYPOSITION SurfaceGDI::ExternalLeading(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
return tm.tmExternalLeading;
}
-int SurfaceImpl::Height(Font &font_) {
+XYPOSITION SurfaceGDI::Height(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
return tm.tmHeight;
}
-int SurfaceImpl::AverageCharWidth(Font &font_) {
+XYPOSITION SurfaceGDI::AverageCharWidth(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
return tm.tmAveCharWidth;
}
-int SurfaceImpl::SetPalette(Palette *pal, bool inBackGround) {
- if (paletteOld) {
- ::SelectPalette(hdc, paletteOld, TRUE);
- }
- paletteOld = 0;
- int changes = 0;
- if (pal->allowRealization) {
- paletteOld = ::SelectPalette(hdc,
- reinterpret_cast<HPALETTE>(pal->hpal), inBackGround);
- changes = ::RealizePalette(hdc);
- }
- return changes;
-}
-
-void SurfaceImpl::SetClip(PRectangle rc) {
+void SurfaceGDI::SetClip(PRectangle rc) {
::IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
}
-void SurfaceImpl::FlushCachedState() {
+void SurfaceGDI::FlushCachedState() {
pen = 0;
brush = 0;
font = 0;
}
-void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
+void SurfaceGDI::SetUnicodeMode(bool unicodeMode_) {
unicodeMode=unicodeMode_;
}
-void SurfaceImpl::SetDBCSMode(int codePage_) {
+void SurfaceGDI::SetDBCSMode(int codePage_) {
// No action on window as automatically handled by system.
codePage = codePage_;
win9xACPSame = !IsNT() && ((unsigned int)codePage == ::GetACP());
}
-Surface *Surface::Allocate() {
- return new SurfaceImpl;
+#if defined(USE_D2D)
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+class SurfaceD2D : public Surface {
+ bool unicodeMode;
+ int x, y;
+
+ int codePage;
+
+ ID2D1RenderTarget *pRenderTarget;
+ bool ownRenderTarget;
+ int clipsActive;
+
+ IDWriteTextFormat *pTextFormat;
+ FLOAT yAscent;
+ FLOAT yDescent;
+
+ ID2D1SolidColorBrush *pBrush;
+
+ int logPixelsY;
+ float dpiScaleX;
+ float dpiScaleY;
+
+ void SetFont(Font &font_);
+
+ // Private so SurfaceD2D objects can not be copied
+ SurfaceD2D(const SurfaceD2D &);
+ SurfaceD2D &operator=(const SurfaceD2D &);
+public:
+ SurfaceD2D();
+ virtual ~SurfaceD2D();
+
+ void SetScale();
+ void Init(WindowID wid);
+ void Init(SurfaceID sid, WindowID wid);
+ void InitPixMap(int width, int height, Surface *surface_, WindowID wid);
+
+ void Release();
+ bool Initialised();
+
+ HRESULT FlushDrawing();
+
+ void PenColour(ColourDesired fore);
+ void D2DPenColour(ColourDesired fore, int alpha=255);
+ int LogPixelsY();
+ int DeviceHeightFont(int points);
+ void MoveTo(int x_, int y_);
+ void LineTo(int x_, int y_);
+ void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back);
+ void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back);
+ void FillRectangle(PRectangle rc, ColourDesired back);
+ void FillRectangle(PRectangle rc, Surface &surfacePattern);
+ void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back);
+ void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+ ColourDesired outline, int alphaOutline, int flags);
+ void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage);
+ void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back);
+ void Copy(PRectangle rc, Point from, Surface &surfaceSource);
+
+ void DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, UINT fuOptions);
+ void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
+ void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
+ void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);
+ void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions);
+ XYPOSITION WidthText(Font &font_, const char *s, int len);
+ XYPOSITION WidthChar(Font &font_, char ch);
+ XYPOSITION Ascent(Font &font_);
+ XYPOSITION Descent(Font &font_);
+ XYPOSITION InternalLeading(Font &font_);
+ XYPOSITION ExternalLeading(Font &font_);
+ XYPOSITION Height(Font &font_);
+ XYPOSITION AverageCharWidth(Font &font_);
+
+ void SetClip(PRectangle rc);
+ void FlushCachedState();
+
+ void SetUnicodeMode(bool unicodeMode_);
+ void SetDBCSMode(int codePage_);
+};
+
+#ifdef SCI_NAMESPACE
+} //namespace Scintilla
+#endif
+
+SurfaceD2D::SurfaceD2D() :
+ unicodeMode(false),
+ x(0), y(0) {
+
+ codePage = 0;
+
+ pRenderTarget = NULL;
+ ownRenderTarget = false;
+ clipsActive = 0;
+
+ // From selected font
+ pTextFormat = NULL;
+ yAscent = 2;
+ yDescent = 1;
+
+ pBrush = NULL;
+
+ logPixelsY = 72;
+ dpiScaleX = 1.0;
+ dpiScaleY = 1.0;
+}
+
+SurfaceD2D::~SurfaceD2D() {
+ Release();
+}
+
+void SurfaceD2D::Release() {
+ if (pBrush) {
+ pBrush->Release();
+ pBrush = 0;
+ }
+ if (pRenderTarget) {
+ while (clipsActive) {
+ pRenderTarget->PopAxisAlignedClip();
+ clipsActive--;
+ }
+ if (ownRenderTarget) {
+ pRenderTarget->Release();
+ }
+ pRenderTarget = 0;
+ }
+}
+
+void SurfaceD2D::SetScale() {
+ HDC hdcMeasure = ::CreateCompatibleDC(NULL);
+ logPixelsY = ::GetDeviceCaps(hdcMeasure, LOGPIXELSY);
+ dpiScaleX = ::GetDeviceCaps(hdcMeasure, LOGPIXELSX) / 96.0f;
+ dpiScaleY = logPixelsY / 96.0f;
+ ::DeleteDC(hdcMeasure);
+}
+
+bool SurfaceD2D::Initialised() {
+ return pRenderTarget != 0;
+}
+
+HRESULT SurfaceD2D::FlushDrawing() {
+ return pRenderTarget->Flush();
+}
+
+void SurfaceD2D::Init(WindowID /* wid */) {
+ Release();
+ SetScale();
+}
+
+void SurfaceD2D::Init(SurfaceID sid, WindowID) {
+ Release();
+ SetScale();
+ pRenderTarget = reinterpret_cast<ID2D1HwndRenderTarget *>(sid);
+}
+
+void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID) {
+ Release();
+ SetScale();
+ SurfaceD2D *psurfOther = static_cast<SurfaceD2D *>(surface_);
+ ID2D1BitmapRenderTarget *pCompatibleRenderTarget = NULL;
+ HRESULT hr = psurfOther->pRenderTarget->CreateCompatibleRenderTarget(
+ D2D1::SizeF(width, height), &pCompatibleRenderTarget);
+ if (SUCCEEDED(hr)) {
+ pRenderTarget = pCompatibleRenderTarget;
+ pRenderTarget->BeginDraw();
+ ownRenderTarget = true;
+ }
+}
+
+void SurfaceD2D::PenColour(ColourDesired fore) {
+ D2DPenColour(fore);
+}
+
+void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) {
+ if (pRenderTarget) {
+ D2D_COLOR_F col;
+ col.r = (fore.AsLong() & 0xff) / 255.0;
+ col.g = ((fore.AsLong() & 0xff00) >> 8) / 255.0;
+ col.b = (fore.AsLong() >> 16) / 255.0;
+ col.a = alpha / 255.0;
+ if (pBrush) {
+ pBrush->SetColor(col);
+ } else {
+ HRESULT hr = pRenderTarget->CreateSolidColorBrush(col, &pBrush);
+ if (!SUCCEEDED(hr) && pBrush) {
+ pBrush->Release();
+ pBrush = 0;
+ }
+ }
+ }
+}
+
+void SurfaceD2D::SetFont(Font &font_) {
+ FormatAndMetrics *pfm = reinterpret_cast<FormatAndMetrics *>(font_.GetID());
+ PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_DIRECTWRITE);
+ pTextFormat = pfm->pTextFormat;
+ yAscent = pfm->yAscent;
+ yDescent = pfm->yDescent;
+ if (pRenderTarget) {
+ pRenderTarget->SetTextAntialiasMode(DWriteMapFontQuality(pfm->extraFontFlag));
+ }
+}
+
+int SurfaceD2D::LogPixelsY() {
+ return logPixelsY;
+}
+
+int SurfaceD2D::DeviceHeightFont(int points) {
+ return ::MulDiv(points, LogPixelsY(), 72);
+}
+
+void SurfaceD2D::MoveTo(int x_, int y_) {
+ x = x_;
+ y = y_;
+}
+
+static int Delta(int difference) {
+ if (difference < 0)
+ return -1;
+ else if (difference > 0)
+ return 1;
+ else
+ return 0;
+}
+
+static int RoundFloat(float f) {
+ return int(f+0.5);
+}
+
+void SurfaceD2D::LineTo(int x_, int y_) {
+ if (pRenderTarget) {
+ int xDiff = x_ - x;
+ int xDelta = Delta(xDiff);
+ int yDiff = y_ - y;
+ int yDelta = Delta(yDiff);
+ if ((xDiff == 0) || (yDiff == 0)) {
+ // Horizontal or vertical lines can be more precisely drawn as a filled rectangle
+ int xEnd = x_ - xDelta;
+ int left = Platform::Minimum(x, xEnd);
+ int width = abs(x - xEnd) + 1;
+ int yEnd = y_ - yDelta;
+ int top = Platform::Minimum(y, yEnd);
+ int height = abs(y - yEnd) + 1;
+ D2D1_RECT_F rectangle1 = D2D1::RectF(left, top, left+width, top+height);
+ pRenderTarget->FillRectangle(&rectangle1, pBrush);
+ } else if ((abs(xDiff) == abs(yDiff))) {
+ // 45 degree slope
+ pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
+ D2D1::Point2F(x_ + 0.5 - xDelta, y_ + 0.5 - yDelta), pBrush);
+ } else {
+ // Line has a different slope so difficult to avoid last pixel
+ pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5, y + 0.5),
+ D2D1::Point2F(x_ + 0.5, y_ + 0.5), pBrush);
+ }
+ x = x_;
+ y = y_;
+ }
+}
+
+void SurfaceD2D::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) {
+ if (pRenderTarget) {
+ ID2D1Factory *pFactory = 0;
+ pRenderTarget->GetFactory(&pFactory);
+ ID2D1PathGeometry *geometry=0;
+ HRESULT hr = pFactory->CreatePathGeometry(&geometry);
+ if (SUCCEEDED(hr)) {
+ ID2D1GeometrySink *sink = 0;
+ hr = geometry->Open(&sink);
+ if (SUCCEEDED(hr)) {
+ sink->BeginFigure(D2D1::Point2F(pts[0].x + 0.5f, pts[0].y + 0.5f), D2D1_FIGURE_BEGIN_FILLED);
+ for (size_t i=1; i<static_cast<size_t>(npts); i++) {
+ sink->AddLine(D2D1::Point2F(pts[i].x + 0.5f, pts[i].y + 0.5f));
+ }
+ sink->EndFigure(D2D1_FIGURE_END_CLOSED);
+ sink->Close();
+ sink->Release();
+
+ D2DPenColour(back);
+ pRenderTarget->FillGeometry(geometry,pBrush);
+ D2DPenColour(fore);
+ pRenderTarget->DrawGeometry(geometry,pBrush);
+ }
+
+ geometry->Release();
+ }
+ }
+}
+
+void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
+ if (pRenderTarget) {
+ D2DPenColour(back);
+ D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left) + 0.5, rc.top+0.5, RoundFloat(rc.right) - 0.5, rc.bottom-0.5);
+ D2DPenColour(back);
+ pRenderTarget->FillRectangle(&rectangle1, pBrush);
+ D2DPenColour(fore);
+ pRenderTarget->DrawRectangle(&rectangle1, pBrush);
+ }
+}
+
+void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) {
+ if (pRenderTarget) {
+ D2DPenColour(back);
+ D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left), rc.top, RoundFloat(rc.right), rc.bottom);
+ pRenderTarget->FillRectangle(&rectangle1, pBrush);
+ }
+}
+
+void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) {
+ SurfaceD2D &surfOther = static_cast<SurfaceD2D &>(surfacePattern);
+ surfOther.FlushDrawing();
+ ID2D1Bitmap *pBitmap = NULL;
+ ID2D1BitmapRenderTarget *pCompatibleRenderTarget = reinterpret_cast<ID2D1BitmapRenderTarget *>(
+ surfOther.pRenderTarget);
+ HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap);
+ if (SUCCEEDED(hr)) {
+ ID2D1BitmapBrush *pBitmapBrush = NULL;
+ D2D1_BITMAP_BRUSH_PROPERTIES brushProperties =
+ D2D1::BitmapBrushProperties(D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP,
+ D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR);
+ // Create the bitmap brush.
+ hr = pRenderTarget->CreateBitmapBrush(pBitmap, brushProperties, &pBitmapBrush);
+ pBitmap->Release();
+ if (SUCCEEDED(hr)) {
+ pRenderTarget->FillRectangle(
+ D2D1::RectF(rc.left, rc.top, rc.right, rc.bottom),
+ pBitmapBrush);
+ pBitmapBrush->Release();
+ }
+ }
+}
+
+void SurfaceD2D::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) {
+ if (pRenderTarget) {
+ D2D1_ROUNDED_RECT roundedRectFill = D2D1::RoundedRect(
+ D2D1::RectF(rc.left+1.0, rc.top+1.0, rc.right-1.0, rc.bottom-1.0),
+ 8, 8);
+ D2DPenColour(back);
+ pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush);
+
+ D2D1_ROUNDED_RECT roundedRect = D2D1::RoundedRect(
+ D2D1::RectF(rc.left + 0.5, rc.top+0.5, rc.right - 0.5, rc.bottom-0.5),
+ 8, 8);
+ D2DPenColour(fore);
+ pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush);
+ }
+}
+
+void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
+ ColourDesired outline, int alphaOutline, int /* flags*/ ) {
+ if (pRenderTarget) {
+ D2D1_ROUNDED_RECT roundedRectFill = D2D1::RoundedRect(
+ D2D1::RectF(rc.left+1.0, rc.top+1.0, rc.right-1.0, rc.bottom-1.0),
+ cornerSize, cornerSize);
+ D2DPenColour(fill, alphaFill);
+ pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush);
+
+ D2D1_ROUNDED_RECT roundedRect = D2D1::RoundedRect(
+ D2D1::RectF(rc.left + 0.5, rc.top+0.5, rc.right - 0.5, rc.bottom-0.5),
+ cornerSize, cornerSize);
+ D2DPenColour(outline, alphaOutline);
+ pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush);
+ }
+}
+
+void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {
+ if (pRenderTarget) {
+ if (rc.Width() > width)
+ rc.left += (rc.Width() - width) / 2;
+ rc.right = rc.left + width;
+ if (rc.Height() > height)
+ rc.top += (rc.Height() - height) / 2;
+ rc.bottom = rc.top + height;
+
+ std::vector<unsigned char> image(height * width * 4);
+ for (int y=0; y<height; y++) {
+ for (int x=0; x<width; x++) {
+ unsigned char *pixel = &image[0] + (y*width+x) * 4;
+ unsigned char alpha = pixelsImage[3];
+ // Input is RGBA, output is BGRA with premultiplied alpha
+ pixel[2] = (*pixelsImage++) * alpha / 255;
+ pixel[1] = (*pixelsImage++) * alpha / 255;
+ pixel[0] = (*pixelsImage++) * alpha / 255;
+ pixel[3] = *pixelsImage++;
+ }
+ }
+
+ ID2D1Bitmap *bitmap = 0;
+ D2D1_SIZE_U size = D2D1::SizeU(width, height);
+ D2D1_BITMAP_PROPERTIES props = {{DXGI_FORMAT_B8G8R8A8_UNORM,
+ D2D1_ALPHA_MODE_PREMULTIPLIED}, 72.0, 72.0};
+ HRESULT hr = pRenderTarget->CreateBitmap(size, &image[0],
+ width * 4, &props, &bitmap);
+ if (SUCCEEDED(hr)) {
+ D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom};
+ pRenderTarget->DrawBitmap(bitmap, rcDestination);
+ }
+ bitmap->Release();
+ }
+}
+
+void SurfaceD2D::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
+ if (pRenderTarget) {
+ FLOAT radius = rc.Width() / 2.0f - 1.0f;
+ D2D1_ELLIPSE ellipse = D2D1::Ellipse(
+ D2D1::Point2F((rc.left + rc.right) / 2.0f, (rc.top + rc.bottom) / 2.0f),
+ radius,radius);
+
+ PenColour(back);
+ pRenderTarget->FillEllipse(ellipse, pBrush);
+ PenColour(fore);
+ pRenderTarget->DrawEllipse(ellipse, pBrush);
+ }
+}
+
+void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
+ SurfaceD2D &surfOther = static_cast<SurfaceD2D &>(surfaceSource);
+ surfOther.FlushDrawing();
+ ID2D1BitmapRenderTarget *pCompatibleRenderTarget = reinterpret_cast<ID2D1BitmapRenderTarget *>(
+ surfOther.pRenderTarget);
+ ID2D1Bitmap *pBitmap = NULL;
+ HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap);
+ if (SUCCEEDED(hr)) {
+ D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom};
+ D2D1_RECT_F rcSource = {from.x, from.y, from.x + rc.Width(), from.y + rc.Height()};
+ pRenderTarget->DrawBitmap(pBitmap, rcDestination, 1.0f,
+ D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, rcSource);
+ pRenderTarget->Flush();
+ pBitmap->Release();
+ }
+}
+
+void SurfaceD2D::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, UINT) {
+ SetFont(font_);
+ RECT rcw = RectFromPRectangle(rc);
+
+ // Use Unicode calls
+ const TextWide tbuf(s, len, unicodeMode, codePage);
+ if (pRenderTarget && pTextFormat && pBrush) {
+
+ // Explicitly creating a text layout appears a little faster
+ IDWriteTextLayout *pTextLayout;
+ 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, D2D1_DRAW_TEXT_OPTIONS_NONE);
+ } else {
+ D2D1_RECT_F layoutRect = D2D1::RectF(
+ static_cast<FLOAT>(rcw.left) / dpiScaleX,
+ static_cast<FLOAT>(ybase-yAscent) / dpiScaleY,
+ static_cast<FLOAT>(rcw.right + 1) / dpiScaleX,
+ static_cast<FLOAT>(rcw.bottom) / dpiScaleY);
+ pRenderTarget->DrawText(tbuf.buffer, tbuf.tlen, pTextFormat, layoutRect, pBrush, D2D1_DRAW_TEXT_OPTIONS_NONE);
+ }
+ }
+}
+
+void SurfaceD2D::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+ ColourDesired fore, ColourDesired back) {
+ if (pRenderTarget) {
+ FillRectangle(rc, back);
+ D2DPenColour(fore);
+ DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE);
+ }
+}
+
+void SurfaceD2D::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+ ColourDesired fore, ColourDesired back) {
+ if (pRenderTarget) {
+ FillRectangle(rc, back);
+ D2DPenColour(fore);
+ DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE | ETO_CLIPPED);
+ }
+}
+
+void SurfaceD2D::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,
+ ColourDesired fore) {
+ // Avoid drawing spaces in transparent mode
+ for (int i=0;i<len;i++) {
+ if (s[i] != ' ') {
+ if (pRenderTarget) {
+ D2DPenColour(fore);
+ DrawTextCommon(rc, font_, ybase, s, len, 0);
+ }
+ return;
+ }
+ }
+}
+
+XYPOSITION SurfaceD2D::WidthText(Font &font_, const char *s, int len) {
+ FLOAT width = 1.0;
+ SetFont(font_);
+ const TextWide tbuf(s, len, unicodeMode, codePage);
+ if (pIDWriteFactory && pTextFormat) {
+ // Create a layout
+ IDWriteTextLayout *pTextLayout = 0;
+ HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 1000.0, 1000.0, &pTextLayout);
+ if (SUCCEEDED(hr)) {
+ DWRITE_TEXT_METRICS textMetrics;
+ pTextLayout->GetMetrics(&textMetrics);
+ width = textMetrics.widthIncludingTrailingWhitespace;
+ pTextLayout->Release();
+ }
+ }
+ return int(width + 0.5);
+}
+
+void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) {
+ SetFont(font_);
+ int fit = 0;
+ const TextWide tbuf(s, len, unicodeMode, codePage);
+ TextPositions poses(tbuf.tlen);
+ fit = tbuf.tlen;
+ const int clusters = 1000;
+ DWRITE_CLUSTER_METRICS clusterMetrics[clusters];
+ UINT32 count = 0;
+ if (pIDWriteFactory && pTextFormat) {
+ SetFont(font_);
+ // Create a layout
+ IDWriteTextLayout *pTextLayout = 0;
+ HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 10000.0, 1000.0, &pTextLayout);
+ if (!SUCCEEDED(hr))
+ return;
+ // For now, assuming WCHAR == cluster
+ pTextLayout->GetClusterMetrics(clusterMetrics, clusters, &count);
+ FLOAT position = 0.0f;
+ size_t ti=0;
+ for (size_t ci=0;ci<count;ci++) {
+ position += clusterMetrics[ci].width;
+ for (size_t inCluster=0; inCluster<clusterMetrics[ci].length; inCluster++) {
+ //poses.buffer[ti++] = int(position + 0.5);
+ poses.buffer[ti++] = position;
+ }
+ }
+ PLATFORM_ASSERT(ti == static_cast<size_t>(tbuf.tlen));
+ pTextLayout->Release();
+ }
+ if (unicodeMode) {
+ // Map the widths given for UTF-16 characters back onto the UTF-8 input string
+ int ui=0;
+ const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
+ int i=0;
+ while (ui<fit) {
+ unsigned char uch = us[i];
+ unsigned int lenChar = 1;
+ if (uch >= (0x80 + 0x40 + 0x20 + 0x10)) {
+ lenChar = 4;
+ ui++;
+ } else if (uch >= (0x80 + 0x40 + 0x20)) {
+ lenChar = 3;
+ } else if (uch >= (0x80)) {
+ lenChar = 2;
+ }
+ for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
+ positions[i++] = poses.buffer[ui];
+ }
+ ui++;
+ }
+ int lastPos = 0;
+ if (i > 0)
+ lastPos = positions[i-1];
+ while (i<len) {
+ positions[i++] = lastPos;
+ }
+ } else if (codePage == 0) {
+
+ // One character per position
+ PLATFORM_ASSERT(len == tbuf.tlen);
+ for (size_t kk=0;kk<static_cast<size_t>(len);kk++) {
+ positions[kk] = poses.buffer[kk];
+ }
+
+ } else {
+
+ // May be more than one byte per position
+ int ui = 0;
+ for (int i=0;i<len;) {
+ if (::IsDBCSLeadByteEx(codePage, s[i])) {
+ positions[i] = poses.buffer[ui];
+ positions[i+1] = poses.buffer[ui];
+ i += 2;
+ } else {
+ positions[i] = poses.buffer[ui];
+ i++;
+ }
+
+ ui++;
+ }
+ }
+}
+
+XYPOSITION SurfaceD2D::WidthChar(Font &font_, char ch) {
+ FLOAT width = 1.0;
+ SetFont(font_);
+ if (pIDWriteFactory && pTextFormat) {
+ // Create a layout
+ IDWriteTextLayout *pTextLayout = 0;
+ const WCHAR wch = ch;
+ HRESULT hr = pIDWriteFactory->CreateTextLayout(&wch, 1, pTextFormat, 1000.0, 1000.0, &pTextLayout);
+ if (SUCCEEDED(hr)) {
+ DWRITE_TEXT_METRICS textMetrics;
+ pTextLayout->GetMetrics(&textMetrics);
+ width = textMetrics.widthIncludingTrailingWhitespace;
+ pTextLayout->Release();
+ }
+ }
+ return int(width + 0.5);
+}
+
+XYPOSITION SurfaceD2D::Ascent(Font &font_) {
+ SetFont(font_);
+ return ceil(yAscent);
+}
+
+XYPOSITION SurfaceD2D::Descent(Font &font_) {
+ SetFont(font_);
+ return ceil(yDescent);
+}
+
+XYPOSITION SurfaceD2D::InternalLeading(Font &) {
+ return 0;
+}
+
+XYPOSITION SurfaceD2D::ExternalLeading(Font &) {
+ return 1;
+}
+
+XYPOSITION SurfaceD2D::Height(Font &font_) {
+ return Ascent(font_) + Descent(font_);
+}
+
+XYPOSITION SurfaceD2D::AverageCharWidth(Font &font_) {
+ FLOAT width = 1.0;
+ SetFont(font_);
+ if (pIDWriteFactory && pTextFormat) {
+ // Create a layout
+ IDWriteTextLayout *pTextLayout = 0;
+ const WCHAR wszAllAlpha[] = L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ HRESULT hr = pIDWriteFactory->CreateTextLayout(wszAllAlpha, static_cast<UINT32>(wcslen(wszAllAlpha)),
+ pTextFormat, 1000.0, 1000.0, &pTextLayout);
+ if (SUCCEEDED(hr)) {
+ DWRITE_TEXT_METRICS textMetrics;
+ pTextLayout->GetMetrics(&textMetrics);
+ width = textMetrics.width / wcslen(wszAllAlpha);
+ pTextLayout->Release();
+ }
+ }
+ return int(width + 0.5);
+}
+
+void SurfaceD2D::SetClip(PRectangle rc) {
+ if (pRenderTarget) {
+ D2D1_RECT_F rcClip = {rc.left, rc.top, rc.right, rc.bottom};
+ pRenderTarget->PushAxisAlignedClip(rcClip, D2D1_ANTIALIAS_MODE_ALIASED);
+ clipsActive++;
+ }
+}
+
+void SurfaceD2D::FlushCachedState() {
+}
+
+void SurfaceD2D::SetUnicodeMode(bool unicodeMode_) {
+ unicodeMode=unicodeMode_;
+}
+
+void SurfaceD2D::SetDBCSMode(int codePage_) {
+ // No action on window as automatically handled by system.
+ codePage = codePage_;
+}
+#endif
+
+Surface *Surface::Allocate(int technology) {
+#if defined(USE_D2D)
+ if (technology == SCWIN_TECH_GDI)
+ return new SurfaceGDI;
+ else
+ return new SurfaceD2D;
+#else
+ return new SurfaceGDI;
+#endif
}
Window::~Window() {
@@ -1097,8 +1827,7 @@ void Window::SetPositionRelative(PRectangle rc, Window w) {
#ifdef MONITOR_DEFAULTTONULL
// We're using the stub functionality of MultiMon.h to decay gracefully on machines
// (ie, pre Win2000, Win95) that do not support the newer functions.
- RECT rcMonitor;
- memcpy(&rcMonitor, &rc, sizeof(rcMonitor)); // RECT and Rectangle are the same really.
+ RECT rcMonitor = {rc.left, rc.top, rc.right, rc.bottom};
MONITORINFO mi = {0};
mi.cbSize = sizeof(mi);
@@ -1370,6 +2099,7 @@ ListBox::~ListBox() {
class ListBoxX : public ListBox {
int lineHeight;
FontID fontCopy;
+ int technology;
RGBAImageSet images;
LineToItem lti;
HWND lb;
@@ -1412,7 +2142,7 @@ class ListBoxX : public ListBox {
static const Point ImageInset; // Padding around image
public:
- ListBoxX() : lineHeight(10), fontCopy(0), lb(0), unicodeMode(false),
+ ListBoxX() : lineHeight(10), fontCopy(0), technology(0), lb(0), unicodeMode(false),
desiredVisibleRows(5), maxItemCharacters(0), aveCharWidth(8),
parent(NULL), ctrlID(0), doubleClickAction(NULL), doubleClickActionData(NULL),
widestItem(NULL), maxCharWidth(1), resizeHit(0), wheelDelta(0) {
@@ -1424,7 +2154,7 @@ public:
}
}
virtual void SetFont(Font &font);
- virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_);
+ virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_);
virtual void SetAverageCharWidth(int width);
virtual void SetVisibleRows(int rows);
virtual int GetVisibleRows() const;
@@ -1459,12 +2189,13 @@ ListBox *ListBox::Allocate() {
return lb;
}
-void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_) {
+void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_, int technology_) {
parent = &parent_;
ctrlID = ctrlID_;
location = location_;
lineHeight = lineHeight_;
unicodeMode = unicodeMode_;
+ technology = technology_;
HWND hwndParent = reinterpret_cast<HWND>(parent->GetID());
HINSTANCE hinstanceParent = GetWindowInstance(hwndParent);
// Window created as popup so not clipped within parent client area
@@ -1476,17 +2207,19 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei
hinstanceParent,
this);
- ::MapWindowPoints(hwndParent, NULL, reinterpret_cast<POINT*>(&location), 1);
+ POINT locationw = {location.x, location.y};
+ ::MapWindowPoints(hwndParent, NULL, &locationw, 1);
+ location = Point(locationw.x, locationw.y);
}
void ListBoxX::SetFont(Font &font) {
- LOGFONT lf;
- if (0 != ::GetObject(font.GetID(), sizeof(lf), &lf)) {
+ if (font.GetID()) {
if (fontCopy) {
::DeleteObject(fontCopy);
fontCopy = 0;
}
- fontCopy = ::CreateFontIndirect(&lf);
+ FormatAndMetrics *pfm = reinterpret_cast<FormatAndMetrics *>(font.GetID());
+ fontCopy = pfm->HFont();
::SendMessage(lb, WM_SETFONT, reinterpret_cast<WPARAM>(fontCopy), 0);
}
}
@@ -1655,16 +2388,48 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) {
// Draw the image, if any
RGBAImage *pimage = images.Get(pixId);
if (pimage) {
- Surface *surfaceItem = Surface::Allocate();
+ Surface *surfaceItem = Surface::Allocate(technology);
if (surfaceItem) {
- surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem);
- int left = pDrawItem->rcItem.left + ItemInset.x + ImageInset.x;
- PRectangle rcImage(left, pDrawItem->rcItem.top,
- left + images.GetWidth(), pDrawItem->rcItem.bottom);
- surfaceItem->DrawRGBAImage(rcImage,
- pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels());
- delete surfaceItem;
- ::SetTextAlign(pDrawItem->hDC, TA_TOP);
+ if (technology == SCWIN_TECH_GDI) {
+ surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem);
+ int left = pDrawItem->rcItem.left + ItemInset.x + ImageInset.x;
+ PRectangle rcImage(left, pDrawItem->rcItem.top,
+ left + images.GetWidth(), pDrawItem->rcItem.bottom);
+ surfaceItem->DrawRGBAImage(rcImage,
+ pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels());
+ delete surfaceItem;
+ ::SetTextAlign(pDrawItem->hDC, TA_TOP);
+ } else {
+#if defined(USE_D2D)
+ D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
+ D2D1_RENDER_TARGET_TYPE_DEFAULT,
+ D2D1::PixelFormat(
+ DXGI_FORMAT_B8G8R8A8_UNORM,
+ D2D1_ALPHA_MODE_IGNORE),
+ 0,
+ 0,
+ D2D1_RENDER_TARGET_USAGE_NONE,
+ D2D1_FEATURE_LEVEL_DEFAULT
+ );
+ ID2D1DCRenderTarget *pDCRT = 0;
+ HRESULT hr = pD2DFactory->CreateDCRenderTarget(&props, &pDCRT);
+ RECT rcWindow;
+ GetClientRect(pDrawItem->hwndItem, &rcWindow);
+ hr = pDCRT->BindDC(pDrawItem->hDC, &rcWindow);
+ if (SUCCEEDED(hr)) {
+ surfaceItem->Init(pDCRT, pDrawItem->hwndItem);
+ pDCRT->BeginDraw();
+ int left = pDrawItem->rcItem.left + ItemInset.x + ImageInset.x;
+ PRectangle rcImage(left, pDrawItem->rcItem.top,
+ left + images.GetWidth(), pDrawItem->rcItem.bottom);
+ surfaceItem->DrawRGBAImage(rcImage,
+ pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels());
+ delete surfaceItem;
+ pDCRT->EndDraw();
+ pDCRT->Release();
+ }
+#endif
+ }
}
}
}
@@ -1731,7 +2496,9 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) {
}
void ListBoxX::AdjustWindowRect(PRectangle *rc) const {
- ::AdjustWindowRectEx(reinterpret_cast<RECT*>(rc), WS_THICKFRAME, false, WS_EX_WINDOWEDGE);
+ RECT rcw = {rc->left, rc->top, rc->right, rc->bottom };
+ ::AdjustWindowRectEx(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE);
+ *rc = PRectangle(rcw.left, rcw.top, rcw.right, rcw.bottom);
}
int ListBoxX::ItemHeight() const {
@@ -1772,8 +2539,9 @@ void ListBoxX::SetRedraw(bool on) {
void ListBoxX::ResizeToCursor() {
PRectangle rc = GetPosition();
- Point pt;
- ::GetCursorPos(reinterpret_cast<POINT*>(&pt));
+ POINT ptw;
+ ::GetCursorPos(&ptw);
+ Point pt(ptw.x, ptw.y);
pt.x += dragOffset.x;
pt.y += dragOffset.y;
diff --git a/scintilla/win32/PlatWin.h b/scintilla/win32/PlatWin.h
new file mode 100644
index 0000000..40c95bf
--- /dev/null
+++ b/scintilla/win32/PlatWin.h
@@ -0,0 +1,16 @@
+// Scintilla source code edit control
+/** @file PlatWin.h
+ ** Implementation of platform facilities on Windows.
+ **/
+// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+extern bool IsNT();
+extern void Platform_Initialise(void *hInstance);
+extern void Platform_Finalise();
+
+#if defined(USE_D2D)
+extern bool LoadD2D();
+extern ID2D1Factory *pD2DFactory;
+extern IDWriteFactory *pIDWriteFactory;
+#endif
diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx
index 2783972..642c1c8 100644
--- a/scintilla/win32/ScintillaWin.cxx
+++ b/scintilla/win32/ScintillaWin.cxx
@@ -28,6 +28,17 @@
#include <richedit.h>
#include <windowsx.h>
+/* notepad2-mod custom code
+ D2D files are not included in WDK 7.1 */
+#if defined(_MSC_VER) && !defined(WDK_BUILD)
+#define USE_D2D 1
+#endif
+
+#if defined(USE_D2D)
+#include <d2d1.h>
+#include <dwrite.h>
+#endif
+
#include "Platform.h"
#include "ILexer.h"
@@ -58,6 +69,7 @@
#include "Editor.h"
#include "ScintillaBase.h"
#include "UniConversion.h"
+#include "PlatWin.h"
#ifdef SCI_LEXER
#include "ExternalLexer.h"
@@ -91,11 +103,6 @@
#define SC_WIN_IDLE 5001
-// Functions imported from PlatWin
-extern bool IsNT();
-extern void Platform_Initialise(void *hInstance);
-extern void Platform_Finalise();
-
typedef BOOL (WINAPI *TrackMouseEventSig)(LPTRACKMOUSEEVENT);
// GCC has trouble with the standard COM ABI so do it the old C way with explicit vtables.
@@ -201,6 +208,10 @@ class ScintillaWin :
static HINSTANCE hInstance;
+#if defined(USE_D2D)
+ ID2D1HwndRenderTarget *pRenderTarget;
+#endif
+
ScintillaWin(HWND hwnd);
ScintillaWin(const ScintillaWin &);
virtual ~ScintillaWin();
@@ -208,6 +219,8 @@ class ScintillaWin :
virtual void Initialise();
virtual void Finalise();
+ void EnsureRenderTarget();
+ void DropRenderTarget();
HWND MainHWND();
static sptr_t DirectFunction(
@@ -263,7 +276,6 @@ class ScintillaWin :
virtual void CopyToClipboard(const SelectionText &selectedText);
void ScrollMessage(WPARAM wParam);
void HorizontalScrollMessage(WPARAM wParam);
- void RealizeWindowPalette(bool inBackGround);
void FullPaint();
void FullPaintDC(HDC dc);
bool IsCompatibleDC(HDC dc);
@@ -354,6 +366,10 @@ ScintillaWin::ScintillaWin(HWND hwnd) {
sysCaretWidth = 0;
sysCaretHeight = 0;
+#if defined(USE_D2D)
+ pRenderTarget = 0;
+#endif
+
keysAlwaysUnicode = false;
caret.period = ::GetCaretBlinkTime();
@@ -388,12 +404,50 @@ void ScintillaWin::Finalise() {
ScintillaBase::Finalise();
SetTicking(false);
SetIdle(false);
+ DropRenderTarget();
::RevokeDragDrop(MainHWND());
if (SUCCEEDED(hrOle)) {
::OleUninitialize();
}
}
+void ScintillaWin::EnsureRenderTarget() {
+#if defined(USE_D2D)
+ if (pD2DFactory && !pRenderTarget) {
+ RECT rc;
+ HWND hw = MainHWND();
+ GetClientRect(hw, &rc);
+
+ D2D1_SIZE_U size = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top);
+
+ // Create a Direct2D render target.
+#if 1
+ pD2DFactory->CreateHwndRenderTarget(
+ D2D1::RenderTargetProperties(),
+ D2D1::HwndRenderTargetProperties(hw, size),
+ &pRenderTarget);
+#else
+ pD2DFactory->CreateHwndRenderTarget(
+ D2D1::RenderTargetProperties(
+ D2D1_RENDER_TARGET_TYPE_DEFAULT ,
+ D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED),
+ 96.0f, 96.0f, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT),
+ D2D1::HwndRenderTargetProperties(hw, size),
+ &pRenderTarget);
+#endif
+ }
+#endif
+}
+
+void ScintillaWin::DropRenderTarget() {
+#if defined(USE_D2D)
+ if (pRenderTarget) {
+ pRenderTarget->Release();
+ pRenderTarget = 0;
+ }
+#endif
+}
+
HWND ScintillaWin::MainHWND() {
return reinterpret_cast<HWND>(wMain.GetID());
}
@@ -509,18 +563,37 @@ LRESULT ScintillaWin::WndPaint(uptr_t wParam) {
pps = &ps;
::BeginPaint(MainHWND(), pps);
}
- AutoSurface surfaceWindow(pps->hdc, this);
- if (surfaceWindow) {
- rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom);
- PRectangle rcClient = GetClientRectangle();
- paintingAllText = rcPaint.Contains(rcClient);
- if (paintingAllText) {
- //Platform::DebugPrintf("Performing full text paint\n");
- } else {
- //Platform::DebugPrintf("Performing partial paint %d .. %d\n", rcPaint.top, rcPaint.bottom);
+ if (technology == SC_TECHNOLOGY_DEFAULT) {
+ AutoSurface surfaceWindow(pps->hdc, this);
+ if (surfaceWindow) {
+ rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom);
+ PRectangle rcClient = GetClientRectangle();
+ paintingAllText = rcPaint.Contains(rcClient);
+ Paint(surfaceWindow, rcPaint);
+ surfaceWindow->Release();
}
- Paint(surfaceWindow, rcPaint);
- surfaceWindow->Release();
+ } else {
+#if defined(USE_D2D)
+ EnsureRenderTarget();
+ AutoSurface surfaceWindow(pRenderTarget, this);
+ if (surfaceWindow) {
+ pRenderTarget->BeginDraw();
+ rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom);
+ PRectangle rcClient = GetClientRectangle();
+ paintingAllText = rcPaint.Contains(rcClient);
+ if (paintingAllText) {
+ //Platform::DebugPrintf("Performing full text paint\n");
+ } else {
+ //Platform::DebugPrintf("Performing partial paint %d .. %d\n", rcPaint.top, rcPaint.bottom);
+ }
+ Paint(surfaceWindow, rcPaint);
+ surfaceWindow->Release();
+ HRESULT hr = pRenderTarget->EndDraw();
+ if (hr == D2DERR_RECREATE_TARGET) {
+ DropRenderTarget();
+ }
+ }
+#endif
}
if (hRgnUpdate) {
::DeleteRgn(hRgnUpdate);
@@ -678,6 +751,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case WM_SIZE: {
+ DropRenderTarget();
//Platform::DebugPrintf("Scintilla WM_SIZE %d %d\n", LoWord(lParam), HiWord(lParam));
ChangeSize();
}
@@ -923,12 +997,10 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
DestroySystemCaret();
}
}
- //RealizeWindowPalette(true);
break;
case WM_SETFOCUS:
SetFocusState(true);
- RealizeWindowPalette(false);
DestroySystemCaret();
CreateSystemCaret();
break;
@@ -938,18 +1010,6 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
InvalidateStyleData();
break;
- case WM_PALETTECHANGED:
- if (wParam != reinterpret_cast<uptr_t>(MainHWND())) {
- //Platform::DebugPrintf("** Palette Changed\n");
- RealizeWindowPalette(true);
- }
- break;
-
- case WM_QUERYNEWPALETTE:
- //Platform::DebugPrintf("** Query palette\n");
- RealizeWindowPalette(false);
- break;
-
case WM_IME_STARTCOMPOSITION: // dbcs
ImeStartComposition();
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
@@ -1089,6 +1149,26 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case SCI_GETKEYSUNICODE:
return keysAlwaysUnicode;
+
+ case SCI_SETTECHNOLOGY:
+ if ((wParam == SC_TECHNOLOGY_DEFAULT) || (wParam == SC_TECHNOLOGY_DIRECTWRITE)) {
+ if (technology != static_cast<int>(wParam)) {
+ if (static_cast<int>(wParam) == SC_TECHNOLOGY_DIRECTWRITE) {
+#if defined(USE_D2D)
+ if (!LoadD2D())
+ // Failed to load Direct2D or DirectWrite so no effect
+ return 0;
+#else
+ return 0;
+#endif
+ }
+ technology = wParam;
+ // Invalidate all cached information including layout.
+ DropGraphics(true);
+ InvalidateStyleRedraw();
+ }
+ }
+ break;
#ifdef SCI_LEXER
case SCI_LOADLEXERLIBRARY:
@@ -1200,11 +1280,12 @@ bool ScintillaWin::PaintContains(PRectangle rc) {
return contains;
}
-void ScintillaWin::ScrollText(int linesToMove) {
+void ScintillaWin::ScrollText(int /* linesToMove */) {
//Platform::DebugPrintf("ScintillaWin::ScrollText %d\n", linesToMove);
- ::ScrollWindow(MainHWND(), 0,
- vs.lineHeight * linesToMove, 0, 0);
- ::UpdateWindow(MainHWND());
+ //::ScrollWindow(MainHWND(), 0,
+ // vs.lineHeight * linesToMove, 0, 0);
+ //::UpdateWindow(MainHWND());
+ Redraw();
}
void ScintillaWin::UpdateSystemCaret() {
@@ -2089,9 +2170,9 @@ void ScintillaWin::ImeStartComposition() {
// The logfont for the IME is recreated here.
int styleHere = (pdoc->StyleAt(sel.MainCaret())) & 31;
LOGFONTA lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ""};
- int sizeZoomed = vs.styles[styleHere].size + vs.zoomLevel;
- if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
- sizeZoomed = 2;
+ int sizeZoomed = vs.styles[styleHere].size + vs.zoomLevel * SC_FONT_SIZE_MULTIPLIER;
+ if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
+ sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
AutoSurface surface(this);
int deviceHeight = sizeZoomed;
if (surface) {
@@ -2099,7 +2180,7 @@ void ScintillaWin::ImeStartComposition() {
}
// The negative is to allow for leading
lf.lfHeight = -(abs(deviceHeight));
- lf.lfWeight = vs.styles[styleHere].bold ? FW_BOLD : FW_NORMAL;
+ lf.lfWeight = vs.styles[styleHere].weight;
lf.lfItalic = static_cast<BYTE>(vs.styles[styleHere].italic ? 1 : 0);
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfFaceName[0] = '\0';
@@ -2294,29 +2375,18 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
HorizontalScrollTo(xPos);
}
-void ScintillaWin::RealizeWindowPalette(bool inBackGround) {
- RefreshStyleData();
- HDC hdc = ::GetDC(MainHWND());
- // Select a stock font to prevent warnings from BoundsChecker
- ::SelectObject(hdc, GetStockFont(DEFAULT_GUI_FONT));
- AutoSurface surfaceWindow(hdc, this);
- if (surfaceWindow) {
- int changes = surfaceWindow->SetPalette(&palette, inBackGround);
- if (changes > 0)
- Redraw();
- surfaceWindow->Release();
- }
- ::ReleaseDC(MainHWND(), hdc);
-}
-
/**
* Redraw all of text area.
* This paint will not be abandoned.
*/
void ScintillaWin::FullPaint() {
- HDC hdc = ::GetDC(MainHWND());
- FullPaintDC(hdc);
- ::ReleaseDC(MainHWND(), hdc);
+ if (technology == SC_TECHNOLOGY_DEFAULT) {
+ HDC hdc = ::GetDC(MainHWND());
+ FullPaintDC(hdc);
+ ::ReleaseDC(MainHWND(), hdc);
+ } else {
+ FullPaintDC(0);
+ }
}
/**
@@ -2327,10 +2397,26 @@ void ScintillaWin::FullPaintDC(HDC hdc) {
paintState = painting;
rcPaint = GetClientRectangle();
paintingAllText = true;
- AutoSurface surfaceWindow(hdc, this);
- if (surfaceWindow) {
- Paint(surfaceWindow, rcPaint);
- surfaceWindow->Release();
+ if (technology == SC_TECHNOLOGY_DEFAULT) {
+ AutoSurface surfaceWindow(hdc, this);
+ if (surfaceWindow) {
+ Paint(surfaceWindow, rcPaint);
+ surfaceWindow->Release();
+ }
+ } else {
+#if defined(USE_D2D)
+ EnsureRenderTarget();
+ AutoSurface surfaceWindow(pRenderTarget, this);
+ if (surfaceWindow) {
+ pRenderTarget->BeginDraw();
+ Paint(surfaceWindow, rcPaint);
+ surfaceWindow->Release();
+ HRESULT hr = pRenderTarget->EndDraw();
+ if (hr == D2DERR_RECREATE_TARGET) {
+ DropRenderTarget();
+ }
+ }
+#endif
}
paintState = notPainting;
}
@@ -2702,14 +2788,39 @@ sptr_t PASCAL ScintillaWin::CTWndProc(
} else if (iMessage == WM_PAINT) {
PAINTSTRUCT ps;
::BeginPaint(hWnd, &ps);
- Surface *surfaceWindow = Surface::Allocate();
+ Surface *surfaceWindow = Surface::Allocate(sciThis->technology);
if (surfaceWindow) {
- surfaceWindow->Init(ps.hdc, hWnd);
+#if defined(USE_D2D)
+ ID2D1HwndRenderTarget *pCTRenderTarget = 0;
+#endif
+ RECT rc;
+ GetClientRect(hWnd, &rc);
+ // Create a Direct2D render target.
+ if (sciThis->technology == SC_TECHNOLOGY_DEFAULT) {
+ surfaceWindow->Init(ps.hdc, hWnd);
+ } else {
+#if defined(USE_D2D)
+ pD2DFactory->CreateHwndRenderTarget(
+ D2D1::RenderTargetProperties(),
+ D2D1::HwndRenderTargetProperties(hWnd, D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top)),
+ &pCTRenderTarget);
+ surfaceWindow->Init(pCTRenderTarget, hWnd);
+ pCTRenderTarget->BeginDraw();
+#endif
+ }
surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == sciThis->ct.codePage);
surfaceWindow->SetDBCSMode(sciThis->ct.codePage);
sciThis->ct.PaintCT(surfaceWindow);
+#if defined(USE_D2D)
+ if (pCTRenderTarget)
+ pCTRenderTarget->EndDraw();
+#endif
surfaceWindow->Release();
delete surfaceWindow;
+#if defined(USE_D2D)
+ if (pCTRenderTarget)
+ pCTRenderTarget->Release();
+#endif
}
::EndPaint(hWnd, &ps);
return 0;
diff --git a/src/Notepad2.vcxproj b/src/Notepad2.vcxproj
index 937d880..4770e92 100644
--- a/src/Notepad2.vcxproj
+++ b/src/Notepad2.vcxproj
@@ -290,6 +290,7 @@ update_version.bat</Command>
<ClInclude Include="..\scintilla\src\UniConversion.h" />
<ClInclude Include="..\scintilla\src\ViewStyle.h" />
<ClInclude Include="..\scintilla\src\XPM.h" />
+ <ClInclude Include="..\scintilla\win32\PlatWin.h" />
<ClInclude Include="Dialogs.h" />
<ClInclude Include="Dlapi.h" />
<ClInclude Include="Edit.h" />
diff --git a/src/Notepad2.vcxproj.filters b/src/Notepad2.vcxproj.filters
index 75a1535..25d165e 100644
--- a/src/Notepad2.vcxproj.filters
+++ b/src/Notepad2.vcxproj.filters
@@ -374,6 +374,9 @@
<ClInclude Include="..\scintilla\src\XPM.h">
<Filter>Scintilla\src</Filter>
</ClInclude>
+ <ClInclude Include="..\scintilla\win32\PlatWin.h">
+ <Filter>Scintilla\src</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\res\Copy.cur">
diff --git a/src/Notepad2_icl12.vcxproj b/src/Notepad2_icl12.vcxproj
index 11f4c6d..51bf26e 100644
--- a/src/Notepad2_icl12.vcxproj
+++ b/src/Notepad2_icl12.vcxproj
@@ -332,6 +332,7 @@ update_version.bat
<ClInclude Include="..\scintilla\src\UniConversion.h" />
<ClInclude Include="..\scintilla\src\ViewStyle.h" />
<ClInclude Include="..\scintilla\src\XPM.h" />
+ <ClInclude Include="..\scintilla\win32\PlatWin.h" />
<ClInclude Include="Dialogs.h" />
<ClInclude Include="Dlapi.h" />
<ClInclude Include="Edit.h" />
diff --git a/src/Notepad2_icl12.vcxproj.filters b/src/Notepad2_icl12.vcxproj.filters
index 546f97c..bf4858d 100644
--- a/src/Notepad2_icl12.vcxproj.filters
+++ b/src/Notepad2_icl12.vcxproj.filters
@@ -374,6 +374,9 @@
<ClInclude Include="..\scintilla\src\XPM.h">
<Filter>Scintilla\src</Filter>
</ClInclude>
+ <ClInclude Include="..\scintilla\win32\PlatWin.h">
+ <Filter>Scintilla\src</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\res\Copy.cur">