author | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
commit | 876e1a4724a7bd75dc642e295de354241096e028 (patch) (unidiff) | |
tree | a37c5dcc9d78e04bb6b859ab89d8cf81e6745087 /noncore/apps/opie-reader/QTReader.h | |
parent | 5fd6636ba3d94b48dd543887316c47c5388a43c2 (diff) | |
download | opie-876e1a4724a7bd75dc642e295de354241096e028.zip opie-876e1a4724a7bd75dc642e295de354241096e028.tar.gz opie-876e1a4724a7bd75dc642e295de354241096e028.tar.bz2 |
update - sorry it took so long. hope this works correctly
Diffstat (limited to 'noncore/apps/opie-reader/QTReader.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReader.h | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 78230b4..3d5f57d 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -1,64 +1,78 @@ | |||
1 | #ifndef __QTREADER_H | 1 | #ifndef __QTREADER_H |
2 | #define __QTREADER_H | 2 | #define __QTREADER_H |
3 | 3 | ||
4 | #include <qwidget.h> | 4 | #include <qwidget.h> |
5 | //#include <qpainter.h> | 5 | //#include <qpainter.h> |
6 | #include "my_list.h" | 6 | #include "my_list.h" |
7 | #include "BuffDoc.h" | 7 | #include "BuffDoc.h" |
8 | #include "FontControl.h" | 8 | #include "FontControl.h" |
9 | 9 | ||
10 | //#include <qtimer.h> | 10 | //#include <qtimer.h> |
11 | 11 | ||
12 | class CDrawBuffer; | 12 | class CDrawBuffer; |
13 | //class CBuffer; | 13 | //class CBuffer; |
14 | class QPainter; | 14 | class QPainter; |
15 | class QTimer; | 15 | class QTimer; |
16 | class QPixmap; | ||
17 | class statedata; | ||
16 | 18 | ||
17 | class QTReader : public QWidget | 19 | class QTReader : public QWidget |
18 | { | 20 | { |
19 | Q_OBJECT | 21 | Q_OBJECT |
20 | 22 | ||
21 | friend class QTReaderApp; | 23 | friend class QTReaderApp; |
24 | void suspend() { buffdoc.suspend(); } | ||
22 | void drawText(QPainter& p, int x, int y, tchar* text); | 25 | void drawText(QPainter& p, int x, int y, tchar* text); |
23 | int m_delay; | 26 | int m_delay; |
24 | unsigned int m_overlap; | 27 | unsigned int m_overlap; |
25 | bool m_autoScroll; | 28 | bool m_autoScroll; |
26 | void autoscroll(); | 29 | void autoscroll(); |
27 | QTimer* timer; | 30 | QTimer* timer; |
28 | int m_scrolldy1, m_scrolldy2, m_encd; | 31 | int m_scrolldy1, m_scrolldy2, m_encd; |
29 | void focusInEvent(QFocusEvent*); | 32 | void focusInEvent(QFocusEvent*); |
30 | void focusOutEvent(QFocusEvent*); | 33 | void focusOutEvent(QFocusEvent*); |
31 | bool ChangeFont(int); | 34 | bool ChangeFont(int); |
32 | bool getline(CDrawBuffer*); | 35 | bool getline(CDrawBuffer*); |
33 | int m_charWidth; | 36 | int m_charWidth; |
34 | int m_charpc; | 37 | int m_charpc; |
35 | FontControl m_fontControl; | 38 | FontControl m_fontControl; |
36 | public: | 39 | public: |
37 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 40 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
38 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 41 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
39 | ~QTReader(); | 42 | ~QTReader(); |
43 | void zoomin(); | ||
44 | void zoomout(); | ||
45 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | ||
46 | { | ||
47 | buffdoc.setSaveData(data, len, src, srclen); | ||
48 | } | ||
49 | void putSaveData(unsigned char*& src, unsigned short& srclen) | ||
50 | { | ||
51 | buffdoc.putSaveData(src, srclen); | ||
52 | } | ||
40 | bool empty(); | 53 | bool empty(); |
54 | void setContinuous(bool _b); | ||
41 | void toggle_autoscroll(); | 55 | void toggle_autoscroll(); |
42 | void setautoscroll(bool); | 56 | void setautoscroll(bool); |
43 | void disableAutoscroll() { m_autoScroll = false; } | 57 | void disableAutoscroll() { m_autoScroll = false; } |
44 | void copy() | 58 | void copy() |
45 | { | 59 | { |
46 | /* | 60 | /* |
47 | size_t nd = locate(); | 61 | size_t nd = locate(); |
48 | jumpto(m_mark); | 62 | jumpto(m_mark); |
49 | QString text; | 63 | QString text; |
50 | while (m_mark < nd) | 64 | while (m_mark < nd) |
51 | { | 65 | { |
52 | text += buffdoc.getch(); | 66 | text += buffdoc.getch(); |
53 | m_mark++; | 67 | m_mark++; |
54 | } | 68 | } |
55 | QApplication::clipboard()->setText(text); | 69 | QApplication::clipboard()->setText(text); |
56 | jumpto(nd); | 70 | jumpto(nd); |
57 | */ | 71 | */ |
58 | }; | 72 | }; |
59 | void clear() {}; | 73 | void clear() {}; |
60 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; | 74 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; |
61 | /* | 75 | /* |
62 | void setText(bool oldfile) | 76 | void setText(bool oldfile) |
63 | { | 77 | { |
64 | if (oldfile) | 78 | if (oldfile) |
@@ -87,48 +101,60 @@ public: | |||
87 | bmakebold = _b; | 101 | bmakebold = _b; |
88 | setfilter(getfilter()); | 102 | setfilter(getfilter()); |
89 | } | 103 | } |
90 | void setautofmt(bool _b) | 104 | void setautofmt(bool _b) |
91 | { | 105 | { |
92 | bautofmt = _b; | 106 | bautofmt = _b; |
93 | if (bautofmt) | 107 | if (bautofmt) |
94 | { | 108 | { |
95 | btextfmt = false; | 109 | btextfmt = false; |
96 | bstriphtml = false;; | 110 | bstriphtml = false;; |
97 | bpeanut = false; | 111 | bpeanut = false; |
98 | } | 112 | } |
99 | setfilter(getfilter()); | 113 | setfilter(getfilter()); |
100 | } | 114 | } |
101 | void settextfmt(bool _b) | 115 | void settextfmt(bool _b) |
102 | { | 116 | { |
103 | btextfmt = _b; | 117 | btextfmt = _b; |
104 | setfilter(getfilter()); | 118 | setfilter(getfilter()); |
105 | } | 119 | } |
106 | void setstripcr(bool _b) | 120 | void setstripcr(bool _b) |
107 | { | 121 | { |
108 | bstripcr = _b; | 122 | bstripcr = _b; |
109 | setfilter(getfilter()); | 123 | setfilter(getfilter()); |
110 | } | 124 | } |
125 | void setonespace(bool _b) | ||
126 | { | ||
127 | bonespace = _b; | ||
128 | setfilter(getfilter()); | ||
129 | } | ||
130 | #ifdef REPALM | ||
131 | void setrepalm(bool _b) | ||
132 | { | ||
133 | brepalm = _b; | ||
134 | setfilter(getfilter()); | ||
135 | } | ||
136 | #endif | ||
111 | void setstriphtml(bool _b) | 137 | void setstriphtml(bool _b) |
112 | { | 138 | { |
113 | bstriphtml = _b; | 139 | bstriphtml = _b; |
114 | setfilter(getfilter()); | 140 | setfilter(getfilter()); |
115 | } | 141 | } |
116 | void setdehyphen(bool _b) | 142 | void setdehyphen(bool _b) |
117 | { | 143 | { |
118 | bdehyphen = _b; | 144 | bdehyphen = _b; |
119 | setfilter(getfilter()); | 145 | setfilter(getfilter()); |
120 | } | 146 | } |
121 | void setunindent(bool _b) | 147 | void setunindent(bool _b) |
122 | { | 148 | { |
123 | bunindent = _b; | 149 | bunindent = _b; |
124 | setfilter(getfilter()); | 150 | setfilter(getfilter()); |
125 | } | 151 | } |
126 | void setrepara(bool _b) | 152 | void setrepara(bool _b) |
127 | { | 153 | { |
128 | brepara = _b; | 154 | brepara = _b; |
129 | setfilter(getfilter()); | 155 | setfilter(getfilter()); |
130 | } | 156 | } |
131 | void setdblspce(bool _b) | 157 | void setdblspce(bool _b) |
132 | { | 158 | { |
133 | bdblspce = _b; | 159 | bdblspce = _b; |
134 | setfilter(getfilter()); | 160 | setfilter(getfilter()); |
@@ -169,104 +195,118 @@ public: | |||
169 | return new CPalm; | 195 | return new CPalm; |
170 | case 1: | 196 | case 1: |
171 | return new CUtf8; | 197 | return new CUtf8; |
172 | case 2: | 198 | case 2: |
173 | return new CUcs16be; | 199 | return new CUcs16be; |
174 | case 3: | 200 | case 3: |
175 | return new CUcs16le; | 201 | return new CUcs16le; |
176 | case 0: | 202 | case 0: |
177 | default: | 203 | default: |
178 | return new CAscii; | 204 | return new CAscii; |
179 | } | 205 | } |
180 | } | 206 | } |
181 | CFilterChain* getfilter() | 207 | CFilterChain* getfilter() |
182 | { | 208 | { |
183 | CFilterChain * filt = new CFilterChain(getencoding()); | 209 | CFilterChain * filt = new CFilterChain(getencoding()); |
184 | if (bstripcr) filt->addfilter(new stripcr); | 210 | if (bstripcr) filt->addfilter(new stripcr); |
185 | 211 | ||
186 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | 212 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); |
187 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | 213 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); |
188 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml); | 214 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml); |
189 | 215 | ||
190 | if (bdehyphen) filt->addfilter(new dehyphen); | 216 | if (bdehyphen) filt->addfilter(new dehyphen); |
191 | if (bunindent) filt->addfilter(new unindent); | 217 | if (bunindent) filt->addfilter(new unindent); |
192 | if (brepara) filt->addfilter(new repara); | 218 | if (brepara) filt->addfilter(new repara); |
219 | if (bonespace) filt->addfilter(new OnePara); | ||
193 | if (bindenter) filt->addfilter(new indenter(bindenter)); | 220 | if (bindenter) filt->addfilter(new indenter(bindenter)); |
194 | if (bdblspce) filt->addfilter(new dblspce); | 221 | if (bdblspce) filt->addfilter(new dblspce); |
222 | #ifdef REPALM | ||
223 | if (brepalm) filt->addfilter(new repalm); | ||
224 | #endif | ||
195 | if (bremap) filt->addfilter(new remap); | 225 | if (bremap) filt->addfilter(new remap); |
196 | if (bmakebold) filt->addfilter(new embolden); | 226 | if (bmakebold) filt->addfilter(new embolden); |
197 | return filt; | 227 | return filt; |
198 | } | 228 | } |
199 | 229 | ||
200 | 230 | ||
201 | private slots: | 231 | private slots: |
202 | void doscroll(); | 232 | void doscroll(); |
203 | void drawIt( QPainter * ); | 233 | void drawIt( QPainter * ); |
204 | void paintEvent( QPaintEvent * ); | 234 | void paintEvent( QPaintEvent * ); |
205 | // void resizeEvent( QResizeEvent * p ) { update(); } | 235 | // void resizeEvent( QResizeEvent * p ) { update(); } |
206 | void keyPressEvent(QKeyEvent*); | 236 | void keyPressEvent(QKeyEvent*); |
207 | void drawFonts(QPainter*); | 237 | void drawFonts(QPainter*); |
208 | private: | 238 | private: |
209 | void setTwoTouch(bool _b); | 239 | void setTwoTouch(bool _b); |
210 | void init(); | 240 | void init(); |
211 | void mousePressEvent( QMouseEvent* ); | 241 | void mousePressEvent( QMouseEvent* ); |
212 | void mouseReleaseEvent( QMouseEvent* ); | 242 | void mouseReleaseEvent( QMouseEvent* ); |
213 | // void mouseDoubleClickEvent( QMouseEvent* ); | 243 | // void mouseDoubleClickEvent( QMouseEvent* ); |
214 | QString m_string, m_fontname; | 244 | QString m_string, m_fontname; |
215 | void setfont(); | 245 | void setfont(); |
216 | //myoutput stuff | 246 | //myoutput stuff |
217 | private: | 247 | private: |
218 | bool mouseUpOn; | 248 | bool mouseUpOn; |
219 | bool getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); | 249 | linkType getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); |
220 | bool m_twotouch, m_touchone; | 250 | bool m_twotouch, m_touchone; |
221 | size_t m_startpos, m_startoffset; | 251 | size_t m_startpos, m_startoffset; |
252 | void dopageup(unsigned int); | ||
222 | void dopageup(); | 253 | void dopageup(); |
223 | void lineDown(); | 254 | void lineDown(); |
224 | void lineUp(); | 255 | void lineUp(); |
225 | void dopagedn(); | 256 | void dopagedn(); |
226 | long real_delay(); | 257 | long real_delay(); |
227 | int m_textsize; | 258 | int m_textsize; |
228 | int m_lastwidth, m_lastheight; | 259 | int m_lastwidth, m_lastheight; |
229 | CBufferFace<CDrawBuffer*> textarray; | 260 | CBufferFace<CDrawBuffer*> textarray; |
230 | CBufferFace<size_t> locnarray; | 261 | CBufferFace<size_t> locnarray; |
231 | unsigned int numlines; | 262 | unsigned int numlines; |
232 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt; | 263 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace; |
233 | bool m_bpagemode, m_bMonoSpaced; | 264 | #ifdef REPALM |
265 | bool brepalm; | ||
266 | #endif | ||
267 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; | ||
234 | unsigned char bindenter; | 268 | unsigned char bindenter; |
235 | QString m_lastfile; | 269 | QString m_lastfile; |
236 | size_t m_lastposn; | 270 | size_t m_lastposn; |
237 | public: | 271 | public: |
272 | bool bDoUpdates; | ||
273 | bool m_navkeys; | ||
274 | void NavUp(); | ||
275 | void NavDown(); | ||
238 | int getch() { return buffdoc.getch(); } | 276 | int getch() { return buffdoc.getch(); } |
239 | bool tight; | 277 | bool tight; |
240 | bool load_file(const char *newfile, unsigned int lcn=0); | 278 | bool load_file(const char *newfile, unsigned int lcn=0); |
241 | BuffDoc buffdoc; | 279 | BuffDoc buffdoc; |
242 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } | 280 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } |
243 | bool locate(unsigned long n); | 281 | bool locate(unsigned long n); |
244 | void jumpto(unsigned long n) { buffdoc.locate(n); } | 282 | void jumpto(unsigned long n) { buffdoc.unsuspend(); buffdoc.locate(n); } |
245 | unsigned long locate() { return buffdoc.locate(); } | 283 | unsigned long locate() { buffdoc.unsuspend(); return buffdoc.locate(); } |
246 | unsigned long explocate() { return buffdoc.explocate(); } | 284 | unsigned long explocate() { buffdoc.unsuspend(); return buffdoc.explocate(); } |
247 | unsigned long pagelocate() { return locnarray[0]; } | 285 | unsigned long pagelocate() { return locnarray[0]; } |
248 | unsigned long mylastpos; | 286 | unsigned long mylastpos; |
249 | void setfilter(CFilterChain *f) { buffdoc.setfilter(f); locate(pagelocate()); } | 287 | void setfilter(CFilterChain *f) { buffdoc.unsuspend(); buffdoc.setfilter(f); locate(pagelocate()); } |
250 | void restore() { jumpto(mylastpos); } | 288 | void restore() { jumpto(mylastpos); } |
251 | void goUp(); | 289 | void goUp(); |
252 | void refresh() { locate(pagelocate()); } | 290 | void refresh() { locate(pagelocate()); } |
253 | void goDown(); | 291 | void goDown(); |
254 | // bool bold; | 292 | // bool bold; |
255 | int textsize() { return m_textsize; } | 293 | int textsize() { return m_textsize; } |
256 | void textsize(int ts) { m_textsize = ts; } | 294 | void textsize(int ts) { m_textsize = ts; } |
257 | bool fillbuffer(int ru = 0, int ht = 0); | 295 | bool fillbuffer(int ru = 0, int ht = 0); |
258 | unsigned int screenlines(); | 296 | unsigned int screenlines(); |
259 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } | 297 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); } |
260 | static const char *fonts[]; | 298 | static const char *fonts[]; |
261 | // unsigned int *fontsizes; | 299 | // unsigned int *fontsizes; |
262 | int m_ascent, m_descent, m_linespacing; | 300 | int m_ascent, m_descent, m_linespacing; |
263 | QFontMetrics* m_fm; | 301 | QFontMetrics* m_fm; |
264 | QString firstword(); | 302 | QString firstword(); |
303 | void setstate(const statedata& sd); | ||
265 | 304 | ||
266 | signals: | 305 | signals: |
267 | void OnRedraw(); | 306 | void OnRedraw(); |
268 | void OnWordSelected(const QString&, size_t, const QString&); | 307 | void OnWordSelected(const QString&, size_t, const QString&); |
269 | void OnActionPressed(); | 308 | void OnActionPressed(); |
309 | void OnShowPicture(QPixmap&); | ||
270 | }; | 310 | }; |
271 | 311 | ||
272 | #endif | 312 | #endif |