-
Notifications
You must be signed in to change notification settings - Fork 2
/
simplepage.cpp
116 lines (102 loc) · 2.58 KB
/
simplepage.cpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "simplepage.h"
Simplepage::Simplepage(const QSize imgSize,
const int topMargin, const int bottemMargin, const int leftMargin, const int rightMargin,
const int columnSpacing, const int lineSpacing, const int fontX,const int fontY)
{
//set attribute
Simplepage::point1 = new QPoint;
Simplepage::point1->setX(leftMargin);
Simplepage::point1->setY(topMargin);
//set step
Simplepage::pageStepPix = new QPoint(fontX+columnSpacing,fontY+lineSpacing);
//pageStructe .x() = total column .y() = total line
Simplepage::pageStructe = new QPoint((imgSize.width()-leftMargin-rightMargin)/Simplepage::pageStepPix->x(),
(imgSize.height()-topMargin-bottemMargin)/Simplepage::pageStepPix->y());
Simplepage::currentLocation = new QPoint(1,1);
}
Simplepage::~Simplepage()
{
delete pageStructe;
delete currentLocation;
delete pageStepPix;
delete point1;
}
int Simplepage::getTotalLine()
{
return pageStructe->y();
}
int Simplepage::totalColumn()
{
return pageStructe->x();
}
int Simplepage::totalColumn(int col)
{
return pageStructe->x();
}
int Simplepage::currentLine()
{
return currentLocation->y();
}
int Simplepage::currentColumn()
{
return currentLocation->x();
}
QPoint Simplepage::atPixel()
{
QPoint currentPixel((point1->x()+pageStepPix->x()*(currentLocation->x()-1)),(point1->y()+pageStepPix->y()*(currentLocation->y()-1)));
return currentPixel;
}
bool Simplepage::isFull()
{
if(currentLocation->x()==pageStructe->x() && currentLocation->y()==pageStructe->y()){
return true;
}
else {
return false;
}
}
bool Simplepage::nextPoint()
{
if(isFull()){
return false;
}
else if(currentLocation->x()==pageStructe->x()){
currentLocation->setX(1);
currentLocation->setY(currentLocation->y()+1);
}
else {
currentLocation->setX(currentLocation->x()+1);
}
return true;
}
void Simplepage::firstPoint()
{
currentLocation->setX(0);
currentLocation->setY(0);
}
bool Simplepage::netLine()
{
if(currentLocation->y()==pageStructe->y()){
return false;
}
else{
currentLocation->setY(currentLocation->y()+1);
return true;
}
}
void Simplepage::firstColumn()
{
currentLocation->setX(1);
}
bool Simplepage::gotoPoint(int ln, int col)
{
if(col>currentLocation->x()||ln>currentLocation->y()
||col<0||ln<0){
return false;
}
else{
currentLocation->setX(col);
currentLocation->setY(ln);
return true;
}
}