diff options
author | Neil <nyamatongwe@gmail.com> | 2022-08-13 19:52:29 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2022-08-13 19:52:29 +1000 |
commit | 5a19e2ac572bb0f3cd614836145a9d759263fd2d (patch) | |
tree | ea32dec9ad42ecfa3da1c7d07462f77ab7573572 /src | |
parent | 7d2f6bd5280613538c4beafac26a39348992d103 (diff) | |
download | scintilla-mirror-5a19e2ac572bb0f3cd614836145a9d759263fd2d.tar.gz |
Avoid access to window IDs (which are platform-dependent) in code that doesn't
need them.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 18 | ||||
-rw-r--r-- | src/Editor.h | 1 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 812b0a7b4..e80ec647b 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -289,13 +289,17 @@ void Editor::RefreshStyleData() { } } +bool Editor::HasMarginWindow() const noexcept { + return wMargin.Created(); +} + Point Editor::GetVisibleOriginInMain() const { return Point(0, 0); } PointDocument Editor::DocumentPointFromView(Point ptView) const { PointDocument ptDocument(ptView); - if (wMargin.GetID()) { + if (HasMarginWindow()) { const Point ptOrigin = GetVisibleOriginInMain(); ptDocument.x += ptOrigin.x; ptDocument.y += ptOrigin.y; @@ -307,7 +311,7 @@ PointDocument Editor::DocumentPointFromView(Point ptView) const { } Sci::Line Editor::TopLineOfMain() const noexcept { - if (wMargin.GetID()) + if (HasMarginWindow()) return 0; else return topLine; @@ -485,7 +489,7 @@ void Editor::Redraw() { //Platform::DebugPrintf("Redraw all\n"); const PRectangle rcClient = GetClientRectangle(); wMain.InvalidateRectangle(rcClient); - if (wMargin.GetID()) { + if (HasMarginWindow()) { wMargin.InvalidateAll(); } else if (paintState == PaintState::notPainting) { redrawPendingText = true; @@ -494,12 +498,12 @@ void Editor::Redraw() { void Editor::RedrawSelMargin(Sci::Line line, bool allAfter) { const bool markersInText = vs.maskInLine || vs.maskDrawInText; - if (!wMargin.GetID() || markersInText) { // May affect text area so may need to abandon and retry + if (!HasMarginWindow() || markersInText) { // May affect text area so may need to abandon and retry if (AbandonPaint()) { return; } } - if (wMargin.GetID() && markersInText) { + if (HasMarginWindow() && markersInText) { Redraw(); return; } @@ -532,7 +536,7 @@ void Editor::RedrawSelMargin(Sci::Line line, bool allAfter) { if (rcMarkers.Empty()) return; } - if (wMargin.GetID()) { + if (HasMarginWindow()) { const Point ptOrigin = GetVisibleOriginInMain(); rcMarkers.Move(-ptOrigin.x, -ptOrigin.y); wMargin.InvalidateRectangle(rcMarkers); @@ -5271,7 +5275,7 @@ bool Editor::PaintContains(PRectangle rc) { } bool Editor::PaintContainsMargin() { - if (wMargin.GetID()) { + if (HasMarginWindow()) { // With separate margin view, paint of text view // never contains margin. return false; diff --git a/src/Editor.h b/src/Editor.h index 2d30cdb72..e96ed391e 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -302,6 +302,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void SetRepresentations(); void DropGraphics() noexcept; + bool HasMarginWindow() const noexcept; // The top left visible point in main window coordinates. Will be 0,0 except for // scroll views where it will be equivalent to the current scroll position. Point GetVisibleOriginInMain() const override; |