@@ -18,33 +18,49 @@ class XG_JumpDialog : public XG_Dialog
18
18
void UpdateUI (HWND hwnd)
19
19
{
20
20
if (!xg_bSolved) {
21
- m_nType = 0 ;
21
+ if (m_nType == 1 )
22
+ m_nType = 0 ;
22
23
}
23
24
24
25
if (m_nType == 0 ) {
25
26
EnableWindow (GetDlgItem (hwnd, edt1), TRUE );
26
27
EnableWindow (GetDlgItem (hwnd, edt2), TRUE );
27
28
EnableWindow (GetDlgItem (hwnd, edt3), FALSE );
29
+ EnableWindow (GetDlgItem (hwnd, edt4), FALSE );
28
30
EnableWindow (GetDlgItem (hwnd, rad3), FALSE );
29
31
EnableWindow (GetDlgItem (hwnd, rad4), FALSE );
30
32
CheckRadioButton (hwnd, rad1, rad2, rad1);
31
33
SetDlgItemInt (hwnd, edt1, m_jCol, FALSE );
32
34
SetDlgItemInt (hwnd, edt2, m_iRow, FALSE );
33
- } else {
35
+ } else if (m_nType == 1 ) {
34
36
EnableWindow (GetDlgItem (hwnd, edt1), FALSE );
35
37
EnableWindow (GetDlgItem (hwnd, edt2), FALSE );
36
38
EnableWindow (GetDlgItem (hwnd, edt3), TRUE );
39
+ EnableWindow (GetDlgItem (hwnd, edt4), FALSE );
37
40
EnableWindow (GetDlgItem (hwnd, rad3), TRUE );
38
41
EnableWindow (GetDlgItem (hwnd, rad4), TRUE );
39
42
CheckRadioButton (hwnd, rad1, rad2, rad2);
40
43
SetDlgItemInt (hwnd, edt3, m_nNumber, FALSE );
41
44
CheckRadioButton (hwnd, rad3, rad4, (m_bVert ? rad4 : rad3));
45
+ } else if (m_nType == 2 ) {
46
+ EnableWindow (GetDlgItem (hwnd, edt1), FALSE );
47
+ EnableWindow (GetDlgItem (hwnd, edt2), FALSE );
48
+ EnableWindow (GetDlgItem (hwnd, edt3), FALSE );
49
+ EnableWindow (GetDlgItem (hwnd, edt4), TRUE );
50
+ EnableWindow (GetDlgItem (hwnd, rad3), FALSE );
51
+ EnableWindow (GetDlgItem (hwnd, rad4), FALSE );
42
52
}
43
53
}
44
54
45
55
BOOL OnOK (HWND hwnd)
46
56
{
47
- m_nType = (IsDlgButtonChecked (hwnd, rad2) == BST_CHECKED);
57
+ if (IsDlgButtonChecked (hwnd, rad2) == BST_CHECKED)
58
+ m_nType = 1 ;
59
+ else if (IsDlgButtonChecked (hwnd, rad5) == BST_CHECKED)
60
+ m_nType = 2 ;
61
+ else
62
+ m_nType = 0 ;
63
+
48
64
m_bVert = (IsDlgButtonChecked (hwnd, rad4) == BST_CHECKED);
49
65
m_jCol = GetDlgItemInt (hwnd, edt1, NULL , FALSE );
50
66
m_iRow = GetDlgItemInt (hwnd, edt2, NULL , FALSE );
@@ -181,6 +197,90 @@ class XG_JumpDialog : public XG_Dialog
181
197
case 1 : // カギ位置。
182
198
XgJumpNumber (hwnd, m_nNumber, m_bVert);
183
199
break ;
200
+ case 2 : // 文字または単語。
201
+ {
202
+ // テキストを取得する。
203
+ WCHAR szText[64 ];
204
+ GetDlgItemText (hwnd, edt4, szText, _countof (szText));
205
+ StrTrimW (szText, XG_WHITE_SPACES);
206
+ if (!szText[0 ])
207
+ return ;
208
+
209
+ auto str = XgNormalizeString (szText);
210
+ XG_Board& xw = (xg_bSolved && xg_bShowAnswer) ? xg_solution : xg_xword;
211
+
212
+ // 次に進む関数。
213
+ auto GetNext = [&](INT& jCol, INT& iRow) {
214
+ ++jCol;
215
+ if (jCol == xg_nCols) {
216
+ jCol = 0 ;
217
+ ++iRow;
218
+ if (iRow == xg_nRows) {
219
+ iRow = 0 ;
220
+ }
221
+ }
222
+ };
223
+ // ヨコの単語を取得する関数。
224
+ auto GetHorzWord = [&](INT jCol, INT iRow) -> XGStringW {
225
+ if (xw.GetAt (iRow, jCol) == ZEN_BLACK) {
226
+ return { ZEN_BLACK };
227
+ }
228
+ if (jCol == 0 || xw.GetAt (iRow, jCol - 1 ) == ZEN_BLACK) {
229
+ XGStringW ret;
230
+ for (INT j = jCol; j < xg_nCols; ++j) {
231
+ WCHAR ch = xw.GetAt (iRow, j);
232
+ if (ch == ZEN_BLACK)
233
+ break ;
234
+ ret += ch;
235
+ }
236
+ return ret;
237
+ }
238
+ return { xw.GetAt (iRow, jCol) };
239
+ };
240
+ // タテの単語を取得する関数。
241
+ auto GetVertWord = [&](INT jCol, INT iRow) -> XGStringW {
242
+ if (xw.GetAt (iRow, jCol) == ZEN_BLACK) {
243
+ return { ZEN_BLACK };
244
+ }
245
+ if (iRow == 0 || xw.GetAt (iRow - 1 , jCol) == ZEN_BLACK) {
246
+ XGStringW ret;
247
+ for (INT i = iRow; i < xg_nRows; ++i) {
248
+ WCHAR ch = xw.GetAt (i, jCol);
249
+ if (ch == ZEN_BLACK)
250
+ break ;
251
+ ret += ch;
252
+ }
253
+ return ret;
254
+ }
255
+ return { xw.GetAt (iRow, jCol) };
256
+ };
257
+
258
+ // 検索する。
259
+ INT j = xg_caret_pos.m_j , i = xg_caret_pos.m_i ;
260
+ for (INT n = 0 ; n < xg_nRows * xg_nCols; ++n) {
261
+ GetNext (j, i);
262
+ auto word0 = GetHorzWord (j, i);
263
+ auto j0 = word0.find (str);
264
+ if (j0 != word0.npos ) {
265
+ xg_caret_pos.m_j = j + j0 ;
266
+ xg_caret_pos.m_i = i;
267
+ break ;
268
+ }
269
+ auto word1 = GetVertWord (j, i);
270
+ auto i0 = word1.find (str);
271
+ if (i0 != word1.npos ) {
272
+ xg_caret_pos.m_j = j;
273
+ xg_caret_pos.m_i = i + i0;
274
+ break ;
275
+ }
276
+ }
277
+ }
278
+ // 表示を更新する。
279
+ XgEnsureCaretVisible (hwnd);
280
+ XgUpdateStatusBar (hwnd);
281
+ // すぐに入力できるようにする。
282
+ SetFocus (hwnd);
283
+ break ;
184
284
}
185
285
}
186
286
break ;
@@ -201,6 +301,12 @@ class XG_JumpDialog : public XG_Dialog
201
301
UpdateUI (hwnd);
202
302
}
203
303
break ;
304
+ case rad5:
305
+ if (IsDlgButtonChecked (hwnd, rad5) == BST_CHECKED) {
306
+ m_nType = 2 ;
307
+ UpdateUI (hwnd);
308
+ }
309
+ break ;
204
310
default :
205
311
break ;
206
312
}
0 commit comments