#ifndef TextLinePainter_First #define TextLinePainter_First #ifdef __GNUG__ #pragma interface #endif #include "Object.h" #include "TextStyles.h" #include "Text.h" class VisualMark; //---- TextPainter ------------------------------------------------------------- // paint text lines class TextPainter: public Object { public: MetaDef(TextPainter); TextPainter(); ~TextPainter(); int LineWidth(Text *t, int from, int to); void LineHeight(Text *t, LineDesc &ld, int start, int end); virtual void Draw(Text *t, const Point &p, int from, int to, const Rectangle &lr, const Rectangle &clip, bool invis= TRUE); virtual int Map(Text *t, int from, int to, int stop, int x, int width, int *posX); int GetFormatWidth(Text *t, int at, int width); int Tabulate(Text *t, int x, int at, int linestart); private: byte *linebuf; byte *line; ParaStyle *ps; // current paragraph style on a line CharStyle *sp; // current character style on a line int graphicChar; // graphic escape character int nextFontChange; // position of next font change on line bool TestFontChange(Text *t, int at, CharStyle *&sp); bool TestVisualMark(Text *t, int at, int ch); void Init(Text *t, int from, int to); int Strip(Text *t, int from, int to); int CalcSpace(Text *t, int w, int from, int to, int &space, int &blanks, int &ntab); int CalcIndent(Text *t, ParaStyle *p, int at, int &width); int CalcWidth(Text *t, int from, int to); int CalcTabWidth(Text *t, ParaStyle *p, int x, int at); int TabColWidth(Text *t, int start, char *stops); void SetCharStyle(CharStyle *cs); bool IsJustified(Text *t, int at); int FirstCharPos(Text *t, int width, int start, int end); void ShowInvisible(byte ch); void ShowNoBreak(const Point &p, const Rectangle &clip, Text *t, int start, int end); void ShowKeepNext(const Point &p, const Rectangle &clip, Text *t, int start, int end); void DrawVisualMark(const Point &p, VisualMark *vmp, const Rectangle &clip, const Rectangle &line, bool border); }; //---- inlines ----------------------------------------------------------------- inline bool TextPainter::TestFontChange(Text *t, int at, CharStyle *&s) { if (at == nextFontChange) { nextFontChange= t->GetNextFontChange(at, s); return TRUE; } else return FALSE; } inline bool TextPainter::TestVisualMark(Text *t, int at, int ch) { return (graphicChar && ch == graphicChar && t->IsVisualMark(at)); } #endif