00001 #ifndef __CDRAWBUFFER_H
00002 #define __CDRAWBUFFER_H
00003
00004 #include <qcolor.h>
00005 #include "StyleConsts.h"
00006 #include "CBuffer.h"
00007 #include "my_list.h"
00008 #include "linktype.h"
00009
00010 class QPainter;
00011 class QImage;
00012
00013 struct textsegment
00014 {
00015 int start;
00016 CStyle style;
00017 textsegment(int _start, const CStyle& _style)
00018 :
00019 start(_start), style(_style)
00020 {}
00021 };
00022
00023 class FontControl;
00024
00025 class CDrawBuffer : public CBuffer
00026 {
00027 bool m_hastext;
00028 CList<textsegment> segs;
00029 int len;
00030 FontControl* fc;
00031 int m_ascent, m_descent, m_lineSpacing, m_lineExtraSpacing;
00032 bool m_bEof, m_bBop;
00033 bool m_bSop, m_bEop;
00034 bool m_showPartial;
00035 CDrawBuffer(const CDrawBuffer&);
00036 CDrawBuffer& operator=(const tchar*sztmp);
00037 void Highlight(QPainter*_p, bool drawBackground, int _x, int _y, int w, QColor bgColour);
00038 public:
00039 void setstartpara() { m_bSop = true; }
00040 void setBop() { m_bBop = true; }
00041 bool isBop() { return m_bBop; }
00042 void setendpara() { m_bEop = true; }
00043 void setendpara(const CStyle& cs);
00044 int leftMargin();
00045 int rightMargin();
00046 void setEof() { m_bEof = true; }
00047 bool eof() { return m_bEof; }
00048 CDrawBuffer& operator=(CDrawBuffer&);
00049 CDrawBuffer(FontControl* _fs = NULL)
00050 :
00051 fc(_fs)
00052 {
00053 empty();
00054 }
00055 ~CDrawBuffer();
00056
00057
00058
00059
00060
00061
00062
00063
00064 int charwidth(int numchars, CStyle& currentstyle);
00065 int charwidth(int numchars);
00066 int width(int availht, int numchars = -1, bool onscreen = false, int scwidth = 0, unsigned short _lborder = 0, unsigned short _rborder = 0);
00067 int offset(int, unsigned short, unsigned short, int);
00068 void render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scw, unsigned short, unsigned short, const QColor&, int availht);
00069 void empty();
00070 void addch(tchar ch, CStyle _style);
00071 void truncate(int);
00072 void setright(CDrawBuffer&, int);
00073 CStyle firststyle();
00074 CStyle laststyle();
00075 int ascent() { return m_ascent; }
00076 int descent() { return m_descent; }
00077 int lineSpacing() { return m_lineSpacing; }
00078 int lineExtraSpacing() { return m_lineExtraSpacing; }
00079
00080
00081 linkType getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*&, size_t&);
00082 void resize(int);
00083 bool showPartial() { return m_showPartial; }
00084 CStyle* getNextLink(int&);
00085 int invertLink(int);
00086 };
00087 #endif