📄 mimerichtextp.h
字号:
/* * $Id: MimeRichTextP.h,v 1.1.1.1 2000/04/25 13:49:01 fnevgeny Exp $ * * Copyright (c) 1994 HAL Computer Systems International, Ltd. * * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. * 1315 Dell Avenue * Campbell, CA 95008 * * Author: Greg Hilton * Contributors: Tom Lang, Frank Bieser, and others * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * http://www.gnu.org/copyleft/gpl.html * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#ifndef _MimeRichTextP_h_#define _MimeRichTextP_h_#include "FontDataC.h"#include "RectC.h"#include "StringC.h"#include "PtrListC.h"#include "PixelListC.h"#include "CallbackListC.h"#include <X11/Intrinsic.h>#include <Xm/Xm.h>#define MIME_ACTION_COUNT 73/*---------------------------------------------------------------------- * Class to hold state information about the text */class TextStateC { char excerpt; // Current level of excerpting char lindent; // Current level of left indenting char rindent; // Current Level of right indenting char underline; // Current level of underlining StringC fstack; // Stack of font commands StringC jstack; // Stack of justify commands PixelListC cstack; // Stack of color commands StringC* plink; // Pointer to link valuepublic: TextStateC(); TextStateC(const TextStateC&); inline char Excerpt() const { return excerpt; } inline char LIndent() const { return lindent; } inline char RIndent() const { return rindent; } inline char Underline() const { return underline; } inline void ExcerptMore() { excerpt++; } inline void ExcerptLess() { if ( excerpt > 0 ) excerpt--; } inline void Excerpt(char val) { excerpt = val; } inline void LIndentMore() { lindent++; } inline void LIndentLess() { if ( lindent > 0 ) lindent--; } inline void LIndent(char val) { lindent = val; } inline void RIndentMore() { rindent++; } inline void RIndentLess() { if ( rindent > 0 ) rindent--; } inline void RIndent(char val) { rindent = val; } inline void UnderlineMore() { underline++; } inline void UnderlineLess() { if ( underline > 0 ) underline--; } inline void Underline(char val) { underline = val; } inline int CmdCount(FontCmdT fc) const { int count = 0; for (int i=0; i<fstack.size(); i++) if ( fstack[i] == fc ) count++; return count; } inline int CmdCount(JustCmdT jc) const { int count = 0; for (int i=0; i<jstack.size(); i++) if ( jstack[i] == jc ) count++; return count; } inline int ColorCount(Pixel pix) const { int count = 0; for (int i=0; i<cstack.size(); i++) if ( *cstack[i] == pix ) count++; return count; } inline int PLinkCount() const { return (plink ? 1 : 0); } inline int ColorCmdCount() const { return cstack.size(); } inline int Bold() const { return CmdCount(FC_BOLD); } inline int Italic() const { return CmdCount(FC_ITALIC); } inline int Fixed() const { return CmdCount(FC_FIXED); } inline int Smaller() const { return CmdCount(FC_SMALLER); } inline int Bigger() const { return CmdCount(FC_BIGGER); } inline int Charset1() const { return CmdCount(FC_CHARSET_1); } inline int Charset2() const { return CmdCount(FC_CHARSET_2); } inline int Charset3() const { return CmdCount(FC_CHARSET_3); } inline int Charset4() const { return CmdCount(FC_CHARSET_4); } inline int Charset5() const { return CmdCount(FC_CHARSET_5); } inline int Charset6() const { return CmdCount(FC_CHARSET_6); } inline int Charset7() const { return CmdCount(FC_CHARSET_7); } inline int Charset8() const { return CmdCount(FC_CHARSET_8); } inline int Charset9() const { return CmdCount(FC_CHARSET_9); } inline int URL() const { return CmdCount(FC_URL); } inline int Center() const { return CmdCount(JC_CENTER); } inline int FlushLeft() const { return CmdCount(JC_LEFT); } inline int FlushRight() const { return CmdCount(JC_RIGHT); } inline int FlushBoth() const { return CmdCount(JC_BOTH); } inline int NoFill() const { return CmdCount(JC_NOFILL); } inline int Charset() const { return (Charset1() + Charset2() + Charset3() + Charset4() + Charset5() + Charset6() + Charset7() + Charset8() + Charset9()); } inline StringC& FontStack() { return fstack; } inline const StringC& FontStack() const { return fstack; } inline FontCmdT CurFontCmd() const { return (FontCmdT)fstack.LastChar(); } inline void PushFont(FontCmdT fcmd) { fstack += (char)fcmd; } inline void PopFont() { if ( fstack.size() > 0 ) fstack.Clear(fstack.size()-1); } inline StringC& JustStack() { return jstack; } inline const StringC& JustStack() const { return jstack; } inline JustCmdT CurJustCmd() const { return (JustCmdT)jstack.LastChar(); } inline void PushJust(JustCmdT jcmd) { jstack += (char)jcmd; } inline void PopJust() { if ( jstack.size() > 0 ) jstack.Clear(jstack.size()-1); } inline PixelListC& ColorStack() { return cstack; } inline const PixelListC& ColorStack() const { return cstack; } inline Pixel CurColor() const { return (cstack.size() > 0 ? *cstack[cstack.size()-1] : (Pixel)NULL); } inline void PushColor(Pixel pix) { cstack.add(pix); } inline void PopColor() { if ( cstack.size() > 0 ) cstack.remove(cstack.size()-1); } inline StringC* PLink() { return plink; } inline void PushLink(StringC &lnk) { if (plink) delete plink; plink = new StringC(lnk); } inline void PopLink() { if (plink) delete plink; plink = NULL; } void Reset(); void operator=(const TextStateC&); int operator==(const TextStateC&) const; int operator!=(const TextStateC& t) const { return !(*this == t); }};#define NULL_CMD_POS -1/*---------------------------------------------------------------------- * Rich/Enriched text drawing data */class SoftLineC;class RichDrawDataC {public: int x; int width; FontDataC *font; StringC string; Boolean underline; SoftLineC *softLine; // Soft line to which this data belongs int cmdPos; // Index of the command that this // data represents. int textOff; // Where this data string starts relative // to the command string. RichGraphicC *graphic;// If this is a graphic object RichDrawDataC *prev; // Previous draw data RichDrawDataC *next; // Next draw data RichDrawDataC() { x = 0; width = 0; font = NULL; underline = False; softLine = NULL; cmdPos = 0; textOff = 0; graphic = NULL; prev = NULL; next = NULL; } int Snap(int); int CharPos(int); int LastPos() { return (graphic ? 1 : string.size()); }//// comparison// inline int compare(const RichDrawDataC& d) const { int result = 0; if ( d.width < width ) result = -1; else if ( d.width > width ) result = 1; return result; } inline int operator<(const RichDrawDataC& d) const { return (compare(d) < 0); } inline int operator>(const RichDrawDataC& d) const { return (compare(d) > 0); } inline int operator==(const RichDrawDataC& d) const { return (compare(d) == 0); } inline int operator!=(const RichDrawDataC& d) const { return (compare(d) != 0); }};/*---------------------------------------------------------------------- * Rich/Enriched line data as wrapped and displayed on the screen */class TextLineC;class SoftLineC {public: TextLineC *textLine; RectC bounds; int totalWd; int descent; RichDrawDataC *drawData; // Linked list of drawing elements SoftLineC *prev; SoftLineC *next; SoftLineC(); ~SoftLineC(); void AddDrawData(RichDrawDataC*); RichDrawDataC *PickData(int); inline RichDrawDataC *FirstData() { return drawData; } inline RichDrawDataC *LastData() { RichDrawDataC *data = drawData; if ( data ) { while ( data->next ) data = data->next; } return data; }//// comparison// inline int compare(const SoftLineC& l) const { int result = 0; if ( l.bounds.ymin < bounds.ymin ) result = -1; else if ( l.bounds.ymin > bounds.ymin ) result = 1; return result; } inline int operator<(const SoftLineC& l) const { return (compare(l) < 0); } inline int operator>(const SoftLineC& l) const { return (compare(l) > 0); } inline int operator==(const SoftLineC& l) const { return (compare(l) == 0); } inline int operator!=(const SoftLineC& l) const { return (compare(l) != 0); }};/*---------------------------------------------------------------------- * Each command consists of a text state and a string. */class RichCmdC {public: RichCmdTypeT type;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -