summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CExpander.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/CExpander.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CExpander.h63
1 files changed, 45 insertions, 18 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,16 +1,20 @@
1#ifndef __CExpander_h 1#ifndef __CExpander_h
2#define __CExpander_h 2#define __CExpander_h
3 3
4#ifndef _WINDOWS
4#include <unistd.h> 5#include <unistd.h>
6#endif
5#include <stdio.h> 7#include <stdio.h>
6#include <time.h> 8#include <time.h>
7#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include "useqpe.h"
8#include "config.h" 11#include "config.h"
9#include "StyleConsts.h" 12#include "StyleConsts.h"
10#include "Markups.h" 13#include "Markups.h"
11#include "name.h" 14#include "names.h"
15#include "linktype.h"
12 16
13class QPixmap; 17class QImage;
14class Bkmk; 18class Bkmk;
15 19
16template<class T> 20template<class T>
@@ -20,6 +24,7 @@ class CCharacterSource
20{ 24{
21 public: 25 public:
22 virtual void getch(tchar&, CStyle&) = 0; 26 virtual void getch(tchar&, CStyle&) = 0;
27 virtual linkType hyperlink(unsigned int n, QString&) = 0;
23}; 28};
24 29
25class CExpander 30class CExpander
@@ -31,11 +36,15 @@ class CExpander
31 bool bSuspended; 36 bool bSuspended;
32 size_t suspos; 37 size_t suspos;
33 time_t sustime; 38 time_t sustime;
39 int m_scrWidth;
40 unsigned long m_currentstart, m_currentend;
34 public: 41 public:
35 virtual void suspend() = 0; 42#ifdef USEQPE
43 virtual void suspend() = 0;
36 virtual void unsuspend() = 0; 44 virtual void unsuspend() = 0;
45#endif
37 size_t getHome() { return m_homepos; } 46 size_t getHome() { return m_homepos; }
38 CExpander() : m_homepos(0), fname(NULL) {}; 47 CExpander() : m_homepos(0), fname(NULL), m_scrWidth(240), m_currentstart(1), m_currentend(0) {};
39 virtual ~CExpander() { if (fname != NULL) delete [] fname; }; 48 virtual ~CExpander() { if (fname != NULL) delete [] fname; };
40 int openfile(const char *src) 49 int openfile(const char *src)
41 { 50 {
@@ -49,35 +58,51 @@ class CExpander
49 virtual bool hasrandomaccess() = 0; 58 virtual bool hasrandomaccess() = 0;
50 virtual void sizes(unsigned long& file, unsigned long& text) = 0; 59 virtual void sizes(unsigned long& file, unsigned long& text) = 0;
51 virtual CList<Bkmk>* getbkmklist() { return NULL; } 60 virtual CList<Bkmk>* getbkmklist() { return NULL; }
52 virtual void getch(int& ch, CStyle& sty) 61 virtual void getch(tchar& ch, CStyle& sty)
53 { 62 {
54 ch = getch(); 63 int ich = getch();
64 ch = (ich == EOF) ? UEOF : ich;
55 sty.unset(); 65 sty.unset();
56 } 66 }
57 virtual int getch() = 0; 67 virtual int getch() = 0;
58 virtual bool hyperlink(unsigned int n) 68 virtual linkType hyperlink(unsigned int n, QString& wrd)
59 { 69 {
60 locate(n); 70 locate(n);
61 return true; 71 return eLink;
62 } 72 }
63 virtual MarkupType PreferredMarkup() = 0; 73 virtual MarkupType PreferredMarkup() = 0;
64 virtual void saveposn(size_t posn) {} 74 virtual void saveposn(size_t posn) {}
65 virtual bool forward(size_t& loc) {} 75 virtual void writeposn(size_t posn) {}
66 virtual bool back(size_t& loc) {} 76 virtual bool forward(size_t& loc) { return false; }
77 virtual bool back(size_t& loc) { return false; }
67 virtual bool hasnavigation() { return false; } 78 virtual bool hasnavigation() { return false; }
68 virtual unsigned long startSection() 79 unsigned long startSection()
80 {
81 unsigned long current = locate();
82 if (m_currentstart > current || current > m_currentend)
83 {
84 start2endSection();
85 }
86 return m_currentstart;
87 }
88 unsigned long endSection()
69 { 89 {
70 return 0; 90 unsigned long current = locate();
91 if (m_currentstart > current || current > m_currentend)
92 {
93 start2endSection();
94 }
95 return m_currentend;
71 } 96 }
72 virtual unsigned long endSection() 97 virtual void start2endSection()
73 { 98 {
74 unsigned long file, text; 99 m_currentstart = 0;
75 sizes(file, text); 100 unsigned long file;
76 return text; 101 sizes(file, m_currentend);
77 } 102 }
78 virtual QPixmap* getPicture(unsigned long tgt) { return NULL; } 103 virtual QImage* getPicture(unsigned long tgt) { return NULL; }
79 void setContinuous(bool _b) { m_continuous = _b; } 104 void setContinuous(bool _b) { m_continuous = _b; }
80 105#ifdef USEQPE
81 virtual void suspend(FILE*& fin) 106 virtual void suspend(FILE*& fin)
82 { 107 {
83 bSuspended = true; 108 bSuspended = true;
@@ -107,6 +132,7 @@ class CExpander
107 suspos = fseek(fin, suspos, SEEK_SET); 132 suspos = fseek(fin, suspos, SEEK_SET);
108 } 133 }
109 } 134 }
135#endif
110 virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 136 virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
111 { 137 {
112 len = srclen; 138 len = srclen;
@@ -120,5 +146,6 @@ class CExpander
120 qDebug("Don't know what to do with non-zero save data"); 146 qDebug("Don't know what to do with non-zero save data");
121 } 147 }
122 } 148 }
149 void setwidth(int w) { m_scrWidth = w; }
123}; 150};
124#endif 151#endif