2 * woptions.c -- Options dialog box routines for WinBoard
\r
4 * Copyright 2000, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
\r
6 * Enhancements Copyright 2005 Alessandro Scotti
\r
8 * ------------------------------------------------------------------------
\r
10 * GNU XBoard is free software: you can redistribute it and/or modify
\r
11 * it under the terms of the GNU General Public License as published by
\r
12 * the Free Software Foundation, either version 3 of the License, or (at
\r
13 * your option) any later version.
\r
15 * GNU XBoard is distributed in the hope that it will be useful, but
\r
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
\r
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
18 * General Public License for more details.
\r
20 * You should have received a copy of the GNU General Public License
\r
21 * along with this program. If not, see http://www.gnu.org/licenses/. *
\r
23 *------------------------------------------------------------------------
\r
24 ** See the file ChangeLog for a revision history. */
\r
28 #include <windows.h> /* required for all Windows applications */
\r
31 #include <shlobj.h> /* [AS] Requires NT 4.0 or Win95 */
\r
35 #include "frontend.h"
\r
36 #include "winboard.h"
\r
37 #include "backend.h"
\r
38 #include "woptions.h"
\r
39 #include "defaults.h"
\r
40 #include <richedit.h>
\r
50 /* Imports from winboard.c */
\r
52 extern MyFont *font[NUM_SIZES][NUM_FONTS];
\r
53 extern HINSTANCE hInst; /* current instance */
\r
54 extern HWND hwndMain; /* root window*/
\r
55 extern BOOLEAN alwaysOnTop;
\r
56 extern RECT boardRect;
\r
57 extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor,
\r
58 blackPieceColor, highlightSquareColor, premoveHighlightColor;
\r
59 extern HPALETTE hPal;
\r
60 extern BoardSize boardSize;
\r
61 extern COLORREF consoleBackgroundColor;
\r
62 extern MyColorizeAttribs colorizeAttribs[]; /* do I need the size? */
\r
63 extern MyTextAttribs textAttribs[];
\r
64 extern MySound sounds[];
\r
65 extern ColorClass currentColorClass;
\r
66 extern HWND hwndConsole;
\r
67 extern char *defaultTextAttribs[];
\r
68 extern HWND commentDialog;
\r
69 extern HWND moveHistoryDialog;
\r
70 extern HWND engineOutputDialog;
\r
71 extern char installDir[];
\r
72 extern HWND hCommPort; /* currently open comm port */
\r
74 extern BOOLEAN chessProgram;
\r
75 extern int startedFromPositionFile; /* [HGM] loadPos */
\r
76 extern int searchTime;
\r
90 /* module prototypes */
\r
92 LRESULT CALLBACK GeneralOptions(HWND, UINT, WPARAM, LPARAM);
\r
93 LRESULT CALLBACK BoardOptions(HWND, UINT, WPARAM, LPARAM);
\r
94 LRESULT CALLBACK NewVariant(HWND, UINT, WPARAM, LPARAM);
\r
95 LRESULT CALLBACK IcsOptions(HWND, UINT, WPARAM, LPARAM);
\r
96 LRESULT CALLBACK FontOptions(HWND, UINT, WPARAM, LPARAM);
\r
97 LRESULT CALLBACK CommPortOptions(HWND, UINT, WPARAM, LPARAM);
\r
98 LRESULT CALLBACK LoadOptions(HWND, UINT, WPARAM, LPARAM);
\r
99 LRESULT CALLBACK SaveOptions(HWND, UINT, WPARAM, LPARAM);
\r
100 LRESULT CALLBACK TimeControl(HWND, UINT, WPARAM, LPARAM);
\r
101 VOID ChangeBoardSize(BoardSize newSize);
\r
102 VOID PaintSampleSquare(
\r
105 COLORREF squareColor,
\r
106 COLORREF pieceColor,
\r
107 COLORREF squareOutlineColor,
\r
108 COLORREF pieceDetailColor,
\r
113 VOID PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color);
\r
114 VOID SetBoardOptionEnables(HWND hDlg);
\r
115 BoardSize BoardOptionsWhichRadio(HWND hDlg);
\r
116 BOOL APIENTRY MyCreateFont(HWND hwnd, MyFont *font);
\r
117 VOID UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca);
\r
118 LRESULT CALLBACK ColorizeTextDialog(HWND , UINT, WPARAM, LPARAM);
\r
119 VOID ColorizeTextPopup(HWND hwnd, ColorClass cc);
\r
120 VOID SetIcsOptionEnables(HWND hDlg);
\r
121 VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf);
\r
122 VOID CopyFont(MyFont *dest, const MyFont *src);
\r
123 void InitSoundComboData(SoundComboData *scd);
\r
124 void ResetSoundComboData(SoundComboData *scd);
\r
125 void InitSoundCombo(HWND hwndCombo, SoundComboData *scd);
\r
126 int SoundDialogWhichRadio(HWND hDlg);
\r
127 VOID SoundDialogSetEnables(HWND hDlg, int radio);
\r
128 char * SoundDialogGetName(HWND hDlg, int radio);
\r
129 void DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name);
\r
130 VOID ParseCommSettings(char *arg, DCB *dcb);
\r
131 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb);
\r
132 void InitCombo(HANDLE hwndCombo, ComboData *cd);
\r
133 void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value);
\r
134 VOID SetLoadOptionEnables(HWND hDlg);
\r
135 VOID SetSaveOptionEnables(HWND hDlg);
\r
136 VOID SetTimeControlEnables(HWND hDlg);
\r
139 InterpretFileName(char *buf, char *homeDir)
\r
140 { // [HGM] file name relative to homeDir. (Taken out of SafeOptionsDialog, because it is generally useful)
\r
141 char *result = NULL;
\r
142 if ((isalpha(buf[0]) && buf[1] == ':') ||
\r
143 (buf[0] == '\\' && buf[1] == '\\')) {
\r
144 return strdup(buf);
\r
146 char buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
148 GetCurrentDirectory(MSG_SIZ, buf3);
\r
149 SetCurrentDirectory(homeDir);
\r
150 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
151 result = strdup(buf2);
\r
153 result = strdup(buf);
\r
155 SetCurrentDirectory(buf3);
\r
160 /*---------------------------------------------------------------------------*\
\r
162 * General Options Dialog functions
\r
164 \*---------------------------------------------------------------------------*/
\r
168 GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
170 static Boolean oldShowCoords;
\r
171 static Boolean oldBlindfold;
\r
172 static Boolean oldShowButtonBar;
\r
173 static Boolean oldAutoLogo;
\r
176 case WM_INITDIALOG: /* message: initialize dialog box */
\r
177 oldShowCoords = appData.showCoords;
\r
178 oldBlindfold = appData.blindfold;
\r
179 oldShowButtonBar = appData.showButtonBar;
\r
180 oldAutoLogo = appData.autoLogo;
\r
182 /* Center the dialog over the application window */
\r
183 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
184 Translate(hDlg, DLG_GeneralOptions);
\r
186 /* Initialize the dialog items */
\r
187 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
189 CHECK_BOX(OPT_AlwaysOnTop, alwaysOnTop);
\r
190 CHECK_BOX(OPT_AlwaysQueen, appData.alwaysPromoteToQueen);
\r
191 CHECK_BOX(OPT_AnimateDragging, appData.animateDragging);
\r
192 CHECK_BOX(OPT_AnimateMoving, appData.animate);
\r
193 CHECK_BOX(OPT_AutoFlag, appData.autoCallFlag);
\r
194 CHECK_BOX(OPT_AutoFlipView, appData.autoFlipView);
\r
195 CHECK_BOX(OPT_AutoRaiseBoard, appData.autoRaiseBoard);
\r
196 CHECK_BOX(OPT_Blindfold, appData.blindfold);
\r
197 CHECK_BOX(OPT_HighlightDragging, appData.highlightDragging);
\r
198 CHECK_BOX(OPT_HighlightLastMove, appData.highlightLastMove);
\r
199 CHECK_BOX(OPT_PeriodicUpdates, appData.periodicUpdates);
\r
200 CHECK_BOX(OPT_PonderNextMove, appData.ponderNextMove);
\r
201 CHECK_BOX(OPT_PopupExitMessage, appData.popupExitMessage);
\r
202 CHECK_BOX(OPT_PopupMoveErrors, appData.popupMoveErrors);
\r
203 CHECK_BOX(OPT_ShowButtonBar, appData.showButtonBar);
\r
204 CHECK_BOX(OPT_ShowCoordinates, appData.showCoords);
\r
205 CHECK_BOX(OPT_ShowThinking, appData.showThinking);
\r
206 CHECK_BOX(OPT_TestLegality, appData.testLegality);
\r
207 CHECK_BOX(OPT_HideThinkFromHuman, appData.hideThinkingFromHuman);
\r
208 CHECK_BOX(OPT_SaveExtPGN, appData.saveExtendedInfoInPGN);
\r
209 CHECK_BOX(OPT_ExtraInfoInMoveHistory, appData.showEvalInMoveHistory);
\r
210 CHECK_BOX(OPT_HighlightMoveArrow, appData.highlightMoveWithArrow);
\r
211 CHECK_BOX(OPT_AutoLogo, appData.autoLogo); // [HGM] logo
\r
212 CHECK_BOX(OPT_SmartMove, appData.oneClick); // [HGM] one-click
\r
213 CHECK_BOX(OPT_AutoTags, appData.autoDisplayTags); // [HGM]
\r
214 CHECK_BOX(OPT_AutoComment, appData.autoDisplayComment); // [HGM]
\r
218 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlag),
\r
219 appData.icsActive || !appData.noChessProgram);
\r
220 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlipView),
\r
221 appData.icsActive || !appData.noChessProgram);
\r
222 EnableWindow(GetDlgItem(hDlg, OPT_PonderNextMove),
\r
223 !appData.noChessProgram);
\r
224 EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates),
\r
225 !appData.noChessProgram && !appData.icsActive);
\r
226 EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking),
\r
227 !appData.noChessProgram);
\r
231 case WM_COMMAND: /* message: received a command */
\r
232 switch (LOWORD(wParam)) {
\r
234 /* Read changed options from the dialog box */
\r
236 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
238 alwaysOnTop = IS_CHECKED(OPT_AlwaysOnTop);
\r
239 appData.alwaysPromoteToQueen = IS_CHECKED(OPT_AlwaysQueen);
\r
240 appData.animateDragging = IS_CHECKED(OPT_AnimateDragging);
\r
241 appData.animate = IS_CHECKED(OPT_AnimateMoving);
\r
242 appData.autoCallFlag = IS_CHECKED(OPT_AutoFlag);
\r
243 appData.autoFlipView = IS_CHECKED(OPT_AutoFlipView);
\r
244 appData.autoRaiseBoard = IS_CHECKED(OPT_AutoRaiseBoard);
\r
245 appData.blindfold = IS_CHECKED(OPT_Blindfold);
\r
246 appData.highlightDragging = IS_CHECKED(OPT_HighlightDragging);
\r
247 appData.highlightLastMove = IS_CHECKED(OPT_HighlightLastMove);
\r
248 PeriodicUpdatesEvent( IS_CHECKED(OPT_PeriodicUpdates));
\r
249 PonderNextMoveEvent( IS_CHECKED(OPT_PonderNextMove));
\r
250 appData.popupExitMessage = IS_CHECKED(OPT_PopupExitMessage);
\r
251 appData.popupMoveErrors = IS_CHECKED(OPT_PopupMoveErrors);
\r
252 appData.showButtonBar = IS_CHECKED(OPT_ShowButtonBar);
\r
253 appData.showCoords = IS_CHECKED(OPT_ShowCoordinates);
\r
254 // [HGM] thinking: next three moved up
\r
255 appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN);
\r
256 appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);
\r
257 appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory);
\r
258 appData.showThinking = IS_CHECKED(OPT_ShowThinking);
\r
259 ShowThinkingEvent(); // [HGM] thinking: tests four options
\r
260 appData.testLegality = IS_CHECKED(OPT_TestLegality);
\r
261 appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);
\r
262 appData.autoLogo =IS_CHECKED(OPT_AutoLogo); // [HGM] logo
\r
263 appData.oneClick =IS_CHECKED(OPT_SmartMove); // [HGM] one-click
\r
264 appData.autoDisplayTags =IS_CHECKED(OPT_AutoTags); // [HGM]
\r
265 appData.autoDisplayComment =IS_CHECKED(OPT_AutoComment); // [HGM]
\r
269 SetWindowPos(hwndMain, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
270 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
273 SetWindowPos(hwndConsole, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
274 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
277 if (!appData.highlightLastMove) {
\r
279 DrawPosition(FALSE, NULL);
\r
282 * for some reason the redraw seems smoother when we invalidate
\r
283 * the board rect after the call to EndDialog()
\r
285 EndDialog(hDlg, TRUE);
\r
287 if (oldAutoLogo != appData.autoLogo) { // [HGM] logo: remove any logos when we switch autologo off
\r
288 if(oldAutoLogo) first.programLogo = second.programLogo = NULL;
\r
289 InitDrawingSizes(boardSize, 0);
\r
290 } else if (oldShowButtonBar != appData.showButtonBar) {
\r
291 InitDrawingSizes(boardSize, 0);
\r
292 } else if ((oldShowCoords != appData.showCoords) ||
\r
293 (oldBlindfold != appData.blindfold)) {
\r
294 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
300 EndDialog(hDlg, FALSE);
\r
310 GeneralOptionsPopup(HWND hwnd)
\r
314 lpProc = MakeProcInstance((FARPROC)GeneralOptionsDialog, hInst);
\r
315 DialogBox(hInst, MAKEINTRESOURCE(DLG_GeneralOptions), hwnd,
\r
317 FreeProcInstance(lpProc);
\r
319 /*---------------------------------------------------------------------------*\
\r
321 * Board Options Dialog functions
\r
323 \*---------------------------------------------------------------------------*/
\r
325 const int SAMPLE_SQ_SIZE = 54;
\r
328 ChangeBoardSize(BoardSize newSize)
\r
330 if (newSize != boardSize) {
\r
331 boardSize = newSize;
\r
332 InitDrawingSizes(boardSize, 0);
\r
340 COLORREF squareColor,
\r
341 COLORREF pieceColor,
\r
342 COLORREF squareOutlineColor,
\r
343 COLORREF pieceDetailColor,
\r
349 HBRUSH brushSquare;
\r
350 HBRUSH brushSquareOutline;
\r
352 HBRUSH brushPieceDetail;
\r
353 HBRUSH oldBrushPiece = NULL;
\r
354 HBRUSH oldBrushSquare;
\r
355 HBITMAP oldBitmapMem;
\r
356 HBITMAP oldBitmapTemp;
\r
357 HBITMAP bufferBitmap;
\r
359 HDC hdcScreen, hdcMem, hdcTemp;
\r
361 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
364 const int SOLID = 0;
\r
365 const int WHITE = 1;
\r
366 const int OUTLINE = 2;
\r
367 const int BORDER = 4;
\r
369 InvalidateRect(hCtrl, NULL, TRUE);
\r
370 UpdateWindow(hCtrl);
\r
371 GetClientRect(hCtrl, &rect);
\r
372 x = rect.left + (BORDER / 2);
\r
373 y = rect.top + (BORDER / 2);
\r
374 hdcScreen = GetDC(hCtrl);
\r
375 hdcMem = CreateCompatibleDC(hdcScreen);
\r
376 hdcTemp = CreateCompatibleDC(hdcScreen);
\r
378 bufferBitmap = CreateCompatibleBitmap(hdcScreen, rect.right-rect.left+1,
\r
379 rect.bottom-rect.top+1);
\r
380 oldBitmapMem = SelectObject(hdcMem, bufferBitmap);
\r
382 SelectPalette(hdcMem, hPal, FALSE);
\r
384 brushSquare = CreateSolidBrush(squareColor);
\r
385 brushSquareOutline = CreateSolidBrush(squareOutlineColor);
\r
386 brushPiece = CreateSolidBrush(pieceColor);
\r
387 brushPieceDetail = CreateSolidBrush(pieceDetailColor);
\r
390 * first draw the rectangle
\r
392 pen = CreatePen(PS_SOLID, BORDER, squareOutlineColor);
\r
393 oldPen = (HPEN) SelectObject(hdcMem, pen);
\r
394 oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare);
\r
395 Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);
\r
398 * now draw the piece
\r
401 oldBitmapTemp = SelectObject(hdcTemp, pieces[OUTLINE]);
\r
402 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0,
\r
403 isWhitePiece ? SRCCOPY : NOTSRCCOPY);
\r
404 SelectObject(hdcTemp, oldBitmapTemp);
\r
406 if (isWhitePiece) {
\r
407 oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]);
\r
408 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
409 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
410 hdcTemp, 0, 0, 0x00B8074A);
\r
411 /* Use black for outline of white pieces */
\r
412 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
413 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
414 hdcTemp, 0, 0, SRCAND);
\r
416 /* Use square color for details of black pieces */
\r
417 oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);
\r
418 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
419 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
420 hdcTemp, 0, 0, 0x00B8074A);
\r
422 SelectObject(hdcMem, oldBrushPiece);
\r
423 SelectObject(hdcTemp, oldBitmapTemp);
\r
426 * copy the memory dc to the screen
\r
428 SelectObject(hdcMem, bufferBitmap);
\r
429 BitBlt(hdcScreen, rect.left, rect.top,
\r
430 rect.right - rect.left,
\r
431 rect.bottom - rect.top,
\r
432 hdcMem, rect.left, rect.top, SRCCOPY);
\r
433 SelectObject(hdcMem, oldBitmapMem);
\r
437 SelectObject(hdcMem, oldBrushPiece);
\r
438 SelectObject(hdcMem, oldPen);
\r
439 DeleteObject(brushPiece);
\r
440 DeleteObject(brushPieceDetail);
\r
441 DeleteObject(brushSquare);
\r
442 DeleteObject(brushSquareOutline);
\r
446 ReleaseDC(hCtrl, hdcScreen);
\r
451 PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color)
\r
454 HBRUSH brush, oldBrush;
\r
456 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
458 hdc = GetDC(hCtrl);
\r
459 InvalidateRect(hCtrl, NULL, TRUE);
\r
460 UpdateWindow(hCtrl);
\r
461 GetClientRect(hCtrl, &rect);
\r
462 brush = CreateSolidBrush(color);
\r
463 oldBrush = (HBRUSH)SelectObject(hdc, brush);
\r
464 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
\r
465 SelectObject(hdc, oldBrush);
\r
466 DeleteObject(brush);
\r
467 ReleaseDC(hCtrl, hdc);
\r
472 SetBoardOptionEnables(HWND hDlg)
\r
474 if (IsDlgButtonChecked(hDlg, OPT_Monochrome)) {
\r
475 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_HIDE);
\r
476 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_HIDE);
\r
477 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_HIDE);
\r
478 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_HIDE);
\r
480 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), FALSE);
\r
481 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), FALSE);
\r
482 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), FALSE);
\r
483 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), FALSE);
\r
485 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_SHOW);
\r
486 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_SHOW);
\r
487 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_SHOW);
\r
488 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_SHOW);
\r
490 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), TRUE);
\r
491 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), TRUE);
\r
492 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), TRUE);
\r
493 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), TRUE);
\r
498 BoardOptionsWhichRadio(HWND hDlg)
\r
500 return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny :
\r
501 (IsDlgButtonChecked(hDlg, OPT_SizeTeeny) ? SizeTeeny :
\r
502 (IsDlgButtonChecked(hDlg, OPT_SizeDinky) ? SizeDinky :
\r
503 (IsDlgButtonChecked(hDlg, OPT_SizePetite) ? SizePetite :
\r
504 (IsDlgButtonChecked(hDlg, OPT_SizeSlim) ? SizeSlim :
\r
505 (IsDlgButtonChecked(hDlg, OPT_SizeSmall) ? SizeSmall :
\r
506 (IsDlgButtonChecked(hDlg, OPT_SizeMediocre) ? SizeMediocre :
\r
507 (IsDlgButtonChecked(hDlg, OPT_SizeMiddling) ? SizeMiddling :
\r
508 (IsDlgButtonChecked(hDlg, OPT_SizeAverage) ? SizeAverage :
\r
509 (IsDlgButtonChecked(hDlg, OPT_SizeModerate) ? SizeModerate :
\r
510 (IsDlgButtonChecked(hDlg, OPT_SizeMedium) ? SizeMedium :
\r
511 (IsDlgButtonChecked(hDlg, OPT_SizeBulky) ? SizeBulky :
\r
512 (IsDlgButtonChecked(hDlg, OPT_SizeLarge) ? SizeLarge :
\r
513 (IsDlgButtonChecked(hDlg, OPT_SizeBig) ? SizeBig :
\r
514 (IsDlgButtonChecked(hDlg, OPT_SizeHuge) ? SizeHuge :
\r
515 (IsDlgButtonChecked(hDlg, OPT_SizeGiant) ? SizeGiant :
\r
516 (IsDlgButtonChecked(hDlg, OPT_SizeColossal) ? SizeColossal :
\r
517 SizeTitanic )))))))))))))))));
\r
521 BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
523 static Boolean mono, white, flip, fonts, bitmaps, grid;
\r
524 static BoardSize size;
\r
525 static COLORREF lsc, dsc, wpc, bpc, hsc, phc;
\r
526 static HBITMAP pieces[3];
\r
529 case WM_INITDIALOG: /* message: initialize dialog box */
\r
530 /* Center the dialog over the application window */
\r
531 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
532 Translate(hDlg, DLG_BoardOptions);
\r
533 /* Initialize the dialog items */
\r
534 switch (boardSize) {
\r
536 CheckDlgButton(hDlg, OPT_SizeTiny, TRUE);
\r
539 CheckDlgButton(hDlg, OPT_SizeTeeny, TRUE);
\r
542 CheckDlgButton(hDlg, OPT_SizeDinky, TRUE);
\r
545 CheckDlgButton(hDlg, OPT_SizePetite, TRUE);
\r
548 CheckDlgButton(hDlg, OPT_SizeSlim, TRUE);
\r
551 CheckDlgButton(hDlg, OPT_SizeSmall, TRUE);
\r
554 CheckDlgButton(hDlg, OPT_SizeMediocre, TRUE);
\r
557 CheckDlgButton(hDlg, OPT_SizeMiddling, TRUE);
\r
560 CheckDlgButton(hDlg, OPT_SizeAverage, TRUE);
\r
563 CheckDlgButton(hDlg, OPT_SizeModerate, TRUE);
\r
566 CheckDlgButton(hDlg, OPT_SizeMedium, TRUE);
\r
569 CheckDlgButton(hDlg, OPT_SizeBulky, TRUE);
\r
572 CheckDlgButton(hDlg, OPT_SizeLarge, TRUE);
\r
575 CheckDlgButton(hDlg, OPT_SizeBig, TRUE);
\r
578 CheckDlgButton(hDlg, OPT_SizeHuge, TRUE);
\r
581 CheckDlgButton(hDlg, OPT_SizeGiant, TRUE);
\r
584 CheckDlgButton(hDlg, OPT_SizeColossal, TRUE);
\r
587 CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE);
\r
588 default: ; // should not happen, but suppresses warning on pedantic compilers
\r
591 if (appData.monoMode)
\r
592 CheckDlgButton(hDlg, OPT_Monochrome, TRUE);
\r
594 if (appData.allWhite)
\r
595 CheckDlgButton(hDlg, OPT_AllWhite, TRUE);
\r
597 if (appData.upsideDown)
\r
598 CheckDlgButton(hDlg, OPT_UpsideDown, TRUE);
\r
600 if (appData.useBitmaps)
\r
601 CheckDlgButton(hDlg, OPT_Bitmaps, TRUE);
\r
603 if (appData.useFont)
\r
604 CheckDlgButton(hDlg, OPT_PieceFont, TRUE);
\r
606 if (appData.overrideLineGap >= 0)
\r
607 CheckDlgButton(hDlg, OPT_Grid, TRUE);
\r
609 pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s");
\r
610 pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w");
\r
611 pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o");
\r
613 lsc = lightSquareColor;
\r
614 dsc = darkSquareColor;
\r
615 fonts = appData.useFont;
\r
616 wpc = fonts ? appData.fontBackColorWhite : whitePieceColor;
\r
617 bpc = fonts ? appData.fontForeColorBlack : blackPieceColor;
\r
618 hsc = highlightSquareColor;
\r
619 phc = premoveHighlightColor;
\r
620 mono = appData.monoMode;
\r
621 white= appData.allWhite;
\r
622 flip = appData.upsideDown;
\r
624 bitmaps = appData.useBitmaps;
\r
625 grid = appData.overrideLineGap >= 0;
\r
627 SetBoardOptionEnables(hDlg);
\r
631 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
632 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
633 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
634 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
635 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
636 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
637 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
638 TRUE, mono, pieces);
\r
639 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
640 FALSE, mono, pieces);
\r
644 case WM_COMMAND: /* message: received a command */
\r
645 switch (LOWORD(wParam)) {
\r
648 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
649 * then ChangeBoardSize() does not take effect, although the new
\r
650 * boardSize is saved. Go figure...
\r
652 EndDialog(hDlg, TRUE);
\r
654 size = BoardOptionsWhichRadio(hDlg);
\r
657 * did any settings change?
\r
659 if (size != boardSize) {
\r
660 ChangeBoardSize(size);
\r
663 if (bitmaps && !appData.useBitmaps) InitTextures();
\r
665 if ((mono != appData.monoMode) ||
\r
666 (lsc != lightSquareColor) ||
\r
667 (dsc != darkSquareColor) ||
\r
668 (wpc != fonts ? appData.fontBackColorWhite : whitePieceColor) ||
\r
669 (bpc != fonts ? appData.fontForeColorBlack : blackPieceColor) ||
\r
670 (hsc != highlightSquareColor) ||
\r
671 (flip != appData.upsideDown) ||
\r
672 (white != appData.allWhite) ||
\r
673 (fonts != appData.useFont) ||
\r
674 (bitmaps != appData.useBitmaps) ||
\r
675 (grid != appData.overrideLineGap >= 0) ||
\r
676 (phc != premoveHighlightColor)) {
\r
678 lightSquareColor = lsc;
\r
679 darkSquareColor = dsc;
\r
681 appData.fontBackColorWhite = wpc;
\r
682 appData.fontForeColorBlack = bpc;
\r
684 whitePieceColor = wpc;
\r
685 blackPieceColor = bpc;
\r
687 highlightSquareColor = hsc;
\r
688 premoveHighlightColor = phc;
\r
689 appData.monoMode = mono;
\r
690 appData.allWhite = white;
\r
691 appData.upsideDown = flip;
\r
692 appData.useFont = fonts;
\r
693 appData.useBitmaps = bitmaps;
\r
694 if(grid != appData.overrideLineGap >= 0) appData.overrideLineGap = grid - 1;
\r
696 InitDrawingColors();
\r
697 InitDrawingSizes(boardSize, 0);
\r
698 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
700 DeleteObject(pieces[0]);
\r
701 DeleteObject(pieces[1]);
\r
703 DeleteObject(pieces[2]);
\r
707 DeleteObject(pieces[0]);
\r
708 DeleteObject(pieces[1]);
\r
709 DeleteObject(pieces[2]);
\r
710 EndDialog(hDlg, FALSE);
\r
713 case OPT_ChooseLightSquareColor:
\r
714 if (ChangeColor(hDlg, &lsc))
\r
715 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
716 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
717 TRUE, mono, pieces);
\r
720 case OPT_ChooseDarkSquareColor:
\r
721 if (ChangeColor(hDlg, &dsc))
\r
722 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
723 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
724 FALSE, mono, pieces);
\r
727 case OPT_ChooseWhitePieceColor:
\r
728 if (ChangeColor(hDlg, &wpc))
\r
729 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
730 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
731 TRUE, mono, pieces);
\r
734 case OPT_ChooseBlackPieceColor:
\r
735 if (ChangeColor(hDlg, &bpc))
\r
736 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
737 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
738 FALSE, mono, pieces);
\r
741 case OPT_ChooseHighlightSquareColor:
\r
742 if (ChangeColor(hDlg, &hsc))
\r
743 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
744 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
745 TRUE, mono, pieces);
\r
748 case OPT_ChoosePremoveHighlightColor:
\r
749 if (ChangeColor(hDlg, &phc))
\r
750 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
751 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
752 FALSE, mono, pieces);
\r
755 case OPT_DefaultBoardColors:
\r
756 lsc = ParseColorName(LIGHT_SQUARE_COLOR);
\r
757 dsc = ParseColorName(DARK_SQUARE_COLOR);
\r
758 wpc = ParseColorName(WHITE_PIECE_COLOR);
\r
759 bpc = ParseColorName(BLACK_PIECE_COLOR);
\r
760 hsc = ParseColorName(HIGHLIGHT_SQUARE_COLOR);
\r
761 phc = ParseColorName(PREMOVE_HIGHLIGHT_COLOR);
\r
765 CheckDlgButton(hDlg, OPT_Monochrome, FALSE);
\r
766 CheckDlgButton(hDlg, OPT_AllWhite, FALSE);
\r
767 CheckDlgButton(hDlg, OPT_UpsideDown, FALSE);
\r
768 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
769 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
770 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
771 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
772 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
773 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
774 SetBoardOptionEnables(hDlg);
\r
775 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
776 TRUE, mono, pieces);
\r
777 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
778 FALSE, mono, pieces);
\r
781 case OPT_Monochrome:
\r
783 SetBoardOptionEnables(hDlg);
\r
790 case OPT_UpsideDown:
\r
795 bitmaps = !bitmaps;
\r
798 case OPT_PieceFont:
\r
813 BoardOptionsPopup(HWND hwnd)
\r
815 FARPROC lpProc = MakeProcInstance((FARPROC)BoardOptionsDialog, hInst);
\r
816 DialogBox(hInst, MAKEINTRESOURCE(DLG_BoardOptions), hwnd,
\r
818 FreeProcInstance(lpProc);
\r
821 int radioButton[] = {
\r
824 OPT_VariantWildcastle,
\r
825 OPT_VariantNocastle,
\r
827 OPT_VariantBughouse,
\r
828 OPT_VariantCrazyhouse,
\r
830 OPT_VariantSuicide,
\r
831 OPT_VariantGiveaway,
\r
832 OPT_VariantTwoKings,
\r
836 OPT_VariantShatranj,
\r
846 OPT_VariantXiangqi,
\r
847 OPT_VariantCourier,
\r
849 OPT_VariantCapablanca,
\r
850 OPT_VariantKnightmate,
\r
852 OPT_VariantCylinder,
\r
855 OPT_VariantBerolina,
\r
864 OPT_VariantSpartan, // Spartan
\r
869 VariantWhichRadio(HWND hDlg)
\r
872 while((j = radioButton[i++]) != -2) {
\r
873 if(j == -1) continue; // no menu button
\r
874 if(IsDlgButtonChecked(hDlg, j) &&
\r
875 (appData.noChessProgram || strstr(first.variants, VariantName(i-1)))) return (VariantClass) i-1;
\r
877 return gameInfo.variant; // If no button checked, keep old
\r
881 VariantShowRadio(HWND hDlg)
\r
884 CheckDlgButton(hDlg, radioButton[gameInfo.variant], TRUE);
\r
885 while((j = radioButton[i++]) != -2) {
\r
886 if(j == -1) continue; // no menu button
\r
887 EnableWindow(GetDlgItem(hDlg, j), appData.noChessProgram || strstr(first.variants, VariantName(i-1)));
\r
892 NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
894 static VariantClass v;
\r
895 static int n1_ok, n2_ok, n3_ok;
\r
898 case WM_INITDIALOG: /* message: initialize dialog box */
\r
899 /* Center the dialog over the application window */
\r
900 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
901 Translate(hDlg, DLG_NewVariant);
\r
903 /* Initialize the dialog items */
\r
904 VariantShowRadio(hDlg);
\r
906 SetDlgItemInt( hDlg, IDC_Files, -1, TRUE );
\r
907 SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 );
\r
909 SetDlgItemInt( hDlg, IDC_Ranks, -1, TRUE );
\r
910 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
912 SetDlgItemInt( hDlg, IDC_Holdings, -1, TRUE );
\r
913 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
915 n1_ok = n2_ok = n3_ok = FALSE;
\r
919 case WM_COMMAND: /* message: received a command */
\r
920 switch (LOWORD(wParam)) {
\r
923 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
924 * then ChangeBoardSize() does not take effect, although the new
\r
925 * boardSize is saved. Go figure...
\r
927 EndDialog(hDlg, TRUE);
\r
929 v = VariantWhichRadio(hDlg);
\r
930 if(!appData.noChessProgram) {
\r
931 char *name = VariantName(v), buf[MSG_SIZ];
\r
932 if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) {
\r
933 /* [HGM] in protocol 2 we check if variant is suported by engine */
\r
934 snprintf(buf, MSG_SIZ, _("Variant %s not supported by %s"), name, first.tidy);
\r
935 DisplayError(buf, 0);
\r
936 return TRUE; /* treat as _("Cancel") if first engine does not support it */
\r
938 if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) {
\r
939 snprintf(buf, MSG_SIZ, _("Warning: second engine (%s) does not support this!"), second.tidy);
\r
940 DisplayError(buf, 0); /* use of second engine is optional; only warn user */
\r
944 gameInfo.variant = v;
\r
945 appData.variant = VariantName(v);
\r
947 appData.NrFiles = (int) GetDlgItemInt(hDlg, IDC_Files, NULL, FALSE );
\r
948 appData.NrRanks = (int) GetDlgItemInt(hDlg, IDC_Ranks, NULL, FALSE );
\r
949 appData.holdingsSize = (int) GetDlgItemInt(hDlg, IDC_Holdings, NULL, FALSE );
\r
951 if(!n1_ok) appData.NrFiles = -1;
\r
952 if(!n2_ok) appData.NrRanks = -1;
\r
953 if(!n3_ok) appData.holdingsSize = -1;
\r
955 shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */
\r
956 startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */
\r
957 appData.pieceToCharTable = NULL;
\r
963 EndDialog(hDlg, FALSE);
\r
969 if( HIWORD(wParam) == EN_CHANGE ) {
\r
971 GetDlgItemInt(hDlg, IDC_Files, &n1_ok, FALSE );
\r
972 GetDlgItemInt(hDlg, IDC_Ranks, &n2_ok, FALSE );
\r
973 GetDlgItemInt(hDlg, IDC_Holdings, &n3_ok, FALSE );
\r
975 /*EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok ? TRUE : FALSE );*/
\r
986 NewVariantPopup(HWND hwnd)
\r
988 FARPROC lpProc = MakeProcInstance((FARPROC)NewVariantDialog, hInst);
\r
989 DialogBox(hInst, MAKEINTRESOURCE(DLG_NewVariant), hwnd,
\r
991 FreeProcInstance(lpProc);
\r
994 /*---------------------------------------------------------------------------*\
\r
996 * ICS Options Dialog functions
\r
998 \*---------------------------------------------------------------------------*/
\r
1001 MyCreateFont(HWND hwnd, MyFont *font)
\r
1006 /* Initialize members of the CHOOSEFONT structure. */
\r
1007 cf.lStructSize = sizeof(CHOOSEFONT);
\r
1008 cf.hwndOwner = hwnd;
\r
1009 cf.hDC = (HDC)NULL;
\r
1010 cf.lpLogFont = &font->lf;
\r
1011 cf.iPointSize = 0;
\r
1012 cf.Flags = CF_SCREENFONTS|/*CF_ANSIONLY|*/CF_INITTOLOGFONTSTRUCT;
\r
1013 cf.rgbColors = RGB(0,0,0);
\r
1014 cf.lCustData = 0L;
\r
1015 cf.lpfnHook = (LPCFHOOKPROC)NULL;
\r
1016 cf.lpTemplateName = (LPSTR)NULL;
\r
1017 cf.hInstance = (HINSTANCE) NULL;
\r
1018 cf.lpszStyle = (LPSTR)NULL;
\r
1019 cf.nFontType = SCREEN_FONTTYPE;
\r
1023 /* Display the CHOOSEFONT common-dialog box. */
\r
1024 if (!ChooseFont(&cf)) {
\r
1028 /* Create a logical font based on the user's */
\r
1029 /* selection and return a handle identifying */
\r
1031 hf = CreateFontIndirect(cf.lpLogFont);
\r
1037 font->mfp.pointSize = (float) (cf.iPointSize / 10.0);
\r
1038 font->mfp.bold = (font->lf.lfWeight >= FW_BOLD);
\r
1039 font->mfp.italic = font->lf.lfItalic;
\r
1040 font->mfp.underline = font->lf.lfUnderline;
\r
1041 font->mfp.strikeout = font->lf.lfStrikeOut;
\r
1042 font->mfp.charset = font->lf.lfCharSet;
\r
1043 safeStrCpy(font->mfp.faceName, font->lf.lfFaceName, sizeof(font->mfp.faceName)/sizeof(font->mfp.faceName[0]) );
\r
1049 UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
\r
1052 cf.cbSize = sizeof(CHARFORMAT);
\r
1054 CFM_COLOR|CFM_CHARSET|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;
\r
1055 cf.crTextColor = mca->color;
\r
1056 cf.dwEffects = mca->effects;
\r
1057 safeStrCpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName, sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]) );
\r
1059 * The 20.0 below is in fact documented. yHeight is expressed in twips.
\r
1060 * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT.
\r
1063 cf.yHeight = (int)(font[boardSize][CONSOLE_FONT]->mfp.pointSize * 20.0 + 0.5);
\r
1064 cf.bCharSet = DEFAULT_CHARSET; /* should be ignored anyway */
\r
1065 cf.bPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
\r
1066 SendDlgItemMessage(hDlg, id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1070 ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1072 static MyColorizeAttribs mca;
\r
1073 static ColorClass cc;
\r
1074 COLORREF background = (COLORREF)0;
\r
1076 switch (message) {
\r
1077 case WM_INITDIALOG:
\r
1078 cc = (ColorClass)lParam;
\r
1079 mca = colorizeAttribs[cc];
\r
1080 /* Center the dialog over the application window */
\r
1081 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1082 Translate(hDlg, DLG_Colorize);
\r
1083 /* Initialize the dialog items */
\r
1084 CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0);
\r
1085 CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0);
\r
1086 CheckDlgButton(hDlg, OPT_Underline, (mca.effects & CFE_UNDERLINE) != 0);
\r
1087 CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0);
\r
1089 /* get the current background color from the parent window */
\r
1090 SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND,
\r
1091 (WPARAM)WM_USER_GetConsoleBackground,
\r
1092 (LPARAM)&background);
\r
1094 /* set the background color */
\r
1095 SendDlgItemMessage(hDlg, OPT_Sample, EM_SETBKGNDCOLOR, FALSE, background);
\r
1097 SetDlgItemText(hDlg, OPT_Sample, T_(mca.name));
\r
1098 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1101 case WM_COMMAND: /* message: received a command */
\r
1102 switch (LOWORD(wParam)) {
\r
1104 /* Read changed options from the dialog box */
\r
1105 colorizeAttribs[cc] = mca;
\r
1106 textAttribs[cc].color = mca.color;
\r
1107 textAttribs[cc].effects = mca.effects;
\r
1108 Colorize(currentColorClass, TRUE);
\r
1109 if (cc == ColorNormal) {
\r
1111 cf.cbSize = sizeof(CHARFORMAT);
\r
1112 cf.dwMask = CFM_COLOR;
\r
1113 cf.crTextColor = mca.color;
\r
1114 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1115 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1117 EndDialog(hDlg, TRUE);
\r
1121 EndDialog(hDlg, FALSE);
\r
1124 case OPT_ChooseColor:
\r
1125 ChangeColor(hDlg, &mca.color);
\r
1126 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1131 (IsDlgButtonChecked(hDlg, OPT_Bold) ? CFE_BOLD : 0) |
\r
1132 (IsDlgButtonChecked(hDlg, OPT_Italic) ? CFE_ITALIC : 0) |
\r
1133 (IsDlgButtonChecked(hDlg, OPT_Underline) ? CFE_UNDERLINE : 0) |
\r
1134 (IsDlgButtonChecked(hDlg, OPT_Strikeout) ? CFE_STRIKEOUT : 0);
\r
1135 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1144 ColorizeTextPopup(HWND hwnd, ColorClass cc)
\r
1148 lpProc = MakeProcInstance((FARPROC)ColorizeTextDialog, hInst);
\r
1149 DialogBoxParam(hInst, MAKEINTRESOURCE(DLG_Colorize),
\r
1150 hwnd, (DLGPROC)lpProc, (LPARAM) cc);
\r
1151 FreeProcInstance(lpProc);
\r
1155 SetIcsOptionEnables(HWND hDlg)
\r
1157 #define ENABLE_DLG_ITEM(x,y) EnableWindow(GetDlgItem(hDlg,(x)), (y))
\r
1159 UINT state = IsDlgButtonChecked(hDlg, OPT_Premove);
\r
1160 ENABLE_DLG_ITEM(OPT_PremoveWhite, state);
\r
1161 ENABLE_DLG_ITEM(OPT_PremoveWhiteText, state);
\r
1162 ENABLE_DLG_ITEM(OPT_PremoveBlack, state);
\r
1163 ENABLE_DLG_ITEM(OPT_PremoveBlackText, state);
\r
1165 ENABLE_DLG_ITEM(OPT_IcsAlarmTime, IsDlgButtonChecked(hDlg, OPT_IcsAlarm));
\r
1167 #undef ENABLE_DLG_ITEM
\r
1172 IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1174 char buf[MSG_SIZ];
\r
1177 static COLORREF cbc;
\r
1178 static MyColorizeAttribs *mca;
\r
1179 COLORREF *colorref;
\r
1181 switch (message) {
\r
1182 case WM_INITDIALOG: /* message: initialize dialog box */
\r
1184 mca = colorizeAttribs;
\r
1186 for (i=0; i < NColorClasses - 1; i++) {
\r
1187 mca[i].color = textAttribs[i].color;
\r
1188 mca[i].effects = textAttribs[i].effects;
\r
1190 cbc = consoleBackgroundColor;
\r
1192 /* Center the dialog over the application window */
\r
1193 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1194 Translate(hDlg, DLG_IcsOptions);
\r
1196 /* Initialize the dialog items */
\r
1197 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
1199 CHECK_BOX(OPT_AutoKibitz, appData.autoKibitz);
\r
1200 CHECK_BOX(OPT_AutoComment, appData.autoComment);
\r
1201 CHECK_BOX(OPT_AutoObserve, appData.autoObserve);
\r
1202 CHECK_BOX(OPT_AutoCreate, appData.autoCreateLogon);
\r
1203 CHECK_BOX(OPT_GetMoveList, appData.getMoveList);
\r
1204 CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing);
\r
1205 CHECK_BOX(OPT_QuietPlay, appData.quietPlay);
\r
1206 CHECK_BOX(OPT_SeekGraph, appData.seekGraph);
\r
1207 CHECK_BOX(OPT_AutoRefresh, appData.autoRefresh);
\r
1208 CHECK_BOX(OPT_BgObserve, appData.bgObserve);
\r
1209 CHECK_BOX(OPT_DualBoard, appData.dualBoard);
\r
1210 CHECK_BOX(OPT_SmartMove, appData.oneClick);
\r
1211 CHECK_BOX(OPT_Premove, appData.premove);
\r
1212 CHECK_BOX(OPT_PremoveWhite, appData.premoveWhite);
\r
1213 CHECK_BOX(OPT_PremoveBlack, appData.premoveBlack);
\r
1214 CHECK_BOX(OPT_IcsAlarm, appData.icsAlarm);
\r
1215 CHECK_BOX(OPT_DontColorize, !appData.colorize);
\r
1219 snprintf(buf, MSG_SIZ, "%d", appData.icsAlarmTime / 1000);
\r
1220 SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);
\r
1221 SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);
\r
1222 SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);
\r
1223 SetDlgItemText(hDlg, OPT_StartupChatBoxes, appData.chatBoxes);
\r
1225 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1226 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1227 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1228 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1229 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1230 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1231 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1232 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1233 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1234 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1236 SetDlgItemText(hDlg, OPT_SampleShout, T_(mca[ColorShout].name));
\r
1237 SetDlgItemText(hDlg, OPT_SampleSShout, T_(mca[ColorSShout].name));
\r
1238 SetDlgItemText(hDlg, OPT_SampleChannel1, T_(mca[ColorChannel1].name));
\r
1239 SetDlgItemText(hDlg, OPT_SampleChannel, T_(mca[ColorChannel].name));
\r
1240 SetDlgItemText(hDlg, OPT_SampleKibitz, T_(mca[ColorKibitz].name));
\r
1241 SetDlgItemText(hDlg, OPT_SampleTell, T_(mca[ColorTell].name));
\r
1242 SetDlgItemText(hDlg, OPT_SampleChallenge, T_(mca[ColorChallenge].name));
\r
1243 SetDlgItemText(hDlg, OPT_SampleRequest, T_(mca[ColorRequest].name));
\r
1244 SetDlgItemText(hDlg, OPT_SampleSeek, T_(mca[ColorSeek].name));
\r
1245 SetDlgItemText(hDlg, OPT_SampleNormal, T_(mca[ColorNormal].name));
\r
1247 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1248 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1249 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1250 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1251 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1252 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1253 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1254 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1255 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1256 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1258 SetIcsOptionEnables(hDlg);
\r
1261 case WM_COMMAND: /* message: received a command */
\r
1262 switch (LOWORD(wParam)) {
\r
1264 case WM_USER_GetConsoleBackground:
\r
1265 /* the ColorizeTextDialog needs the current background color */
\r
1266 colorref = (COLORREF *)lParam;
\r
1271 /* Read changed options from the dialog box */
\r
1272 GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ);
\r
1273 if (sscanf(buf, "%d", &number) != 1 || (number < 0)){
\r
1274 MessageBox(hDlg, _("Invalid ICS Alarm Time"),
\r
1275 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
1279 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
1281 appData.icsAlarm = IS_CHECKED(OPT_IcsAlarm);
\r
1282 appData.premove = IS_CHECKED(OPT_Premove);
\r
1283 appData.premoveWhite = IS_CHECKED(OPT_PremoveWhite);
\r
1284 appData.premoveBlack = IS_CHECKED(OPT_PremoveBlack);
\r
1285 appData.autoKibitz = IS_CHECKED(OPT_AutoKibitz);
\r
1286 appData.autoComment = IS_CHECKED(OPT_AutoComment);
\r
1287 appData.autoObserve = IS_CHECKED(OPT_AutoObserve);
\r
1288 appData.autoCreateLogon = IS_CHECKED(OPT_AutoCreate);
\r
1289 appData.getMoveList = IS_CHECKED(OPT_GetMoveList);
\r
1290 appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing);
\r
1291 appData.quietPlay = IS_CHECKED(OPT_QuietPlay);
\r
1292 appData.seekGraph = IS_CHECKED(OPT_SeekGraph);
\r
1293 appData.autoRefresh = IS_CHECKED(OPT_AutoRefresh);
\r
1294 appData.bgObserve = IS_CHECKED(OPT_BgObserve);
\r
1295 appData.dualBoard = IS_CHECKED(OPT_DualBoard);
\r
1296 appData.oneClick = IS_CHECKED(OPT_SmartMove);
\r
1300 appData.icsAlarmTime = number * 1000;
\r
1301 GetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText, 5);
\r
1302 GetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText, 5);
\r
1303 GetDlgItemText(hDlg, OPT_StartupChatBoxes, buf, sizeof(buf));
\r
1304 buf[sizeof(buf)-1] = NULLCHAR; appData.chatBoxes = StrSave(buf); // memory leak
\r
1306 if (appData.localLineEditing) {
\r
1314 appData.colorize =
\r
1315 (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize);
\r
1317 ChangedConsoleFont();
\r
1319 if (!appData.colorize) {
\r
1321 COLORREF background = ParseColorName(COLOR_BKGD);
\r
1323 SetDefaultTextAttribs();
\r
1324 Colorize(currentColorClass);
\r
1326 cf.cbSize = sizeof(CHARFORMAT);
\r
1327 cf.dwMask = CFM_COLOR;
\r
1328 cf.crTextColor = ParseColorName(COLOR_NORMAL);
\r
1330 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1331 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1332 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1333 EM_SETBKGNDCOLOR, FALSE, background);
\r
1334 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1335 EM_SETBKGNDCOLOR, FALSE, background);
\r
1338 if (cbc != consoleBackgroundColor) {
\r
1339 consoleBackgroundColor = cbc;
\r
1340 if (appData.colorize) {
\r
1341 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1342 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1343 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1344 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1348 for (i=0; i < NColorClasses - 1; i++) {
\r
1349 textAttribs[i].color = mca[i].color;
\r
1350 textAttribs[i].effects = mca[i].effects;
\r
1353 EndDialog(hDlg, TRUE);
\r
1357 EndDialog(hDlg, FALSE);
\r
1360 case OPT_ChooseShoutColor:
\r
1361 ColorizeTextPopup(hDlg, ColorShout);
\r
1362 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1365 case OPT_ChooseSShoutColor:
\r
1366 ColorizeTextPopup(hDlg, ColorSShout);
\r
1367 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1370 case OPT_ChooseChannel1Color:
\r
1371 ColorizeTextPopup(hDlg, ColorChannel1);
\r
1372 UpdateSampleText(hDlg, OPT_SampleChannel1,
\r
1373 &colorizeAttribs[ColorChannel1]);
\r
1376 case OPT_ChooseChannelColor:
\r
1377 ColorizeTextPopup(hDlg, ColorChannel);
\r
1378 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1381 case OPT_ChooseKibitzColor:
\r
1382 ColorizeTextPopup(hDlg, ColorKibitz);
\r
1383 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1386 case OPT_ChooseTellColor:
\r
1387 ColorizeTextPopup(hDlg, ColorTell);
\r
1388 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1391 case OPT_ChooseChallengeColor:
\r
1392 ColorizeTextPopup(hDlg, ColorChallenge);
\r
1393 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1396 case OPT_ChooseRequestColor:
\r
1397 ColorizeTextPopup(hDlg, ColorRequest);
\r
1398 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1401 case OPT_ChooseSeekColor:
\r
1402 ColorizeTextPopup(hDlg, ColorSeek);
\r
1403 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1406 case OPT_ChooseNormalColor:
\r
1407 ColorizeTextPopup(hDlg, ColorNormal);
\r
1408 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1411 case OPT_ChooseBackgroundColor:
\r
1412 if (ChangeColor(hDlg, &cbc)) {
\r
1413 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1414 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1415 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1416 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1417 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1418 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1419 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1420 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1421 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1422 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1426 case OPT_DefaultColors:
\r
1427 for (i=0; i < NColorClasses - 1; i++)
\r
1428 ParseAttribs(&mca[i].color,
\r
1430 defaultTextAttribs[i]);
\r
1432 cbc = ParseColorName(COLOR_BKGD);
\r
1433 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1434 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1435 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1436 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1437 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1438 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1439 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1440 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1441 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1442 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1444 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1445 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1446 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1447 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1448 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1449 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1450 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1451 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1452 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1453 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1457 SetIcsOptionEnables(hDlg);
\r
1466 IcsOptionsPopup(HWND hwnd)
\r
1468 FARPROC lpProc = MakeProcInstance((FARPROC)IcsOptionsDialog, hInst);
\r
1469 DialogBox(hInst, MAKEINTRESOURCE(DLG_IcsOptions), hwnd,
\r
1470 (DLGPROC) lpProc);
\r
1471 FreeProcInstance(lpProc);
\r
1474 /*---------------------------------------------------------------------------*\
\r
1476 * Fonts Dialog functions
\r
1478 \*---------------------------------------------------------------------------*/
\r
1480 char *string; // sorry
\r
1483 SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
\r
1485 char buf[MSG_SIZ];
\r
1490 RECT rectClient, rectFormat;
\r
1495 len = snprintf(buf, MSG_SIZ, "%.0f pt. %s%s%s\n",
\r
1496 mf->mfp.pointSize, mf->mfp.faceName,
\r
1497 mf->mfp.bold ? " bold" : "",
\r
1498 mf->mfp.italic ? " italic" : "");
\r
1499 if(id != OPT_SamplePieceFont)
\r
1500 SetDlgItemText(hwnd, id, buf);
\r
1501 else SetDlgItemText(hwnd, id, string);
\r
1503 hControl = GetDlgItem(hwnd, id);
\r
1504 hdc = GetDC(hControl);
\r
1505 SetMapMode(hdc, MM_TEXT); /* 1 pixel == 1 logical unit */
\r
1506 oldFont = SelectObject(hdc, mf->hf);
\r
1508 /* get number of logical units necessary to display font name */
\r
1509 GetTextExtentPoint32(hdc, buf, len, &size);
\r
1511 /* calculate formatting rectangle in the rich edit control.
\r
1512 * May be larger or smaller than the actual control.
\r
1514 GetClientRect(hControl, &rectClient);
\r
1515 center.x = (rectClient.left + rectClient.right) / 2;
\r
1516 center.y = (rectClient.top + rectClient.bottom) / 2;
\r
1517 rectFormat.top = center.y - (size.cy / 2) - 1;
\r
1518 rectFormat.bottom = center.y + (size.cy / 2) + 1;
\r
1519 rectFormat.left = center.x - (size.cx / 2) - 1;
\r
1520 rectFormat.right = center.x + (size.cx / 2) + 1;
\r
1522 cf.cbSize = sizeof(CHARFORMAT);
\r
1523 cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC;
\r
1525 if (mf->lf.lfWeight == FW_BOLD) cf.dwEffects |= CFE_BOLD;
\r
1526 if (mf->lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
\r
1527 safeStrCpy(cf.szFaceName, mf->mfp.faceName, sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]) );
\r
1529 * yHeight is expressed in twips. A twip is 1/20 of a font's point
\r
1530 * size. See documentation of CHARFORMAT. --msw
\r
1532 cf.yHeight = (int)(mf->mfp.pointSize * 20.0 + 0.5);
\r
1533 cf.bCharSet = mf->lf.lfCharSet;
\r
1534 cf.bPitchAndFamily = mf->lf.lfPitchAndFamily;
\r
1536 /* format the text in the rich edit control */
\r
1537 SendMessage(hControl, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf);
\r
1538 if(id != OPT_SamplePieceFont)
\r
1539 SendMessage(hControl, EM_SETRECT, (WPARAM)0, (LPARAM) &rectFormat);
\r
1542 SelectObject(hdc, oldFont);
\r
1543 ReleaseDC(hControl, hdc);
\r
1547 CopyFont(MyFont *dest, const MyFont *src)
\r
1549 dest->mfp.pointSize = src->mfp.pointSize;
\r
1550 dest->mfp.bold = src->mfp.bold;
\r
1551 dest->mfp.italic = src->mfp.italic;
\r
1552 dest->mfp.underline = src->mfp.underline;
\r
1553 dest->mfp.strikeout = src->mfp.strikeout;
\r
1554 dest->mfp.charset = src->mfp.charset;
\r
1555 safeStrCpy(dest->mfp.faceName, src->mfp.faceName, sizeof(dest->mfp.faceName)/sizeof(dest->mfp.faceName[0]) );
\r
1556 CreateFontInMF(dest);
\r
1561 FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1563 static MyFont workFont[NUM_FONTS+1];
\r
1564 static BOOL firstPaint;
\r
1565 static char pieceText[] = "ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";
\r
1569 switch (message) {
\r
1570 case WM_INITDIALOG:
\r
1572 /* copy the current font settings into a working copy */
\r
1573 for (i=0; i < NUM_FONTS; i++)
\r
1574 CopyFont(&workFont[i], font[boardSize][i]);
\r
1575 strncpy(workFont[NUM_FONTS].mfp.faceName, appData.renderPiecesWithFont, sizeof(workFont[NUM_FONTS].mfp.faceName));
\r
1576 workFont[NUM_FONTS].mfp.pointSize = 16.;
\r
1577 workFont[NUM_FONTS].mfp.charset = DEFAULT_CHARSET;
\r
1579 Translate(hDlg, DLG_Fonts);
\r
1580 if (!appData.icsActive)
\r
1581 EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE);
\r
1583 firstPaint = TRUE; /* see rant below */
\r
1585 /* If I don't call SetFocus(), the dialog won't respond to the keyboard
\r
1586 * when first drawn. Why is this the only dialog that behaves this way? Is
\r
1587 * is the WM_PAINT stuff below?? Sigh...
\r
1589 SetFocus(GetDlgItem(hDlg, IDOK));
\r
1593 /* This should not be necessary. However, if SetSampleFontText() is called
\r
1594 * in response to WM_INITDIALOG, the strings are not properly centered in
\r
1595 * the controls when the dialog first appears. I can't figure out why, so
\r
1596 * this is the workaround. --msw
\r
1599 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1600 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1601 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1602 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1603 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1604 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1605 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1606 SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]);
\r
1607 string = appData.fontToPieceTable;
\r
1608 SetSampleFontText(hDlg, OPT_SamplePieceFont, &workFont[NUM_FONTS]);
\r
1609 firstPaint = FALSE;
\r
1613 case WM_COMMAND: /* message: received a command */
\r
1614 switch (LOWORD(wParam)) {
\r
1617 /* again, it seems to avoid redraw problems if we call EndDialog first */
\r
1618 EndDialog(hDlg, FALSE);
\r
1620 /* copy modified settings back to the fonts array */
\r
1621 for (i=0; i < NUM_FONTS; i++)
\r
1622 CopyFont(font[boardSize][i], &workFont[i]);
\r
1624 { // Make new piece-to-char table
\r
1625 char buf[MSG_SIZ];
\r
1626 GetDlgItemText(hDlg, OPT_SamplePieceFont, buf, MSG_SIZ);
\r
1627 ASSIGN(appData.fontToPieceTable, buf);
\r
1629 ASSIGN(appData.renderPiecesWithFont, workFont[NUM_FONTS].mfp.faceName); // piece font
\r
1631 /* a sad necessity due to the original design of having a separate
\r
1632 * console font, tags font, and comment font for each board size. IMHO
\r
1633 * these fonts should not be dependent on the current board size. I'm
\r
1634 * running out of time, so I am doing this hack rather than redesign the
\r
1635 * data structure. Besides, I think if I redesigned the data structure, I
\r
1636 * might break backwards compatibility with old winboard.ini files.
\r
1639 for (i=0; i < NUM_SIZES; i++) {
\r
1640 CopyFont(font[i][EDITTAGS_FONT], &workFont[EDITTAGS_FONT]);
\r
1641 CopyFont(font[i][CONSOLE_FONT], &workFont[CONSOLE_FONT]);
\r
1642 CopyFont(font[i][COMMENT_FONT], &workFont[COMMENT_FONT]);
\r
1643 CopyFont(font[i][MOVEHISTORY_FONT], &workFont[MOVEHISTORY_FONT]);
\r
1644 CopyFont(font[i][GAMELIST_FONT], &workFont[GAMELIST_FONT]);
\r
1646 /* end sad necessity */
\r
1648 InitDrawingSizes(boardSize, 0);
\r
1649 InvalidateRect(hwndMain, NULL, TRUE);
\r
1651 if (commentDialog) {
\r
1652 SendDlgItemMessage(commentDialog, OPT_CommentText,
\r
1653 WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf,
\r
1654 MAKELPARAM(TRUE, 0));
\r
1655 GetClientRect(GetDlgItem(commentDialog, OPT_CommentText), &rect);
\r
1656 InvalidateRect(commentDialog, &rect, TRUE);
\r
1659 if (editTagsDialog) {
\r
1660 SendDlgItemMessage(editTagsDialog, OPT_TagsText,
\r
1661 WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf,
\r
1662 MAKELPARAM(TRUE, 0));
\r
1663 GetClientRect(GetDlgItem(editTagsDialog, OPT_TagsText), &rect);
\r
1664 InvalidateRect(editTagsDialog, &rect, TRUE);
\r
1667 if( moveHistoryDialog != NULL ) {
\r
1668 SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory,
\r
1669 WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,
\r
1670 MAKELPARAM(TRUE, 0));
\r
1671 SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 );
\r
1672 // InvalidateRect(editTagsDialog, NULL, TRUE); // [HGM] this ws improperly cloned?
\r
1675 if( engineOutputDialog != NULL ) {
\r
1676 SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1,
\r
1677 WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,
\r
1678 MAKELPARAM(TRUE, 0));
\r
1679 SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo2,
\r
1680 WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,
\r
1681 MAKELPARAM(TRUE, 0));
\r
1684 if (hwndConsole) {
\r
1685 ChangedConsoleFont();
\r
1688 for (i=0; i<NUM_FONTS; i++)
\r
1689 DeleteObject(&workFont[i].hf);
\r
1694 for (i=0; i<NUM_FONTS; i++)
\r
1695 DeleteObject(&workFont[i].hf);
\r
1696 EndDialog(hDlg, FALSE);
\r
1699 case OPT_ChooseClockFont:
\r
1700 MyCreateFont(hDlg, &workFont[CLOCK_FONT]);
\r
1701 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1704 case OPT_ChooseMessageFont:
\r
1705 MyCreateFont(hDlg, &workFont[MESSAGE_FONT]);
\r
1706 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1709 case OPT_ChooseCoordFont:
\r
1710 MyCreateFont(hDlg, &workFont[COORD_FONT]);
\r
1711 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1714 case OPT_ChooseTagFont:
\r
1715 MyCreateFont(hDlg, &workFont[EDITTAGS_FONT]);
\r
1716 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1719 case OPT_ChooseCommentsFont:
\r
1720 MyCreateFont(hDlg, &workFont[COMMENT_FONT]);
\r
1721 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1724 case OPT_ChooseConsoleFont:
\r
1725 MyCreateFont(hDlg, &workFont[CONSOLE_FONT]);
\r
1726 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1729 case OPT_ChooseMoveHistoryFont:
\r
1730 MyCreateFont(hDlg, &workFont[MOVEHISTORY_FONT]);
\r
1731 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1734 case OPT_ChooseGameListFont:
\r
1735 MyCreateFont(hDlg, &workFont[GAMELIST_FONT]);
\r
1736 SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]);
\r
1739 case OPT_ChoosePieceFont:
\r
1740 MyCreateFont(hDlg, &workFont[NUM_FONTS]);
\r
1741 string = pieceText;
\r
1742 SetSampleFontText(hDlg, OPT_SamplePieceFont, &workFont[NUM_FONTS]);
\r
1745 case OPT_DefaultFonts:
\r
1746 for (i=0; i<NUM_FONTS; i++) {
\r
1747 DeleteObject(&workFont[i].hf);
\r
1748 ParseFontName(font[boardSize][i]->def, &workFont[i].mfp);
\r
1749 CreateFontInMF(&workFont[i]);
\r
1751 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1752 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1753 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1754 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1755 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1756 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1757 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1758 SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]);
\r
1766 FontsOptionsPopup(HWND hwnd)
\r
1768 FARPROC lpProc = MakeProcInstance((FARPROC)FontOptionsDialog, hInst);
\r
1769 DialogBox(hInst, MAKEINTRESOURCE(DLG_Fonts), hwnd,
\r
1770 (DLGPROC) lpProc);
\r
1771 FreeProcInstance(lpProc);
\r
1774 /*---------------------------------------------------------------------------*\
\r
1776 * Sounds Dialog functions
\r
1778 \*---------------------------------------------------------------------------*/
\r
1781 SoundComboData soundComboData[] = {
\r
1782 {N_("Move"), NULL},
\r
1783 {N_("Bell"), NULL},
\r
1784 {N_("ICS Alarm"), NULL},
\r
1785 {N_("ICS Win"), NULL},
\r
1786 {N_("ICS Loss"), NULL},
\r
1787 {N_("ICS Draw"), NULL},
\r
1788 {N_("ICS Unfinished"), NULL},
\r
1789 {N_("Shout"), NULL},
\r
1790 {N_("SShout/CShout"), NULL},
\r
1791 {N_("Channel 1"), NULL},
\r
1792 {N_("Channel"), NULL},
\r
1793 {N_("Kibitz"), NULL},
\r
1794 {N_("Tell"), NULL},
\r
1795 {N_("Challenge"), NULL},
\r
1796 {N_("Request"), NULL},
\r
1797 {N_("Seek"), NULL},
\r
1803 InitSoundComboData(SoundComboData *scd)
\r
1809 /* copy current sound settings to combo array */
\r
1811 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1812 scd[sc].name = strdup(sounds[sc].name);
\r
1814 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1815 index = (int)cc + (int)NSoundClasses;
\r
1816 scd[index].name = strdup(textAttribs[cc].sound.name);
\r
1822 ResetSoundComboData(SoundComboData *scd)
\r
1824 while (scd->label) {
\r
1825 if (scd->name != NULL) {
\r
1834 InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
\r
1839 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
1841 /* send the labels to the combo box */
\r
1842 while (scd->label) {
\r
1843 err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) T_(scd->label));
\r
1844 if (err != cnt++) {
\r
1845 snprintf(buf, MSG_SIZ, "InitSoundCombo(): err '%d', cnt '%d'\n",
\r
1846 (int)err, (int)cnt);
\r
1847 MessageBox(NULL, buf, NULL, MB_OK);
\r
1851 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
1855 SoundDialogWhichRadio(HWND hDlg)
\r
1857 if (IsDlgButtonChecked(hDlg, OPT_NoSound)) return OPT_NoSound;
\r
1858 if (IsDlgButtonChecked(hDlg, OPT_DefaultBeep)) return OPT_DefaultBeep;
\r
1859 if (IsDlgButtonChecked(hDlg, OPT_BuiltInSound)) return OPT_BuiltInSound;
\r
1860 if (IsDlgButtonChecked(hDlg, OPT_WavFile)) return OPT_WavFile;
\r
1865 SoundDialogSetEnables(HWND hDlg, int radio)
\r
1867 EnableWindow(GetDlgItem(hDlg, OPT_BuiltInSoundName),
\r
1868 radio == OPT_BuiltInSound);
\r
1869 EnableWindow(GetDlgItem(hDlg, OPT_WavFileName), radio == OPT_WavFile);
\r
1870 EnableWindow(GetDlgItem(hDlg, OPT_BrowseSound), radio == OPT_WavFile);
\r
1874 SoundDialogGetName(HWND hDlg, int radio)
\r
1876 static char buf[MSG_SIZ], buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
1877 char *dummy, *ret;
\r
1882 case OPT_DefaultBeep:
\r
1884 case OPT_BuiltInSound:
\r
1886 GetDlgItemText(hDlg, OPT_BuiltInSoundName, buf + 1, sizeof(buf) - 1);
\r
1889 GetDlgItemText(hDlg, OPT_WavFileName, buf, sizeof(buf));
\r
1890 GetCurrentDirectory(MSG_SIZ, buf3);
\r
1891 SetCurrentDirectory(installDir);
\r
1892 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
1897 SetCurrentDirectory(buf3);
\r
1903 DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
\r
1907 * I think it's best to clear the combo and edit boxes. It looks stupid
\r
1908 * to have a value from another sound event sitting there grayed out.
\r
1910 SetDlgItemText(hDlg, OPT_WavFileName, "");
\r
1911 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1913 if (appData.debugMode)
\r
1914 fprintf(debugFP, "DisplaySelectedSound(,,'%s'):\n", name);
\r
1915 switch (name[0]) {
\r
1917 radio = OPT_NoSound;
\r
1920 if (name[1] == NULLCHAR) {
\r
1921 radio = OPT_DefaultBeep;
\r
1923 radio = OPT_WavFile;
\r
1924 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1928 if (name[1] == NULLCHAR) {
\r
1929 radio = OPT_NoSound;
\r
1931 radio = OPT_BuiltInSound;
\r
1932 if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1,
\r
1933 (LPARAM) (name + 1)) == CB_ERR) {
\r
1934 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1935 SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1));
\r
1940 radio = OPT_WavFile;
\r
1941 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1944 SoundDialogSetEnables(hDlg, radio);
\r
1945 CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio);
\r
1949 char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES;
\r
1952 SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1954 static HWND hSoundCombo;
\r
1955 static DWORD index;
\r
1956 static HWND hBISN;
\r
1960 char buf[MSG_SIZ];
\r
1964 SoundComboData *scd;
\r
1967 switch (message) {
\r
1968 case WM_INITDIALOG:
\r
1969 /* Center the dialog over the application window */
\r
1970 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1971 Translate(hDlg, DLG_Sound);
\r
1973 /* Initialize the built-in sounds combo */
\r
1974 hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName);
\r
1975 InitComboStrings(hBISN, builtInSoundNames);
\r
1977 /* Initialize the sound events combo */
\r
1979 InitSoundComboData(soundComboData);
\r
1980 hSoundCombo = GetDlgItem(hDlg, CBO_Sounds);
\r
1981 InitSoundCombo(hSoundCombo, soundComboData);
\r
1983 /* update the dialog */
\r
1984 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1987 case WM_COMMAND: /* message: received a command */
\r
1989 if (((HWND)lParam == hSoundCombo) &&
\r
1990 (HIWORD(wParam) == CBN_SELCHANGE)) {
\r
1992 * the user has selected a new sound event. We must store the name for
\r
1993 * the previously selected event, then retrieve the name for the
\r
1994 * newly selected event and update the dialog.
\r
1996 radio = SoundDialogWhichRadio(hDlg);
\r
1997 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1999 if (strcmp(newName, soundComboData[index].name) != 0) {
\r
2000 free(soundComboData[index].name);
\r
2001 soundComboData[index].name = newName;
\r
2006 /* now get the settings for the newly selected event */
\r
2007 index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
\r
2008 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
2012 switch (LOWORD(wParam)) {
\r
2015 * save the name for the currently selected sound event
\r
2017 radio = SoundDialogWhichRadio(hDlg);
\r
2018 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
2020 if (strcmp(soundComboData[index].name, newName) != 0) {
\r
2021 free(soundComboData[index].name);
\r
2022 soundComboData[index].name = newName;
\r
2028 /* save all the sound names that changed and load the sounds */
\r
2030 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
2031 if (strcmp(soundComboData[sc].name, sounds[sc].name) != 0) {
\r
2032 free(sounds[sc].name);
\r
2033 sounds[sc].name = strdup(soundComboData[sc].name);
\r
2034 MyLoadSound(&sounds[sc]);
\r
2037 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
2038 index = (int)cc + (int)NSoundClasses;
\r
2039 if (strcmp(soundComboData[index].name,
\r
2040 textAttribs[cc].sound.name) != 0) {
\r
2041 free(textAttribs[cc].sound.name);
\r
2042 textAttribs[cc].sound.name = strdup(soundComboData[index].name);
\r
2043 MyLoadSound(&textAttribs[cc].sound);
\r
2047 mute = FALSE; // [HGM] mute: switch sounds automatically on if we select one
\r
2048 CheckMenuItem(GetMenu(hwndMain),IDM_MuteSounds,MF_BYCOMMAND|MF_UNCHECKED);
\r
2049 ResetSoundComboData(soundComboData);
\r
2050 EndDialog(hDlg, TRUE);
\r
2054 ResetSoundComboData(soundComboData);
\r
2055 EndDialog(hDlg, FALSE);
\r
2058 case OPT_DefaultSounds:
\r
2059 /* can't use SetDefaultSounds() because we need to be able to "undo" if
\r
2060 * user selects "Cancel" later on. So we do it the hard way here.
\r
2062 scd = &soundComboData[0];
\r
2063 while (scd->label != NULL) {
\r
2064 if (scd->name != NULL) free(scd->name);
\r
2065 scd->name = strdup("");
\r
2068 free(soundComboData[(int)SoundBell].name);
\r
2069 soundComboData[(int)SoundBell].name = strdup(SOUND_BELL);
\r
2070 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
2073 case OPT_PlaySound:
\r
2074 radio = SoundDialogWhichRadio(hDlg);
\r
2075 tmp.name = strdup(SoundDialogGetName(hDlg, radio));
\r
2077 MyLoadSound(&tmp);
\r
2078 oldMute = mute; mute = FALSE; // [HGM] mute: always sound when user presses play, ignorig mute setting
\r
2079 MyPlaySound(&tmp);
\r
2081 if (tmp.data != NULL) FreeResource(tmp.data); // technically obsolete fn, but tmp.data is NOT malloc'd mem
\r
2082 if (tmp.name != NULL) free(tmp.name);
\r
2085 case OPT_BrowseSound:
\r
2086 f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT,
\r
2087 _("Browse for Sound File"), NULL, NULL, buf);
\r
2090 SetDlgItemText(hDlg, OPT_WavFileName, buf);
\r
2095 radio = SoundDialogWhichRadio(hDlg);
\r
2096 SoundDialogSetEnables(hDlg, radio);
\r
2105 VOID SoundOptionsPopup(HWND hwnd)
\r
2109 lpProc = MakeProcInstance((FARPROC)SoundOptionsDialog, hInst);
\r
2110 DialogBox(hInst, MAKEINTRESOURCE(DLG_Sound), hwnd, (DLGPROC)lpProc);
\r
2111 FreeProcInstance(lpProc);
\r
2115 /*---------------------------------------------------------------------------*\
\r
2117 * Comm Port dialog functions
\r
2119 \*---------------------------------------------------------------------------*/
\r
2122 #define FLOW_NONE 0
\r
2123 #define FLOW_XOFF 1
\r
2124 #define FLOW_CTS 2
\r
2125 #define FLOW_DSR 3
\r
2129 ComboData cdPort[] = { {"None", PORT_NONE}, {"COM1", 1}, {"COM2", 2},
\r
2130 {"COM3", 3}, {"COM4", 4}, {NULL, 0} };
\r
2131 ComboData cdDataRate[] = { {"110", 110}, {"300", 300}, {"600", 600}, {"1200", 1200},
\r
2132 {"2400", 2400}, {"4800", 4800}, {"9600", 9600}, {"19200", 19200},
\r
2133 {"38400", 38400}, {NULL, 0} };
\r
2134 ComboData cdDataBits[] = { {"5", 5}, {"6", 6}, {"7", 7}, {"8", 8}, {NULL, 0} };
\r
2135 ComboData cdParity[] = { {"None", NOPARITY}, {"Odd", ODDPARITY}, {"Even", EVENPARITY},
\r
2136 {"Mark", MARKPARITY}, {"Space", SPACEPARITY}, {NULL, 0} };
\r
2137 ComboData cdStopBits[] = { {"1", ONESTOPBIT}, {"1.5", ONE5STOPBITS},
\r
2138 {"2", TWOSTOPBITS}, {NULL, 0} };
\r
2139 ComboData cdFlow[] = { {"None", FLOW_NONE}, {"Xoff/Xon", FLOW_XOFF}, {"CTS", FLOW_CTS},
\r
2140 {"DSR", FLOW_DSR}, {NULL, 0} };
\r
2144 ParseCommSettings(char *arg, DCB *dcb)
\r
2146 int dataRate, count;
\r
2147 char bits[MSG_SIZ], parity[MSG_SIZ], stopBits[MSG_SIZ], flow[MSG_SIZ];
\r
2149 count = sscanf(arg, "%d%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]",
\r
2150 &dataRate, bits, parity, stopBits, flow);
\r
2151 if (count != 5) goto cant_parse;
\r
2152 dcb->BaudRate = dataRate;
\r
2154 while (cd->label != NULL) {
\r
2155 if (StrCaseCmp(cd->label, bits) == 0) {
\r
2156 dcb->ByteSize = cd->value;
\r
2161 if (cd->label == NULL) goto cant_parse;
\r
2163 while (cd->label != NULL) {
\r
2164 if (StrCaseCmp(cd->label, parity) == 0) {
\r
2165 dcb->Parity = cd->value;
\r
2170 if (cd->label == NULL) goto cant_parse;
\r
2172 while (cd->label != NULL) {
\r
2173 if (StrCaseCmp(cd->label, stopBits) == 0) {
\r
2174 dcb->StopBits = cd->value;
\r
2180 if (cd->label == NULL) goto cant_parse;
\r
2181 while (cd->label != NULL) {
\r
2182 if (StrCaseCmp(cd->label, flow) == 0) {
\r
2183 switch (cd->value) {
\r
2185 dcb->fOutX = FALSE;
\r
2186 dcb->fOutxCtsFlow = FALSE;
\r
2187 dcb->fOutxDsrFlow = FALSE;
\r
2190 dcb->fOutX = FALSE;
\r
2191 dcb->fOutxCtsFlow = TRUE;
\r
2192 dcb->fOutxDsrFlow = FALSE;
\r
2195 dcb->fOutX = FALSE;
\r
2196 dcb->fOutxCtsFlow = FALSE;
\r
2197 dcb->fOutxDsrFlow = TRUE;
\r
2200 dcb->fOutX = TRUE;
\r
2201 dcb->fOutxCtsFlow = FALSE;
\r
2202 dcb->fOutxDsrFlow = FALSE;
\r
2209 if (cd->label == NULL) goto cant_parse;
\r
2212 ExitArgError(_("Can't parse com port settings"), arg, TRUE);
\r
2216 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
\r
2218 char *flow = "??", *parity = "??", *stopBits = "??";
\r
2222 while (cd->label != NULL) {
\r
2223 if (dcb->Parity == cd->value) {
\r
2224 parity = cd->label;
\r
2230 while (cd->label != NULL) {
\r
2231 if (dcb->StopBits == cd->value) {
\r
2232 stopBits = cd->label;
\r
2238 flow = cdFlow[FLOW_XOFF].label;
\r
2239 } else if (dcb->fOutxCtsFlow) {
\r
2240 flow = cdFlow[FLOW_CTS].label;
\r
2241 } else if (dcb->fOutxDsrFlow) {
\r
2242 flow = cdFlow[FLOW_DSR].label;
\r
2244 flow = cdFlow[FLOW_NONE].label;
\r
2246 fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name,
\r
2247 (int)dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow);
\r
2252 InitCombo(HANDLE hwndCombo, ComboData *cd)
\r
2254 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
2256 while (cd->label != NULL) {
\r
2257 SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) cd->label);
\r
2263 SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value)
\r
2268 while (cd->label != NULL) {
\r
2269 if (cd->value == value) {
\r
2270 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) i, (LPARAM) 0);
\r
2279 CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2281 char buf[MSG_SIZ];
\r
2288 switch (message) {
\r
2289 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2290 /* Center the dialog over the application window */
\r
2291 CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER));
\r
2292 Translate(hDlg, DLG_CommPort);
\r
2293 /* Initialize the dialog items */
\r
2294 /* !! There should probably be some synchronization
\r
2295 in accessing hCommPort and dcb. Or does modal nature
\r
2296 of this dialog box do it for us?
\r
2298 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2299 InitCombo(hwndCombo, cdPort);
\r
2300 p = strrchr(appData.icsCommPort, '\\');
\r
2301 if (p++ == NULL) p = appData.icsCommPort;
\r
2302 if ((*p == '\0') ||
\r
2303 (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) p) == CB_ERR)) {
\r
2304 SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) "None");
\r
2306 EnableWindow(hwndCombo, hCommPort == NULL); /*!! don't allow change for now*/
\r
2308 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2309 InitCombo(hwndCombo, cdDataRate);
\r
2310 snprintf(buf, MSG_SIZ, "%u", (int)dcb.BaudRate);
\r
2311 if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) {
\r
2312 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
2313 SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf);
\r
2316 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2317 InitCombo(hwndCombo, cdDataBits);
\r
2318 SelectComboValue(hwndCombo, cdDataBits, dcb.ByteSize);
\r
2320 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2321 InitCombo(hwndCombo, cdParity);
\r
2322 SelectComboValue(hwndCombo, cdParity, dcb.Parity);
\r
2324 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2325 InitCombo(hwndCombo, cdStopBits);
\r
2326 SelectComboValue(hwndCombo, cdStopBits, dcb.StopBits);
\r
2328 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2329 InitCombo(hwndCombo, cdFlow);
\r
2331 SelectComboValue(hwndCombo, cdFlow, FLOW_XOFF);
\r
2332 } else if (dcb.fOutxCtsFlow) {
\r
2333 SelectComboValue(hwndCombo, cdFlow, FLOW_CTS);
\r
2334 } else if (dcb.fOutxDsrFlow) {
\r
2335 SelectComboValue(hwndCombo, cdFlow, FLOW_DSR);
\r
2337 SelectComboValue(hwndCombo, cdFlow, FLOW_NONE);
\r
2341 case WM_COMMAND: /* message: received a command */
\r
2342 switch (LOWORD(wParam)) {
\r
2344 /* Read changed options from the dialog box */
\r
2346 /* !! Currently we can't change comm ports in midstream */
\r
2347 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2348 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2349 if (index == PORT_NONE) {
\r
2350 appData.icsCommPort = "";
\r
2351 if (hCommPort != NULL) {
\r
2352 CloseHandle(hCommPort);
\r
2355 EndDialog(hDlg, TRUE);
\r
2358 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2359 appData.icsCommPort = strdup(buf);
\r
2360 if (hCommPort != NULL) {
\r
2361 CloseHandle(hCommPort);
\r
2364 /* now what?? can't really do this; have to fix up the ChildProc
\r
2365 and InputSource records for the comm port that we gave to the
\r
2369 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2370 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2371 if (sscanf(buf, "%u", &value) != 1) {
\r
2372 MessageBox(hDlg, _("Invalid data rate"),
\r
2373 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2376 dcb.BaudRate = value;
\r
2378 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2379 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2380 dcb.ByteSize = cdDataBits[index].value;
\r
2382 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2383 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2384 dcb.Parity = cdParity[index].value;
\r
2386 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2387 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2388 dcb.StopBits = cdStopBits[index].value;
\r
2390 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2391 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2392 switch (cdFlow[index].value) {
\r
2394 dcb.fOutX = FALSE;
\r
2395 dcb.fOutxCtsFlow = FALSE;
\r
2396 dcb.fOutxDsrFlow = FALSE;
\r
2399 dcb.fOutX = FALSE;
\r
2400 dcb.fOutxCtsFlow = TRUE;
\r
2401 dcb.fOutxDsrFlow = FALSE;
\r
2404 dcb.fOutX = FALSE;
\r
2405 dcb.fOutxCtsFlow = FALSE;
\r
2406 dcb.fOutxDsrFlow = TRUE;
\r
2410 dcb.fOutxCtsFlow = FALSE;
\r
2411 dcb.fOutxDsrFlow = FALSE;
\r
2414 if (!SetCommState(hCommPort, (LPDCB) &dcb)) {
\r
2415 err = GetLastError();
\r
2416 switch(MessageBox(hDlg,
\r
2417 "Failed to set comm port state;\r\ninvalid options?",
\r
2418 _("Option Error"), MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {
\r
2420 DisplayFatalError(_("Failed to set comm port state"), err, 1);
\r
2421 exit(1); /*is it ok to do this from here?*/
\r
2427 EndDialog(hDlg, TRUE);
\r
2432 EndDialog(hDlg, TRUE);
\r
2436 EndDialog(hDlg, FALSE);
\r
2448 CommPortOptionsPopup(HWND hwnd)
\r
2450 FARPROC lpProc = MakeProcInstance((FARPROC)CommPortOptionsDialog, hInst);
\r
2451 DialogBox(hInst, MAKEINTRESOURCE(DLG_CommPort), hwnd, (DLGPROC) lpProc);
\r
2452 FreeProcInstance(lpProc);
\r
2455 /*---------------------------------------------------------------------------*\
\r
2457 * Load Options dialog functions
\r
2459 \*---------------------------------------------------------------------------*/
\r
2462 LoadOptionsWhichRadio(HWND hDlg)
\r
2464 return (IsDlgButtonChecked(hDlg, OPT_Exact) ? 1 :
\r
2465 (IsDlgButtonChecked(hDlg, OPT_Subset) ? 2 :
\r
2466 (IsDlgButtonChecked(hDlg, OPT_Struct) ? 3 :
\r
2467 (IsDlgButtonChecked(hDlg, OPT_Material) ? 4 :
\r
2468 (IsDlgButtonChecked(hDlg, OPT_Range) ? 5 :
\r
2469 (IsDlgButtonChecked(hDlg, OPT_Difference) ? 6 : -1))))));
\r
2473 SetLoadOptionEnables(HWND hDlg)
\r
2477 state = IsDlgButtonChecked(hDlg, OPT_Autostep);
\r
2478 EnableWindow(GetDlgItem(hDlg, OPT_ASTimeDelay), state);
\r
2479 EnableWindow(GetDlgItem(hDlg, OPT_AStext1), state);
\r
2483 LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2485 char buf[MSG_SIZ];
\r
2489 switch (message) {
\r
2490 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2491 /* Center the dialog over the application window */
\r
2492 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2493 Translate(hDlg, DLG_LoadOptions);
\r
2494 /* Initialize the dialog items */
\r
2495 if (appData.timeDelay >= 0.0) {
\r
2496 CheckDlgButton(hDlg, OPT_Autostep, TRUE);
\r
2497 snprintf(buf, MSG_SIZ, "%.2g", appData.timeDelay);
\r
2498 SetDlgItemText(hDlg, OPT_ASTimeDelay, buf);
\r
2500 CheckDlgButton(hDlg, OPT_Autostep, FALSE);
\r
2502 SetLoadOptionEnables(hDlg);
\r
2503 SetDlgItemInt(hDlg, OPT_elo1, appData.eloThreshold1, FALSE);
\r
2504 SetDlgItemInt(hDlg, OPT_elo2, appData.eloThreshold2, FALSE);
\r
2505 SetDlgItemInt(hDlg, OPT_date, appData.dateThreshold, FALSE);
\r
2506 SetDlgItemInt(hDlg, OPT_Stretch, appData.stretch, FALSE);
\r
2507 CheckDlgButton(hDlg, OPT_Reversed, appData.ignoreColors);
\r
2508 CheckDlgButton(hDlg, OPT_Mirror, appData.findMirror);
\r
2509 switch (appData.searchMode) {
\r
2511 CheckDlgButton(hDlg, OPT_Exact, TRUE);
\r
2514 CheckDlgButton(hDlg, OPT_Subset, TRUE);
\r
2517 CheckDlgButton(hDlg, OPT_Struct, TRUE);
\r
2520 CheckDlgButton(hDlg, OPT_Material, TRUE);
\r
2523 CheckDlgButton(hDlg, OPT_Range, TRUE);
\r
2526 CheckDlgButton(hDlg, OPT_Difference, TRUE);
\r
2531 case WM_COMMAND: /* message: received a command */
\r
2532 switch (LOWORD(wParam)) {
\r
2534 /* Read changed options from the dialog box */
\r
2535 if (IsDlgButtonChecked(hDlg, OPT_Autostep)) {
\r
2536 GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ);
\r
2537 if (sscanf(buf, "%f", &fnumber) != 1) {
\r
2538 MessageBox(hDlg, _("Invalid load game step rate"),
\r
2539 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2542 appData.timeDelay = fnumber;
\r
2544 appData.timeDelay = (float) -1.0;
\r
2546 appData.eloThreshold1 = GetDlgItemInt(hDlg, OPT_elo1, &ok, FALSE);
\r
2547 appData.eloThreshold2 = GetDlgItemInt(hDlg, OPT_elo2, &ok, FALSE);
\r
2548 appData.dateThreshold = GetDlgItemInt(hDlg, OPT_date, &ok, FALSE);
\r
2549 appData.stretch = GetDlgItemInt(hDlg, OPT_Stretch, &ok, FALSE);
\r
2550 appData.searchMode = LoadOptionsWhichRadio(hDlg);
\r
2551 appData.ignoreColors = IsDlgButtonChecked(hDlg, OPT_Reversed);
\r
2552 appData.findMirror = IsDlgButtonChecked(hDlg, OPT_Mirror);
\r
2553 EndDialog(hDlg, TRUE);
\r
2557 EndDialog(hDlg, FALSE);
\r
2561 SetLoadOptionEnables(hDlg);
\r
2571 LoadOptionsPopup(HWND hwnd)
\r
2573 FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst);
\r
2574 DialogBox(hInst, MAKEINTRESOURCE(DLG_LoadOptions), hwnd, (DLGPROC) lpProc);
\r
2575 FreeProcInstance(lpProc);
\r
2578 /*---------------------------------------------------------------------------*\
\r
2580 * Save Options dialog functions
\r
2582 \*---------------------------------------------------------------------------*/
\r
2585 SetSaveOptionEnables(HWND hDlg)
\r
2589 state = IsDlgButtonChecked(hDlg, OPT_Autosave);
\r
2590 EnableWindow(GetDlgItem(hDlg, OPT_AVPrompt), state);
\r
2591 EnableWindow(GetDlgItem(hDlg, OPT_AVToFile), state);
\r
2592 if (state && !IsDlgButtonChecked(hDlg, OPT_AVPrompt) &&
\r
2593 !IsDlgButtonChecked(hDlg, OPT_AVToFile)) {
\r
2594 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2597 state = state && IsDlgButtonChecked(hDlg, OPT_AVToFile);
\r
2598 EnableWindow(GetDlgItem(hDlg, OPT_AVFilename), state);
\r
2599 EnableWindow(GetDlgItem(hDlg, OPT_AVBrowse), state);
\r
2603 SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2605 char buf[MSG_SIZ];
\r
2608 switch (message) {
\r
2609 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2610 /* Center the dialog over the application window */
\r
2611 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2612 Translate(hDlg, DLG_SaveOptions);
\r
2613 /* Initialize the dialog items */
\r
2614 if (*appData.saveGameFile != NULLCHAR) {
\r
2615 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2616 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVToFile);
\r
2617 SetDlgItemText(hDlg, OPT_AVFilename, appData.saveGameFile);
\r
2618 } else if (appData.autoSaveGames) {
\r
2619 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2620 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2622 CheckDlgButton(hDlg, OPT_Autosave, (UINT) FALSE);
\r
2624 if (appData.oldSaveStyle) {
\r
2625 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_Old);
\r
2627 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_PGN);
\r
2629 CheckDlgButton( hDlg, OPT_OutOfBookInfo, appData.saveOutOfBookInfo );
\r
2630 SetSaveOptionEnables(hDlg);
\r
2633 case WM_COMMAND: /* message: received a command */
\r
2634 switch (LOWORD(wParam)) {
\r
2636 /* Read changed options from the dialog box */
\r
2637 if (IsDlgButtonChecked(hDlg, OPT_Autosave)) {
\r
2638 appData.autoSaveGames = TRUE;
\r
2639 if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) {
\r
2640 ASSIGN(appData.saveGameFile, ""); // [HGM] make sure value is ALWAYS in allocated memory
\r
2641 } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ {
\r
2642 GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ);
\r
2643 if (*buf == NULLCHAR) {
\r
2644 MessageBox(hDlg, _("Invalid save game file name"),
\r
2645 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2648 FREE(appData.saveGameFile);
\r
2649 appData.saveGameFile = InterpretFileName(buf, homeDir);
\r
2652 appData.autoSaveGames = FALSE;
\r
2653 ASSIGN(appData.saveGameFile, "");
\r
2655 appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old);
\r
2656 appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo );
\r
2657 EndDialog(hDlg, TRUE);
\r
2661 EndDialog(hDlg, FALSE);
\r
2664 case OPT_AVBrowse:
\r
2665 f = OpenFileDialog(hDlg, "a", NULL,
\r
2666 appData.oldSaveStyle ? "gam" : "pgn",
\r
2667 GAME_FILT, _("Browse for Auto Save File"),
\r
2671 SetDlgItemText(hDlg, OPT_AVFilename, buf);
\r
2676 SetSaveOptionEnables(hDlg);
\r
2685 SaveOptionsPopup(HWND hwnd)
\r
2687 FARPROC lpProc = MakeProcInstance((FARPROC)SaveOptionsDialog, hInst);
\r
2688 DialogBox(hInst, MAKEINTRESOURCE(DLG_SaveOptions), hwnd, (DLGPROC) lpProc);
\r
2689 FreeProcInstance(lpProc);
\r
2692 /*---------------------------------------------------------------------------*\
\r
2694 * Time Control Options dialog functions
\r
2696 \*---------------------------------------------------------------------------*/
\r
2699 SetTimeControlEnables(HWND hDlg)
\r
2703 state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves)
\r
2704 + 2*IsDlgButtonChecked(hDlg, OPT_TCUseFixed);
\r
2705 EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state == 1);
\r
2706 EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state == 1);
\r
2707 EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state == 1);
\r
2708 EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state == 1);
\r
2709 EnableWindow(GetDlgItem(hDlg, OPT_TCTime2), !state);
\r
2710 EnableWindow(GetDlgItem(hDlg, OPT_TCInc), !state);
\r
2711 EnableWindow(GetDlgItem(hDlg, OPT_TCitext1), !state);
\r
2712 EnableWindow(GetDlgItem(hDlg, OPT_TCitext2), !state);
\r
2713 EnableWindow(GetDlgItem(hDlg, OPT_TCitext3), !state);
\r
2714 EnableWindow(GetDlgItem(hDlg, OPT_TCFixed), state == 2);
\r
2715 EnableWindow(GetDlgItem(hDlg, OPT_TCftext), state == 2);
\r
2720 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2722 char buf[MSG_SIZ], *tc;
\r
2723 int mps, odds1, odds2, st;
\r
2727 switch (message) {
\r
2728 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2729 /* Center the dialog over the application window */
\r
2730 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2731 Translate(hDlg, DLG_TimeControl);
\r
2732 /* Initialize the dialog items */
\r
2733 if (/*appData.clockMode &&*/ !appData.icsActive) { // [HGM] even if !clockMode, we could want to set it in tournament dialog
\r
2735 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,
\r
2737 SetDlgItemInt(hDlg, OPT_TCFixed, searchTime, FALSE);
\r
2739 if (appData.timeIncrement == -1) {
\r
2740 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,
\r
2742 SetDlgItemText(hDlg, OPT_TCTime, appData.timeControl);
\r
2743 SetDlgItemInt(hDlg, OPT_TCMoves, appData.movesPerSession,
\r
2745 SetDlgItemText(hDlg, OPT_TCTime2, "");
\r
2746 SetDlgItemText(hDlg, OPT_TCInc, "");
\r
2748 int i = appData.timeIncrement;
\r
2749 if(i == appData.timeIncrement) snprintf(buf, MSG_SIZ, "%d", i);
\r
2750 else snprintf(buf, MSG_SIZ, "%4.2f", appData.timeIncrement);
\r
2751 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,
\r
2753 SetDlgItemText(hDlg, OPT_TCTime, "");
\r
2754 SetDlgItemText(hDlg, OPT_TCMoves, "");
\r
2755 SetDlgItemText(hDlg, OPT_TCTime2, appData.timeControl);
\r
2756 SetDlgItemText(hDlg, OPT_TCInc, buf);
\r
2758 SetDlgItemInt(hDlg, OPT_TCOdds1, 1, FALSE);
\r
2759 SetDlgItemInt(hDlg, OPT_TCOdds2, 1, FALSE);
\r
2760 SetTimeControlEnables(hDlg);
\r
2764 case WM_COMMAND: /* message: received a command */
\r
2765 switch (LOWORD(wParam)) {
\r
2767 mps = appData.movesPerSession;
\r
2768 increment = appData.timeIncrement;
\r
2769 tc = appData.timeControl;
\r
2771 /* Read changed options from the dialog box */
\r
2772 if (IsDlgButtonChecked(hDlg, OPT_TCUseFixed)) {
\r
2773 st = GetDlgItemInt(hDlg, OPT_TCFixed, &ok, FALSE);
\r
2774 if (!ok || st <= 0) {
\r
2775 MessageBox(hDlg, _("Invalid max time per move"),
\r
2776 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2780 if (IsDlgButtonChecked(hDlg, OPT_TCUseMoves)) {
\r
2782 mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE);
\r
2783 if (!ok || mps <= 0) {
\r
2784 MessageBox(hDlg, _("Invalid moves per time control"),
\r
2785 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2788 GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ);
\r
2789 if (!ParseTimeControl(buf, increment, mps)) {
\r
2790 MessageBox(hDlg, _("Invalid minutes per time control"),
\r
2791 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2796 GetDlgItemText(hDlg, OPT_TCInc, buf, MSG_SIZ);
\r
2797 ok = (sscanf(buf, "%f%c", &increment, buf) == 1);
\r
2798 if (!ok || increment < 0) {
\r
2799 MessageBox(hDlg, _("Invalid increment"),
\r
2800 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2803 GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ);
\r
2804 if (!ParseTimeControl(buf, increment, mps)) {
\r
2805 MessageBox(hDlg, _("Invalid initial time"),
\r
2806 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2811 odds1 = GetDlgItemInt(hDlg, OPT_TCOdds1, &ok, FALSE);
\r
2812 odds2 = GetDlgItemInt(hDlg, OPT_TCOdds2, &ok2, FALSE);
\r
2813 if (!ok || !ok2 || odds1 <= 0 || odds2 <= 0) {
\r
2814 MessageBox(hDlg, _("Invalid time-odds factor"),
\r
2815 _("Option Error"), MB_OK|MB_ICONEXCLAMATION);
\r
2819 appData.timeControl = strdup(tc);
\r
2820 appData.movesPerSession = mps;
\r
2821 appData.timeIncrement = increment;
\r
2822 appData.firstTimeOdds = first.timeOdds = odds1;
\r
2823 appData.secondTimeOdds = second.timeOdds = odds2;
\r
2824 Reset(TRUE, TRUE);
\r
2825 EndDialog(hDlg, TRUE);
\r
2829 EndDialog(hDlg, FALSE);
\r
2833 SetTimeControlEnables(hDlg);
\r
2842 TimeControlOptionsPopup(HWND hwnd)
\r
2844 if (gameMode != BeginningOfGame) {
\r
2845 DisplayError(_("Changing time control during a game is not implemented"), 0);
\r
2847 FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst);
\r
2848 DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc);
\r
2849 FreeProcInstance(lpProc);
\r
2853 /*---------------------------------------------------------------------------*\
\r
2855 * Engine Options Dialog functions
\r
2857 \*---------------------------------------------------------------------------*/
\r
2858 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
2859 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
2861 #define INT_ABS( n ) ((n) >= 0 ? (n) : -(n))
\r
2863 LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2865 switch (message) {
\r
2866 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2868 /* Center the dialog over the application window */
\r
2869 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2870 Translate(hDlg, DLG_EnginePlayOptions);
\r
2872 /* Initialize the dialog items */
\r
2873 CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates);
\r
2874 CHECK_BOX(IDC_EpPonder, appData.ponderNextMove);
\r
2875 CHECK_BOX(IDC_EpShowThinking, appData.showThinking);
\r
2876 CHECK_BOX(IDC_EpHideThinkingHuman, appData.hideThinkingFromHuman);
\r
2878 CHECK_BOX(IDC_TestClaims, appData.testClaims);
\r
2879 CHECK_BOX(IDC_DetectMates, appData.checkMates);
\r
2880 CHECK_BOX(IDC_MaterialDraws, appData.materialDraws);
\r
2881 CHECK_BOX(IDC_TrivialDraws, appData.trivialDraws);
\r
2883 CHECK_BOX(IDC_ScoreAbs1, appData.firstScoreIsAbsolute);
\r
2884 CHECK_BOX(IDC_ScoreAbs2, appData.secondScoreIsAbsolute);
\r
2886 SetDlgItemInt( hDlg, IDC_EpDrawMoveCount, appData.adjudicateDrawMoves, TRUE );
\r
2887 SendDlgItemMessage( hDlg, IDC_EpDrawMoveCount, EM_SETSEL, 0, -1 );
\r
2889 SetDlgItemInt( hDlg, IDC_EpAdjudicationThreshold, INT_ABS(appData.adjudicateLossThreshold), TRUE );
\r
2890 SendDlgItemMessage( hDlg, IDC_EpAdjudicationThreshold, EM_SETSEL, 0, -1 );
\r
2892 SetDlgItemInt( hDlg, IDC_RuleMoves, appData.ruleMoves, TRUE );
\r
2893 SendDlgItemMessage( hDlg, IDC_RuleMoves, EM_SETSEL, 0, -1 );
\r
2895 SetDlgItemInt( hDlg, IDC_DrawRepeats, INT_ABS(appData.drawRepeats), TRUE );
\r
2896 SendDlgItemMessage( hDlg, IDC_DrawRepeats, EM_SETSEL, 0, -1 );
\r
2900 case WM_COMMAND: /* message: received a command */
\r
2901 switch (LOWORD(wParam)) {
\r
2903 /* Read changed options from the dialog box */
\r
2904 PeriodicUpdatesEvent( IS_CHECKED(IDC_EpPeriodicUpdates));
\r
2905 PonderNextMoveEvent( IS_CHECKED(IDC_EpPonder));
\r
2906 appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up
\r
2907 appData.showThinking = IS_CHECKED(IDC_EpShowThinking);
\r
2908 ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output
\r
2909 appData.testClaims = IS_CHECKED(IDC_TestClaims);
\r
2910 appData.checkMates = IS_CHECKED(IDC_DetectMates);
\r
2911 appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);
\r
2912 appData.trivialDraws = IS_CHECKED(IDC_TrivialDraws);
\r
2914 appData.adjudicateDrawMoves = GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, NULL, FALSE );
\r
2915 appData.adjudicateLossThreshold = - (int) GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, NULL, FALSE );
\r
2916 appData.ruleMoves = GetDlgItemInt(hDlg, IDC_RuleMoves, NULL, FALSE );
\r
2917 appData.drawRepeats = (int) GetDlgItemInt(hDlg, IDC_DrawRepeats, NULL, FALSE );
\r
2919 first.scoreIsAbsolute = appData.firstScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs1);
\r
2920 second.scoreIsAbsolute = appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2);
\r
2922 EndDialog(hDlg, TRUE);
\r
2926 EndDialog(hDlg, FALSE);
\r
2929 case IDC_EpDrawMoveCount:
\r
2930 case IDC_EpAdjudicationThreshold:
\r
2931 case IDC_DrawRepeats:
\r
2932 case IDC_RuleMoves:
\r
2933 if( HIWORD(wParam) == EN_CHANGE ) {
\r
2939 GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, &n1_ok, FALSE );
\r
2940 GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, &n2_ok, FALSE );
\r
2941 GetDlgItemInt(hDlg, IDC_RuleMoves, &n3_ok, FALSE );
\r
2942 GetDlgItemInt(hDlg, IDC_DrawRepeats, &n4_ok, FALSE );
\r
2944 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok && n4_ok ? TRUE : FALSE );
\r
2953 VOID EnginePlayOptionsPopup(HWND hwnd)
\r
2957 lpProc = MakeProcInstance((FARPROC)EnginePlayOptionsDialog, hInst);
\r
2958 DialogBox(hInst, MAKEINTRESOURCE(DLG_EnginePlayOptions), hwnd, (DLGPROC) lpProc);
\r
2959 FreeProcInstance(lpProc);
\r
2962 /*---------------------------------------------------------------------------*\
\r
2964 * UCI Options Dialog functions
\r
2966 \*---------------------------------------------------------------------------*/
\r
2967 INT CALLBACK BrowseCallbackProc(HWND hwnd,
\r
2974 case BFFM_INITIALIZED:
\r
2975 SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)pData);
\r
2981 BOOL BrowseForFolder( const char * title, char * path )
\r
2983 BOOL result = FALSE;
\r
2985 LPITEMIDLIST pidl;
\r
2987 ZeroMemory( &bi, sizeof(bi) );
\r
2989 bi.lpszTitle = title == 0 ? _("Choose Folder") : title;
\r
2990 bi.ulFlags = BIF_RETURNONLYFSDIRS;
\r
2991 bi.lpfn = BrowseCallbackProc;
\r
2992 bi.lParam = (LPARAM) path;
\r
2994 pidl = SHBrowseForFolder( &bi );
\r
2997 IMalloc * imalloc = 0;
\r
2999 if( SHGetPathFromIDList( pidl, path ) ) {
\r
3003 if( SUCCEEDED( SHGetMalloc ( &imalloc ) ) ) {
\r
3004 imalloc->lpVtbl->Free(imalloc,pidl);
\r
3005 imalloc->lpVtbl->Release(imalloc);
\r
3013 IsMultiFormat(char *s)
\r
3015 char *p = strchr(s, ':');
\r
3016 return p && p != s+1;
\r
3019 LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
3021 char buf[MAX_PATH];
\r
3024 switch (message) {
\r
3025 case WM_INITDIALOG: /* message: initialize dialog box */
\r
3027 /* Center the dialog over the application window */
\r
3028 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
3029 Translate(hDlg, DLG_OptionsUCI);
\r
3031 /* Initialize the dialog items */
\r
3032 SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir );
\r
3033 SetDlgItemInt( hDlg, IDC_HashSize, appData.defaultHashSize, TRUE );
\r
3034 if(appData.defaultPathEGTB[0])
\r
3035 SetDlgItemText( hDlg, IDC_PathToEGTB, appData.defaultPathEGTB );
\r
3037 SetDlgItemText( hDlg, IDC_PathToEGTB, appData.egtFormats );
\r
3038 SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE );
\r
3039 CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook );
\r
3040 SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook );
\r
3041 // [HGM] smp: input field for nr of cores:
\r
3042 SetDlgItemInt( hDlg, IDC_Cores, appData.smpCores, TRUE );
\r
3043 // [HGM] book: tick boxes for own book use
\r
3044 CheckDlgButton( hDlg, IDC_OwnBook1, (BOOL) appData.firstHasOwnBookUCI );
\r
3045 CheckDlgButton( hDlg, IDC_OwnBook2, (BOOL) appData.secondHasOwnBookUCI );
\r
3046 SetDlgItemInt( hDlg, IDC_BookDep, appData.bookDepth, TRUE );
\r
3047 SetDlgItemInt( hDlg, IDC_BookStr, appData.bookStrength, TRUE );
\r
3048 SetDlgItemInt( hDlg, IDC_Games, appData.defaultMatchGames, TRUE );
\r
3050 SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 );
\r
3054 case WM_COMMAND: /* message: received a command */
\r
3055 switch (LOWORD(wParam)) {
\r
3057 GetDlgItemText( hDlg, IDC_PolyglotDir, buf, sizeof(buf) );
\r
3058 appData.polyglotDir = strdup(buf);
\r
3059 appData.defaultHashSize = GetDlgItemInt(hDlg, IDC_HashSize, NULL, FALSE );
\r
3060 appData.defaultCacheSizeEGTB = GetDlgItemInt(hDlg, IDC_SizeOfEGTB, NULL, FALSE );
\r
3061 GetDlgItemText( hDlg, IDC_PathToEGTB, buf, sizeof(buf) );
\r
3062 if(IsMultiFormat(buf)) {
\r
3063 ASSIGN(appData.egtFormats, buf);
\r
3065 ASSIGN(appData.defaultPathEGTB, buf);
\r
3067 GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) );
\r
3068 appData.polyglotBook = strdup(buf);
\r
3069 appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook );
\r
3070 // [HGM] smp: get nr of cores:
\r
3071 oldCores = appData.smpCores;
\r
3072 appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE );
\r
3073 if(appData.smpCores != oldCores) NewSettingEvent(FALSE, &(first.maxCores), "cores", appData.smpCores);
\r
3074 // [HGM] book: read tick boxes for own book use
\r
3075 appData.firstHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 );
\r
3076 appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 );
\r
3077 appData.bookDepth = GetDlgItemInt(hDlg, IDC_BookDep, NULL, FALSE );
\r
3078 appData.bookStrength = GetDlgItemInt(hDlg, IDC_BookStr, NULL, FALSE );
\r
3079 appData.defaultMatchGames = GetDlgItemInt(hDlg, IDC_Games, NULL, FALSE );
\r
3081 if(gameMode == BeginningOfGame) Reset(TRUE, TRUE);
\r
3082 EndDialog(hDlg, TRUE);
\r
3086 EndDialog(hDlg, FALSE);
\r
3089 case IDC_BrowseForBook:
\r
3092 'A','l','l',' ','F','i','l','e','s', 0,
\r
3094 'B','I','N',' ','F','i','l','e','s', 0,
\r
3095 '*','.','b','i','n', 0,
\r
3100 safeStrCpy( buf, "" , sizeof( buf)/sizeof( buf[0]) );
\r
3102 ZeroMemory( &ofn, sizeof(ofn) );
\r
3104 ofn.lStructSize = sizeof(ofn);
\r
3105 ofn.hwndOwner = hDlg;
\r
3106 ofn.hInstance = hInst;
\r
3107 ofn.lpstrFilter = filter;
\r
3108 ofn.lpstrFile = buf;
\r
3109 ofn.nMaxFile = sizeof(buf);
\r
3110 ofn.lpstrTitle = _("Choose Book");
\r
3111 ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
\r
3113 if( GetOpenFileName( &ofn ) ) {
\r
3114 SetDlgItemText( hDlg, IDC_BookFile, buf );
\r
3119 case IDC_BrowseForPolyglotDir:
\r
3120 if( BrowseForFolder( _("Choose Polyglot Directory"), buf ) ) {
\r
3121 SetDlgItemText( hDlg, IDC_PolyglotDir, buf );
\r
3123 strcat( buf, "\\polyglot.exe" );
\r
3125 if( GetFileAttributes(buf) == 0xFFFFFFFF ) {
\r
3126 MessageBox( hDlg, _("Polyglot was not found in the specified folder!"), "Warning", MB_OK | MB_ICONWARNING );
\r
3131 case IDC_BrowseForEGTB:
\r
3132 if( BrowseForFolder( _("Choose EGTB Directory:"), buf ) ) {
\r
3133 SetDlgItemText( hDlg, IDC_PathToEGTB, buf );
\r
3137 case IDC_HashSize:
\r
3138 case IDC_SizeOfEGTB:
\r
3139 if( HIWORD(wParam) == EN_CHANGE ) {
\r
3143 GetDlgItemInt(hDlg, IDC_HashSize, &n1_ok, FALSE );
\r
3144 GetDlgItemInt(hDlg, IDC_SizeOfEGTB, &n2_ok, FALSE );
\r
3146 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok ? TRUE : FALSE );
\r
3155 VOID UciOptionsPopup(HWND hwnd)
\r
3159 lpProc = MakeProcInstance((FARPROC)UciOptionsDialog, hInst);
\r
3160 DialogBox(hInst, MAKEINTRESOURCE(DLG_OptionsUCI), hwnd, (DLGPROC) lpProc);
\r
3161 FreeProcInstance(lpProc);
\r