/* */
This source file includes following definitions.
- keyboard
- keyinput00
- keyinput01
- keyinput02
- keyinput03
- keyinput04
- keyinput05
- keyinput06
- keyinput07
- keyinput08
- keyinput09
- keyinput10
- keyinput11
- keyinput12
- keyinput13
- keyinput14
- keyinput15
- keyinput16
- keyinput17
- keyinput18
- keyinput19
- keyinput20
- keyinput21
- keyinput22
- keyinput23
- keyinput24
- keyinput25
- keyinput26
- keyinput27
- keyinput28
- keyinput29
- keyinput30
- keyinput31
- keyinput32
- keyinput33
- keyinput
- tabchange
- makeinput
1 /* -*- coding: utf-8; mode: c++; -*-
2 * Concordance to A. S. Pushkin's Works - Russian Pseud-Keyboard
3 * $Id: ConcordanceKeyboard.cpp 16 2013-11-04 16:38:10Z isao $
4 * Copyright (C) 2012, isao yasuda
5 */
6
7 #include "Concordance.hpp"
8
9 using namespace Wt;
10
11 void Concordance::keyboard()
12 {
13 // 初期状態は jcuken
14 if (keytype == none)
15 keytype = yawerty;
16 else {
17 for (int i = 0; i < 34; i++)
18 delete bk[i];
19 for (int i = 0; i < 4; i++)
20 delete rk[i];
21 }
22
23 // キーボード配列セットアップ
24 if (keytype == jcuken) {
25 // 現在値が jcuken なら yawerty 配列に変更
26 // ywerty (phonetic) 配列キー
27 // явертыуиопшщэ
28 // асдфгхйклчъ
29 // зьцжбнмюё
30 // 1 段目
31 rk[0] = new WContainerWidget(rkbd);
32 rk[0]->setStyleClass("cyrkbd");
33 bk[33] = new WPushButton(L"Я", rk[0]);
34 bk[3] = new WPushButton(L"В", rk[0]);
35 bk[6] = new WPushButton(L"Е", rk[0]);
36 bk[18] = new WPushButton(L"Р", rk[0]);
37 bk[20] = new WPushButton(L"Т", rk[0]);
38 bk[29] = new WPushButton(L"Ы", rk[0]);
39 bk[21] = new WPushButton(L"У", rk[0]);
40 bk[10] = new WPushButton(L"И", rk[0]);
41 bk[16] = new WPushButton(L"О", rk[0]);
42 bk[17] = new WPushButton(L"П", rk[0]);
43 bk[26] = new WPushButton(L"Ш", rk[0]);
44 bk[27] = new WPushButton(L"Щ", rk[0]);
45 bk[31] = new WPushButton(L"Э", rk[0]);
46 // 2 段目
47 rk[1] = new WContainerWidget(rkbd);
48 rk[1]->setStyleClass("cyrkbd");
49 bk[1] = new WPushButton(L"А", rk[1]);
50 bk[19] = new WPushButton(L"С", rk[1]);
51 bk[5] = new WPushButton(L"Д", rk[1]);
52 bk[22] = new WPushButton(L"Ф", rk[1]);
53 bk[4] = new WPushButton(L"Г", rk[1]);
54 bk[23] = new WPushButton(L"Х", rk[1]);
55 bk[11] = new WPushButton(L"Й", rk[1]);
56 bk[12] = new WPushButton(L"К", rk[1]);
57 bk[13] = new WPushButton(L"Л", rk[1]);
58 bk[25] = new WPushButton(L"Ч", rk[1]);
59 bk[28] = new WPushButton(L"Ъ", rk[1]);
60 // 3 段目
61 rk[2] = new WContainerWidget(rkbd);
62 rk[2]->setStyleClass("cyrkbd");
63 bk[9] = new WPushButton(L"З", rk[2]);
64 bk[30] = new WPushButton(L"Ь", rk[2]);
65 bk[24] = new WPushButton(L"Ц", rk[2]);
66 bk[8] = new WPushButton(L"Ж", rk[2]);
67 bk[2] = new WPushButton(L"Б", rk[2]);
68 bk[15] = new WPushButton(L"Н", rk[2]);
69 bk[14] = new WPushButton(L"М", rk[2]);
70 bk[32] = new WPushButton(L"Ю", rk[2]);
71 bk[7] = new WPushButton(L"Ё", rk[2]);
72 // 入力クリア,配列切替ボタン
73 rk[3] = new WContainerWidget(rkbd);
74 rk[3]->setStyleClass("cyrkbd2");
75 bk[0] = new WPushButton(L"clear", rk[3]);
76 bk[0]->setStyleClass("btn2");
77 rk[3]->addWidget(new WText(WString::tr("changekbd"), XHTMLText));
78 bk[34] = new WPushButton(L"ЙЦУКЕН", rk[3]);
79 bk[34]->setStyleClass("btn2");
80 keytype = yawerty;
81 } else {
82 // 現在値が yawerty なら jcukeny 配列に変更
83 // jcuken 配列キー
84 // йцукенгшщзхъ
85 // фывапролджэ
86 // ячсмитьбюё
87 // 1 段目
88 rk[0] = new WContainerWidget(rkbd);
89 rk[0]->setStyleClass("cyrkbd");
90 bk[11] = new WPushButton(L"Й", rk[0]);
91 bk[24] = new WPushButton(L"Ц", rk[0]);
92 bk[21] = new WPushButton(L"У", rk[0]);
93 bk[12] = new WPushButton(L"К", rk[0]);
94 bk[6] = new WPushButton(L"Е", rk[0]);
95 bk[15] = new WPushButton(L"Н", rk[0]);
96 bk[4] = new WPushButton(L"Г", rk[0]);
97 bk[26] = new WPushButton(L"Ш", rk[0]);
98 bk[27] = new WPushButton(L"Щ", rk[0]);
99 bk[9] = new WPushButton(L"З", rk[0]);
100 bk[23] = new WPushButton(L"Х", rk[0]);
101 bk[28] = new WPushButton(L"Ъ", rk[0]);
102 // 2 段目
103 rk[1] = new WContainerWidget(rkbd);
104 rk[1]->setStyleClass("cyrkbd");
105 bk[22] = new WPushButton(L"Ф", rk[1]);
106 bk[29] = new WPushButton(L"Ы", rk[1]);
107 bk[3] = new WPushButton(L"В", rk[1]);
108 bk[1] = new WPushButton(L"А", rk[1]);
109 bk[17] = new WPushButton(L"П", rk[1]);
110 bk[18] = new WPushButton(L"Р", rk[1]);
111 bk[16] = new WPushButton(L"О", rk[1]);
112 bk[13] = new WPushButton(L"Л", rk[1]);
113 bk[5] = new WPushButton(L"Д", rk[1]);
114 bk[8] = new WPushButton(L"Ж", rk[1]);
115 bk[31] = new WPushButton(L"Э", rk[1]);
116 // 3 段目
117 rk[2] = new WContainerWidget(rkbd);
118 rk[2]->setStyleClass("cyrkbd");
119 bk[33] = new WPushButton(L"Я", rk[2]);
120 bk[25] = new WPushButton(L"Ч", rk[2]);
121 bk[19] = new WPushButton(L"С", rk[2]);
122 bk[14] = new WPushButton(L"М", rk[2]);
123 bk[10] = new WPushButton(L"И", rk[2]);
124 bk[20] = new WPushButton(L"Т", rk[2]);
125 bk[30] = new WPushButton(L"Ь", rk[2]);
126 bk[2] = new WPushButton(L"Б", rk[2]);
127 bk[32] = new WPushButton(L"Ю", rk[2]);
128 bk[7] = new WPushButton(L"Ё", rk[2]);
129 // 入力クリア,配列切替ボタン
130 rk[3] = new WContainerWidget(rkbd);
131 rk[3]->setStyleClass("cyrkbd2");
132 bk[0] = new WPushButton(L"clear", rk[3]);
133 bk[0]->setStyleClass("btn2");
134 rk[3]->addWidget(new WText(WString::tr("changekbd"), XHTMLText));
135 bk[34] = new WPushButton(L"ЯВЕРТЫ", rk[3]);
136 bk[34]->setStyleClass("btn2");
137 keytype = jcuken;
138 }
139
140 // ボタンのスタイル
141 for (int i = 1; i < 34; i++)
142 bk[i]->setStyleClass("btn");
143
144 // それぞれボタンが押されたときの処理を登録
145 bk[0]->clicked().connect(this, &Concordance::keyinput00);
146 bk[1]->clicked().connect(this, &Concordance::keyinput01);
147 bk[2]->clicked().connect(this, &Concordance::keyinput02);
148 bk[3]->clicked().connect(this, &Concordance::keyinput03);
149 bk[4]->clicked().connect(this, &Concordance::keyinput04);
150 bk[5]->clicked().connect(this, &Concordance::keyinput05);
151 bk[6]->clicked().connect(this, &Concordance::keyinput06);
152 bk[7]->clicked().connect(this, &Concordance::keyinput07);
153 bk[8]->clicked().connect(this, &Concordance::keyinput08);
154 bk[9]->clicked().connect(this, &Concordance::keyinput09);
155 bk[10]->clicked().connect(this, &Concordance::keyinput10);
156 bk[11]->clicked().connect(this, &Concordance::keyinput11);
157 bk[12]->clicked().connect(this, &Concordance::keyinput12);
158 bk[13]->clicked().connect(this, &Concordance::keyinput13);
159 bk[14]->clicked().connect(this, &Concordance::keyinput14);
160 bk[15]->clicked().connect(this, &Concordance::keyinput15);
161 bk[16]->clicked().connect(this, &Concordance::keyinput16);
162 bk[17]->clicked().connect(this, &Concordance::keyinput17);
163 bk[18]->clicked().connect(this, &Concordance::keyinput18);
164 bk[19]->clicked().connect(this, &Concordance::keyinput19);
165 bk[20]->clicked().connect(this, &Concordance::keyinput20);
166 bk[21]->clicked().connect(this, &Concordance::keyinput21);
167 bk[22]->clicked().connect(this, &Concordance::keyinput22);
168 bk[23]->clicked().connect(this, &Concordance::keyinput23);
169 bk[24]->clicked().connect(this, &Concordance::keyinput24);
170 bk[25]->clicked().connect(this, &Concordance::keyinput25);
171 bk[26]->clicked().connect(this, &Concordance::keyinput26);
172 bk[27]->clicked().connect(this, &Concordance::keyinput27);
173 bk[28]->clicked().connect(this, &Concordance::keyinput28);
174 bk[29]->clicked().connect(this, &Concordance::keyinput29);
175 bk[30]->clicked().connect(this, &Concordance::keyinput30);
176 bk[31]->clicked().connect(this, &Concordance::keyinput31);
177 bk[32]->clicked().connect(this, &Concordance::keyinput32);
178 bk[33]->clicked().connect(this, &Concordance::keyinput33);
179 bk[34]->clicked().connect(this, &Concordance::keyboard);
180 }
181
182 // キーインプット
183 void Concordance::keyinput00()
184 {
185 keyinput(bk[0]);
186 }
187 void Concordance::keyinput01()
188 {
189 keyinput(bk[1]);
190 }
191 void Concordance::keyinput02()
192 {
193 keyinput(bk[2]);
194 }
195 void Concordance::keyinput03()
196 {
197 keyinput(bk[3]);
198 }
199 void Concordance::keyinput04()
200 {
201 keyinput(bk[4]);
202 }
203 void Concordance::keyinput05()
204 {
205 keyinput(bk[5]);
206 }
207 void Concordance::keyinput06()
208 {
209 keyinput(bk[6]);
210 }
211 void Concordance::keyinput07()
212 {
213 keyinput(bk[7]);
214 }
215 void Concordance::keyinput08()
216 {
217 keyinput(bk[8]);
218 }
219 void Concordance::keyinput09()
220 {
221 keyinput(bk[9]);
222 }
223 void Concordance::keyinput10()
224 {
225 keyinput(bk[10]);
226 }
227 void Concordance::keyinput11()
228 {
229 keyinput(bk[11]);
230 }
231 void Concordance::keyinput12()
232 {
233 keyinput(bk[12]);
234 }
235 void Concordance::keyinput13()
236 {
237 keyinput(bk[13]);
238 }
239 void Concordance::keyinput14()
240 {
241 keyinput(bk[14]);
242 }
243 void Concordance::keyinput15()
244 {
245 keyinput(bk[15]);
246 }
247 void Concordance::keyinput16()
248 {
249 keyinput(bk[16]);
250 }
251 void Concordance::keyinput17()
252 {
253 keyinput(bk[17]);
254 }
255 void Concordance::keyinput18()
256 {
257 keyinput(bk[18]);
258 }
259 void Concordance::keyinput19()
260 {
261 keyinput(bk[19]);
262 }
263 void Concordance::keyinput20()
264 {
265 keyinput(bk[20]);
266 }
267 void Concordance::keyinput21()
268 {
269 keyinput(bk[21]);
270 }
271 void Concordance::keyinput22()
272 {
273 keyinput(bk[22]);
274 }
275 void Concordance::keyinput23()
276 {
277 keyinput(bk[23]);
278 }
279 void Concordance::keyinput24()
280 {
281 keyinput(bk[24]);
282 }
283 void Concordance::keyinput25()
284 {
285 keyinput(bk[25]);
286 }
287 void Concordance::keyinput26()
288 {
289 keyinput(bk[26]);
290 }
291 void Concordance::keyinput27()
292 {
293 keyinput(bk[27]);
294 }
295 void Concordance::keyinput28()
296 {
297 keyinput(bk[28]);
298 }
299 void Concordance::keyinput29()
300 {
301 keyinput(bk[29]);
302 }
303 void Concordance::keyinput30()
304 {
305 keyinput(bk[30]);
306 }
307 void Concordance::keyinput31()
308 {
309 keyinput(bk[31]);
310 }
311 void Concordance::keyinput32()
312 {
313 keyinput(bk[32]);
314 }
315 void Concordance::keyinput33()
316 {
317 keyinput(bk[33]);
318 }
319
320 // テキストエリアに文字を挿入
321 void Concordance::keyinput(WPushButton* bt)
322 {
323 WString ls = expEdit->valueText();
324 if (bt->text() == "clear")
325 ls = "";
326 else
327 ls += bt->text();
328 expEdit->setValueText(ls);
329 }
330
331 //
332 void Concordance::tabchange()
333 {
334 if (tabs->currentIndex() == tabs->indexOf(rkbd)) {
335 WString ls = expEdit->valueText();
336 delete iarea;
337 WString emp("");
338 makeinput(emp);
339 expEdit->setValueText(ls);
340 } else {
341 if (expEdit->valueText().empty()) {
342 WString emptxt = WString::tr("emptytext");
343 expEdit->setEmptyText(emptxt);
344 }
345 }
346 }
347
348 // input エリアの生成
349 void Concordance::makeinput(WString& et)
350 {
351 // 式入力エリアの生成
352 iarea = new WContainerWidget(iframe);
353 iarea->setStyleClass("inner-area");
354
355 // 入力プロンプト(初期値付き))
356 iarea->addWidget(new WText(WString::tr("prompt"), XHTMLText));
357 expEdit = new WLineEdit(iarea);
358 expEdit->setId("Exps");
359 if (! et.empty()) expEdit->setEmptyText(et);
360 expEdit->setTextSize(70);
361
362 // submit ボタン
363 button1 = new WPushButton(WString::tr("submit"), iarea);
364 iarea->addWidget(new WBreak());
365
366 // submit する動作を登録
367 // - 入力エリア Enter key
368 expEdit->enterPressed().connect(this, &Concordance::generate);
369 // - submit ボタンクリック
370 button1->clicked().connect(this, &Concordance::generate);
371 }
/* */