Diffstat (limited to 'noncore/apps/opie-reader/QTReader.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReader.h | 99 |
1 files changed, 77 insertions, 22 deletions
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 2efb988..78230b4 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -3,10 +3,15 @@ | |||
3 | 3 | ||
4 | #include <qwidget.h> | 4 | #include <qwidget.h> |
5 | #include <qpainter.h> | 5 | //#include <qpainter.h> |
6 | #include <qclipboard.h> | ||
7 | #include "CBuffer.h" | ||
8 | #include "my_list.h" | 6 | #include "my_list.h" |
9 | #include "BuffDoc.h" | 7 | #include "BuffDoc.h" |
10 | #include <qtimer.h> | 8 | #include "FontControl.h" |
9 | |||
10 | //#include <qtimer.h> | ||
11 | |||
12 | class CDrawBuffer; | ||
13 | //class CBuffer; | ||
14 | class QPainter; | ||
15 | class QTimer; | ||
11 | 16 | ||
12 | class QTReader : public QWidget | 17 | class QTReader : public QWidget |
@@ -21,11 +26,12 @@ class QTReader : public QWidget | |||
21 | void autoscroll(); | 26 | void autoscroll(); |
22 | QTimer* timer; | 27 | QTimer* timer; |
23 | int m_scrolldy, m_encd; | 28 | int m_scrolldy1, m_scrolldy2, m_encd; |
24 | void focusInEvent(QFocusEvent*); | 29 | void focusInEvent(QFocusEvent*); |
25 | void focusOutEvent(QFocusEvent*); | 30 | void focusOutEvent(QFocusEvent*); |
26 | void ChangeFont(int); | 31 | bool ChangeFont(int); |
27 | bool getline(CBuffer*); | 32 | bool getline(CDrawBuffer*); |
28 | int m_charWidth; | 33 | int m_charWidth; |
29 | int m_charpc; | 34 | int m_charpc; |
35 | FontControl m_fontControl; | ||
30 | public: | 36 | public: |
31 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 37 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
@@ -67,4 +73,35 @@ public: | |||
67 | }; | 73 | }; |
68 | */ | 74 | */ |
75 | void setpeanut(bool _b) | ||
76 | { | ||
77 | bpeanut = _b; | ||
78 | setfilter(getfilter()); | ||
79 | } | ||
80 | void setremap(bool _b) | ||
81 | { | ||
82 | bremap = _b; | ||
83 | setfilter(getfilter()); | ||
84 | } | ||
85 | void setmakebold(bool _b) | ||
86 | { | ||
87 | bmakebold = _b; | ||
88 | setfilter(getfilter()); | ||
89 | } | ||
90 | void setautofmt(bool _b) | ||
91 | { | ||
92 | bautofmt = _b; | ||
93 | if (bautofmt) | ||
94 | { | ||
95 | btextfmt = false; | ||
96 | bstriphtml = false;; | ||
97 | bpeanut = false; | ||
98 | } | ||
99 | setfilter(getfilter()); | ||
100 | } | ||
101 | void settextfmt(bool _b) | ||
102 | { | ||
103 | btextfmt = _b; | ||
104 | setfilter(getfilter()); | ||
105 | } | ||
69 | void setstripcr(bool _b) | 106 | void setstripcr(bool _b) |
70 | { | 107 | { |
@@ -114,6 +151,6 @@ public: | |||
114 | { | 151 | { |
115 | m_bMonoSpaced = _b; | 152 | m_bMonoSpaced = _b; |
116 | ChangeFont(fontsizes[m_textsize]); | 153 | ChangeFont(m_fontControl.currentsize()); |
117 | locate(pagepos); | 154 | locate(pagelocate()); |
118 | } | 155 | } |
119 | void setencoding(int _f) | 156 | void setencoding(int _f) |
@@ -122,4 +159,5 @@ public: | |||
122 | setfilter(getfilter()); | 159 | setfilter(getfilter()); |
123 | } | 160 | } |
161 | MarkupType PreferredMarkup(); | ||
124 | CEncoding* getencoding() | 162 | CEncoding* getencoding() |
125 | { | 163 | { |
@@ -145,5 +183,9 @@ public: | |||
145 | CFilterChain * filt = new CFilterChain(getencoding()); | 183 | CFilterChain * filt = new CFilterChain(getencoding()); |
146 | if (bstripcr) filt->addfilter(new stripcr); | 184 | if (bstripcr) filt->addfilter(new stripcr); |
147 | if (bstriphtml) filt->addfilter(new striphtml); | 185 | |
186 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | ||
187 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | ||
188 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml); | ||
189 | |||
148 | if (bdehyphen) filt->addfilter(new dehyphen); | 190 | if (bdehyphen) filt->addfilter(new dehyphen); |
149 | if (bunindent) filt->addfilter(new unindent); | 191 | if (bunindent) filt->addfilter(new unindent); |
@@ -151,4 +193,6 @@ public: | |||
151 | if (bindenter) filt->addfilter(new indenter(bindenter)); | 193 | if (bindenter) filt->addfilter(new indenter(bindenter)); |
152 | if (bdblspce) filt->addfilter(new dblspce); | 194 | if (bdblspce) filt->addfilter(new dblspce); |
195 | if (bremap) filt->addfilter(new remap); | ||
196 | if (bmakebold) filt->addfilter(new embolden); | ||
153 | return filt; | 197 | return filt; |
154 | } | 198 | } |
@@ -163,11 +207,17 @@ private slots: | |||
163 | void drawFonts(QPainter*); | 207 | void drawFonts(QPainter*); |
164 | private: | 208 | private: |
209 | void setTwoTouch(bool _b); | ||
165 | void init(); | 210 | void init(); |
211 | void mousePressEvent( QMouseEvent* ); | ||
166 | void mouseReleaseEvent( QMouseEvent* ); | 212 | void mouseReleaseEvent( QMouseEvent* ); |
167 | // void mouseDoubleClickEvent( QMouseEvent* ); | 213 | // void mouseDoubleClickEvent( QMouseEvent* ); |
168 | QString m_string, m_fontname; | 214 | QString m_string, m_fontname; |
169 | void setfont(QPainter*); | 215 | void setfont(); |
170 | //myoutput stuff | 216 | //myoutput stuff |
171 | private: | 217 | private: |
218 | bool mouseUpOn; | ||
219 | bool getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); | ||
220 | bool m_twotouch, m_touchone; | ||
221 | size_t m_startpos, m_startoffset; | ||
172 | void dopageup(); | 222 | void dopageup(); |
173 | void lineDown(); | 223 | void lineDown(); |
@@ -176,11 +226,10 @@ private slots: | |||
176 | long real_delay(); | 226 | long real_delay(); |
177 | int m_textsize; | 227 | int m_textsize; |
178 | int m_lastwidth; | 228 | int m_lastwidth, m_lastheight; |
179 | CBuffer** textarray; | 229 | CBufferFace<CDrawBuffer*> textarray; |
180 | size_t* locnarray; | 230 | CBufferFace<size_t> locnarray; |
181 | unsigned int numlines; | 231 | unsigned int numlines; |
182 | bool bstripcr, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, m_bBold; | 232 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt; |
183 | bool m_bpagemode, m_bMonoSpaced; | 233 | bool m_bpagemode, m_bMonoSpaced; |
184 | QString m_targetapp, m_targetmsg; | ||
185 | unsigned char bindenter; | 234 | unsigned char bindenter; |
186 | QString m_lastfile; | 235 | QString m_lastfile; |
@@ -195,22 +244,28 @@ private slots: | |||
195 | void jumpto(unsigned long n) { buffdoc.locate(n); } | 244 | void jumpto(unsigned long n) { buffdoc.locate(n); } |
196 | unsigned long locate() { return buffdoc.locate(); } | 245 | unsigned long locate() { return buffdoc.locate(); } |
197 | unsigned long pagelocate() { return pagepos; } | 246 | unsigned long explocate() { return buffdoc.explocate(); } |
198 | unsigned long pagepos, mylastpos; | 247 | unsigned long pagelocate() { return locnarray[0]; } |
199 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); locate(pagepos); } | 248 | unsigned long mylastpos; |
249 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); locate(pagelocate()); } | ||
200 | void restore() { jumpto(mylastpos); } | 250 | void restore() { jumpto(mylastpos); } |
201 | void goUp(); | 251 | void goUp(); |
202 | void refresh() { locate(pagepos); } | 252 | void refresh() { locate(pagelocate()); } |
203 | void goDown(); | 253 | void goDown(); |
204 | // bool bold; | 254 | // bool bold; |
205 | int textsize() { return m_textsize; } | 255 | int textsize() { return m_textsize; } |
206 | void textsize(int ts) { m_textsize = ts; } | 256 | void textsize(int ts) { m_textsize = ts; } |
207 | bool fillbuffer(); | 257 | bool fillbuffer(int ru = 0, int ht = 0); |
208 | unsigned int screenlines(); | 258 | unsigned int screenlines(); |
209 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } | 259 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } |
210 | static const char *fonts[]; | 260 | static const char *fonts[]; |
211 | unsigned int *fontsizes; | 261 | // unsigned int *fontsizes; |
212 | int m_ascent, m_descent, m_linespacing; | 262 | int m_ascent, m_descent, m_linespacing; |
213 | QFontMetrics* m_fm; | 263 | QFontMetrics* m_fm; |
214 | QString firstword(); | 264 | QString firstword(); |
265 | |||
266 | signals: | ||
267 | void OnRedraw(); | ||
268 | void OnWordSelected(const QString&, size_t, const QString&); | ||
269 | void OnActionPressed(); | ||
215 | }; | 270 | }; |
216 | 271 | ||