summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/QTReader.h
authorpohly <pohly>2004-08-24 20:52:45 (UTC)
committer pohly <pohly>2004-08-24 20:52:45 (UTC)
commit73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (side-by-side diff)
tree1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/QTReader.h
parente90847c784c48bd21bf8768cb38edb853b832697 (diff)
downloadopie-73253e93327cf4ef0932de1b4afb56af22a0f37e.zip
opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.gz
opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.bz2
updated source to opie-reader 0.7g
Diffstat (limited to 'noncore/apps/opie-reader/QTReader.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/QTReader.h230
1 files changed, 187 insertions, 43 deletions
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h
index f89de63..7b0ebc8 100644
--- a/noncore/apps/opie-reader/QTReader.h
+++ b/noncore/apps/opie-reader/QTReader.h
@@ -4,3 +4,3 @@
//#define _SCROLLPIPE
-
+#include "static.h"
#include <qwidget.h>
@@ -15,5 +15,18 @@ class CDrawBuffer;
//class CBuffer;
+#include <qpixmap.h>
class QPainter;
class QTimer;
-class QPixmap;
+class QImage;
+
+#include "BGType.h"
+#include "striphtml.h"
+
+#define ROTATION_ENABLED
+#define SPECIALSCROLL
+#define DOUBLEBUFFER
+#ifdef DOUBLEBUFFER
+class QPainter;
+#endif
+
+class CStyle;
@@ -22,7 +35,32 @@ class QTReader : public QWidget
Q_OBJECT
+ friend class QTReaderApp;
+#ifdef DOUBLEBUFFER
+ QPixmap *dbuff;
+ QPainter* dbp;
+#endif
+ void drawSingleLine(int lineno);
+ void gotoLink();
+ void emitRedraw();
+ CStyle* m_currentlinkstyle;
+ int m_currentlink;
+ int m_currentlinkoffset;
+ QPixmap m_bgpm;
+ bool m_bgIsScaled;
+ bground m_bgtype;
+ int m_scrollpos;
+ unsigned short m_scrollstep;
+ void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt);
+ void setBackgroundBitmap(const QPixmap& _pm, bground bg)
+ {
+ m_bgpm = _pm;
+ m_bgtype = bg;
+ m_bgIsScaled = false;
+ }
+ QColor m_bg, m_default_bg, m_default_fg, m_negative_fg;
static tchar pluckernextpart[];
static tchar jplucknextpart[];
- friend class QTReaderApp;
- void suspend();
+ CList<Bkmk>* pBkmklist;
+ void setHyphenThreshold(int _v) { buffdoc.setHyphenThreshold(_v); }
+ void ResetScroll();
void increaseScroll();
@@ -30,8 +68,19 @@ class QTReader : public QWidget
void drawText(QPainter& p, int x, int y, tchar* text);
- int m_delay;
+ void DrawScroll( QPainter *p, int w, int h );
+ void dorollingscroll(bool);
+ void doinplacescroll();
+ void dostaticscroll();
+ void suspend();
+ void redrawScroll(QPainter* p);
+ int m_delay, m_scrolltype;
unsigned int m_overlap;
bool m_autoScroll, m_swapmouse;
+ void drawBackground();
+#ifdef ROTATION_ENABLED
+ bool m_rotated;
+ void setrotated(bool);
+#endif
void autoscroll();
QTimer* timer;
- int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart;
+ int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll;
void focusInEvent(QFocusEvent*);
@@ -44,3 +93,4 @@ class QTReader : public QWidget
int m_charpc;
- unsigned char m_border;
+ unsigned short m_absleft_border, m_absright_border;
+ unsigned short m_left_border, m_right_border;
FontControl m_fontControl;
@@ -58,2 +108,19 @@ public:
~QTReader();
+ QString about();
+ CList<Bkmk>* Bkmklist() { return pBkmklist; }
+ void setBackground(const QColor& _c)
+ {
+ m_default_bg = _c;
+ reset_bg();
+ }
+ void setForeground(const QColor& _c)
+ {
+ m_default_fg = _c;
+ int r,g,b;
+ m_default_fg.rgb(&r, &g, &b);
+ r = 255-r;
+ g = 255-g;
+ b = 255-b;
+ m_negative_fg.setRgb(r,g,b);
+ }
void zoomin();
@@ -138,3 +205,3 @@ public:
{
-// odebug << "m_encd:" << m_encd << oendl;
+// qDebug("m_encd:%d", m_encd);
switch (m_encd)
@@ -142,15 +209,15 @@ public:
case 4:
-// odebug << "palm" << oendl;
+// qDebug("palm");
return new CPalm;
case 1:
-// odebug << "utf8" << oendl;
+// qDebug("utf8");
return new CUtf8;
case 2:
-// odebug << "ucs16be" << oendl;
+// qDebug("ucs16be");
return new CUcs16be;
case 3:
-// odebug << "ucs16le" << oendl;
+// qDebug("ucs16le");
return new CUcs16le;
case 0:
-// odebug << "ascii" << oendl;
+// qDebug("ascii");
return new CAscii;
@@ -160,2 +227,3 @@ public:
}
+ HighlightFilter* m_highlightfilter;
CFilterChain* getfilter()
@@ -167,3 +235,21 @@ public:
if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter);
- if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml);
+ // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
+
+#ifdef __STATIC
+ if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
+ if (bautofmt && (PreferredMarkup() == cCHM))
+ {
+ filt->addfilter(new striphtml(m_lastfile));
+ }
+#else
+ if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile));
+ if (bautofmt && (PreferredMarkup() == cCHM))
+ {
+ ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile);
+ ((striphtml*)f->filter())->setchm(true);
+ filt->addfilter(f);
+ }
+#endif
+ m_highlightfilter = new HighlightFilter(this);
+ filt->addfilter(m_highlightfilter);
@@ -171,3 +257,3 @@ public:
if (bunindent) filt->addfilter(new unindent);
- if (brepara) filt->addfilter(new repara);
+ if (brepara) filt->addfilter(new repara(m_reparastring));
if (bonespace) filt->addfilter(new OnePara);
@@ -175,10 +261,18 @@ public:
if (bdblspce) filt->addfilter(new dblspce);
-#ifdef REPALM
- if (brepalm) filt->addfilter(new repalm);
-#endif
- if (bremap) filt->addfilter(new remap);
if (bdepluck) filt->addfilter(new DePluck(pluckernextpart));
if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart));
+ if (brepalm) filt->addfilter(new repalm);
+ if (bkern) filt->addfilter(new kern);
+ if (bremap) filt->addfilter(new remap);
if (bmakebold) filt->addfilter(new embolden);
if (bfulljust) filt->addfilter(new FullJust);
+ int r,g,b;
+ m_default_bg.rgb(&r, &g, &b);
+ if (r != 255 || g != 255 || b != 255)
+ filt->addfilter(new setbg(r,g,b));
+ m_default_fg.rgb(&r, &g, &b);
+ if (r != 0 || g != 0 || b != 0)
+ filt->addfilter(new setfg(r,g,b));
+ // if (bNegative) filt->addfilter(new makeNegative);
+ if (bInverse) filt->addfilter(new makeInverse);
return filt;
@@ -188,2 +282,6 @@ public:
private slots:
+ void dopageup();
+ void lineDown();
+ void lineUp();
+ void dopagedn();
void goHome();
@@ -192,8 +290,13 @@ private slots:
void doscroll();
- void drawIt( QPainter * );
void paintEvent( QPaintEvent * );
-// void resizeEvent( QResizeEvent * p ) { update(); }
+#ifdef DOUBLEBUFFER
+ void resizeEvent( QResizeEvent * p );
+#endif
void keyPressEvent(QKeyEvent*);
- void drawFonts(QPainter*);
private:
+ // void drawIt( QPainter * );
+ void redrawall();
+ void drawFonts();
+ void DrawStraight(QPainter* p, int w, int h);
+ QColor m_scrollcolor, m_scrollbarcolor;
void setTwoTouch(bool _b);
@@ -203,3 +306,3 @@ private slots:
// void mouseDoubleClickEvent( QMouseEvent* );
- QString m_string, m_fontname;
+ QString m_string, m_fontname, m_reparastring;
void setfont();
@@ -207,4 +310,7 @@ private slots:
private:
+#ifdef SPECIALSCROLL
+ int m_scrolldy;
+#endif
bool mouseUpOn;
- linkType getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt);
+ 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*&);
bool m_twotouch, m_touchone;
@@ -212,6 +318,2 @@ private slots:
void dopageup(unsigned int);
- void dopageup();
- void lineDown();
- void lineUp();
- void dopagedn();
long real_delay();
@@ -223,6 +325,4 @@ private slots:
// bool m_showlast;
- bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust;
-#ifdef REPALM
- bool brepalm;
-#endif
+ bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse;
+ bool bkern, brepalm;
bool m_bpagemode, m_bMonoSpaced, m_continuousDocument;
@@ -231,4 +331,6 @@ private slots:
size_t m_lastposn;
- public:
bool bDoUpdates;
+ public:
+ void setDoUpdates(bool b) { bDoUpdates = b; }
+ void setStripCR(bool b) { bstripcr = b; }
void NavUp();
@@ -242,11 +344,12 @@ private slots:
bool locate(unsigned long n);
- void jumpto(unsigned long n) { buffdoc.unsuspend(); buffdoc.locate(n); }
- unsigned long locate() { buffdoc.unsuspend(); return buffdoc.locate(); }
- unsigned long explocate() { buffdoc.unsuspend(); return buffdoc.explocate(); }
+ void jumpto(unsigned long n) { buffdoc.locate(n); }
+ unsigned long locate() { return buffdoc.locate(); }
+ unsigned long explocate() { return buffdoc.explocate(); }
unsigned long pagelocate() { return locnarray[0]; }
unsigned long mylastpos;
- void setfilter(CFilterChain *f) { buffdoc.unsuspend(); buffdoc.setfilter(f); locate(pagelocate()); }
+ void getNextLink();
+ void setfilter(CFilterChain *f) { buffdoc.setfilter(f); if (bDoUpdates) locate(pagelocate()); }
void restore() { jumpto(mylastpos); }
void goUp();
- void refresh() { locate(pagelocate()); }
+ void refresh(bool full = false);
void goDown();
@@ -255,5 +358,6 @@ private slots:
void textsize(int ts) { m_textsize = ts; }
- bool fillbuffer(int ru = 0, int ht = 0, int newht = -1);
+ bool fillbuffer(int ru = 0, int ht = -1, int newht = -1);
+ void CalculateScrollParameters();
unsigned int screenlines();
- void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.unsuspend(); buffdoc.sizes(fs,ts); }
+ void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); }
static const char *fonts[];
@@ -261,10 +365,50 @@ private slots:
int m_ascent, m_descent, m_linespacing;
+ int m_topmargin, m_bottommargin;
+ int m_abstopmargin, m_absbottommargin;
QFontMetrics* m_fm;
QString firstword();
-
+ bool hyphenate;
+ void reset_bg()
+ {
+ int r,g,b;
+ m_default_bg.rgb(&r, &g, &b);
+ if (bInverse)
+ {
+ r = 255-r;
+ g = 255-g;
+ b = 255-b;
+ }
+ m_bg.setRgb(r,g,b);
+ /*
+ int h,s,v;
+ m_bg.hsv(&h, &s, &v);
+ if (bNegative)
+ {
+ v = 255-v;
+ m_bg.setHsv(h,s,v);
+ }
+ */
+ setBackgroundColor( m_bg );
+ }
+ void setInverse(bool b)
+ {
+ bInverse = b;
+ reset_bg();
+ }
+ /*
+ void setNegative()
+ {
+ bNegative = !bNegative;
+ reset_bg();
+ }
+ */
signals:
void OnRedraw();
- void OnWordSelected(const QString&, size_t, const QString&);
+ void OnWordSelected(const QString&, size_t, size_t, const QString&);
void OnShowPicture(QImage&);
- void OnURLSelected(const QString&);
+ void OnURLSelected(const QString&, const size_t);
+ void NewFileRequest(const QString&);
+ void HandleKeyRequest(QKeyEvent*);
+ void SetScrollState(bool);
+ void RefreshBitmap();
};