00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _TEXTPART_H_
00028 #define _TEXTPART_H_
00029
00030 #include <string>
00031 #include <list>
00032 #include "CCTChar.h"
00033
00035 typedef std::list<std::tstring> STRLIST;
00036
00040 struct TextLetter
00041 {
00042
00046 TextLetter() : wLetter(0), x(0), nWidth(0) {};
00053 TextLetter(WCHAR w, long _x, int width) : wLetter(w), x(_x), nWidth(width) {};
00058 TextLetter(const TextLetter& other) : wLetter(other.wLetter), x(other.x), nWidth(other.nWidth) {};
00059
00060
00062 WCHAR wLetter;
00064 long x;
00066 int nWidth;
00067 };
00068
00072 struct TextWord : public std::list<TextLetter>
00073 {
00074
00078 TextWord() {};
00083 TextWord(const TextWord& other) {assign(other.begin(), other.end());};
00085 TextWord(const std::wstring& s, const PGLYPHPOS& arGlyphPos, const POINTQF* pWidths, std::tstring::size_type nStart, std::tstring::size_type nEnd = -1);
00087 TextWord(const std::wstring& s, int nCharWidth, std::tstring::size_type nStart, std::tstring::size_type nEnd = -1);
00088
00089
00095 long GetStart(size_type nLetter) const
00096 {
00097 if ((nLetter < 0) || (nLetter >= size()))
00098 return 0;
00099 const_iterator i;
00100 for (i = begin(); nLetter > 0; nLetter--, i++) ;
00101 return (*i).x;
00102 };
00108 long GetEnd(size_type nLetter) const
00109 {
00110 if ((nLetter < 0) || (nLetter >= (int)size()))
00111 return 0;
00112 const_iterator i;
00113 for (i = begin(); nLetter > 0; nLetter--, i++) ;
00114 return (*i).x + (*i).nWidth;
00115 };
00120 std::wstring GetText() const {std::wstring s; for (const_iterator i = begin(); i != end(); i++) s += (*i).wLetter; return s;};
00121
00122
00128 const TextWord& operator+=(const TextWord& other) {insert(end(), other.begin(), other.end()); return *this;};
00129 };
00130
00134 struct TextLine : public std::list<TextWord>
00135 {
00136
00140 TextLine() {rcArea.left = 0; rcArea.top = 0; rcArea.right = 0; rcArea.bottom = 0;};
00145 TextLine(const TextLine& other) {rcArea = other.rcArea; assign(other.begin(), other.end());};
00147 TextLine(const std::wstring& s, const RECTL& rc, const PGLYPHPOS& arGlyphPos, const POINTQF* pWidths);
00149 TextLine(const std::wstring& s, const RECTL& rc, int nCharWidth);
00150
00151
00153 RECTL rcArea;
00154
00156 bool AddTextSameLine(const TextLine& other);
00157
00158 protected:
00160 void SetSides();
00161 };
00162
00166 struct TextArea : public std::list<TextLine>
00167 {
00168 protected:
00169
00171 const_iterator m_iLine;
00173 TextLine::const_iterator m_iWord;
00174
00175 public:
00176
00178 void AddLine(const TextLine& line);
00179
00180
00182 void InitSearch();
00193 bool SearchFor(const STRLIST& words, RECTL& rectArea, int nRepeat) {do {if (!SearchFor(words, rectArea)) return false; nRepeat--;} while (nRepeat > 0); return true;};
00195 bool SearchFor(const STRLIST& words, RECTL& rectArea);
00197 bool SearchForURL(RECTL& rectArea, std::wstring& sWord);
00198 };
00199
00200 #endif //#define _TEXTPART_H_