From d9ee18e69f2c05da38410637842a39518497018e Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 10 Jan 2003 11:13:32 +0000 Subject: Moved XPM code out to XPM file. --- src/LineMarker.cxx | 148 ++--------------------------------------------------- src/LineMarker.h | 23 +-------- 2 files changed, 6 insertions(+), 165 deletions(-) (limited to 'src') diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index faf265475..ec9c86f74 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -2,147 +2,17 @@ /** @file LineMarker.cxx ** Defines the look of a line marker in the margin . **/ -// Copyright 1998-2001 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include -#include #include "Platform.h" #include "Scintilla.h" +#include "XPM.h" #include "LineMarker.h" -static const char *NextField(const char *s) { - while (*s && *s != ' ') { - s++; - } - while (*s && *s == ' ') { - s++; - } - return s; -} - -void XPM::Init(const char * const *linesForm) { - height = 1; - width = 1; - nColours = 1; - data = NULL; - codeTransparent = ' '; - codes = NULL; - colours = NULL; - if (!linesForm) - return; - - const char *line0 = linesForm[0]; - width = atoi(line0); - line0 = NextField(line0); - height = atoi(line0); - line0 = NextField(line0); - nColours = atoi(line0); - data = new char[height * width]; - codes = new char[nColours]; - colours = new ColourPair[nColours]; - - for (int c=0; cFillRectangle(rc, ColourFromCode(code)); - } -} - -XPM::XPM(const char *textForm) { - int countQuotes = 0; - for (int i=0; textForm[i]; i++) { - if (textForm[i] == '\"') { - countQuotes++; - } - } - const char **linesForm = new const char *[countQuotes/2]; - countQuotes = 0; - if (linesForm) { - for (int j=0; textForm[j]; j++) { - if (textForm[j] == '\"') { - if ((countQuotes & 1) == 0) { - linesForm[countQuotes / 2] = textForm + j + 1; - } - countQuotes++; - } - } - } - Init(linesForm); - delete []linesForm; -} - -XPM::XPM(const char * const *linesForm) { - Init(linesForm); -} - -XPM::~XPM() { - delete []data; - delete []codes; - delete []colours; -} - -void XPM::RefreshColourPalette(Palette &pal, bool want) { - if (!data || !codes || !colours) { - return; - } - for (int i=0;i(textForm)); - } + delete pxpm; + pxpm = new XPM(textForm); + markType = SC_MARK_PIXMAP; } void LineMarker::SetXPM(const char * const *linesForm) { diff --git a/src/LineMarker.h b/src/LineMarker.h index c75a31230..50a0331da 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -2,33 +2,12 @@ /** @file LineMarker.h ** Defines the look of a line marker in the margin . **/ -// Copyright 1998-2001 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef LINEMARKER_H #define LINEMARKER_H -class XPM { - int height; - int width; - int nColours; - char *data; - char codeTransparent; - char *codes; - ColourPair *colours; - void Init(const char * const *linesForm); - ColourAllocated ColourFromCode(int ch); - void FillRun(Surface *surface, int code, int startX, int y, int x); -public: - XPM(const char *textForm); - XPM(const char * const *linesForm); - ~XPM(); - // Similar to same named method in ViewStyle: - void RefreshColourPalette(Palette &pal, bool want); - // Decompose image into runs and use FillRectangle for each run: - void Draw(Surface *surface, PRectangle &rc); -}; - /** */ class LineMarker { -- cgit v1.2.3