-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabwidget.cpp
185 lines (167 loc) · 5.58 KB
/
tabwidget.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include "tabwidget.h"
#include "ui_tabwidget.h"
#include "editwindow.h"
#include "mainwindow.h"
TabWidget::TabWidget(BYTE Dbcs, QWidget *parent) :
QWidget(parent),
ui(new Ui::TabWidget)
{
ui->setupUi(this);
mainWindow = (MainWindow*)parent;
this-> Dbcs = Dbcs;
ui->idc_fw->setValue(mainWindow->FontWidth[mainWindow->Dbcs]);
ui->idc_fh->setValue(mainWindow->FontHeight[mainWindow->Dbcs]);
if(Dbcs)
ui->idc_remap->setHidden(true);
WORD code;
code = mainWindow->CurrentCode[mainWindow->Dbcs];
ui->idc_char->setText(QChar(code));
ui->idc_code->setText(QString::number(code, 2, 16));
connect(ui->idc_load, &QPushButton::clicked, [=]{
UINT f;
f = mainWindow->load_file(1);
// if (f )
// mainWindow->change_tab(f);
if(mainWindow->fontDbcs == 0)
{
ui->idc_info->setText(tr("SBC, %1 chars ").arg(mainWindow->fontMap.count()));
}
else
{
ui->idc_info->setText(tr("DBC, %1 chars ").arg(mainWindow->fontMap.count()));
}
});
connect(ui->idc_save, &QPushButton::clicked, [=]{
if (mainWindow->FileChanged[this->Dbcs]) {
if (mainWindow->save_file(0)) {
mainWindow->file_set_changed(false);
}
}
});
connect(ui->idc_saveas, &QPushButton::clicked, [=]{
if (mainWindow->save_file( 1)) {
mainWindow->file_set_changed(false);
}
});
connect(ui->idc_prev, &QPushButton::clicked, [=]{
mainWindow->change_code(-1);
});
connect(ui->idc_next, &QPushButton::clicked, [=]{
mainWindow->change_code(1);
});
connect(ui->idc_copy, &QPushButton::clicked, [=]{
});
connect(ui->idc_paste, &QPushButton::clicked, [=]{
});
connect(ui->idc_rotl, &QPushButton::clicked, [=]{
mainWindow->edit_rotate(1);
});
connect(ui->idc_rotr, &QPushButton::clicked, [=]{
mainWindow->edit_rotate(2);
});
connect(ui->idc_rotu, &QPushButton::clicked, [=]{
mainWindow->edit_rotate(3);
});
connect(ui->idc_rotd, &QPushButton::clicked, [=]{
mainWindow->edit_rotate(-1);
});
connect(ui->idc_inv, &QPushButton::clicked, [=]{
//for (n = 0, bp = EditFont[0]; n < sizeof EditFont; *bp = ~*bp, bp++, n++) ;
int sz = MAX_FONT_SQ * MAX_FONT_WB;
for(int i=0; i < sz; i++)
mainWindow->EditFont[i] = -mainWindow->EditFont[i];
mainWindow->edit_set_changed(true);
//InvalidateRect(hEdit, 0, TRUE);
update();
});
connect(ui->idc_clr, &QPushButton::clicked, [=]{
int sz = MAX_FONT_SQ * MAX_FONT_WB;
for(int i=0; i< sz; i++)
mainWindow->EditFont[i] = (char)0;
mainWindow->edit_set_changed(true);
//InvalidateRect(hEdit, 0, TRUE);
update();
});
connect(ui->idc_code, &QLineEdit::editingFinished, [=]{
bool ok;
uint nHex = ui->idc_code->text().toUInt(&ok, 16);
mainWindow->CurrentCode[mainWindow->Dbcs] = nHex;
mainWindow->get_font(nHex, mainWindow->EditFont);
mainWindow->change_code(0);
emit code_changed(mainWindow->Dbcs, nHex);
update();
});
connect(mainWindow, SIGNAL(size_change(int,int,int)), this, SLOT(size_change(int,int,int)));
connect(ui->idc_fw, SIGNAL(valueChanged(int)), this, SLOT(idc_fw_value_changed(int)));
connect(ui->idc_fh, SIGNAL(valueChanged(int)), this, SLOT(idc_fh_value_changed(int)));
connect(ui->idc_remap, &QCheckBox::clicked, [=]{
mainWindow->tabs.at(1)->setVisible(ui->idc_remap->isChecked());
});
ui->frame_2->setLayout(new QVBoxLayout());
ui->frame_2->layout()->addWidget(new EditWindow(mainWindow->Dbcs, mainWindow->FontHeight[mainWindow->Dbcs],
mainWindow->FontWidth[mainWindow->Dbcs],mainWindow->EditFont,
mainWindow));
}
void TabWidget::size_change(int Dbcs, int fw, int fh)
{
if(this->Dbcs == Dbcs)
{
setting = true;
if(fh != ui->idc_fh->value())
ui->idc_fh->setValue(fh);
if(fw != ui->idc_fw->value())
ui->idc_fw->setValue(fw);
setting = false;
}
}
void TabWidget::idc_fh_value_changed(int fh)
{
if(!setting && ui->idc_fh->value() != mainWindow->FontHeight[mainWindow->Dbcs])
emit fh_changed(mainWindow->Dbcs, fh);
}
void TabWidget::idc_fw_value_changed(int fw)
{
if(!setting && ui->idc_fw->value() != mainWindow->FontWidth[mainWindow->Dbcs])
emit fw_changed(mainWindow->Dbcs, fw);
}
TabWidget::~TabWidget()
{
delete ui;
}
/* コード入力エディトボックスから文字コードを取得 (Get character code from code input edit box)*/
int TabWidget::get_code (void)
{
//TCHAR str[16], *s;
QString str;
UINT l;
WORD c;
ui->idc_code->text();
l = str.length();
bool ok;
if (Dbcs) {
if (l == 2) {
//c = (BYTE)str[0] * 256 + (BYTE)str[1];
c = str.toInt(&ok,16);
if (ok && IS_DBC(c)) return c;
}
if (l == 4) {
//c = (WORD)strtoul(str, &s, 16);
c = str.toInt(&ok,16);
//if (s == &str[4] && IS_DBC(c)) return c;
if(ok && IS_DBC(c)) return c;
}
return -1;
} else {
if (l == 1) {
//c = (BYTE)str[0];
c = str.toInt(&ok, 16);
if (ok &&IS_SBC(c)) return c;
}
if (l == 2) {
//c = (WORD)strtoul(str, &s, 16);
//if (s == &str[2]) return c;
if (ok &&IS_SBC(c)) return c;
}
return -1;
}
}