Diffstat (limited to 'noncore/apps/opie-reader/QTReader.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReader.h | 96 |
1 files changed, 28 insertions, 68 deletions
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 3bcdde4..9daa07a 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -9,43 +9,46 @@ | |||
9 | #include "FontControl.h" | 9 | #include "FontControl.h" |
10 | 10 | ||
11 | //#include <qtimer.h> | 11 | //#include <qtimer.h> |
12 | 12 | ||
13 | class CDrawBuffer; | 13 | class CDrawBuffer; |
14 | //class CBuffer; | 14 | //class CBuffer; |
15 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
16 | class QPainter; | 16 | class QPainter; |
17 | class QTimer; | 17 | class QTimer; |
18 | class QImage; | 18 | class QImage; |
19 | 19 | ||
20 | #include "BGType.h" | 20 | #include "BGType.h" |
21 | #include "striphtml.h" | ||
22 | 21 | ||
23 | #define ROTATION_ENABLED | ||
24 | #define SPECIALSCROLL | 22 | #define SPECIALSCROLL |
25 | #define DOUBLEBUFFER | 23 | |
26 | #ifdef DOUBLEBUFFER | ||
27 | class QPainter; | 24 | class QPainter; |
28 | #endif | 25 | class COutput; |
29 | 26 | ||
30 | class CStyle; | 27 | class CStyle; |
28 | #define USETIMER | ||
31 | 29 | ||
32 | class QTReader : public QWidget | 30 | class QTReader : public QWidget |
33 | { | 31 | { |
34 | Q_OBJECT | 32 | Q_OBJECT |
35 | friend class QTReaderApp; | 33 | friend class QTReaderApp; |
36 | #ifdef DOUBLEBUFFER | 34 | #ifdef USETIMER |
35 | QTimer* m_dragtimer; | ||
36 | unsigned long m_dragtarget; | ||
37 | #endif | ||
38 | COutput* m_output; | ||
39 | bool checkoutput(); | ||
40 | bool m_outofdate, m_drageligible; | ||
37 | QPixmap *dbuff; | 41 | QPixmap *dbuff; |
38 | QPainter* dbp; | 42 | QPainter* dbp; |
39 | #endif | ||
40 | void drawSingleLine(int lineno); | 43 | void drawSingleLine(int lineno); |
41 | void gotoLink(); | 44 | void gotoLink(); |
42 | void emitRedraw(); | 45 | void emitRedraw(); |
43 | CStyle* m_currentlinkstyle; | 46 | CStyle* m_currentlinkstyle; |
44 | int m_currentlink; | 47 | int m_currentlink; |
45 | int m_currentlinkoffset; | 48 | int m_currentlinkoffset; |
46 | QPixmap m_bgpm; | 49 | QPixmap m_bgpm; |
47 | bool m_bgIsScaled; | 50 | bool m_bgIsScaled; |
48 | bground m_bgtype; | 51 | bground m_bgtype; |
49 | int m_scrollpos; | 52 | int m_scrollpos; |
50 | unsigned short m_scrollstep; | 53 | unsigned short m_scrollstep; |
51 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); | 54 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); |
@@ -65,56 +68,56 @@ class QTReader : public QWidget | |||
65 | void increaseScroll(); | 68 | void increaseScroll(); |
66 | void reduceScroll(); | 69 | void reduceScroll(); |
67 | void drawText(QPainter& p, int x, int y, tchar* text); | 70 | void drawText(QPainter& p, int x, int y, tchar* text); |
68 | void DrawScroll( QPainter *p, int w, int h ); | 71 | void DrawScroll( QPainter *p, int w, int h ); |
69 | void dorollingscroll(bool); | 72 | void dorollingscroll(bool); |
70 | void doinplacescroll(); | 73 | void doinplacescroll(); |
71 | void dostaticscroll(); | 74 | void dostaticscroll(); |
72 | void suspend(); | 75 | void suspend(); |
73 | void redrawScroll(QPainter* p); | 76 | void redrawScroll(QPainter* p); |
74 | int m_delay, m_scrolltype; | 77 | int m_delay, m_scrolltype; |
75 | unsigned int m_overlap; | 78 | unsigned int m_overlap; |
76 | bool m_autoScroll, m_swapmouse; | 79 | bool m_autoScroll, m_swapmouse; |
77 | void drawBackground(); | 80 | void drawBackground(QPainter*); |
78 | #ifdef ROTATION_ENABLED | ||
79 | bool m_rotated; | 81 | bool m_rotated; |
80 | void setrotated(bool); | 82 | void setrotated(bool); |
81 | #endif | ||
82 | void autoscroll(); | 83 | void autoscroll(); |
83 | QTimer* timer; | 84 | QTimer* timer; |
84 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; | 85 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; |
85 | void focusInEvent(QFocusEvent*); | 86 | void focusInEvent(QFocusEvent*); |
86 | void focusOutEvent(QFocusEvent*); | 87 | void focusOutEvent(QFocusEvent*); |
87 | void processmousepositionevent( QMouseEvent* _e ); | 88 | void processmousepositionevent( QMouseEvent* _e ); |
88 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); | 89 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); |
89 | bool ChangeFont(int); | 90 | bool ChangeFont(int); |
90 | bool getline(CDrawBuffer*); | 91 | bool getline(CDrawBuffer*); |
91 | int m_charWidth; | 92 | int m_charWidth; |
92 | int m_charpc; | 93 | int m_charpc; |
93 | unsigned short m_absleft_border, m_absright_border; | 94 | unsigned short m_absleft_border, m_absright_border; |
94 | unsigned short m_left_border, m_right_border; | 95 | unsigned short m_left_border, m_right_border; |
95 | FontControl m_fontControl; | 96 | FontControl m_fontControl; |
96 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } | 97 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } |
97 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } | 98 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } |
99 | QString m_outputName; | ||
98 | #ifdef _SCROLLPIPE | 100 | #ifdef _SCROLLPIPE |
99 | FILE* m_pipeout; | 101 | FILE* m_pipeout; |
100 | QString m_pipetarget; | 102 | QString m_pipetarget; |
101 | bool m_isPaused; | 103 | bool m_isPaused; |
102 | bool m_pauseAfterEachPara; | 104 | bool m_pauseAfterEachPara; |
103 | #endif | 105 | #endif |
104 | public: | 106 | public: |
105 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 107 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
106 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 108 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
107 | ~QTReader(); | 109 | ~QTReader(); |
108 | QString about(); | 110 | QString about(); |
111 | void readAloud(); | ||
109 | CList<Bkmk>* Bkmklist() { return pBkmklist; } | 112 | CList<Bkmk>* Bkmklist() { return pBkmklist; } |
110 | void setBackground(const QColor& _c) | 113 | void setBackground(const QColor& _c) |
111 | { | 114 | { |
112 | m_default_bg = _c; | 115 | m_default_bg = _c; |
113 | reset_bg(); | 116 | reset_bg(); |
114 | } | 117 | } |
115 | void setForeground(const QColor& _c) | 118 | void setForeground(const QColor& _c) |
116 | { | 119 | { |
117 | m_default_fg = _c; | 120 | m_default_fg = _c; |
118 | int r,g,b; | 121 | int r,g,b; |
119 | m_default_fg.rgb(&r, &g, &b); | 122 | m_default_fg.rgb(&r, &g, &b); |
120 | r = 255-r; | 123 | r = 255-r; |
@@ -144,25 +147,25 @@ public: | |||
144 | jumpto(m_mark); | 147 | jumpto(m_mark); |
145 | QString text; | 148 | QString text; |
146 | while (m_mark < nd) | 149 | while (m_mark < nd) |
147 | { | 150 | { |
148 | text += buffdoc.getch(); | 151 | text += buffdoc.getch(); |
149 | m_mark++; | 152 | m_mark++; |
150 | } | 153 | } |
151 | QApplication::clipboard()->setText(text); | 154 | QApplication::clipboard()->setText(text); |
152 | jumpto(nd); | 155 | jumpto(nd); |
153 | */ | 156 | */ |
154 | }; | 157 | }; |
155 | void clear() {}; | 158 | void clear() {}; |
156 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; | 159 | void setText(const QString& n, const QString& s, unsigned int lcn = 0) { m_string = n; load_file((const char*)s, lcn); }; |
157 | /* | 160 | /* |
158 | void setText(bool oldfile) | 161 | void setText(bool oldfile) |
159 | { | 162 | { |
160 | if (oldfile) | 163 | if (oldfile) |
161 | { | 164 | { |
162 | m_string = m_lastfile; | 165 | m_string = m_lastfile; |
163 | load_file((const tchar*)m_string); | 166 | load_file((const tchar*)m_string); |
164 | } | 167 | } |
165 | else | 168 | else |
166 | { | 169 | { |
167 | m_string = QString::null; | 170 | m_string = QString::null; |
168 | } | 171 | } |
@@ -216,129 +219,86 @@ public: | |||
216 | return new CUcs16be; | 219 | return new CUcs16be; |
217 | case 3: | 220 | case 3: |
218 | // qDebug("ucs16le"); | 221 | // qDebug("ucs16le"); |
219 | return new CUcs16le; | 222 | return new CUcs16le; |
220 | case 0: | 223 | case 0: |
221 | // qDebug("ascii"); | 224 | // qDebug("ascii"); |
222 | return new CAscii; | 225 | return new CAscii; |
223 | default: | 226 | default: |
224 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); | 227 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); |
225 | } | 228 | } |
226 | } | 229 | } |
227 | HighlightFilter* m_highlightfilter; | 230 | HighlightFilter* m_highlightfilter; |
228 | CFilterChain* getfilter() | 231 | CFilterChain* getfilter(); |
229 | { | ||
230 | CFilterChain * filt = new CFilterChain(getencoding()); | ||
231 | if (bstripcr) filt->addfilter(new stripcr); | ||
232 | |||
233 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | ||
234 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | ||
235 | // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
236 | |||
237 | #ifdef __STATIC | ||
238 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); | ||
239 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
240 | { | ||
241 | filt->addfilter(new striphtml(m_lastfile)); | ||
242 | } | ||
243 | #else | ||
244 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); | ||
245 | if (bautofmt && (PreferredMarkup() == cCHM)) | ||
246 | { | ||
247 | ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); | ||
248 | ((striphtml*)f->filter())->setchm(true); | ||
249 | filt->addfilter(f); | ||
250 | } | ||
251 | #endif | ||
252 | m_highlightfilter = new HighlightFilter(this); | ||
253 | filt->addfilter(m_highlightfilter); | ||
254 | |||
255 | if (bdehyphen) filt->addfilter(new dehyphen); | ||
256 | if (bunindent) filt->addfilter(new unindent); | ||
257 | if (brepara) filt->addfilter(new repara(m_reparastring)); | ||
258 | if (bonespace) filt->addfilter(new OnePara); | ||
259 | if (bindenter) filt->addfilter(new indenter(bindenter)); | ||
260 | if (bdblspce) filt->addfilter(new dblspce); | ||
261 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | ||
262 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | ||
263 | if (brepalm) filt->addfilter(new repalm); | ||
264 | if (bkern) filt->addfilter(new kern); | ||
265 | if (bremap) filt->addfilter(new remap); | ||
266 | if (bmakebold) filt->addfilter(new embolden); | ||
267 | if (bfulljust) filt->addfilter(new FullJust); | ||
268 | int r,g,b; | ||
269 | m_default_bg.rgb(&r, &g, &b); | ||
270 | if (r != 255 || g != 255 || b != 255) | ||
271 | filt->addfilter(new setbg(r,g,b)); | ||
272 | m_default_fg.rgb(&r, &g, &b); | ||
273 | if (r != 0 || g != 0 || b != 0) | ||
274 | filt->addfilter(new setfg(r,g,b)); | ||
275 | // if (bNegative) filt->addfilter(new makeNegative); | ||
276 | if (bInverse) filt->addfilter(new makeInverse); | ||
277 | return filt; | ||
278 | } | ||
279 | |||
280 | 232 | ||
281 | private slots: | 233 | private slots: |
234 | #ifdef USETIMER | ||
235 | void actionDrag(); | ||
236 | #endif | ||
282 | void dopageup(); | 237 | void dopageup(); |
283 | void lineDown(); | 238 | void lineDown(); |
284 | void lineUp(); | 239 | void lineUp(); |
285 | void dopagedn(); | 240 | void dopagedn(); |
286 | void goHome(); | 241 | void goHome(); |
287 | void goBack(); | 242 | void goBack(); |
288 | void goForward(); | 243 | void goForward(); |
289 | void doscroll(); | 244 | void doscroll(); |
290 | void paintEvent( QPaintEvent * ); | 245 | void paintEvent( QPaintEvent * ); |
291 | #ifdef DOUBLEBUFFER | 246 | |
292 | void resizeEvent( QResizeEvent * p ); | 247 | void resizeEvent( QResizeEvent * p ); |
293 | #endif | 248 | |
294 | void keyPressEvent(QKeyEvent*); | 249 | void keyPressEvent(QKeyEvent*); |
295 | private: | 250 | private: |
296 | // void drawIt( QPainter * ); | 251 | // void drawIt( QPainter * ); |
297 | void redrawall(); | 252 | void redrawall(); |
298 | void drawFonts(); | 253 | void drawFonts(); |
299 | void DrawStraight(QPainter* p, int w, int h); | 254 | void DrawStraight(QPainter* p, int w, int h); |
300 | QColor m_scrollcolor, m_scrollbarcolor; | 255 | QColor m_scrollcolor, m_scrollbarcolor; |
301 | void setTwoTouch(bool _b); | 256 | void setTwoTouch(bool _b); |
302 | void init(); | 257 | void init(); |
258 | void mouseMoveEvent( QMouseEvent* ); | ||
303 | void mousePressEvent( QMouseEvent* ); | 259 | void mousePressEvent( QMouseEvent* ); |
304 | void mouseReleaseEvent( QMouseEvent* ); | 260 | void mouseReleaseEvent( QMouseEvent* ); |
305 | // void mouseDoubleClickEvent( QMouseEvent* ); | 261 | // void mouseDoubleClickEvent( QMouseEvent* ); |
306 | QString m_string, m_fontname, m_reparastring; | 262 | QString m_string, m_fontname, m_reparastring; |
307 | void setfont(); | 263 | void setfont(); |
264 | bool m_doubleBuffered; | ||
265 | |||
266 | void setDoubleBuffer(bool _b); | ||
308 | //myoutput stuff | 267 | //myoutput stuff |
309 | private: | 268 | private: |
310 | #ifdef SPECIALSCROLL | 269 | #ifdef SPECIALSCROLL |
311 | int m_scrolldy; | 270 | int m_scrolldy; |
312 | #endif | 271 | #endif |
313 | bool mouseUpOn; | 272 | bool mouseUpOn; |
314 | linkType getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*&); | 273 | linkType getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*&, size_t&); |
315 | bool m_twotouch, m_touchone; | 274 | bool m_twotouch, m_touchone; |
316 | size_t m_startpos, m_startoffset; | 275 | size_t m_startpos, m_startoffset; |
317 | void dopageup(unsigned int); | 276 | void dopageup(unsigned int); |
318 | long real_delay(); | 277 | long real_delay(); |
319 | int m_textsize; | 278 | int m_textsize; |
320 | int m_lastwidth, m_lastheight; | 279 | int m_lastwidth, m_lastheight; |
321 | CBufferFace<CDrawBuffer*> textarray; | 280 | CBufferFace<CDrawBuffer*> textarray; |
322 | CBufferFace<size_t> locnarray; | 281 | CBufferFace<size_t> locnarray; |
323 | unsigned int numlines; | 282 | unsigned int numlines; |
324 | // bool m_showlast; | 283 | // bool m_showlast; |
325 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse; | 284 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse, bNoInlineTables; |
326 | bool bkern, brepalm; | 285 | bool bkern, brepalm, bunderlineLink; |
327 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; | 286 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; |
328 | unsigned char bindenter; | 287 | unsigned char bindenter; |
329 | QString m_lastfile; | 288 | QString m_lastfile; |
330 | size_t m_lastposn; | 289 | size_t m_lastposn; |
331 | bool bDoUpdates; | 290 | bool bDoUpdates; |
332 | public: | 291 | public: |
292 | bool doOutput(const QString& wrd); | ||
333 | void setDoUpdates(bool b) { bDoUpdates = b; } | 293 | void setDoUpdates(bool b) { bDoUpdates = b; } |
334 | void setStripCR(bool b) { bstripcr = b; } | 294 | void setStripCR(bool b) { bstripcr = b; } |
335 | void NavUp(); | 295 | void NavUp(); |
336 | void NavDown(); | 296 | void NavDown(); |
337 | tchar getch() { return buffdoc.getch(); } | 297 | tchar getch() { return buffdoc.getch(); } |
338 | bool synch(size_t, size_t); | 298 | bool synch(size_t, size_t); |
339 | bool tight; | 299 | bool tight; |
340 | bool load_file(const char *newfile, unsigned int lcn=0); | 300 | bool load_file(const char *newfile, unsigned int lcn=0); |
341 | BuffDoc buffdoc; | 301 | BuffDoc buffdoc; |
342 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } | 302 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } |
343 | bool locate(unsigned long n); | 303 | bool locate(unsigned long n); |
344 | void jumpto(unsigned long n) { buffdoc.locate(n); } | 304 | void jumpto(unsigned long n) { buffdoc.locate(n); } |