diff options
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 271 |
1 files changed, 126 insertions, 145 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 507ae60a1..01f55b333 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -280,7 +280,6 @@ void Editor::InvalidateStyleData() { vs.technology = technology; DropGraphics(false); AllocateGraphics(); - palette.Release(); llc.Invalidate(LineLayout::llInvalid); posCache.Clear(); } @@ -291,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; @@ -1737,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; } @@ -1747,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); } } @@ -1783,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; @@ -1962,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; @@ -2015,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); @@ -2401,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); @@ -2421,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; } } @@ -2440,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 @@ -2485,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); } @@ -2517,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; @@ -2539,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++) { @@ -2574,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)); @@ -2600,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); @@ -2623,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); @@ -2743,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; } @@ -2766,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, @@ -2805,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; @@ -2829,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; } @@ -2861,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; @@ -2889,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) { @@ -2943,12 +2935,12 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis 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 @@ -2967,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; @@ -2994,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 @@ -3005,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; } @@ -3030,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) { @@ -3109,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, @@ -3145,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) { @@ -3245,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; } @@ -3263,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; } @@ -3272,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; @@ -3330,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); } @@ -3345,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); @@ -3377,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); } } @@ -3469,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 { @@ -3496,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; @@ -3509,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 @@ -3544,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); } } @@ -3654,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)) @@ -3662,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); } } @@ -3699,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( @@ -3780,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 @@ -3805,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; @@ -3887,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 @@ -7008,10 +6988,10 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLESETFORE: - vs.styles[wParam].fore.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].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL; @@ -7062,9 +7042,9 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLEGETFORE: - return vs.styles[wParam].fore.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].weight > SC_WEIGHT_NORMAL; case SCI_STYLEGETWEIGHT: @@ -8010,13 +7990,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: @@ -8034,13 +8015,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: @@ -8049,7 +8030,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; @@ -8247,9 +8228,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: @@ -8362,15 +8343,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; @@ -8393,23 +8374,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) @@ -8462,13 +8443,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) { @@ -8684,10 +8665,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; @@ -8841,33 +8822,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; @@ -9202,12 +9183,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; @@ -9220,12 +9201,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(); |