Diffstat (limited to 'noncore/apps/opie-reader/QTReader.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReader.h | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index dfbdfb9..f89de63 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -1,216 +1,216 @@ | |||
1 | #ifndef __QTREADER_H | 1 | #ifndef __QTREADER_H |
2 | #define __QTREADER_H | 2 | #define __QTREADER_H |
3 | 3 | ||
4 | //#define _SCROLLPIPE | 4 | //#define _SCROLLPIPE |
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | //#include <qpainter.h> | 7 | //#include <qpainter.h> |
8 | #include "my_list.h" | 8 | #include "my_list.h" |
9 | #include "BuffDoc.h" | 9 | #include "BuffDoc.h" |
10 | #include "FontControl.h" | 10 | #include "FontControl.h" |
11 | 11 | ||
12 | //#include <qtimer.h> | 12 | //#include <qtimer.h> |
13 | 13 | ||
14 | class CDrawBuffer; | 14 | class CDrawBuffer; |
15 | //class CBuffer; | 15 | //class CBuffer; |
16 | class QPainter; | 16 | class QPainter; |
17 | class QTimer; | 17 | class QTimer; |
18 | class QPixmap; | 18 | class QPixmap; |
19 | 19 | ||
20 | class QTReader : public QWidget | 20 | class QTReader : public QWidget |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | 23 | ||
24 | static tchar pluckernextpart[]; | 24 | static tchar pluckernextpart[]; |
25 | static tchar jplucknextpart[]; | 25 | static tchar jplucknextpart[]; |
26 | friend class QTReaderApp; | 26 | friend class QTReaderApp; |
27 | void suspend(); | 27 | void suspend(); |
28 | void increaseScroll(); | 28 | void increaseScroll(); |
29 | void reduceScroll(); | 29 | void reduceScroll(); |
30 | void drawText(QPainter& p, int x, int y, tchar* text); | 30 | void drawText(QPainter& p, int x, int y, tchar* text); |
31 | int m_delay; | 31 | int m_delay; |
32 | unsigned int m_overlap; | 32 | unsigned int m_overlap; |
33 | bool m_autoScroll, m_swapmouse; | 33 | bool m_autoScroll, m_swapmouse; |
34 | void autoscroll(); | 34 | void autoscroll(); |
35 | QTimer* timer; | 35 | QTimer* timer; |
36 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart; | 36 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart; |
37 | void focusInEvent(QFocusEvent*); | 37 | void focusInEvent(QFocusEvent*); |
38 | void focusOutEvent(QFocusEvent*); | 38 | void focusOutEvent(QFocusEvent*); |
39 | void processmousepositionevent( QMouseEvent* _e ); | 39 | void processmousepositionevent( QMouseEvent* _e ); |
40 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); | 40 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); |
41 | bool ChangeFont(int); | 41 | bool ChangeFont(int); |
42 | bool getline(CDrawBuffer*); | 42 | bool getline(CDrawBuffer*); |
43 | int m_charWidth; | 43 | int m_charWidth; |
44 | int m_charpc; | 44 | int m_charpc; |
45 | unsigned char m_border; | 45 | unsigned char m_border; |
46 | FontControl m_fontControl; | 46 | FontControl m_fontControl; |
47 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } | 47 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } |
48 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } | 48 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } |
49 | #ifdef _SCROLLPIPE | 49 | #ifdef _SCROLLPIPE |
50 | FILE* m_pipeout; | 50 | FILE* m_pipeout; |
51 | QString m_pipetarget; | 51 | QString m_pipetarget; |
52 | bool m_isPaused; | 52 | bool m_isPaused; |
53 | bool m_pauseAfterEachPara; | 53 | bool m_pauseAfterEachPara; |
54 | #endif | 54 | #endif |
55 | public: | 55 | public: |
56 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 56 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
57 | // 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); |
58 | ~QTReader(); | 58 | ~QTReader(); |
59 | void zoomin(); | 59 | void zoomin(); |
60 | void zoomout(); | 60 | void zoomout(); |
61 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 61 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
62 | { | 62 | { |
63 | buffdoc.setSaveData(data, len, src, srclen); | 63 | buffdoc.setSaveData(data, len, src, srclen); |
64 | } | 64 | } |
65 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 65 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
66 | { | 66 | { |
67 | buffdoc.putSaveData(src, srclen); | 67 | buffdoc.putSaveData(src, srclen); |
68 | } | 68 | } |
69 | bool empty(); | 69 | bool empty(); |
70 | void setContinuous(bool _b); | 70 | void setContinuous(bool _b); |
71 | void toggle_autoscroll(); | 71 | void toggle_autoscroll(); |
72 | void setautoscroll(bool); | 72 | void setautoscroll(bool); |
73 | void disableAutoscroll() { m_autoScroll = false; } | 73 | void disableAutoscroll() { m_autoScroll = false; } |
74 | void copy() | 74 | void copy() |
75 | { | 75 | { |
76 | /* | 76 | /* |
77 | size_t nd = locate(); | 77 | size_t nd = locate(); |
78 | jumpto(m_mark); | 78 | jumpto(m_mark); |
79 | QString text; | 79 | QString text; |
80 | while (m_mark < nd) | 80 | while (m_mark < nd) |
81 | { | 81 | { |
82 | text += buffdoc.getch(); | 82 | text += buffdoc.getch(); |
83 | m_mark++; | 83 | m_mark++; |
84 | } | 84 | } |
85 | QApplication::clipboard()->setText(text); | 85 | QApplication::clipboard()->setText(text); |
86 | jumpto(nd); | 86 | jumpto(nd); |
87 | */ | 87 | */ |
88 | }; | 88 | }; |
89 | void clear() {}; | 89 | void clear() {}; |
90 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; | 90 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; |
91 | /* | 91 | /* |
92 | void setText(bool oldfile) | 92 | void setText(bool oldfile) |
93 | { | 93 | { |
94 | if (oldfile) | 94 | if (oldfile) |
95 | { | 95 | { |
96 | m_string = m_lastfile; | 96 | m_string = m_lastfile; |
97 | load_file((const tchar*)m_string); | 97 | load_file((const tchar*)m_string); |
98 | } | 98 | } |
99 | else | 99 | else |
100 | { | 100 | { |
101 | m_string = QString::null; | 101 | m_string = QString::null; |
102 | } | 102 | } |
103 | }; | 103 | }; |
104 | */ | 104 | */ |
105 | void setlead(int _lead) | 105 | void setlead(int _lead) |
106 | { | 106 | { |
107 | m_fontControl.setlead(_lead); | 107 | m_fontControl.setlead(_lead); |
108 | } | 108 | } |
109 | int getlead() | 109 | int getlead() |
110 | { | 110 | { |
111 | return m_fontControl.getlead(); | 111 | return m_fontControl.getlead(); |
112 | } | 112 | } |
113 | void setextraspace(int _lead) | 113 | void setextraspace(int _lead) |
114 | { | 114 | { |
115 | m_fontControl.setextraspace(_lead); | 115 | m_fontControl.setextraspace(_lead); |
116 | } | 116 | } |
117 | int getextraspace() | 117 | int getextraspace() |
118 | { | 118 | { |
119 | return m_fontControl.getextraspace(); | 119 | return m_fontControl.getextraspace(); |
120 | } | 120 | } |
121 | void setpagemode(bool _b) | 121 | void setpagemode(bool _b) |
122 | { | 122 | { |
123 | m_bpagemode = _b; | 123 | m_bpagemode = _b; |
124 | } | 124 | } |
125 | void setmono(bool _b) | 125 | void setmono(bool _b) |
126 | { | 126 | { |
127 | m_bMonoSpaced = _b; | 127 | m_bMonoSpaced = _b; |
128 | ChangeFont(m_fontControl.currentsize()); | 128 | ChangeFont(m_fontControl.currentsize()); |
129 | locate(pagelocate()); | 129 | locate(pagelocate()); |
130 | } | 130 | } |
131 | void setencoding(int _f) | 131 | void setencoding(int _f) |
132 | { | 132 | { |
133 | m_encd = _f; | 133 | m_encd = _f; |
134 | setfilter(getfilter()); | 134 | setfilter(getfilter()); |
135 | } | 135 | } |
136 | MarkupType PreferredMarkup(); | 136 | MarkupType PreferredMarkup(); |
137 | CEncoding* getencoding() | 137 | CEncoding* getencoding() |
138 | { | 138 | { |
139 | // qDebug("m_encd:%d", m_encd); | 139 | // odebug << "m_encd:" << m_encd << oendl; |
140 | switch (m_encd) | 140 | switch (m_encd) |
141 | { | 141 | { |
142 | case 4: | 142 | case 4: |
143 | // qDebug("palm"); | 143 | // odebug << "palm" << oendl; |
144 | return new CPalm; | 144 | return new CPalm; |
145 | case 1: | 145 | case 1: |
146 | // qDebug("utf8"); | 146 | // odebug << "utf8" << oendl; |
147 | return new CUtf8; | 147 | return new CUtf8; |
148 | case 2: | 148 | case 2: |
149 | // qDebug("ucs16be"); | 149 | // odebug << "ucs16be" << oendl; |
150 | return new CUcs16be; | 150 | return new CUcs16be; |
151 | case 3: | 151 | case 3: |
152 | // qDebug("ucs16le"); | 152 | // odebug << "ucs16le" << oendl; |
153 | return new CUcs16le; | 153 | return new CUcs16le; |
154 | case 0: | 154 | case 0: |
155 | // qDebug("ascii"); | 155 | // odebug << "ascii" << oendl; |
156 | return new CAscii; | 156 | return new CAscii; |
157 | default: | 157 | default: |
158 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); | 158 | return new CGeneral8Bit(m_encd-MAX_ENCODING+1); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | CFilterChain* getfilter() | 161 | CFilterChain* getfilter() |
162 | { | 162 | { |
163 | CFilterChain * filt = new CFilterChain(getencoding()); | 163 | CFilterChain * filt = new CFilterChain(getencoding()); |
164 | if (bstripcr) filt->addfilter(new stripcr); | 164 | if (bstripcr) filt->addfilter(new stripcr); |
165 | 165 | ||
166 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); | 166 | if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); |
167 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); | 167 | if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); |
168 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml); | 168 | if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml); |
169 | 169 | ||
170 | if (bdehyphen) filt->addfilter(new dehyphen); | 170 | if (bdehyphen) filt->addfilter(new dehyphen); |
171 | if (bunindent) filt->addfilter(new unindent); | 171 | if (bunindent) filt->addfilter(new unindent); |
172 | if (brepara) filt->addfilter(new repara); | 172 | if (brepara) filt->addfilter(new repara); |
173 | if (bonespace) filt->addfilter(new OnePara); | 173 | if (bonespace) filt->addfilter(new OnePara); |
174 | if (bindenter) filt->addfilter(new indenter(bindenter)); | 174 | if (bindenter) filt->addfilter(new indenter(bindenter)); |
175 | if (bdblspce) filt->addfilter(new dblspce); | 175 | if (bdblspce) filt->addfilter(new dblspce); |
176 | #ifdef REPALM | 176 | #ifdef REPALM |
177 | if (brepalm) filt->addfilter(new repalm); | 177 | if (brepalm) filt->addfilter(new repalm); |
178 | #endif | 178 | #endif |
179 | if (bremap) filt->addfilter(new remap); | 179 | if (bremap) filt->addfilter(new remap); |
180 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); | 180 | if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); |
181 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); | 181 | if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); |
182 | if (bmakebold) filt->addfilter(new embolden); | 182 | if (bmakebold) filt->addfilter(new embolden); |
183 | if (bfulljust) filt->addfilter(new FullJust); | 183 | if (bfulljust) filt->addfilter(new FullJust); |
184 | return filt; | 184 | return filt; |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | private slots: | 188 | private slots: |
189 | void goHome(); | 189 | void goHome(); |
190 | void goBack(); | 190 | void goBack(); |
191 | void goForward(); | 191 | void goForward(); |
192 | void doscroll(); | 192 | void doscroll(); |
193 | void drawIt( QPainter * ); | 193 | void drawIt( QPainter * ); |
194 | void paintEvent( QPaintEvent * ); | 194 | void paintEvent( QPaintEvent * ); |
195 | // void resizeEvent( QResizeEvent * p ) { update(); } | 195 | // void resizeEvent( QResizeEvent * p ) { update(); } |
196 | void keyPressEvent(QKeyEvent*); | 196 | void keyPressEvent(QKeyEvent*); |
197 | void drawFonts(QPainter*); | 197 | void drawFonts(QPainter*); |
198 | private: | 198 | private: |
199 | void setTwoTouch(bool _b); | 199 | void setTwoTouch(bool _b); |
200 | void init(); | 200 | void init(); |
201 | void mousePressEvent( QMouseEvent* ); | 201 | void mousePressEvent( QMouseEvent* ); |
202 | void mouseReleaseEvent( QMouseEvent* ); | 202 | void mouseReleaseEvent( QMouseEvent* ); |
203 | // void mouseDoubleClickEvent( QMouseEvent* ); | 203 | // void mouseDoubleClickEvent( QMouseEvent* ); |
204 | QString m_string, m_fontname; | 204 | QString m_string, m_fontname; |
205 | void setfont(); | 205 | void setfont(); |
206 | //myoutput stuff | 206 | //myoutput stuff |
207 | private: | 207 | private: |
208 | bool mouseUpOn; | 208 | bool mouseUpOn; |
209 | linkType getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); | 209 | linkType getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); |
210 | bool m_twotouch, m_touchone; | 210 | bool m_twotouch, m_touchone; |
211 | size_t m_startpos, m_startoffset; | 211 | size_t m_startpos, m_startoffset; |
212 | void dopageup(unsigned int); | 212 | void dopageup(unsigned int); |
213 | void dopageup(); | 213 | void dopageup(); |
214 | void lineDown(); | 214 | void lineDown(); |
215 | void lineUp(); | 215 | void lineUp(); |
216 | void dopagedn(); | 216 | void dopagedn(); |