From b434694066b1d042e3d465ba370295e84c01cde1 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 30 Mar 2000 11:41:02 +0000 Subject: Fixed bugs in handling undo history. Fixed bugs with null fonts. --- src/ViewStyle.cxx | 453 +++++++++++++++++++++++++++--------------------------- 1 file changed, 227 insertions(+), 226 deletions(-) (limited to 'src/ViewStyle.cxx') diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 903ae94f4..a67ee21a0 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -1,226 +1,227 @@ -// 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); -} - -void ViewStyle::Refresh(Surface &surface) { - selbar.desired = Platform::Chrome(); - selbarlight.desired = Platform::ChromeHighlight(); - 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]); - 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; - } -} - -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 (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));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); -} +// 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); +} + +void ViewStyle::Refresh(Surface &surface) { + selbar.desired = Platform::Chrome(); + selbarlight.desired = Platform::ChromeHighlight(); + 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]); + 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; + } +} + +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 (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));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