Diffstat (limited to 'noncore/apps/opie-reader/CExpander.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CExpander.h | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index c281398..7b21d3e 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h @@ -1,44 +1,53 @@ #ifndef __CExpander_h #define __CExpander_h +#ifndef _WINDOWS #include <unistd.h> +#endif #include <stdio.h> #include <time.h> #include <qmessagebox.h> +#include "useqpe.h" #include "config.h" #include "StyleConsts.h" #include "Markups.h" -#include "name.h" +#include "names.h" +#include "linktype.h" -class QPixmap; +class QImage; class Bkmk; template<class T> class CList; class CCharacterSource { public: virtual void getch(tchar&, CStyle&) = 0; + virtual linkType hyperlink(unsigned int n, QString&) = 0; }; class CExpander { protected: size_t m_homepos; bool m_continuous; char* fname; bool bSuspended; size_t suspos; time_t sustime; + int m_scrWidth; + unsigned long m_currentstart, m_currentend; public: +#ifdef USEQPE virtual void suspend() = 0; virtual void unsuspend() = 0; +#endif size_t getHome() { return m_homepos; } - CExpander() : m_homepos(0), fname(NULL) {}; + CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {}; virtual ~CExpander() { if (fname != NULL) delete [] fname; }; int openfile(const char *src) { bSuspended = false; fname = strdup(src); return OpenFile(src); @@ -46,41 +55,57 @@ class CExpander virtual int OpenFile(const char *src) = 0; virtual unsigned int locate() = 0; virtual void locate(unsigned int n) = 0; virtual bool hasrandomaccess() = 0; virtual void sizes(unsigned long& file, unsigned long& text) = 0; virtual CList<Bkmk>* getbkmklist() { return NULL; } - virtual void getch(int& ch, CStyle& sty) + virtual void getch(tchar& ch, CStyle& sty) { - ch = getch(); + int ich = getch(); + ch = (ich == EOF) ? UEOF : ich; sty.unset(); } virtual int getch() = 0; - virtual bool hyperlink(unsigned int n) + virtual linkType hyperlink(unsigned int n, QString& wrd) { locate(n); - return true; + return eLink; } virtual MarkupType PreferredMarkup() = 0; virtual void saveposn(size_t posn) {} - virtual bool forward(size_t& loc) {} - virtual bool back(size_t& loc) {} + virtual void writeposn(size_t posn) {} + virtual bool forward(size_t& loc) { return false; } + virtual bool back(size_t& loc) { return false; } virtual bool hasnavigation() { return false; } - virtual unsigned long startSection() + unsigned long startSection() + { + unsigned long current = locate(); + if (m_currentstart > current || current > m_currentend) + { + start2endSection(); + } + return m_currentstart; + } + unsigned long endSection() + { + unsigned long current = locate(); + if (m_currentstart > current || current > m_currentend) { - return 0; + start2endSection(); + } + return m_currentend; } - virtual unsigned long endSection() + virtual void start2endSection() { - unsigned long file, text; - sizes(file, text); - return text; + m_currentstart = 0; + unsigned long file; + sizes(file, m_currentend); } - virtual QPixmap* getPicture(unsigned long tgt) { return NULL; } + virtual QImage* getPicture(unsigned long tgt) { return NULL; } void setContinuous(bool _b) { m_continuous = _b; } - +#ifdef USEQPE virtual void suspend(FILE*& fin) { bSuspended = true; suspos = ftell(fin); fclose(fin); fin = NULL; @@ -104,12 +129,13 @@ class CExpander QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); exit(0); } suspos = fseek(fin, suspos, SEEK_SET); } } +#endif virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { len = srclen; data = new unsigned char[len]; memcpy(data, src, len); } @@ -117,8 +143,9 @@ class CExpander { if (srclen != 0) { qDebug("Don't know what to do with non-zero save data"); } } + void setwidth(int w) { m_scrWidth = w; } }; #endif |