-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatter.h
65 lines (52 loc) · 1.41 KB
/
formatter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Text Formatter.
* It will reformatting paragraph with UI information ( Font, Width, Height )
* vim:sw=2:et
*/
#ifndef __FORMATTER_H__
#define __FORMATTER_H__
#include "para.h"
#include <qmap.h>
class TParser;
class QPainter;
class QFontMetrics;
class QFont;
class QColor;
struct FLine;
class Formatter
{
private:
int m_width, m_height, m_lmargin, m_tabwidth, m_iheight;
bool m_fakebold;
struct FontM {
QFont *f;
QFontMetrics *m;
bool b;
} m_metrics, m_bmetrics;
int m_pstart, m_poffset, m_pend;
TParser *m_ps;
QColor *m_colors;
QMap<int,Paragraph> m_cache;
FLine *m_head, *m_ptr, *m_last;
private:
FLine *getFLines(int idx);
public:
Formatter();
~Formatter();
void updateLines();
void cleanLines();
void setParser(TParser *ps);
void setLineMargin(int margin);
void setSize(int width, int height);
void setFont(QFont f, bool isBold, bool can_fake_bold);
void setColors(QColor *colors);
void setParagraph(int paragraph, int idx);
void getParagraph(int ¶, int &offset);
void getLastParagraph(int ¶, int &offset);
void drawLines(QPainter *dc,
int fx, int fy, int dx, int dy, int dw, int dh);
bool nextPage();
bool prevPage();
bool nextLine(int cnt=1, int *move=NULL, int *valid_height=NULL);
};
#endif