diff options
author | nyamatongwe <unknown> | 2011-04-07 21:26:47 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-04-07 21:26:47 +1000 |
commit | 0adca4ad14500910cca14a54d7d4c19e740606da (patch) | |
tree | be10d8a118fb4e5fd92a549d47aa80c1df01a5cf /src/LineMarker.cxx | |
parent | e7dea4ff60eba17362902d514ff29ebfbc8ea3a1 (diff) | |
download | scintilla-mirror-0adca4ad14500910cca14a54d7d4c19e740606da.tar.gz |
Add highlighting of current folding block. Feature #3147069.
APIs MarkerEnableHighlight and MarkerSetBackSelected.
From Jérôme Laforge.
Diffstat (limited to 'src/LineMarker.cxx')
-rw-r--r-- | src/LineMarker.cxx | 130 |
1 files changed, 93 insertions, 37 deletions
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index 74d164de9..747c5ff12 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -20,6 +20,7 @@ using namespace Scintilla; 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); } @@ -67,7 +68,30 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C surface->FillRectangle(rcH, fore); } -void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter) { +void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold) { + ColourPair head = back; + ColourPair body = back; + ColourPair tail = back; + + switch (tFold) { + case LineMarker::head : + head = backSelected; + tail = backSelected; + break; + case LineMarker::body : + head = backSelected; + body = backSelected; + break; + case LineMarker::tail : + body = backSelected; + tail = backSelected; + break; + default : + // LineMarker::undefined + break; + } + + if ((markType == SC_MARK_PIXMAP) && (pxpm)) { pxpm->Draw(surface, rcWhole); return; @@ -159,106 +183,138 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac // An invisible marker so don't draw anything } else if (markType == SC_MARK_VLINE) { - surface->PenColour(back.allocated); + surface->PenColour(body.allocated); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_LCORNER) { - surface->PenColour(back.allocated); + surface->PenColour(tail.allocated); 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(back.allocated); - surface->MoveTo(centreX, rcWhole.top); - surface->LineTo(centreX, rcWhole.bottom); + surface->PenColour(tail.allocated); surface->MoveTo(centreX, rc.top + dimOn2); surface->LineTo(rc.right - 2, rc.top + dimOn2); + surface->PenColour(body.allocated); + surface->MoveTo(centreX, rcWhole.top); + surface->LineTo(centreX, rc.top + dimOn2 + 1); + + surface->PenColour(head.allocated); + surface->LineTo(centreX, rcWhole.bottom); + } else if (markType == SC_MARK_LCORNERCURVE) { - surface->PenColour(back.allocated); + surface->PenColour(tail.allocated); 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(back.allocated); - surface->MoveTo(centreX, rcWhole.top); - surface->LineTo(centreX, rcWhole.bottom); - + surface->PenColour(tail.allocated); 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->MoveTo(centreX, rcWhole.top); + surface->LineTo(centreX, rc.top + dimOn2-2); + + surface->PenColour(head.allocated); + surface->LineTo(centreX, rcWhole.bottom); + } else if (markType == SC_MARK_BOXPLUS) { - surface->PenColour(back.allocated); - DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - DrawPlus(surface, centreX, centreY, blobSize, back.allocated); + DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated); + DrawPlus(surface, centreX, centreY, blobSize, tail.allocated); } else if (markType == SC_MARK_BOXPLUSCONNECTED) { - surface->PenColour(back.allocated); - DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - DrawPlus(surface, centreX, centreY, blobSize, back.allocated); - + surface->PenColour(body.allocated); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); + surface->PenColour(body.allocated); 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); + + if (tFold == LineMarker::body) { + surface->PenColour(tail.allocated); + surface->MoveTo(centreX + 1, centreY + blobSize); + surface->LineTo(centreX + blobSize + 1, centreY + blobSize); + + surface->MoveTo(centreX + blobSize, centreY + blobSize); + surface->LineTo(centreX + blobSize, centreY - blobSize); + + surface->MoveTo(centreX + 1, centreY - blobSize); + surface->LineTo(centreX + blobSize + 1, centreY - blobSize); + } } else if (markType == SC_MARK_BOXMINUS) { - surface->PenColour(back.allocated); - DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - DrawMinus(surface, centreX, centreY, blobSize, back.allocated); + DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated); + DrawMinus(surface, centreX, centreY, blobSize, tail.allocated); + surface->PenColour(head.allocated); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_BOXMINUSCONNECTED) { - surface->PenColour(back.allocated); - DrawBox(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - DrawMinus(surface, centreX, centreY, blobSize, back.allocated); + DrawBox(surface, centreX, centreY, blobSize, fore.allocated, head.allocated); + DrawMinus(surface, centreX, centreY, blobSize, tail.allocated); + surface->PenColour(head.allocated); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); + surface->PenColour(body.allocated); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY - blobSize); + if (tFold == LineMarker::body) { + surface->PenColour(tail.allocated); + surface->MoveTo(centreX + 1, centreY + blobSize); + surface->LineTo(centreX + blobSize + 1, centreY + blobSize); + + surface->MoveTo(centreX + blobSize, centreY + blobSize); + surface->LineTo(centreX + blobSize, centreY - blobSize); + + surface->MoveTo(centreX + 1, centreY - blobSize); + surface->LineTo(centreX + blobSize + 1, centreY - blobSize); + } } else if (markType == SC_MARK_CIRCLEPLUS) { - DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - surface->PenColour(back.allocated); - DrawPlus(surface, centreX, centreY, blobSize, back.allocated); + DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated); + DrawPlus(surface, centreX, centreY, blobSize, tail.allocated); } else if (markType == SC_MARK_CIRCLEPLUSCONNECTED) { - DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - surface->PenColour(back.allocated); - DrawPlus(surface, centreX, centreY, blobSize, back.allocated); - + surface->PenColour(body.allocated); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); 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); + } else if (markType == SC_MARK_CIRCLEMINUS) { - DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - surface->PenColour(back.allocated); - DrawMinus(surface, centreX, centreY, blobSize, back.allocated); + DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated); + DrawMinus(surface, centreX, centreY, blobSize, tail.allocated); + surface->PenColour(head.allocated); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); } else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) { - DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, back.allocated); - surface->PenColour(back.allocated); - DrawMinus(surface, centreX, centreY, blobSize, back.allocated); + DrawCircle(surface, centreX, centreY, blobSize, fore.allocated, head.allocated); + DrawMinus(surface, centreX, centreY, blobSize, tail.allocated); + surface->PenColour(head.allocated); surface->MoveTo(centreX, centreY + blobSize); surface->LineTo(centreX, rcWhole.bottom); + surface->PenColour(body.allocated); surface->MoveTo(centreX, rcWhole.top); surface->LineTo(centreX, centreY - blobSize); |