author | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
commit | 118d03d815a7615b9c53363218a7ac45b3f4c514 (patch) (unidiff) | |
tree | 356953e2413cddcec0f35bd47bb6439767da7051 /noncore/apps/opie-reader/QTReader.h | |
parent | 00894537decf01c5a5cdc565b2740b5e67a2e90f (diff) | |
download | opie-118d03d815a7615b9c53363218a7ac45b3f4c514.zip opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.gz opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.bz2 |
Incorporated TimWs current source tree and make it compile
Diffstat (limited to 'noncore/apps/opie-reader/QTReader.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReader.h | 150 |
1 files changed, 55 insertions, 95 deletions
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 3d5f57d..dfbdfb9 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -1,9 +1,11 @@ | |||
1 | #ifndef __QTREADER_H | 1 | #ifndef __QTREADER_H |
2 | #define __QTREADER_H | 2 | #define __QTREADER_H |
3 | 3 | ||
4 | //#define _SCROLLPIPE | ||
5 | |||
4 | #include <qwidget.h> | 6 | #include <qwidget.h> |
5 | //#include <qpainter.h> | 7 | //#include <qpainter.h> |
6 | #include "my_list.h" | 8 | #include "my_list.h" |
7 | #include "BuffDoc.h" | 9 | #include "BuffDoc.h" |
8 | #include "FontControl.h" | 10 | #include "FontControl.h" |
9 | 11 | ||
@@ -11,34 +13,48 @@ | |||
11 | 13 | ||
12 | class CDrawBuffer; | 14 | class CDrawBuffer; |
13 | //class CBuffer; | 15 | //class CBuffer; |
14 | class QPainter; | 16 | class QPainter; |
15 | class QTimer; | 17 | class QTimer; |
16 | class QPixmap; | 18 | class QPixmap; |
17 | class statedata; | ||
18 | 19 | ||
19 | class QTReader : public QWidget | 20 | class QTReader : public QWidget |
20 | { | 21 | { |
21 | Q_OBJECT | 22 | Q_OBJECT |
22 | 23 | ||
24 | static tchar pluckernextpart[]; | ||
25 | static tchar jplucknextpart[]; | ||
23 | friend class QTReaderApp; | 26 | friend class QTReaderApp; |
24 | void suspend() { buffdoc.suspend(); } | 27 | void suspend(); |
28 | void increaseScroll(); | ||
29 | void reduceScroll(); | ||
25 | void drawText(QPainter& p, int x, int y, tchar* text); | 30 | void drawText(QPainter& p, int x, int y, tchar* text); |
26 | int m_delay; | 31 | int m_delay; |
27 | unsigned int m_overlap; | 32 | unsigned int m_overlap; |
28 | bool m_autoScroll; | 33 | bool m_autoScroll, m_swapmouse; |
29 | void autoscroll(); | 34 | void autoscroll(); |
30 | QTimer* timer; | 35 | QTimer* timer; |
31 | int m_scrolldy1, m_scrolldy2, m_encd; | 36 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart; |
32 | void focusInEvent(QFocusEvent*); | 37 | void focusInEvent(QFocusEvent*); |
33 | void focusOutEvent(QFocusEvent*); | 38 | void focusOutEvent(QFocusEvent*); |
39 | void processmousepositionevent( QMouseEvent* _e ); | ||
40 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); | ||
34 | bool ChangeFont(int); | 41 | bool ChangeFont(int); |
35 | bool getline(CDrawBuffer*); | 42 | bool getline(CDrawBuffer*); |
36 | int m_charWidth; | 43 | int m_charWidth; |
37 | int m_charpc; | 44 | int m_charpc; |
45 | unsigned char m_border; | ||
38 | FontControl m_fontControl; | 46 | FontControl m_fontControl; |
47 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } | ||
48 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } | ||
49 | #ifdef _SCROLLPIPE | ||
50 | FILE* m_pipeout; | ||
51 | QString m_pipetarget; | ||
52 | bool m_isPaused; | ||
53 | bool m_pauseAfterEachPara; | ||
54 | #endif | ||
39 | public: | 55 | public: |
40 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 56 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
41 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 57 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
42 | ~QTReader(); | 58 | ~QTReader(); |
43 | void zoomin(); | 59 | void zoomin(); |
44 | void zoomout(); | 60 | void zoomout(); |
@@ -83,95 +99,28 @@ public: | |||
83 | else | 99 | else |
84 | { | 100 | { |
85 | m_string = QString::null; | 101 | m_string = QString::null; |
86 | } | 102 | } |
87 | }; | 103 | }; |
88 | */ | 104 | */ |
89 | void setpeanut(bool _b) | 105 | void setlead(int _lead) |
90 | { | ||
91 | bpeanut = _b; | ||
92 | setfilter(getfilter()); | ||
93 | } | ||
94 | void setremap(bool _b) | ||
95 | { | ||
96 | bremap = _b; | ||
97 | setfilter(getfilter()); | ||
98 | } | ||
99 | void setmakebold(bool _b) | ||
100 | { | ||
101 | bmakebold = _b; | ||
102 | setfilter(getfilter()); | ||
103 | } | ||
104 | void setautofmt(bool _b) | ||
105 | { | ||
106 | bautofmt = _b; | ||
107 | if (bautofmt) | ||
108 | { | 106 | { |
109 | btextfmt = false; | 107 | m_fontControl.setlead(_lead); |
110 | bstriphtml = false;; | 108 | } |
111 | bpeanut = false; | 109 | int getlead() |
110 | { | ||
111 | return m_fontControl.getlead(); | ||
112 | } | ||
113 | void setextraspace(int _lead) | ||
114 | { | ||
115 | m_fontControl.setextraspace(_lead); | ||
116 | } | ||
117 | int getextraspace() | ||
118 | { | ||
119 | return m_fontControl.getextraspace(); | ||
112 | } | 120 | } |
113 | setfilter(getfilter()); | ||
114 | } | ||
115 | void settextfmt(bool _b) | ||
116 | { | ||
117 | btextfmt = _b; | ||
118 | setfilter(getfilter()); | ||
119 | } | ||
120 | void setstripcr(bool _b) | ||
121 | { | ||
122 | bstripcr = _b; | ||
123 | setfilter(getfilter()); | ||
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 | ||
137 | void setstriphtml(bool _b) | ||
138 | { | ||
139 | bstriphtml = _b; | ||
140 | setfilter(getfilter()); | ||
141 | } | ||
142 | void setdehyphen(bool _b) | ||
143 | { | ||
144 | bdehyphen = _b; | ||
145 | setfilter(getfilter()); | ||
146 | } | ||
147 | void setunindent(bool _b) | ||
148 | { | ||
149 | bunindent = _b; | ||
150 | setfilter(getfilter()); | ||
151 | } | ||
152 | void setrepara(bool _b) | ||
153 | { | ||
154 | brepara = _b; | ||
155 | setfilter(getfilter()); | ||
156 | } | ||
157 | void setdblspce(bool _b) | ||
158 | { | ||
159 | bdblspce = _b; | ||
160 | setfilter(getfilter()); | ||
161 | } | ||
162 | void indentplus() | ||
163 | { | ||
164 | if (bindenter < 15) bindenter += 2; | ||
165 | setfilter(getfilter()); | ||
166 | } | ||
167 | void indentminus() | ||
168 | { | ||
169 | if (bindenter > 1) bindenter -= 2; | ||
170 | setfilter(getfilter()); | ||
171 | } | ||
172 | void setpagemode(bool _b) | 121 | void setpagemode(bool _b) |
173 | { | 122 | { |
174 | m_bpagemode = _b; | 123 | m_bpagemode = _b; |
175 | } | 124 | } |
176 | void setmono(bool _b) | 125 | void setmono(bool _b) |
177 | { | 126 | { |
@@ -184,27 +133,32 @@ public: | |||
184 | m_encd = _f; | 133 | m_encd = _f; |
185 | setfilter(getfilter()); | 134 | setfilter(getfilter()); |
186 | } | 135 | } |
187 | MarkupType PreferredMarkup(); | 136 | MarkupType PreferredMarkup(); |
188 | CEncoding* getencoding() | 137 | CEncoding* getencoding() |
189 | { | 138 | { |
139 | // qDebug("m_encd:%d", m_encd); | ||
190 | switch (m_encd) | 140 | switch (m_encd) |
191 | { | 141 | { |
192 | case 5: | ||
193 | return new Ccp1252; | ||
194 | case 4: | 142 | case 4: |
143 | // qDebug("palm"); | ||
195 | return new CPalm; | 144 | return new CPalm; |
196 | case 1: | 145 | case 1: |
146 | // qDebug("utf8"); | ||
197 | return new CUtf8; | 147 | return new CUtf8; |
198 | case 2: | 148 | case 2: |
149 | // qDebug("ucs16be"); | ||
199 | return new CUcs16be; | 150 | return new CUcs16be; |
200 | case 3: | 151 | case 3: |
152 | // qDebug("ucs16le"); | ||
201 | return new CUcs16le; | 153 | return new CUcs16le; |
202 | case 0: | 154 | case 0: |
203 | default: | 155 | // qDebug("ascii"); |
204 | return new CAscii; | 156 | return new CAscii; |
157 | default: | ||
158 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); | ||
205 | } | 159 | } |
206 | } | 160 | } |
207 | CFilterChain* getfilter() | 161 | CFilterChain* getfilter() |
208 | { | 162 | { |
209 | CFilterChain * filt = new CFilterChain(getencoding()); | 163 | CFilterChain * filt = new CFilterChain(getencoding()); |
210 | if (bstripcr) filt->addfilter(new stripcr); | 164 | if (bstripcr) filt->addfilter(new stripcr); |
@@ -220,18 +174,24 @@ public: | |||
220 | if (bindenter) filt->addfilter(new indenter(bindenter)); | 174 | if (bindenter) filt->addfilter(new indenter(bindenter)); |
221 | if (bdblspce) filt->addfilter(new dblspce); | 175 | if (bdblspce) filt->addfilter(new dblspce); |
222 | #ifdef REPALM | 176 | #ifdef REPALM |
223 | if (brepalm) filt->addfilter(new repalm); | 177 | if (brepalm) filt->addfilter(new repalm); |
224 | #endif | 178 | #endif |
225 | if (bremap) filt->addfilter(new remap); | 179 | if (bremap) filt->addfilter(new remap); |
180 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | ||
181 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | ||
226 | if (bmakebold) filt->addfilter(new embolden); | 182 | if (bmakebold) filt->addfilter(new embolden); |
183 | if (bfulljust) filt->addfilter(new FullJust); | ||
227 | return filt; | 184 | return filt; |
228 | } | 185 | } |
229 | 186 | ||
230 | 187 | ||
231 | private slots: | 188 | private slots: |
189 | void goHome(); | ||
190 | void goBack(); | ||
191 | void goForward(); | ||
232 | void doscroll(); | 192 | void doscroll(); |
233 | void drawIt( QPainter * ); | 193 | void drawIt( QPainter * ); |
234 | void paintEvent( QPaintEvent * ); | 194 | void paintEvent( QPaintEvent * ); |
235 | // void resizeEvent( QResizeEvent * p ) { update(); } | 195 | // void resizeEvent( QResizeEvent * p ) { update(); } |
236 | void keyPressEvent(QKeyEvent*); | 196 | void keyPressEvent(QKeyEvent*); |
237 | void drawFonts(QPainter*); | 197 | void drawFonts(QPainter*); |
@@ -257,26 +217,27 @@ private slots: | |||
257 | long real_delay(); | 217 | long real_delay(); |
258 | int m_textsize; | 218 | int m_textsize; |
259 | int m_lastwidth, m_lastheight; | 219 | int m_lastwidth, m_lastheight; |
260 | CBufferFace<CDrawBuffer*> textarray; | 220 | CBufferFace<CDrawBuffer*> textarray; |
261 | CBufferFace<size_t> locnarray; | 221 | CBufferFace<size_t> locnarray; |
262 | unsigned int numlines; | 222 | unsigned int numlines; |
263 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace; | 223 | // bool m_showlast; |
224 | bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust; | ||
264 | #ifdef REPALM | 225 | #ifdef REPALM |
265 | bool brepalm; | 226 | bool brepalm; |
266 | #endif | 227 | #endif |
267 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; | 228 | bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; |
268 | unsigned char bindenter; | 229 | unsigned char bindenter; |
269 | QString m_lastfile; | 230 | QString m_lastfile; |
270 | size_t m_lastposn; | 231 | size_t m_lastposn; |
271 | public: | 232 | public: |
272 | bool bDoUpdates; | 233 | bool bDoUpdates; |
273 | bool m_navkeys; | ||
274 | void NavUp(); | 234 | void NavUp(); |
275 | void NavDown(); | 235 | void NavDown(); |
276 | int getch() { return buffdoc.getch(); } | 236 | tchar getch() { return buffdoc.getch(); } |
237 | bool synch(size_t, size_t); | ||
277 | bool tight; | 238 | bool tight; |
278 | bool load_file(const char *newfile, unsigned int lcn=0); | 239 | bool load_file(const char *newfile, unsigned int lcn=0); |
279 | BuffDoc buffdoc; | 240 | BuffDoc buffdoc; |
280 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } | 241 | CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } |
281 | bool locate(unsigned long n); | 242 | bool locate(unsigned long n); |
282 | void jumpto(unsigned long n) { buffdoc.unsuspend(); buffdoc.locate(n); } | 243 | void jumpto(unsigned long n) { buffdoc.unsuspend(); buffdoc.locate(n); } |
@@ -289,24 +250,23 @@ private slots: | |||
289 | void goUp(); | 250 | void goUp(); |
290 | void refresh() { locate(pagelocate()); } | 251 | void refresh() { locate(pagelocate()); } |
291 | void goDown(); | 252 | void goDown(); |
292 | // bool bold; | 253 | // bool bold; |
293 | int textsize() { return m_textsize; } | 254 | int textsize() { return m_textsize; } |
294 | void textsize(int ts) { m_textsize = ts; } | 255 | void textsize(int ts) { m_textsize = ts; } |
295 | bool fillbuffer(int ru = 0, int ht = 0); | 256 | bool fillbuffer(int ru = 0, int ht = 0, int newht = -1); |
296 | unsigned int screenlines(); | 257 | unsigned int screenlines(); |
297 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); } | 258 | void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); } |
298 | static const char *fonts[]; | 259 | static const char *fonts[]; |
299 | // unsigned int *fontsizes; | 260 | // unsigned int *fontsizes; |
300 | int m_ascent, m_descent, m_linespacing; | 261 | int m_ascent, m_descent, m_linespacing; |
301 | QFontMetrics* m_fm; | 262 | QFontMetrics* m_fm; |
302 | QString firstword(); | 263 | QString firstword(); |
303 | void setstate(const statedata& sd); | ||
304 | 264 | ||
305 | signals: | 265 | signals: |
306 | void OnRedraw(); | 266 | void OnRedraw(); |
307 | void OnWordSelected(const QString&, size_t, const QString&); | 267 | void OnWordSelected(const QString&, size_t, const QString&); |
308 | void OnActionPressed(); | 268 | void OnShowPicture(QImage&); |
309 | void OnShowPicture(QPixmap&); | 269 | void OnURLSelected(const QString&); |
310 | }; | 270 | }; |
311 | 271 | ||
312 | #endif | 272 | #endif |