From 2d0c1ffcb39f9fac8193ed2e9e93794de0bd7975 Mon Sep 17 00:00:00 2001 From: llornkcor Date: Sat, 14 Sep 2002 02:19:09 +0000 Subject: update by Tim --- (limited to 'noncore/apps/opie-reader/QTReader.h') 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 @@ -2,12 +2,17 @@ #define __QTREADER_H #include -#include -#include -#include "CBuffer.h" +//#include #include "my_list.h" #include "BuffDoc.h" -#include +#include "FontControl.h" + +//#include + +class CDrawBuffer; +//class CBuffer; +class QPainter; +class QTimer; class QTReader : public QWidget { @@ -20,13 +25,14 @@ class QTReader : public QWidget bool m_autoScroll; void autoscroll(); QTimer* timer; - int m_scrolldy, m_encd; + int m_scrolldy1, m_scrolldy2, m_encd; void focusInEvent(QFocusEvent*); void focusOutEvent(QFocusEvent*); - void ChangeFont(int); - bool getline(CBuffer*); + bool ChangeFont(int); + bool getline(CDrawBuffer*); int m_charWidth; int m_charpc; + FontControl m_fontControl; public: QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); @@ -66,6 +72,37 @@ public: } }; */ + void setpeanut(bool _b) + { + bpeanut = _b; + setfilter(getfilter()); + } + void setremap(bool _b) + { + bremap = _b; + setfilter(getfilter()); + } + void setmakebold(bool _b) + { + bmakebold = _b; + setfilter(getfilter()); + } + void setautofmt(bool _b) + { + bautofmt = _b; + if (bautofmt) + { + btextfmt = false; + bstriphtml = false;; + bpeanut = false; + } + setfilter(getfilter()); + } + void settextfmt(bool _b) + { + btextfmt = _b; + setfilter(getfilter()); + } void setstripcr(bool _b) { bstripcr = _b; @@ -113,14 +150,15 @@ public: void setmono(bool _b) { m_bMonoSpaced = _b; - ChangeFont(fontsizes[m_textsize]); - locate(pagepos); + ChangeFont(m_fontControl.currentsize()); + locate(pagelocate()); } void setencoding(int _f) { m_encd = _f; setfilter(getfilter()); } + MarkupType PreferredMarkup(); CEncoding* getencoding() { switch (m_encd) @@ -144,12 +182,18 @@ public: { CFilterChain * filt = new CFilterChain(getencoding()); if (bstripcr) filt->addfilter(new stripcr); - if (bstriphtml) filt->addfilter(new striphtml); + + if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); + if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); + if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml); + if (bdehyphen) filt->addfilter(new dehyphen); if (bunindent) filt->addfilter(new unindent); if (brepara) filt->addfilter(new repara); if (bindenter) filt->addfilter(new indenter(bindenter)); if (bdblspce) filt->addfilter(new dblspce); + if (bremap) filt->addfilter(new remap); + if (bmakebold) filt->addfilter(new embolden); return filt; } @@ -162,26 +206,31 @@ private slots: void keyPressEvent(QKeyEvent*); void drawFonts(QPainter*); private: + void setTwoTouch(bool _b); void init(); + void mousePressEvent( QMouseEvent* ); void mouseReleaseEvent( QMouseEvent* ); // void mouseDoubleClickEvent( QMouseEvent* ); QString m_string, m_fontname; - void setfont(QPainter*); + void setfont(); //myoutput stuff private: + bool mouseUpOn; + bool getcurrentpos(int x, int y, size_t& start, size_t& offset, size_t& tgt); + bool m_twotouch, m_touchone; + size_t m_startpos, m_startoffset; void dopageup(); void lineDown(); void lineUp(); void dopagedn(); long real_delay(); int m_textsize; - int m_lastwidth; - CBuffer** textarray; - size_t* locnarray; + int m_lastwidth, m_lastheight; + CBufferFace textarray; + CBufferFace locnarray; unsigned int numlines; - bool bstripcr, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, m_bBold; + bool bstripcr, btextfmt, bstriphtml, bdehyphen, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt; bool m_bpagemode, m_bMonoSpaced; - QString m_targetapp, m_targetmsg; unsigned char bindenter; QString m_lastfile; size_t m_lastposn; @@ -194,24 +243,30 @@ private slots: bool locate(unsigned long n); void jumpto(unsigned long n) { buffdoc.locate(n); } unsigned long locate() { return buffdoc.locate(); } - unsigned long pagelocate() { return pagepos; } - unsigned long pagepos, mylastpos; - void setfilter(CFilterChain *f) { buffdoc.setfilter(f); locate(pagepos); } + unsigned long explocate() { return buffdoc.explocate(); } + unsigned long pagelocate() { return locnarray[0]; } + unsigned long mylastpos; + void setfilter(CFilterChain *f) { buffdoc.setfilter(f); locate(pagelocate()); } void restore() { jumpto(mylastpos); } void goUp(); - void refresh() { locate(pagepos); } + void refresh() { locate(pagelocate()); } void goDown(); // bool bold; int textsize() { return m_textsize; } void textsize(int ts) { m_textsize = ts; } - bool fillbuffer(); + bool fillbuffer(int ru = 0, int ht = 0); unsigned int screenlines(); void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } static const char *fonts[]; - unsigned int *fontsizes; +// unsigned int *fontsizes; int m_ascent, m_descent, m_linespacing; QFontMetrics* m_fm; QString firstword(); + + signals: + void OnRedraw(); + void OnWordSelected(const QString&, size_t, const QString&); + void OnActionPressed(); }; #endif -- cgit v0.9.0.2