diff options
-rw-r--r-- | gtk/PlatGTK.cxx | 3 | ||||
-rw-r--r-- | include/Platform.h | 1 | ||||
-rw-r--r-- | src/Editor.cxx | 11 | ||||
-rw-r--r-- | src/Style.cxx | 5 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 6 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 6 |
6 files changed, 24 insertions, 8 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 15d3d160b..d5183e02b 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -486,6 +486,9 @@ void Surface::SetClip(PRectangle rc) { gdk_gc_set_clip_rectangle(gc, &area); } +void Surface::FlushCachedState() { +} + Window::~Window() { } diff --git a/include/Platform.h b/include/Platform.h index b077e2e34..021bcf686 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -292,6 +292,7 @@ public: int SetPalette(Palette *pal, bool inBackGround); void SetClip(PRectangle rc); + void FlushCachedState(); }; // Class to hide the details of window manipulation diff --git a/src/Editor.cxx b/src/Editor.cxx index f7ad2f735..a606671dd 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -853,7 +853,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int xStart, } else { rcSegment.left = ll.positions[startseg] + xStart; rcSegment.right = ll.positions[i + 1] + xStart; - // Only try do draw if really visible - enhances performance by not calling environment to + // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if (rcSegment.left <= rcLine.right) { surface->DrawText(rcSegment, textFont, @@ -1236,20 +1236,27 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) { PRectangle rcNumber = rcLine; rcNumber.right = rcNumber.left + lineNumberWidth; // Right justify - rcNumber.left += lineNumberWidth - + rcNumber.left -= surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number)); surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, ypos + vsPrint.maxAscent, number, strlen(number), vsPrint.styles[STYLE_LINENUMBER].fore.allocated, vsPrint.styles[STYLE_LINENUMBER].back.allocated); } + + // When printing, the hdc and hdcTarget may be the same, so + // changing the state of surfaceMeasure may change the underlying + // state of surface. Therefore, any cached state is discarded before + // using each surface. // Copy this line and its styles from the document into local arrays // and determine the x position at which each character starts. + surfaceMeasure->FlushCachedState(); LineLayout ll; LayoutLine(line, surfaceMeasure, vsPrint, ll); // Draw the line + surface->FlushCachedState(); DrawLine(surface, vsPrint, line, xStart, rcLine, ll); ypos += vsPrint.lineHeight; diff --git a/src/Style.cxx b/src/Style.cxx index 120fd6e95..75dc6eb93 100644 --- a/src/Style.cxx +++ b/src/Style.cxx @@ -25,17 +25,14 @@ Style::~Style() { Style &Style::operator=(const Style &source) { if (this == &source) return *this; - // Crash: - *(char *)0 = 1; Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), - Platform::DefaultFontSize(), 0, + 0, 0, false, false, false); fore.desired = source.fore.desired; back.desired = source.back.desired; bold = source.bold; italic = source.italic; size = source.size; - fontName = source.fontName; eolFilled = source.eolFilled; return *this; } diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 976593de3..d5c36981b 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -53,6 +53,8 @@ ViewStyle::ViewStyle(const ViewStyle &source) { Init(); for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) { styles[sty] = source.styles[sty]; + // Can't just copy fontname as its lifetime is relative to its owning ViewStyle + styles[sty].fontName = fontNames.Save(source.styles[sty].fontName); } for (int mrk=0;mrk<=MARKER_MAX;mrk++) { markers[mrk] = source.markers[mrk]; @@ -166,9 +168,9 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) { void ViewStyle::Refresh(Surface &surface) { selbar.desired = Platform::Chrome(); selbarlight.desired = Platform::ChromeHighlight(); - maxAscent = 1; - maxDescent = 1; styles[STYLE_DEFAULT].Realise(surface, zoomLevel); + maxAscent = styles[STYLE_DEFAULT].ascent; + maxDescent = styles[STYLE_DEFAULT].descent; for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) { if (i != STYLE_DEFAULT) { styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]); diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 9fde8a272..d3997e96b 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -419,6 +419,12 @@ void Surface::SetClip(PRectangle rc) { ::IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); } +void Surface::FlushCachedState() { + pen = 0; + brush = 0; + font = 0; +} + Window::~Window() { } |