From c196d2fc7c3ece7ccb7d89c425499a75ead7e59b Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 8 Mar 2000 01:43:56 +0000 Subject: Initial revision --- src/ViewStyle.cxx | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 src/ViewStyle.cxx (limited to 'src/ViewStyle.cxx') diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx new file mode 100644 index 000000000..122db6a00 --- /dev/null +++ b/src/ViewStyle.cxx @@ -0,0 +1,226 @@ +// Scintilla source code edit control +// ViewStyle.cxx - store information on how the document is to be viewed +// Copyright 1998-2000 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include + +#include "Platform.h" + +#include "Scintilla.h" +#include "Indicator.h" +#include "LineMarker.h" +#include "Style.h" +#include "ViewStyle.h" + +MarginStyle::MarginStyle() : + symbol(false), width(16), mask(0xffffffff), sensitive(false) { +} + +// A list of the fontnames - avoids wasting space in each style +FontNames::FontNames() { + max = 0; +} + +FontNames::~FontNames() { + Clear(); +} + +void FontNames::Clear() { + for (int i=0;i 0) + maskInLine &= ~ms[margin].mask; + } + zoomLevel = 0; + viewWhitespace = false; + viewEOL = false; + showMarkedLines = true; +} + +void ViewStyle::RefreshColourPalette(Palette &pal, bool want) { + unsigned int i; + for (i=0;i<(sizeof(styles)/sizeof(styles[0]));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++) { + pal.WantFind(markers[i].fore, want); + pal.WantFind(markers[i].back, want); + } + pal.WantFind(selforeground, want); + pal.WantFind(selbackground, want); + pal.WantFind(selbar, want); + pal.WantFind(selbarlight, want); + pal.WantFind(caretcolour, want); + pal.WantFind(edgecolour, want); +} + +#include +void ViewStyle::Refresh(Surface &surface) { +DWORD dwStart = timeGetTime(); + selbar.desired = Platform::Chrome(); + selbarlight.desired = Platform::ChromeHighlight(); + maxAscent = 1; + maxDescent = 1; + styles[STYLE_DEFAULT].Realise(surface, zoomLevel); + for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) { + if (i != STYLE_DEFAULT) { + styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]); + if (maxAscent < styles[i].ascent) + maxAscent = styles[i].ascent; + if (maxDescent < styles[i].descent) + maxDescent = styles[i].descent; + } + } + + lineHeight = maxAscent + maxDescent; + aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth; + spaceWidth = styles[STYLE_DEFAULT].spaceWidth; + + fixedColumnWidth = leftMarginWidth; + symbolMargin = false; + maskInLine = 0xffffffff; + for (int margin=0; margin < margins; margin++) { + fixedColumnWidth += ms[margin].width; + symbolMargin = symbolMargin || ms[margin].symbol; + if (ms[margin].width > 0) + maskInLine &= ~ms[margin].mask; + } +DWORD dwEnd = timeGetTime(); +Platform::DebugPrintf("Refresh took %d\n", dwEnd - dwStart); +} + +void ViewStyle::ResetDefaultStyle() { + styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), + Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()), + false, false, false); +} + +void ViewStyle::ClearStyles() { + // Reset all styles to be like the default style + for (int i=0; i<=STYLE_MAX; i++) { + if (i != STYLE_DEFAULT) { + styles[i].Clear( + styles[STYLE_DEFAULT].fore.desired, + styles[STYLE_DEFAULT].back.desired, + styles[STYLE_DEFAULT].size, + styles[STYLE_DEFAULT].fontName, + styles[STYLE_DEFAULT].bold, + styles[STYLE_DEFAULT].italic, + styles[STYLE_DEFAULT].eolFilled); + } + } + styles[STYLE_LINENUMBER].back.desired = Platform::Chrome(); +} + +void ViewStyle::SetStyleFontName(int styleIndex, const char *name) { + styles[styleIndex].fontName = fontNames.Save(name); +} -- cgit v1.2.3