From edda78a585df567374ddf6f8e657f16db8adcd19 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 27 Jan 2009 12:10:34 +0000 Subject: [PATCH] ParseQTF removed scolors option - fixed problem with bad colors in X11 git-svn-id: svn://ultimatepp.org/upp/trunk@814 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/LabelBase.cpp | 2 +- uppsrc/CtrlLib/RichText.h | 4 ++-- uppsrc/CtrlLib/RichTextView.cpp | 4 ++-- uppsrc/RichText/ParseQtf.cpp | 34 +++++++-------------------------- uppsrc/RichText/RichText.h | 2 +- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/uppsrc/CtrlLib/LabelBase.cpp b/uppsrc/CtrlLib/LabelBase.cpp index 0c22bc8b8..d1c023e59 100644 --- a/uppsrc/CtrlLib/LabelBase.cpp +++ b/uppsrc/CtrlLib/LabelBase.cpp @@ -97,7 +97,7 @@ int GetSmartTextHeight(const char *s, int cx, Font font) { void DrawSmartText(Draw& draw, int x, int y, int cx, const char *text, Font font, Color ink, int accesskey) { if(*text == '\1') { Size sz; - RichText txt = ParseQTF(text + 1, false, accesskey); + RichText txt = ParseQTF(text + 1, accesskey); txt.ApplyZoom(GetRichTextStdScreenZoom()); txt.Paint(Zoom(1, 1), draw, x, y, cx); return; diff --git a/uppsrc/CtrlLib/RichText.h b/uppsrc/CtrlLib/RichText.h index 1c1ad42a1..730190f5f 100644 --- a/uppsrc/CtrlLib/RichText.h +++ b/uppsrc/CtrlLib/RichText.h @@ -50,7 +50,7 @@ public: void Clear(); void Pick(pick_ RichText& t); void Pick(pick_ RichText& txt, Zoom z); - void SetQTF(const char *qtf, Zoom z = Zoom(1, 1), bool scolors = false); + void SetQTF(const char *qtf, Zoom z = Zoom(1, 1)); const RichText& Get() const { return text; } String GetQTF(byte cs = CHARSET_UTF8) const { return AsQTF(text, cs); } @@ -104,7 +104,7 @@ public: virtual void SetData(const Value& v); public: - void SetQTF(const char *qtf, Zoom z = GetRichTextStdScreenZoom()) { RichTextView::SetQTF(qtf, z, true); } + void SetQTF(const char *qtf, Zoom z = GetRichTextStdScreenZoom()) { RichTextView::SetQTF(qtf, z); } void operator=(const char *qtf) { SetQTF(qtf); } RichTextCtrl(); }; diff --git a/uppsrc/CtrlLib/RichTextView.cpp b/uppsrc/CtrlLib/RichTextView.cpp index 52ebb8a02..b1af2d08f 100644 --- a/uppsrc/CtrlLib/RichTextView.cpp +++ b/uppsrc/CtrlLib/RichTextView.cpp @@ -308,9 +308,9 @@ void RichTextView::Pick(pick_ RichText& txt, Zoom z) { sb.SetLine(z * 100); } -void RichTextView::SetQTF(const char *qtf, Zoom z, bool scolors) +void RichTextView::SetQTF(const char *qtf, Zoom z) { - Pick(ParseQTF(qtf, scolors), z); + Pick(ParseQTF(qtf), z); } RichTextView& RichTextView::PageWidth(int _cx) diff --git a/uppsrc/RichText/ParseQtf.cpp b/uppsrc/RichText/ParseQtf.cpp index 89a544ac7..23acae54f 100644 --- a/uppsrc/RichText/ParseQtf.cpp +++ b/uppsrc/RichText/ParseQtf.cpp @@ -6,10 +6,6 @@ Color (*QTFColor[])() = { Black, LtGray, White, Red, Green, Blue, LtRed, WhiteGray, LtCyan, Yellow }; -Color (*QTFSColor[])()= { - SColorText, SColorFace, SColorPaper, Red, Green, Blue, LtRed, WhiteGray, LtCyan, Yellow -}; - Color NullColorF() { return Null; @@ -29,27 +25,12 @@ static Color (*QTFColorL[])() = { /*Y*/LtYellow, /*Z*/White }; -static Color (*QTFSColorl[])() = { //TODO - /*a*/SColorPaper, /*b*/SColorHighlight, /*c*/Cyan, /*d*/SColorPaper, /*e*/SColorPaper, /*f*/SColorPaper, /*g*/ Green, /*h*/SColorPaper, - /*i*/SColorPaper, /*j*/SColorPaper, /*k*/SColorText, /*l*/SColorFace, /*m*/Magenta, /*n*/NullColorF, /*o*/Brown, /*p*/SColorPaper, - /*q*/SColorPaper, /*r*/Red, /*s*/SColorPaper, /*t*/SColorPaper, /*u*/SColorPaper, /*v*/SColorPaper, /*w*/WhiteGray, /*x*/SColorPaper, - /*y*/Yellow, /*z*/ White -}; - -static Color (*QTFSColorL[])() = { //TODO - /*A*/SColorPaper, /*B*/LtBlue, /*C*/LtCyan, /*D*/SColorPaper, /*E*/SColorPaper, /*F*/SColorPaper, /*G*/LtGreen, /*H*/SColorPaper, - /*I*/SColorPaper, /*J*/SColorPaper, /*K*/SColorShadow, /*L*/WhiteGray, /*M*/LtMagenta, /*N*/NullColorF, /*O*/Brown, /*P*/SColorPaper, - /*Q*/SColorPaper, /*R*/LtRed, /*S*/SColorPaper, /*T*/SColorPaper, /*U*/SColorPaper, /*V*/SColorPaper, /*W*/SColorPaper, /*X*/SColorPaper, - /*Y*/LtYellow, /*Z*/White -}; - int QTFFontHeight[] = { 50, 67, 84, 100, 134, 167, 200, 234, 300, 400 }; class RichQtfParser { const char *term; - bool scolors; WString text; RichPara paragraph; RichTable tablepart; @@ -115,12 +96,12 @@ public: void Parse(const char *qtf, byte accesskey); - RichQtfParser(bool scolors); + RichQtfParser(); }; void init_s_nodeqtf(); -RichQtfParser::RichQtfParser(bool _scolors) +RichQtfParser::RichQtfParser() { format.Face(Font::ARIAL); format.Height(100); @@ -130,7 +111,6 @@ RichQtfParser::RichQtfParser(bool _scolors) istable = false; oldtab = false; init_s_nodeqtf(); - scolors = _scolors; } bool RichQtfParser::Key2(int c, int d) @@ -211,13 +191,13 @@ Color RichQtfParser::GetColor() } else if(c >= '0' && c <= '9') - return (*((scolors ? QTFSColor : QTFColor)[c - '0']))(); + return QTFColor[c - '0'](); else if(c >= 'a' && c <= 'z') - return (*((scolors ? QTFSColorl : QTFColorl)[c - 'a']))(); + return QTFColorl[c - 'a'](); else if(c >= 'A' && c <= 'Z') - return (*((scolors ? QTFSColorL : QTFColorL)[c - 'A']))(); + return QTFColorL[c - 'A'](); else return Red; } @@ -945,9 +925,9 @@ void RichQtfParser::Parse(const char *qtf, byte _accesskey) FlushStyles(); } -RichText ParseQTF(const char *qtf, bool scolors, byte accesskey) +RichText ParseQTF(const char *qtf, byte accesskey) { - RichQtfParser p(scolors); + RichQtfParser p; try { p.Parse(qtf, accesskey); } diff --git a/uppsrc/RichText/RichText.h b/uppsrc/RichText/RichText.h index 4ae6f1d17..3958e75a9 100644 --- a/uppsrc/RichText/RichText.h +++ b/uppsrc/RichText/RichText.h @@ -370,7 +370,7 @@ public: String AsQTF(const RichObject& obj); -RichText ParseQTF(const char *qtf, bool scolors = false, byte accesskey = 0); +RichText ParseQTF(const char *qtf, byte accesskey = 0); RichText AsRichText(const wchar *s, const RichPara::Format& f = RichPara::Format());