This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
forked from apinprastya/sultan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomerdisplay.cpp
83 lines (71 loc) · 2.14 KB
/
customerdisplay.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
/*
* Copyright 2021, Apin <[email protected]>
*
* This file is part of Sultan.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "customerdisplay.h"
#include <QString>
using namespace LibPrint;
CustomerDisplay::CustomerDisplay() {}
CustomerDisplay &CustomerDisplay::clear() {
mData.append((char)0x0c);
return *this;
}
CustomerDisplay &CustomerDisplay::home() {
mData.append((char)0x0b);
return *this;
}
CustomerDisplay &CustomerDisplay::bottom() {
mData.append((char)0x0a);
return *this;
}
CustomerDisplay &CustomerDisplay::left(int step) {
if (step < 0) {
mData.append((char)0x0d);
} else {
for (int i = 0; i < step; i++)
mData.append((char)0x08);
}
return *this;
}
CustomerDisplay &CustomerDisplay::right(int step) {
if (step < 0) {
mData.append((char)0x1f).append((char)0x0d);
} else {
for (int i = 0; i < step; i++)
mData.append((char)0x09);
}
return *this;
}
CustomerDisplay &CustomerDisplay::writeString(const QString &str) {
mData.append(str.toUtf8());
return *this;
}
CustomerDisplay &CustomerDisplay::writeString(const QString &leftStr, const QString &rightStr) {
left();
mData.append(leftStr.toUtf8());
right();
left(rightStr.toUtf8().length());
mData.append(rightStr.toUtf8());
return *this;
}
CustomerDisplay &CustomerDisplay::writeRight(const QString &str) {
right();
left(str.toUtf8().length());
mData.append(str.toUtf8());
return *this;
}
QByteArray CustomerDisplay::data() { return mData; }