2 * woptions.c -- Options dialog box routines for WinBoard
\r
4 * Copyright 2000, 2009, 2010 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
47 /* Imports from winboard.c */
\r
49 extern MyFont *font[NUM_SIZES][NUM_FONTS];
\r
50 extern HINSTANCE hInst; /* current instance */
\r
51 extern HWND hwndMain; /* root window*/
\r
52 extern BOOLEAN alwaysOnTop;
\r
53 extern RECT boardRect;
\r
54 extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor,
\r
55 blackPieceColor, highlightSquareColor, premoveHighlightColor;
\r
56 extern HPALETTE hPal;
\r
57 extern BoardSize boardSize;
\r
58 extern COLORREF consoleBackgroundColor;
\r
59 extern MyColorizeAttribs colorizeAttribs[]; /* do I need the size? */
\r
60 extern MyTextAttribs textAttribs[];
\r
61 extern MySound sounds[];
\r
62 extern ColorClass currentColorClass;
\r
63 extern HWND hwndConsole;
\r
64 extern char *defaultTextAttribs[];
\r
65 extern HWND commentDialog;
\r
66 extern HWND moveHistoryDialog;
\r
67 extern HWND engineOutputDialog;
\r
68 extern char installDir[];
\r
69 extern HWND hCommPort; /* currently open comm port */
\r
71 extern BOOLEAN chessProgram;
\r
72 extern int startedFromPositionFile; /* [HGM] loadPos */
\r
73 extern int searchTime;
\r
87 /* module prototypes */
\r
89 LRESULT CALLBACK GeneralOptions(HWND, UINT, WPARAM, LPARAM);
\r
90 LRESULT CALLBACK BoardOptions(HWND, UINT, WPARAM, LPARAM);
\r
91 LRESULT CALLBACK NewVariant(HWND, UINT, WPARAM, LPARAM);
\r
92 LRESULT CALLBACK IcsOptions(HWND, UINT, WPARAM, LPARAM);
\r
93 LRESULT CALLBACK FontOptions(HWND, UINT, WPARAM, LPARAM);
\r
94 LRESULT CALLBACK CommPortOptions(HWND, UINT, WPARAM, LPARAM);
\r
95 LRESULT CALLBACK LoadOptions(HWND, UINT, WPARAM, LPARAM);
\r
96 LRESULT CALLBACK SaveOptions(HWND, UINT, WPARAM, LPARAM);
\r
97 LRESULT CALLBACK TimeControl(HWND, UINT, WPARAM, LPARAM);
\r
98 VOID ChangeBoardSize(BoardSize newSize);
\r
99 VOID PaintSampleSquare(
\r
102 COLORREF squareColor,
\r
103 COLORREF pieceColor,
\r
104 COLORREF squareOutlineColor,
\r
105 COLORREF pieceDetailColor,
\r
110 VOID PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color);
\r
111 VOID SetBoardOptionEnables(HWND hDlg);
\r
112 BoardSize BoardOptionsWhichRadio(HWND hDlg);
\r
113 BOOL APIENTRY MyCreateFont(HWND hwnd, MyFont *font);
\r
114 VOID UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca);
\r
115 LRESULT CALLBACK ColorizeTextDialog(HWND , UINT, WPARAM, LPARAM);
\r
116 VOID ColorizeTextPopup(HWND hwnd, ColorClass cc);
\r
117 VOID SetIcsOptionEnables(HWND hDlg);
\r
118 VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf);
\r
119 VOID CopyFont(MyFont *dest, const MyFont *src);
\r
120 void InitSoundComboData(SoundComboData *scd);
\r
121 void ResetSoundComboData(SoundComboData *scd);
\r
122 void InitSoundCombo(HWND hwndCombo, SoundComboData *scd);
\r
123 int SoundDialogWhichRadio(HWND hDlg);
\r
124 VOID SoundDialogSetEnables(HWND hDlg, int radio);
\r
125 char * SoundDialogGetName(HWND hDlg, int radio);
\r
126 void DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name);
\r
127 VOID ParseCommSettings(char *arg, DCB *dcb);
\r
128 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb);
\r
129 void InitCombo(HANDLE hwndCombo, ComboData *cd);
\r
130 void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value);
\r
131 VOID SetLoadOptionEnables(HWND hDlg);
\r
132 VOID SetSaveOptionEnables(HWND hDlg);
\r
133 VOID SetTimeControlEnables(HWND hDlg);
\r
134 void NewSettingEvent(int option, char *command, int value);
\r
136 /*---------------------------------------------------------------------------*\
\r
138 * General Options Dialog functions
\r
140 \*---------------------------------------------------------------------------*/
\r
144 GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
146 static Boolean oldShowCoords;
\r
147 static Boolean oldBlindfold;
\r
148 static Boolean oldShowButtonBar;
\r
151 case WM_INITDIALOG: /* message: initialize dialog box */
\r
152 oldShowCoords = appData.showCoords;
\r
153 oldBlindfold = appData.blindfold;
\r
154 oldShowButtonBar = appData.showButtonBar;
\r
156 /* Center the dialog over the application window */
\r
157 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
159 /* Initialize the dialog items */
\r
160 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
162 CHECK_BOX(OPT_AlwaysOnTop, alwaysOnTop);
\r
163 CHECK_BOX(OPT_AlwaysQueen, appData.alwaysPromoteToQueen);
\r
164 CHECK_BOX(OPT_AnimateDragging, appData.animateDragging);
\r
165 CHECK_BOX(OPT_AnimateMoving, appData.animate);
\r
166 CHECK_BOX(OPT_AutoFlag, appData.autoCallFlag);
\r
167 CHECK_BOX(OPT_AutoFlipView, appData.autoFlipView);
\r
168 CHECK_BOX(OPT_AutoRaiseBoard, appData.autoRaiseBoard);
\r
169 CHECK_BOX(OPT_Blindfold, appData.blindfold);
\r
170 CHECK_BOX(OPT_HighlightDragging, appData.highlightDragging);
\r
171 CHECK_BOX(OPT_HighlightLastMove, appData.highlightLastMove);
\r
172 CHECK_BOX(OPT_PeriodicUpdates, appData.periodicUpdates);
\r
173 CHECK_BOX(OPT_PonderNextMove, appData.ponderNextMove);
\r
174 CHECK_BOX(OPT_PopupExitMessage, appData.popupExitMessage);
\r
175 CHECK_BOX(OPT_PopupMoveErrors, appData.popupMoveErrors);
\r
176 CHECK_BOX(OPT_ShowButtonBar, appData.showButtonBar);
\r
177 CHECK_BOX(OPT_ShowCoordinates, appData.showCoords);
\r
178 CHECK_BOX(OPT_ShowThinking, appData.showThinking);
\r
179 CHECK_BOX(OPT_TestLegality, appData.testLegality);
\r
180 CHECK_BOX(OPT_HideThinkFromHuman, appData.hideThinkingFromHuman);
\r
181 CHECK_BOX(OPT_SaveExtPGN, appData.saveExtendedInfoInPGN);
\r
182 CHECK_BOX(OPT_ExtraInfoInMoveHistory, appData.showEvalInMoveHistory);
\r
183 CHECK_BOX(OPT_HighlightMoveArrow, appData.highlightMoveWithArrow);
\r
187 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlag),
\r
188 appData.icsActive || !appData.noChessProgram);
\r
189 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlipView),
\r
190 appData.icsActive || !appData.noChessProgram);
\r
191 EnableWindow(GetDlgItem(hDlg, OPT_PonderNextMove),
\r
192 !appData.noChessProgram);
\r
193 EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates),
\r
194 !appData.noChessProgram && !appData.icsActive);
\r
195 EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking),
\r
196 !appData.noChessProgram);
\r
200 case WM_COMMAND: /* message: received a command */
\r
201 switch (LOWORD(wParam)) {
\r
203 /* Read changed options from the dialog box */
\r
205 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
207 alwaysOnTop = IS_CHECKED(OPT_AlwaysOnTop);
\r
208 appData.alwaysPromoteToQueen = IS_CHECKED(OPT_AlwaysQueen);
\r
209 appData.animateDragging = IS_CHECKED(OPT_AnimateDragging);
\r
210 appData.animate = IS_CHECKED(OPT_AnimateMoving);
\r
211 appData.autoCallFlag = IS_CHECKED(OPT_AutoFlag);
\r
212 appData.autoFlipView = IS_CHECKED(OPT_AutoFlipView);
\r
213 appData.autoRaiseBoard = IS_CHECKED(OPT_AutoRaiseBoard);
\r
214 appData.blindfold = IS_CHECKED(OPT_Blindfold);
\r
215 appData.highlightDragging = IS_CHECKED(OPT_HighlightDragging);
\r
216 appData.highlightLastMove = IS_CHECKED(OPT_HighlightLastMove);
\r
217 PeriodicUpdatesEvent( IS_CHECKED(OPT_PeriodicUpdates));
\r
218 PonderNextMoveEvent( IS_CHECKED(OPT_PonderNextMove));
\r
219 appData.popupExitMessage = IS_CHECKED(OPT_PopupExitMessage);
\r
220 appData.popupMoveErrors = IS_CHECKED(OPT_PopupMoveErrors);
\r
221 appData.showButtonBar = IS_CHECKED(OPT_ShowButtonBar);
\r
222 appData.showCoords = IS_CHECKED(OPT_ShowCoordinates);
\r
223 // [HGM] thinking: next three moved up
\r
224 appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN);
\r
225 appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);
\r
226 appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory);
\r
227 appData.showThinking = IS_CHECKED(OPT_ShowThinking);
\r
228 ShowThinkingEvent(); // [HGM] thinking: tests four options
\r
229 appData.testLegality = IS_CHECKED(OPT_TestLegality);
\r
230 appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);
\r
234 SetWindowPos(hwndMain, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
235 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
238 SetWindowPos(hwndConsole, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
239 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
242 if (!appData.highlightLastMove) {
\r
244 DrawPosition(FALSE, NULL);
\r
247 * for some reason the redraw seems smoother when we invalidate
\r
248 * the board rect after the call to EndDialog()
\r
250 EndDialog(hDlg, TRUE);
\r
252 if (oldShowButtonBar != appData.showButtonBar) {
\r
253 InitDrawingSizes(boardSize, 0);
\r
254 } else if ((oldShowCoords != appData.showCoords) ||
\r
255 (oldBlindfold != appData.blindfold)) {
\r
256 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
262 EndDialog(hDlg, FALSE);
\r
272 GeneralOptionsPopup(HWND hwnd)
\r
276 lpProc = MakeProcInstance((FARPROC)GeneralOptionsDialog, hInst);
\r
277 DialogBox(hInst, MAKEINTRESOURCE(DLG_GeneralOptions), hwnd,
\r
279 FreeProcInstance(lpProc);
\r
281 /*---------------------------------------------------------------------------*\
\r
283 * Board Options Dialog functions
\r
285 \*---------------------------------------------------------------------------*/
\r
287 const int SAMPLE_SQ_SIZE = 54;
\r
290 ChangeBoardSize(BoardSize newSize)
\r
292 if (newSize != boardSize) {
\r
293 boardSize = newSize;
\r
294 InitDrawingSizes(boardSize, 0);
\r
302 COLORREF squareColor,
\r
303 COLORREF pieceColor,
\r
304 COLORREF squareOutlineColor,
\r
305 COLORREF pieceDetailColor,
\r
311 HBRUSH brushSquare;
\r
312 HBRUSH brushSquareOutline;
\r
314 HBRUSH brushPieceDetail;
\r
315 HBRUSH oldBrushPiece = NULL;
\r
316 HBRUSH oldBrushSquare;
\r
317 HBITMAP oldBitmapMem;
\r
318 HBITMAP oldBitmapTemp;
\r
319 HBITMAP bufferBitmap;
\r
321 HDC hdcScreen, hdcMem, hdcTemp;
\r
323 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
326 const int SOLID = 0;
\r
327 const int WHITE = 1;
\r
328 const int OUTLINE = 2;
\r
329 const int BORDER = 4;
\r
331 InvalidateRect(hCtrl, NULL, TRUE);
\r
332 UpdateWindow(hCtrl);
\r
333 GetClientRect(hCtrl, &rect);
\r
334 x = rect.left + (BORDER / 2);
\r
335 y = rect.top + (BORDER / 2);
\r
336 hdcScreen = GetDC(hCtrl);
\r
337 hdcMem = CreateCompatibleDC(hdcScreen);
\r
338 hdcTemp = CreateCompatibleDC(hdcScreen);
\r
340 bufferBitmap = CreateCompatibleBitmap(hdcScreen, rect.right-rect.left+1,
\r
341 rect.bottom-rect.top+1);
\r
342 oldBitmapMem = SelectObject(hdcMem, bufferBitmap);
\r
344 SelectPalette(hdcMem, hPal, FALSE);
\r
346 brushSquare = CreateSolidBrush(squareColor);
\r
347 brushSquareOutline = CreateSolidBrush(squareOutlineColor);
\r
348 brushPiece = CreateSolidBrush(pieceColor);
\r
349 brushPieceDetail = CreateSolidBrush(pieceDetailColor);
\r
352 * first draw the rectangle
\r
354 pen = CreatePen(PS_SOLID, BORDER, squareOutlineColor);
\r
355 oldPen = (HPEN) SelectObject(hdcMem, pen);
\r
356 oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare);
\r
357 Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);
\r
360 * now draw the piece
\r
363 oldBitmapTemp = SelectObject(hdcTemp, pieces[OUTLINE]);
\r
364 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0,
\r
365 isWhitePiece ? SRCCOPY : NOTSRCCOPY);
\r
366 SelectObject(hdcTemp, oldBitmapTemp);
\r
368 if (isWhitePiece) {
\r
369 oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]);
\r
370 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
371 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
372 hdcTemp, 0, 0, 0x00B8074A);
\r
373 /* Use black for outline of white pieces */
\r
374 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
375 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
376 hdcTemp, 0, 0, SRCAND);
\r
378 /* Use square color for details of black pieces */
\r
379 oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);
\r
380 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
381 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
382 hdcTemp, 0, 0, 0x00B8074A);
\r
384 SelectObject(hdcMem, oldBrushPiece);
\r
385 SelectObject(hdcTemp, oldBitmapTemp);
\r
388 * copy the memory dc to the screen
\r
390 SelectObject(hdcMem, bufferBitmap);
\r
391 BitBlt(hdcScreen, rect.left, rect.top,
\r
392 rect.right - rect.left,
\r
393 rect.bottom - rect.top,
\r
394 hdcMem, rect.left, rect.top, SRCCOPY);
\r
395 SelectObject(hdcMem, oldBitmapMem);
\r
399 SelectObject(hdcMem, oldBrushPiece);
\r
400 SelectObject(hdcMem, oldPen);
\r
401 DeleteObject(brushPiece);
\r
402 DeleteObject(brushPieceDetail);
\r
403 DeleteObject(brushSquare);
\r
404 DeleteObject(brushSquareOutline);
\r
408 ReleaseDC(hCtrl, hdcScreen);
\r
413 PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color)
\r
416 HBRUSH brush, oldBrush;
\r
418 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
420 hdc = GetDC(hCtrl);
\r
421 InvalidateRect(hCtrl, NULL, TRUE);
\r
422 UpdateWindow(hCtrl);
\r
423 GetClientRect(hCtrl, &rect);
\r
424 brush = CreateSolidBrush(color);
\r
425 oldBrush = (HBRUSH)SelectObject(hdc, brush);
\r
426 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
\r
427 SelectObject(hdc, oldBrush);
\r
428 DeleteObject(brush);
\r
429 ReleaseDC(hCtrl, hdc);
\r
434 SetBoardOptionEnables(HWND hDlg)
\r
436 if (IsDlgButtonChecked(hDlg, OPT_Monochrome)) {
\r
437 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_HIDE);
\r
438 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_HIDE);
\r
439 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_HIDE);
\r
440 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_HIDE);
\r
442 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), FALSE);
\r
443 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), FALSE);
\r
444 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), FALSE);
\r
445 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), FALSE);
\r
447 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_SHOW);
\r
448 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_SHOW);
\r
449 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_SHOW);
\r
450 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_SHOW);
\r
452 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), TRUE);
\r
453 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), TRUE);
\r
454 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), TRUE);
\r
455 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), TRUE);
\r
460 BoardOptionsWhichRadio(HWND hDlg)
\r
462 return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny :
\r
463 (IsDlgButtonChecked(hDlg, OPT_SizeTeeny) ? SizeTeeny :
\r
464 (IsDlgButtonChecked(hDlg, OPT_SizeDinky) ? SizeDinky :
\r
465 (IsDlgButtonChecked(hDlg, OPT_SizePetite) ? SizePetite :
\r
466 (IsDlgButtonChecked(hDlg, OPT_SizeSlim) ? SizeSlim :
\r
467 (IsDlgButtonChecked(hDlg, OPT_SizeSmall) ? SizeSmall :
\r
468 (IsDlgButtonChecked(hDlg, OPT_SizeMediocre) ? SizeMediocre :
\r
469 (IsDlgButtonChecked(hDlg, OPT_SizeMiddling) ? SizeMiddling :
\r
470 (IsDlgButtonChecked(hDlg, OPT_SizeAverage) ? SizeAverage :
\r
471 (IsDlgButtonChecked(hDlg, OPT_SizeModerate) ? SizeModerate :
\r
472 (IsDlgButtonChecked(hDlg, OPT_SizeMedium) ? SizeMedium :
\r
473 (IsDlgButtonChecked(hDlg, OPT_SizeBulky) ? SizeBulky :
\r
474 (IsDlgButtonChecked(hDlg, OPT_SizeLarge) ? SizeLarge :
\r
475 (IsDlgButtonChecked(hDlg, OPT_SizeBig) ? SizeBig :
\r
476 (IsDlgButtonChecked(hDlg, OPT_SizeHuge) ? SizeHuge :
\r
477 (IsDlgButtonChecked(hDlg, OPT_SizeGiant) ? SizeGiant :
\r
478 (IsDlgButtonChecked(hDlg, OPT_SizeColossal) ? SizeColossal :
\r
479 SizeTitanic )))))))))))))))));
\r
483 BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
485 static Boolean mono, white, flip;
\r
486 static BoardSize size;
\r
487 static COLORREF lsc, dsc, wpc, bpc, hsc, phc;
\r
488 static HBITMAP pieces[3];
\r
491 case WM_INITDIALOG: /* message: initialize dialog box */
\r
492 /* Center the dialog over the application window */
\r
493 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
494 /* Initialize the dialog items */
\r
495 switch (boardSize) {
\r
497 CheckDlgButton(hDlg, OPT_SizeTiny, TRUE);
\r
500 CheckDlgButton(hDlg, OPT_SizeTeeny, TRUE);
\r
503 CheckDlgButton(hDlg, OPT_SizeDinky, TRUE);
\r
506 CheckDlgButton(hDlg, OPT_SizePetite, TRUE);
\r
509 CheckDlgButton(hDlg, OPT_SizeSlim, TRUE);
\r
512 CheckDlgButton(hDlg, OPT_SizeSmall, TRUE);
\r
515 CheckDlgButton(hDlg, OPT_SizeMediocre, TRUE);
\r
518 CheckDlgButton(hDlg, OPT_SizeMiddling, TRUE);
\r
521 CheckDlgButton(hDlg, OPT_SizeAverage, TRUE);
\r
524 CheckDlgButton(hDlg, OPT_SizeModerate, TRUE);
\r
527 CheckDlgButton(hDlg, OPT_SizeMedium, TRUE);
\r
530 CheckDlgButton(hDlg, OPT_SizeBulky, TRUE);
\r
533 CheckDlgButton(hDlg, OPT_SizeLarge, TRUE);
\r
536 CheckDlgButton(hDlg, OPT_SizeBig, TRUE);
\r
539 CheckDlgButton(hDlg, OPT_SizeHuge, TRUE);
\r
542 CheckDlgButton(hDlg, OPT_SizeGiant, TRUE);
\r
545 CheckDlgButton(hDlg, OPT_SizeColossal, TRUE);
\r
548 CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE);
\r
549 default: ; // should not happen, but suppresses warning on pedantic compilers
\r
552 if (appData.monoMode)
\r
553 CheckDlgButton(hDlg, OPT_Monochrome, TRUE);
\r
555 if (appData.allWhite)
\r
556 CheckDlgButton(hDlg, OPT_AllWhite, TRUE);
\r
558 if (appData.upsideDown)
\r
559 CheckDlgButton(hDlg, OPT_UpsideDown, TRUE);
\r
561 pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s");
\r
562 pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w");
\r
563 pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o");
\r
565 lsc = lightSquareColor;
\r
566 dsc = darkSquareColor;
\r
567 wpc = whitePieceColor;
\r
568 bpc = blackPieceColor;
\r
569 hsc = highlightSquareColor;
\r
570 phc = premoveHighlightColor;
\r
571 mono = appData.monoMode;
\r
572 white= appData.allWhite;
\r
573 flip = appData.upsideDown;
\r
576 SetBoardOptionEnables(hDlg);
\r
580 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
581 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
582 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
583 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
584 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
585 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
586 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
587 TRUE, mono, pieces);
\r
588 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
589 FALSE, mono, pieces);
\r
593 case WM_COMMAND: /* message: received a command */
\r
594 switch (LOWORD(wParam)) {
\r
597 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
598 * then ChangeBoardSize() does not take effect, although the new
\r
599 * boardSize is saved. Go figure...
\r
601 EndDialog(hDlg, TRUE);
\r
603 size = BoardOptionsWhichRadio(hDlg);
\r
606 * did any settings change?
\r
608 if (size != boardSize) {
\r
609 ChangeBoardSize(size);
\r
612 if ((mono != appData.monoMode) ||
\r
613 (lsc != lightSquareColor) ||
\r
614 (dsc != darkSquareColor) ||
\r
615 (wpc != whitePieceColor) ||
\r
616 (bpc != blackPieceColor) ||
\r
617 (hsc != highlightSquareColor) ||
\r
618 (flip != appData.upsideDown) ||
\r
619 (white != appData.allWhite) ||
\r
620 (phc != premoveHighlightColor)) {
\r
622 lightSquareColor = lsc;
\r
623 darkSquareColor = dsc;
\r
624 whitePieceColor = wpc;
\r
625 blackPieceColor = bpc;
\r
626 highlightSquareColor = hsc;
\r
627 premoveHighlightColor = phc;
\r
628 appData.monoMode = mono;
\r
629 appData.allWhite = white;
\r
630 appData.upsideDown = flip;
\r
632 InitDrawingColors();
\r
633 InitDrawingSizes(boardSize, 0);
\r
634 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
636 DeleteObject(pieces[0]);
\r
637 DeleteObject(pieces[1]);
\r
638 DeleteObject(pieces[2]);
\r
642 DeleteObject(pieces[0]);
\r
643 DeleteObject(pieces[1]);
\r
644 DeleteObject(pieces[2]);
\r
645 EndDialog(hDlg, FALSE);
\r
648 case OPT_ChooseLightSquareColor:
\r
649 if (ChangeColor(hDlg, &lsc))
\r
650 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
651 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
652 TRUE, mono, pieces);
\r
655 case OPT_ChooseDarkSquareColor:
\r
656 if (ChangeColor(hDlg, &dsc))
\r
657 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
658 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
659 FALSE, mono, pieces);
\r
662 case OPT_ChooseWhitePieceColor:
\r
663 if (ChangeColor(hDlg, &wpc))
\r
664 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
665 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
666 TRUE, mono, pieces);
\r
669 case OPT_ChooseBlackPieceColor:
\r
670 if (ChangeColor(hDlg, &bpc))
\r
671 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
672 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
673 FALSE, mono, pieces);
\r
676 case OPT_ChooseHighlightSquareColor:
\r
677 if (ChangeColor(hDlg, &hsc))
\r
678 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
679 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
680 TRUE, mono, pieces);
\r
683 case OPT_ChoosePremoveHighlightColor:
\r
684 if (ChangeColor(hDlg, &phc))
\r
685 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
686 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
687 FALSE, mono, pieces);
\r
690 case OPT_DefaultBoardColors:
\r
691 lsc = ParseColorName(LIGHT_SQUARE_COLOR);
\r
692 dsc = ParseColorName(DARK_SQUARE_COLOR);
\r
693 wpc = ParseColorName(WHITE_PIECE_COLOR);
\r
694 bpc = ParseColorName(BLACK_PIECE_COLOR);
\r
695 hsc = ParseColorName(HIGHLIGHT_SQUARE_COLOR);
\r
696 phc = ParseColorName(PREMOVE_HIGHLIGHT_COLOR);
\r
700 CheckDlgButton(hDlg, OPT_Monochrome, FALSE);
\r
701 CheckDlgButton(hDlg, OPT_AllWhite, FALSE);
\r
702 CheckDlgButton(hDlg, OPT_UpsideDown, FALSE);
\r
703 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
704 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
705 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
706 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
707 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
708 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
709 SetBoardOptionEnables(hDlg);
\r
710 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
711 TRUE, mono, pieces);
\r
712 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
713 FALSE, mono, pieces);
\r
716 case OPT_Monochrome:
\r
718 SetBoardOptionEnables(hDlg);
\r
723 SetBoardOptionEnables(hDlg);
\r
726 case OPT_UpsideDown:
\r
728 SetBoardOptionEnables(hDlg);
\r
738 BoardOptionsPopup(HWND hwnd)
\r
740 FARPROC lpProc = MakeProcInstance((FARPROC)BoardOptionsDialog, hInst);
\r
741 DialogBox(hInst, MAKEINTRESOURCE(DLG_BoardOptions), hwnd,
\r
743 FreeProcInstance(lpProc);
\r
747 VariantWhichRadio(HWND hDlg)
\r
749 return (IsDlgButtonChecked(hDlg, OPT_VariantFairy) ? VariantFairy :
\r
750 (IsDlgButtonChecked(hDlg, OPT_VariantGothic) ? VariantGothic :
\r
751 (IsDlgButtonChecked(hDlg, OPT_VariantCrazyhouse) ? VariantCrazyhouse :
\r
752 (IsDlgButtonChecked(hDlg, OPT_VariantBughouse) ? VariantBughouse :
\r
753 (IsDlgButtonChecked(hDlg, OPT_VariantCourier) ? VariantCourier :
\r
754 (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :
\r
755 (IsDlgButtonChecked(hDlg, OPT_VariantShogi) ? VariantShogi :
\r
756 (IsDlgButtonChecked(hDlg, OPT_VariantXiangqi) ? VariantXiangqi :
\r
757 (IsDlgButtonChecked(hDlg, OPT_VariantCapablanca) ? VariantCapablanca :
\r
758 (IsDlgButtonChecked(hDlg, OPT_VariantTwoKings) ? VariantTwoKings :
\r
759 (IsDlgButtonChecked(hDlg, OPT_VariantKnightmate) ? VariantKnightmate :
\r
760 (IsDlgButtonChecked(hDlg, OPT_VariantLosers) ? VariantLosers :
\r
761 (IsDlgButtonChecked(hDlg, OPT_VariantSuicide) ? VariantSuicide :
\r
762 (IsDlgButtonChecked(hDlg, OPT_VariantAtomic) ? VariantAtomic :
\r
763 (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :
\r
764 (IsDlgButtonChecked(hDlg, OPT_VariantFRC) ? VariantFischeRandom :
\r
765 (IsDlgButtonChecked(hDlg, OPT_VariantCylinder) ? VariantCylinder :
\r
766 (IsDlgButtonChecked(hDlg, OPT_VariantFalcon) ? VariantFalcon :
\r
767 (IsDlgButtonChecked(hDlg, OPT_VariantCRC) ? VariantCapaRandom :
\r
768 (IsDlgButtonChecked(hDlg, OPT_VariantSuper) ? VariantSuper :
\r
769 (IsDlgButtonChecked(hDlg, OPT_VariantBerolina) ? VariantBerolina :
\r
770 (IsDlgButtonChecked(hDlg, OPT_VariantJanus) ? VariantJanus :
\r
771 (IsDlgButtonChecked(hDlg, OPT_VariantWildcastle) ? VariantWildCastle :
\r
772 (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle :
\r
773 (IsDlgButtonChecked(hDlg, OPT_Variant3Check) ? Variant3Check :
\r
774 (IsDlgButtonChecked(hDlg, OPT_VariantGreat) ? VariantGreat :
\r
775 (IsDlgButtonChecked(hDlg, OPT_VariantGiveaway) ? VariantGiveaway :
\r
776 (IsDlgButtonChecked(hDlg, OPT_VariantTwilight) ? VariantTwilight :
\r
777 (IsDlgButtonChecked(hDlg, OPT_VariantMakruk) ? VariantMakruk :
\r
778 VariantNormal )))))))))))))))))))))))))))));
\r
782 NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
784 static VariantClass v;
\r
785 static int n1_ok, n2_ok, n3_ok;
\r
788 case WM_INITDIALOG: /* message: initialize dialog box */
\r
789 /* Center the dialog over the application window */
\r
790 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
791 /* Initialize the dialog items */
\r
792 switch (gameInfo.variant) {
\r
793 case VariantNormal:
\r
794 CheckDlgButton(hDlg, OPT_VariantNormal, TRUE);
\r
796 case VariantCrazyhouse:
\r
797 CheckDlgButton(hDlg, OPT_VariantCrazyhouse, TRUE);
\r
799 case VariantBughouse:
\r
800 CheckDlgButton(hDlg, OPT_VariantBughouse, TRUE);
\r
803 CheckDlgButton(hDlg, OPT_VariantShogi, TRUE);
\r
805 case VariantXiangqi:
\r
806 CheckDlgButton(hDlg, OPT_VariantXiangqi, TRUE);
\r
808 case VariantCapablanca:
\r
809 CheckDlgButton(hDlg, OPT_VariantCapablanca, TRUE);
\r
811 case VariantGothic:
\r
812 CheckDlgButton(hDlg, OPT_VariantGothic, TRUE);
\r
814 case VariantCourier:
\r
815 CheckDlgButton(hDlg, OPT_VariantCourier, TRUE);
\r
817 case VariantKnightmate:
\r
818 CheckDlgButton(hDlg, OPT_VariantKnightmate, TRUE);
\r
820 case VariantTwoKings:
\r
821 CheckDlgButton(hDlg, OPT_VariantTwoKings, TRUE);
\r
824 CheckDlgButton(hDlg, OPT_VariantFairy, TRUE);
\r
826 case VariantAtomic:
\r
827 CheckDlgButton(hDlg, OPT_VariantAtomic, TRUE);
\r
829 case VariantSuicide:
\r
830 CheckDlgButton(hDlg, OPT_VariantSuicide, TRUE);
\r
832 case VariantLosers:
\r
833 CheckDlgButton(hDlg, OPT_VariantLosers, TRUE);
\r
835 case VariantShatranj:
\r
836 CheckDlgButton(hDlg, OPT_VariantShatranj, TRUE);
\r
838 case VariantFischeRandom:
\r
839 CheckDlgButton(hDlg, OPT_VariantFRC, TRUE);
\r
841 case VariantCapaRandom:
\r
842 CheckDlgButton(hDlg, OPT_VariantCRC, TRUE);
\r
844 case VariantFalcon:
\r
845 CheckDlgButton(hDlg, OPT_VariantFalcon, TRUE);
\r
847 case VariantCylinder:
\r
848 CheckDlgButton(hDlg, OPT_VariantCylinder, TRUE);
\r
850 case Variant3Check:
\r
851 CheckDlgButton(hDlg, OPT_Variant3Check, TRUE);
\r
854 CheckDlgButton(hDlg, OPT_VariantSuper, TRUE);
\r
856 case VariantBerolina:
\r
857 CheckDlgButton(hDlg, OPT_VariantBerolina, TRUE);
\r
860 CheckDlgButton(hDlg, OPT_VariantJanus, TRUE);
\r
862 case VariantWildCastle:
\r
863 CheckDlgButton(hDlg, OPT_VariantWildcastle, TRUE);
\r
865 case VariantNoCastle:
\r
866 CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE);
\r
869 CheckDlgButton(hDlg, OPT_VariantGreat, TRUE);
\r
871 case VariantGiveaway:
\r
872 CheckDlgButton(hDlg, OPT_VariantGiveaway, TRUE);
\r
874 case VariantTwilight:
\r
875 CheckDlgButton(hDlg, OPT_VariantTwilight, TRUE);
\r
877 case VariantMakruk:
\r
878 CheckDlgButton(hDlg, OPT_VariantMakruk, TRUE);
\r
883 SetDlgItemInt( hDlg, IDC_Files, -1, TRUE );
\r
884 SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 );
\r
886 SetDlgItemInt( hDlg, IDC_Ranks, -1, TRUE );
\r
887 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
889 SetDlgItemInt( hDlg, IDC_Holdings, -1, TRUE );
\r
890 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
892 n1_ok = n2_ok = n3_ok = FALSE;
\r
896 case WM_COMMAND: /* message: received a command */
\r
897 switch (LOWORD(wParam)) {
\r
900 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
901 * then ChangeBoardSize() does not take effect, although the new
\r
902 * boardSize is saved. Go figure...
\r
904 EndDialog(hDlg, TRUE);
\r
906 v = VariantWhichRadio(hDlg);
\r
907 if(!appData.noChessProgram) { char *name = VariantName(v), buf[MSG_SIZ];
\r
908 if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) {
\r
909 /* [HGM] in protocol 2 we check if variant is suported by engine */
\r
910 sprintf(buf, "Variant %s not supported by %s", name, first.tidy);
\r
911 DisplayError(buf, 0);
\r
912 return TRUE; /* treat as "Cancel" if first engine does not support it */
\r
914 if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) {
\r
915 sprintf(buf, "Warning: second engine (%s) does not support this!", second.tidy);
\r
916 DisplayError(buf, 0); /* use of second engine is optional; only warn user */
\r
920 gameInfo.variant = v;
\r
921 appData.variant = VariantName(v);
\r
923 appData.NrFiles = (int) GetDlgItemInt(hDlg, IDC_Files, NULL, FALSE );
\r
924 appData.NrRanks = (int) GetDlgItemInt(hDlg, IDC_Ranks, NULL, FALSE );
\r
925 appData.holdingsSize = (int) GetDlgItemInt(hDlg, IDC_Holdings, NULL, FALSE );
\r
927 if(!n1_ok) appData.NrFiles = -1;
\r
928 if(!n2_ok) appData.NrRanks = -1;
\r
929 if(!n3_ok) appData.holdingsSize = -1;
\r
931 shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */
\r
932 startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */
\r
933 appData.pieceToCharTable = NULL;
\r
939 EndDialog(hDlg, FALSE);
\r
945 if( HIWORD(wParam) == EN_CHANGE ) {
\r
947 GetDlgItemInt(hDlg, IDC_Files, &n1_ok, FALSE );
\r
948 GetDlgItemInt(hDlg, IDC_Ranks, &n2_ok, FALSE );
\r
949 GetDlgItemInt(hDlg, IDC_Holdings, &n3_ok, FALSE );
\r
951 /*EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok ? TRUE : FALSE );*/
\r
962 NewVariantPopup(HWND hwnd)
\r
964 FARPROC lpProc = MakeProcInstance((FARPROC)NewVariantDialog, hInst);
\r
965 DialogBox(hInst, MAKEINTRESOURCE(DLG_NewVariant), hwnd,
\r
967 FreeProcInstance(lpProc);
\r
970 /*---------------------------------------------------------------------------*\
\r
972 * ICS Options Dialog functions
\r
974 \*---------------------------------------------------------------------------*/
\r
977 MyCreateFont(HWND hwnd, MyFont *font)
\r
982 /* Initialize members of the CHOOSEFONT structure. */
\r
983 cf.lStructSize = sizeof(CHOOSEFONT);
\r
984 cf.hwndOwner = hwnd;
\r
985 cf.hDC = (HDC)NULL;
\r
986 cf.lpLogFont = &font->lf;
\r
988 cf.Flags = CF_SCREENFONTS|/*CF_ANSIONLY|*/CF_INITTOLOGFONTSTRUCT;
\r
989 cf.rgbColors = RGB(0,0,0);
\r
991 cf.lpfnHook = (LPCFHOOKPROC)NULL;
\r
992 cf.lpTemplateName = (LPSTR)NULL;
\r
993 cf.hInstance = (HINSTANCE) NULL;
\r
994 cf.lpszStyle = (LPSTR)NULL;
\r
995 cf.nFontType = SCREEN_FONTTYPE;
\r
999 /* Display the CHOOSEFONT common-dialog box. */
\r
1000 if (!ChooseFont(&cf)) {
\r
1004 /* Create a logical font based on the user's */
\r
1005 /* selection and return a handle identifying */
\r
1007 hf = CreateFontIndirect(cf.lpLogFont);
\r
1013 font->mfp.pointSize = (float) (cf.iPointSize / 10.0);
\r
1014 font->mfp.bold = (font->lf.lfWeight >= FW_BOLD);
\r
1015 font->mfp.italic = font->lf.lfItalic;
\r
1016 font->mfp.underline = font->lf.lfUnderline;
\r
1017 font->mfp.strikeout = font->lf.lfStrikeOut;
\r
1018 font->mfp.charset = font->lf.lfCharSet;
\r
1019 strcpy(font->mfp.faceName, font->lf.lfFaceName);
\r
1025 UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
\r
1028 cf.cbSize = sizeof(CHARFORMAT);
\r
1030 CFM_COLOR|CFM_CHARSET|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;
\r
1031 cf.crTextColor = mca->color;
\r
1032 cf.dwEffects = mca->effects;
\r
1033 strcpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName);
\r
1035 * The 20.0 below is in fact documented. yHeight is expressed in twips.
\r
1036 * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT.
\r
1039 cf.yHeight = (int)(font[boardSize][CONSOLE_FONT]->mfp.pointSize * 20.0 + 0.5);
\r
1040 cf.bCharSet = DEFAULT_CHARSET; /* should be ignored anyway */
\r
1041 cf.bPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
\r
1042 SendDlgItemMessage(hDlg, id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1046 ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1048 static MyColorizeAttribs mca;
\r
1049 static ColorClass cc;
\r
1050 COLORREF background = (COLORREF)0;
\r
1052 switch (message) {
\r
1053 case WM_INITDIALOG:
\r
1054 cc = (ColorClass)lParam;
\r
1055 mca = colorizeAttribs[cc];
\r
1056 /* Center the dialog over the application window */
\r
1057 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1058 /* Initialize the dialog items */
\r
1059 CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0);
\r
1060 CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0);
\r
1061 CheckDlgButton(hDlg, OPT_Underline, (mca.effects & CFE_UNDERLINE) != 0);
\r
1062 CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0);
\r
1064 /* get the current background color from the parent window */
\r
1065 SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND,
\r
1066 (WPARAM)WM_USER_GetConsoleBackground,
\r
1067 (LPARAM)&background);
\r
1069 /* set the background color */
\r
1070 SendDlgItemMessage(hDlg, OPT_Sample, EM_SETBKGNDCOLOR, FALSE, background);
\r
1072 SetDlgItemText(hDlg, OPT_Sample, mca.name);
\r
1073 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1076 case WM_COMMAND: /* message: received a command */
\r
1077 switch (LOWORD(wParam)) {
\r
1079 /* Read changed options from the dialog box */
\r
1080 colorizeAttribs[cc] = mca;
\r
1081 textAttribs[cc].color = mca.color;
\r
1082 textAttribs[cc].effects = mca.effects;
\r
1083 Colorize(currentColorClass, TRUE);
\r
1084 if (cc == ColorNormal) {
\r
1086 cf.cbSize = sizeof(CHARFORMAT);
\r
1087 cf.dwMask = CFM_COLOR;
\r
1088 cf.crTextColor = mca.color;
\r
1089 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1090 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1092 EndDialog(hDlg, TRUE);
\r
1096 EndDialog(hDlg, FALSE);
\r
1099 case OPT_ChooseColor:
\r
1100 ChangeColor(hDlg, &mca.color);
\r
1101 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1106 (IsDlgButtonChecked(hDlg, OPT_Bold) ? CFE_BOLD : 0) |
\r
1107 (IsDlgButtonChecked(hDlg, OPT_Italic) ? CFE_ITALIC : 0) |
\r
1108 (IsDlgButtonChecked(hDlg, OPT_Underline) ? CFE_UNDERLINE : 0) |
\r
1109 (IsDlgButtonChecked(hDlg, OPT_Strikeout) ? CFE_STRIKEOUT : 0);
\r
1110 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1119 ColorizeTextPopup(HWND hwnd, ColorClass cc)
\r
1123 lpProc = MakeProcInstance((FARPROC)ColorizeTextDialog, hInst);
\r
1124 DialogBoxParam(hInst, MAKEINTRESOURCE(DLG_Colorize),
\r
1125 hwnd, (DLGPROC)lpProc, (LPARAM) cc);
\r
1126 FreeProcInstance(lpProc);
\r
1130 SetIcsOptionEnables(HWND hDlg)
\r
1132 #define ENABLE_DLG_ITEM(x,y) EnableWindow(GetDlgItem(hDlg,(x)), (y))
\r
1134 UINT state = IsDlgButtonChecked(hDlg, OPT_Premove);
\r
1135 ENABLE_DLG_ITEM(OPT_PremoveWhite, state);
\r
1136 ENABLE_DLG_ITEM(OPT_PremoveWhiteText, state);
\r
1137 ENABLE_DLG_ITEM(OPT_PremoveBlack, state);
\r
1138 ENABLE_DLG_ITEM(OPT_PremoveBlackText, state);
\r
1140 ENABLE_DLG_ITEM(OPT_IcsAlarmTime, IsDlgButtonChecked(hDlg, OPT_IcsAlarm));
\r
1142 #undef ENABLE_DLG_ITEM
\r
1147 IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1149 char buf[MSG_SIZ];
\r
1152 static COLORREF cbc;
\r
1153 static MyColorizeAttribs *mca;
\r
1154 COLORREF *colorref;
\r
1156 switch (message) {
\r
1157 case WM_INITDIALOG: /* message: initialize dialog box */
\r
1159 mca = colorizeAttribs;
\r
1161 for (i=0; i < NColorClasses - 1; i++) {
\r
1162 mca[i].color = textAttribs[i].color;
\r
1163 mca[i].effects = textAttribs[i].effects;
\r
1165 cbc = consoleBackgroundColor;
\r
1167 /* Center the dialog over the application window */
\r
1168 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1170 /* Initialize the dialog items */
\r
1171 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
1173 CHECK_BOX(OPT_AutoComment, appData.autoComment);
\r
1174 CHECK_BOX(OPT_AutoObserve, appData.autoObserve);
\r
1175 CHECK_BOX(OPT_GetMoveList, appData.getMoveList);
\r
1176 CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing);
\r
1177 CHECK_BOX(OPT_QuietPlay, appData.quietPlay);
\r
1178 CHECK_BOX(OPT_SeekGraph, appData.seekGraph);
\r
1179 CHECK_BOX(OPT_AutoRefresh, appData.autoRefresh);
\r
1180 CHECK_BOX(OPT_BgObserve, appData.bgObserve);
\r
1181 CHECK_BOX(OPT_DualBoard, appData.dualBoard);
\r
1182 CHECK_BOX(OPT_SmartMove, appData.oneClick);
\r
1183 CHECK_BOX(OPT_Premove, appData.premove);
\r
1184 CHECK_BOX(OPT_PremoveWhite, appData.premoveWhite);
\r
1185 CHECK_BOX(OPT_PremoveBlack, appData.premoveBlack);
\r
1186 CHECK_BOX(OPT_IcsAlarm, appData.icsAlarm);
\r
1187 CHECK_BOX(OPT_DontColorize, !appData.colorize);
\r
1191 sprintf(buf, "%d", appData.icsAlarmTime / 1000);
\r
1192 SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);
\r
1193 SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);
\r
1194 SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);
\r
1195 SetDlgItemText(hDlg, OPT_StartupChatBoxes, appData.chatBoxes);
\r
1197 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1198 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1199 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1200 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1201 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1202 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1203 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1204 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1205 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1206 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1208 SetDlgItemText(hDlg, OPT_SampleShout, mca[ColorShout].name);
\r
1209 SetDlgItemText(hDlg, OPT_SampleSShout, mca[ColorSShout].name);
\r
1210 SetDlgItemText(hDlg, OPT_SampleChannel1, mca[ColorChannel1].name);
\r
1211 SetDlgItemText(hDlg, OPT_SampleChannel, mca[ColorChannel].name);
\r
1212 SetDlgItemText(hDlg, OPT_SampleKibitz, mca[ColorKibitz].name);
\r
1213 SetDlgItemText(hDlg, OPT_SampleTell, mca[ColorTell].name);
\r
1214 SetDlgItemText(hDlg, OPT_SampleChallenge, mca[ColorChallenge].name);
\r
1215 SetDlgItemText(hDlg, OPT_SampleRequest, mca[ColorRequest].name);
\r
1216 SetDlgItemText(hDlg, OPT_SampleSeek, mca[ColorSeek].name);
\r
1217 SetDlgItemText(hDlg, OPT_SampleNormal, mca[ColorNormal].name);
\r
1219 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1220 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1221 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1222 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1223 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1224 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1225 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1226 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1227 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1228 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1230 SetIcsOptionEnables(hDlg);
\r
1233 case WM_COMMAND: /* message: received a command */
\r
1234 switch (LOWORD(wParam)) {
\r
1236 case WM_USER_GetConsoleBackground:
\r
1237 /* the ColorizeTextDialog needs the current background color */
\r
1238 colorref = (COLORREF *)lParam;
\r
1243 /* Read changed options from the dialog box */
\r
1244 GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ);
\r
1245 if (sscanf(buf, "%d", &number) != 1 || (number < 0)){
\r
1246 MessageBox(hDlg, "Invalid ICS Alarm Time",
\r
1247 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
1251 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
1253 appData.icsAlarm = IS_CHECKED(OPT_IcsAlarm);
\r
1254 appData.premove = IS_CHECKED(OPT_Premove);
\r
1255 appData.premoveWhite = IS_CHECKED(OPT_PremoveWhite);
\r
1256 appData.premoveBlack = IS_CHECKED(OPT_PremoveBlack);
\r
1257 appData.autoComment = IS_CHECKED(OPT_AutoComment);
\r
1258 appData.autoObserve = IS_CHECKED(OPT_AutoObserve);
\r
1259 appData.getMoveList = IS_CHECKED(OPT_GetMoveList);
\r
1260 appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing);
\r
1261 appData.quietPlay = IS_CHECKED(OPT_QuietPlay);
\r
1262 appData.seekGraph = IS_CHECKED(OPT_SeekGraph);
\r
1263 appData.autoRefresh = IS_CHECKED(OPT_AutoRefresh);
\r
1264 appData.bgObserve = IS_CHECKED(OPT_BgObserve);
\r
1265 appData.dualBoard = IS_CHECKED(OPT_DualBoard);
\r
1266 appData.oneClick = IS_CHECKED(OPT_SmartMove);
\r
1270 appData.icsAlarmTime = number * 1000;
\r
1271 GetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText, 5);
\r
1272 GetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText, 5);
\r
1273 GetDlgItemText(hDlg, OPT_StartupChatBoxes, buf, sizeof(buf));
\r
1274 buf[sizeof(buf)-1] = NULLCHAR; appData.chatBoxes = StrSave(buf); // memory leak
\r
1276 if (appData.localLineEditing) {
\r
1284 appData.colorize =
\r
1285 (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize);
\r
1287 ChangedConsoleFont();
\r
1289 if (!appData.colorize) {
\r
1291 COLORREF background = ParseColorName(COLOR_BKGD);
\r
1293 SetDefaultTextAttribs();
\r
1294 Colorize(currentColorClass);
\r
1296 cf.cbSize = sizeof(CHARFORMAT);
\r
1297 cf.dwMask = CFM_COLOR;
\r
1298 cf.crTextColor = ParseColorName(COLOR_NORMAL);
\r
1300 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1301 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1302 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1303 EM_SETBKGNDCOLOR, FALSE, background);
\r
1304 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1305 EM_SETBKGNDCOLOR, FALSE, background);
\r
1308 if (cbc != consoleBackgroundColor) {
\r
1309 consoleBackgroundColor = cbc;
\r
1310 if (appData.colorize) {
\r
1311 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1312 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1313 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1314 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1318 for (i=0; i < NColorClasses - 1; i++) {
\r
1319 textAttribs[i].color = mca[i].color;
\r
1320 textAttribs[i].effects = mca[i].effects;
\r
1323 EndDialog(hDlg, TRUE);
\r
1327 EndDialog(hDlg, FALSE);
\r
1330 case OPT_ChooseShoutColor:
\r
1331 ColorizeTextPopup(hDlg, ColorShout);
\r
1332 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1335 case OPT_ChooseSShoutColor:
\r
1336 ColorizeTextPopup(hDlg, ColorSShout);
\r
1337 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1340 case OPT_ChooseChannel1Color:
\r
1341 ColorizeTextPopup(hDlg, ColorChannel1);
\r
1342 UpdateSampleText(hDlg, OPT_SampleChannel1,
\r
1343 &colorizeAttribs[ColorChannel1]);
\r
1346 case OPT_ChooseChannelColor:
\r
1347 ColorizeTextPopup(hDlg, ColorChannel);
\r
1348 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1351 case OPT_ChooseKibitzColor:
\r
1352 ColorizeTextPopup(hDlg, ColorKibitz);
\r
1353 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1356 case OPT_ChooseTellColor:
\r
1357 ColorizeTextPopup(hDlg, ColorTell);
\r
1358 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1361 case OPT_ChooseChallengeColor:
\r
1362 ColorizeTextPopup(hDlg, ColorChallenge);
\r
1363 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1366 case OPT_ChooseRequestColor:
\r
1367 ColorizeTextPopup(hDlg, ColorRequest);
\r
1368 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1371 case OPT_ChooseSeekColor:
\r
1372 ColorizeTextPopup(hDlg, ColorSeek);
\r
1373 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1376 case OPT_ChooseNormalColor:
\r
1377 ColorizeTextPopup(hDlg, ColorNormal);
\r
1378 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1381 case OPT_ChooseBackgroundColor:
\r
1382 if (ChangeColor(hDlg, &cbc)) {
\r
1383 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1384 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1385 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1386 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1387 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1388 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1389 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1390 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1391 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1392 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1396 case OPT_DefaultColors:
\r
1397 for (i=0; i < NColorClasses - 1; i++)
\r
1398 ParseAttribs(&mca[i].color,
\r
1400 defaultTextAttribs[i]);
\r
1402 cbc = ParseColorName(COLOR_BKGD);
\r
1403 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1404 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1405 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1406 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1407 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1408 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1409 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1410 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1411 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1412 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1414 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1415 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1416 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1417 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1418 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1419 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1420 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1421 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1422 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1423 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1427 SetIcsOptionEnables(hDlg);
\r
1436 IcsOptionsPopup(HWND hwnd)
\r
1438 FARPROC lpProc = MakeProcInstance((FARPROC)IcsOptionsDialog, hInst);
\r
1439 DialogBox(hInst, MAKEINTRESOURCE(DLG_IcsOptions), hwnd,
\r
1440 (DLGPROC) lpProc);
\r
1441 FreeProcInstance(lpProc);
\r
1444 /*---------------------------------------------------------------------------*\
\r
1446 * Fonts Dialog functions
\r
1448 \*---------------------------------------------------------------------------*/
\r
1451 SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
\r
1453 char buf[MSG_SIZ];
\r
1458 RECT rectClient, rectFormat;
\r
1463 len = sprintf(buf, "%.0f pt. %s%s%s\n",
\r
1464 mf->mfp.pointSize, mf->mfp.faceName,
\r
1465 mf->mfp.bold ? " bold" : "",
\r
1466 mf->mfp.italic ? " italic" : "");
\r
1467 SetDlgItemText(hwnd, id, buf);
\r
1469 hControl = GetDlgItem(hwnd, id);
\r
1470 hdc = GetDC(hControl);
\r
1471 SetMapMode(hdc, MM_TEXT); /* 1 pixel == 1 logical unit */
\r
1472 oldFont = SelectObject(hdc, mf->hf);
\r
1474 /* get number of logical units necessary to display font name */
\r
1475 GetTextExtentPoint32(hdc, buf, len, &size);
\r
1477 /* calculate formatting rectangle in the rich edit control.
\r
1478 * May be larger or smaller than the actual control.
\r
1480 GetClientRect(hControl, &rectClient);
\r
1481 center.x = (rectClient.left + rectClient.right) / 2;
\r
1482 center.y = (rectClient.top + rectClient.bottom) / 2;
\r
1483 rectFormat.top = center.y - (size.cy / 2) - 1;
\r
1484 rectFormat.bottom = center.y + (size.cy / 2) + 1;
\r
1485 rectFormat.left = center.x - (size.cx / 2) - 1;
\r
1486 rectFormat.right = center.x + (size.cx / 2) + 1;
\r
1488 cf.cbSize = sizeof(CHARFORMAT);
\r
1489 cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC;
\r
1491 if (mf->lf.lfWeight == FW_BOLD) cf.dwEffects |= CFE_BOLD;
\r
1492 if (mf->lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
\r
1493 strcpy(cf.szFaceName, mf->mfp.faceName);
\r
1495 * yHeight is expressed in twips. A twip is 1/20 of a font's point
\r
1496 * size. See documentation of CHARFORMAT. --msw
\r
1498 cf.yHeight = (int)(mf->mfp.pointSize * 20.0 + 0.5);
\r
1499 cf.bCharSet = mf->lf.lfCharSet;
\r
1500 cf.bPitchAndFamily = mf->lf.lfPitchAndFamily;
\r
1502 /* format the text in the rich edit control */
\r
1503 SendMessage(hControl, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf);
\r
1504 SendMessage(hControl, EM_SETRECT, (WPARAM)0, (LPARAM) &rectFormat);
\r
1507 SelectObject(hdc, oldFont);
\r
1508 ReleaseDC(hControl, hdc);
\r
1512 CopyFont(MyFont *dest, const MyFont *src)
\r
1514 dest->mfp.pointSize = src->mfp.pointSize;
\r
1515 dest->mfp.bold = src->mfp.bold;
\r
1516 dest->mfp.italic = src->mfp.italic;
\r
1517 dest->mfp.underline = src->mfp.underline;
\r
1518 dest->mfp.strikeout = src->mfp.strikeout;
\r
1519 dest->mfp.charset = src->mfp.charset;
\r
1520 lstrcpy(dest->mfp.faceName, src->mfp.faceName);
\r
1521 CreateFontInMF(dest);
\r
1526 FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1528 static MyFont workFont[NUM_FONTS];
\r
1529 static BOOL firstPaint;
\r
1533 switch (message) {
\r
1534 case WM_INITDIALOG:
\r
1536 /* copy the current font settings into a working copy */
\r
1537 for (i=0; i < NUM_FONTS; i++)
\r
1538 CopyFont(&workFont[i], font[boardSize][i]);
\r
1540 if (!appData.icsActive)
\r
1541 EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE);
\r
1543 firstPaint = TRUE; /* see rant below */
\r
1545 /* If I don't call SetFocus(), the dialog won't respond to the keyboard
\r
1546 * when first drawn. Why is this the only dialog that behaves this way? Is
\r
1547 * is the WM_PAINT stuff below?? Sigh...
\r
1549 SetFocus(GetDlgItem(hDlg, IDOK));
\r
1553 /* This should not be necessary. However, if SetSampleFontText() is called
\r
1554 * in response to WM_INITDIALOG, the strings are not properly centered in
\r
1555 * the controls when the dialog first appears. I can't figure out why, so
\r
1556 * this is the workaround. --msw
\r
1559 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1560 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1561 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1562 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1563 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1564 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1565 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1566 firstPaint = FALSE;
\r
1570 case WM_COMMAND: /* message: received a command */
\r
1571 switch (LOWORD(wParam)) {
\r
1574 /* again, it seems to avoid redraw problems if we call EndDialog first */
\r
1575 EndDialog(hDlg, FALSE);
\r
1577 /* copy modified settings back to the fonts array */
\r
1578 for (i=0; i < NUM_FONTS; i++)
\r
1579 CopyFont(font[boardSize][i], &workFont[i]);
\r
1581 /* a sad necessity due to the original design of having a separate
\r
1582 * console font, tags font, and comment font for each board size. IMHO
\r
1583 * these fonts should not be dependent on the current board size. I'm
\r
1584 * running out of time, so I am doing this hack rather than redesign the
\r
1585 * data structure. Besides, I think if I redesigned the data structure, I
\r
1586 * might break backwards compatibility with old winboard.ini files.
\r
1589 for (i=0; i < NUM_SIZES; i++) {
\r
1590 CopyFont(font[i][EDITTAGS_FONT], &workFont[EDITTAGS_FONT]);
\r
1591 CopyFont(font[i][CONSOLE_FONT], &workFont[CONSOLE_FONT]);
\r
1592 CopyFont(font[i][COMMENT_FONT], &workFont[COMMENT_FONT]);
\r
1593 CopyFont(font[i][MOVEHISTORY_FONT], &workFont[MOVEHISTORY_FONT]);
\r
1595 /* end sad necessity */
\r
1597 InitDrawingSizes(boardSize, 0);
\r
1598 InvalidateRect(hwndMain, NULL, TRUE);
\r
1600 if (commentDialog) {
\r
1601 SendDlgItemMessage(commentDialog, OPT_CommentText,
\r
1602 WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf,
\r
1603 MAKELPARAM(TRUE, 0));
\r
1604 GetClientRect(GetDlgItem(commentDialog, OPT_CommentText), &rect);
\r
1605 InvalidateRect(commentDialog, &rect, TRUE);
\r
1608 if (editTagsDialog) {
\r
1609 SendDlgItemMessage(editTagsDialog, OPT_TagsText,
\r
1610 WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf,
\r
1611 MAKELPARAM(TRUE, 0));
\r
1612 GetClientRect(GetDlgItem(editTagsDialog, OPT_TagsText), &rect);
\r
1613 InvalidateRect(editTagsDialog, &rect, TRUE);
\r
1616 if( moveHistoryDialog != NULL ) {
\r
1617 SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory,
\r
1618 WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,
\r
1619 MAKELPARAM(TRUE, 0));
\r
1620 SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 );
\r
1621 // InvalidateRect(editTagsDialog, NULL, TRUE); // [HGM] this ws improperly cloned?
\r
1624 if( engineOutputDialog != NULL ) {
\r
1625 SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1,
\r
1626 WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,
\r
1627 MAKELPARAM(TRUE, 0));
\r
1628 SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo2,
\r
1629 WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,
\r
1630 MAKELPARAM(TRUE, 0));
\r
1633 if (hwndConsole) {
\r
1634 ChangedConsoleFont();
\r
1637 for (i=0; i<NUM_FONTS; i++)
\r
1638 DeleteObject(&workFont[i].hf);
\r
1643 for (i=0; i<NUM_FONTS; i++)
\r
1644 DeleteObject(&workFont[i].hf);
\r
1645 EndDialog(hDlg, FALSE);
\r
1648 case OPT_ChooseClockFont:
\r
1649 MyCreateFont(hDlg, &workFont[CLOCK_FONT]);
\r
1650 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1653 case OPT_ChooseMessageFont:
\r
1654 MyCreateFont(hDlg, &workFont[MESSAGE_FONT]);
\r
1655 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1658 case OPT_ChooseCoordFont:
\r
1659 MyCreateFont(hDlg, &workFont[COORD_FONT]);
\r
1660 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1663 case OPT_ChooseTagFont:
\r
1664 MyCreateFont(hDlg, &workFont[EDITTAGS_FONT]);
\r
1665 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1668 case OPT_ChooseCommentsFont:
\r
1669 MyCreateFont(hDlg, &workFont[COMMENT_FONT]);
\r
1670 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1673 case OPT_ChooseConsoleFont:
\r
1674 MyCreateFont(hDlg, &workFont[CONSOLE_FONT]);
\r
1675 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1678 case OPT_ChooseMoveHistoryFont:
\r
1679 MyCreateFont(hDlg, &workFont[MOVEHISTORY_FONT]);
\r
1680 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1683 case OPT_DefaultFonts:
\r
1684 for (i=0; i<NUM_FONTS; i++) {
\r
1685 DeleteObject(&workFont[i].hf);
\r
1686 ParseFontName(font[boardSize][i]->def, &workFont[i].mfp);
\r
1687 CreateFontInMF(&workFont[i]);
\r
1689 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1690 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1691 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1692 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1693 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1694 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1695 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1703 FontsOptionsPopup(HWND hwnd)
\r
1705 FARPROC lpProc = MakeProcInstance((FARPROC)FontOptionsDialog, hInst);
\r
1706 DialogBox(hInst, MAKEINTRESOURCE(DLG_Fonts), hwnd,
\r
1707 (DLGPROC) lpProc);
\r
1708 FreeProcInstance(lpProc);
\r
1711 /*---------------------------------------------------------------------------*\
\r
1713 * Sounds Dialog functions
\r
1715 \*---------------------------------------------------------------------------*/
\r
1718 SoundComboData soundComboData[] = {
\r
1721 {"ICS Alarm", NULL},
\r
1722 {"ICS Win", NULL},
\r
1723 {"ICS Loss", NULL},
\r
1724 {"ICS Draw", NULL},
\r
1725 {"ICS Unfinished", NULL},
\r
1727 {"SShout/CShout", NULL},
\r
1728 {"Channel 1", NULL},
\r
1729 {"Channel", NULL},
\r
1732 {"Challenge", NULL},
\r
1733 {"Request", NULL},
\r
1740 InitSoundComboData(SoundComboData *scd)
\r
1746 /* copy current sound settings to combo array */
\r
1748 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1749 scd[sc].name = strdup(sounds[sc].name);
\r
1751 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1752 index = (int)cc + (int)NSoundClasses;
\r
1753 scd[index].name = strdup(textAttribs[cc].sound.name);
\r
1759 ResetSoundComboData(SoundComboData *scd)
\r
1761 while (scd->label) {
\r
1762 if (scd->name != NULL) {
\r
1771 InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
\r
1776 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
1778 /* send the labels to the combo box */
\r
1779 while (scd->label) {
\r
1780 err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label);
\r
1781 if (err != cnt++) {
\r
1782 sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n",
\r
1783 (int)err, (int)cnt);
\r
1784 MessageBox(NULL, buf, NULL, MB_OK);
\r
1788 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
1792 SoundDialogWhichRadio(HWND hDlg)
\r
1794 if (IsDlgButtonChecked(hDlg, OPT_NoSound)) return OPT_NoSound;
\r
1795 if (IsDlgButtonChecked(hDlg, OPT_DefaultBeep)) return OPT_DefaultBeep;
\r
1796 if (IsDlgButtonChecked(hDlg, OPT_BuiltInSound)) return OPT_BuiltInSound;
\r
1797 if (IsDlgButtonChecked(hDlg, OPT_WavFile)) return OPT_WavFile;
\r
1802 SoundDialogSetEnables(HWND hDlg, int radio)
\r
1804 EnableWindow(GetDlgItem(hDlg, OPT_BuiltInSoundName),
\r
1805 radio == OPT_BuiltInSound);
\r
1806 EnableWindow(GetDlgItem(hDlg, OPT_WavFileName), radio == OPT_WavFile);
\r
1807 EnableWindow(GetDlgItem(hDlg, OPT_BrowseSound), radio == OPT_WavFile);
\r
1811 SoundDialogGetName(HWND hDlg, int radio)
\r
1813 static char buf[MSG_SIZ], buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
1814 char *dummy, *ret;
\r
1819 case OPT_DefaultBeep:
\r
1821 case OPT_BuiltInSound:
\r
1823 GetDlgItemText(hDlg, OPT_BuiltInSoundName, buf + 1, sizeof(buf) - 1);
\r
1826 GetDlgItemText(hDlg, OPT_WavFileName, buf, sizeof(buf));
\r
1827 GetCurrentDirectory(MSG_SIZ, buf3);
\r
1828 SetCurrentDirectory(installDir);
\r
1829 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
1834 SetCurrentDirectory(buf3);
\r
1840 DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
\r
1844 * I think it's best to clear the combo and edit boxes. It looks stupid
\r
1845 * to have a value from another sound event sitting there grayed out.
\r
1847 SetDlgItemText(hDlg, OPT_WavFileName, "");
\r
1848 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1850 if (appData.debugMode)
\r
1851 fprintf(debugFP, "DisplaySelectedSound(,,'%s'):\n", name);
\r
1852 switch (name[0]) {
\r
1854 radio = OPT_NoSound;
\r
1857 if (name[1] == NULLCHAR) {
\r
1858 radio = OPT_DefaultBeep;
\r
1860 radio = OPT_WavFile;
\r
1861 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1865 if (name[1] == NULLCHAR) {
\r
1866 radio = OPT_NoSound;
\r
1868 radio = OPT_BuiltInSound;
\r
1869 if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1,
\r
1870 (LPARAM) (name + 1)) == CB_ERR) {
\r
1871 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1872 SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1));
\r
1877 radio = OPT_WavFile;
\r
1878 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1881 SoundDialogSetEnables(hDlg, radio);
\r
1882 CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio);
\r
1886 char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES;
\r
1889 SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1891 static HWND hSoundCombo;
\r
1892 static DWORD index;
\r
1893 static HWND hBISN;
\r
1897 char buf[MSG_SIZ];
\r
1901 SoundComboData *scd;
\r
1904 switch (message) {
\r
1905 case WM_INITDIALOG:
\r
1906 /* Center the dialog over the application window */
\r
1907 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1909 /* Initialize the built-in sounds combo */
\r
1910 hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName);
\r
1911 InitComboStrings(hBISN, builtInSoundNames);
\r
1913 /* Initialize the sound events combo */
\r
1915 InitSoundComboData(soundComboData);
\r
1916 hSoundCombo = GetDlgItem(hDlg, CBO_Sounds);
\r
1917 InitSoundCombo(hSoundCombo, soundComboData);
\r
1919 /* update the dialog */
\r
1920 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1923 case WM_COMMAND: /* message: received a command */
\r
1925 if (((HWND)lParam == hSoundCombo) &&
\r
1926 (HIWORD(wParam) == CBN_SELCHANGE)) {
\r
1928 * the user has selected a new sound event. We must store the name for
\r
1929 * the previously selected event, then retrieve the name for the
\r
1930 * newly selected event and update the dialog.
\r
1932 radio = SoundDialogWhichRadio(hDlg);
\r
1933 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1935 if (strcmp(newName, soundComboData[index].name) != 0) {
\r
1936 free(soundComboData[index].name);
\r
1937 soundComboData[index].name = newName;
\r
1942 /* now get the settings for the newly selected event */
\r
1943 index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
\r
1944 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1948 switch (LOWORD(wParam)) {
\r
1951 * save the name for the currently selected sound event
\r
1953 radio = SoundDialogWhichRadio(hDlg);
\r
1954 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1956 if (strcmp(soundComboData[index].name, newName) != 0) {
\r
1957 free(soundComboData[index].name);
\r
1958 soundComboData[index].name = newName;
\r
1964 /* save all the sound names that changed and load the sounds */
\r
1966 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1967 if (strcmp(soundComboData[sc].name, sounds[sc].name) != 0) {
\r
1968 free(sounds[sc].name);
\r
1969 sounds[sc].name = strdup(soundComboData[sc].name);
\r
1970 MyLoadSound(&sounds[sc]);
\r
1973 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1974 index = (int)cc + (int)NSoundClasses;
\r
1975 if (strcmp(soundComboData[index].name,
\r
1976 textAttribs[cc].sound.name) != 0) {
\r
1977 free(textAttribs[cc].sound.name);
\r
1978 textAttribs[cc].sound.name = strdup(soundComboData[index].name);
\r
1979 MyLoadSound(&textAttribs[cc].sound);
\r
1983 mute = FALSE; // [HGM] mute: switch sounds automatically on if we select one
\r
1984 CheckMenuItem(GetMenu(hwndMain),IDM_MuteSounds,MF_BYCOMMAND|MF_UNCHECKED);
\r
1985 ResetSoundComboData(soundComboData);
\r
1986 EndDialog(hDlg, TRUE);
\r
1990 ResetSoundComboData(soundComboData);
\r
1991 EndDialog(hDlg, FALSE);
\r
1994 case OPT_DefaultSounds:
\r
1995 /* can't use SetDefaultSounds() because we need to be able to "undo" if
\r
1996 * user selects "Cancel" later on. So we do it the hard way here.
\r
1998 scd = &soundComboData[0];
\r
1999 while (scd->label != NULL) {
\r
2000 if (scd->name != NULL) free(scd->name);
\r
2001 scd->name = strdup("");
\r
2004 free(soundComboData[(int)SoundBell].name);
\r
2005 soundComboData[(int)SoundBell].name = strdup(SOUND_BELL);
\r
2006 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
2009 case OPT_PlaySound:
\r
2010 radio = SoundDialogWhichRadio(hDlg);
\r
2011 tmp.name = strdup(SoundDialogGetName(hDlg, radio));
\r
2013 MyLoadSound(&tmp);
\r
2014 oldMute = mute; mute = FALSE; // [HGM] mute: always sound when user presses play, ignorig mute setting
\r
2015 MyPlaySound(&tmp);
\r
2017 if (tmp.data != NULL) FreeResource(tmp.data); // technically obsolete fn, but tmp.data is NOT malloc'd mem
\r
2018 if (tmp.name != NULL) free(tmp.name);
\r
2021 case OPT_BrowseSound:
\r
2022 f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT,
\r
2023 "Browse for Sound File", NULL, NULL, buf);
\r
2026 SetDlgItemText(hDlg, OPT_WavFileName, buf);
\r
2031 radio = SoundDialogWhichRadio(hDlg);
\r
2032 SoundDialogSetEnables(hDlg, radio);
\r
2041 VOID SoundOptionsPopup(HWND hwnd)
\r
2045 lpProc = MakeProcInstance((FARPROC)SoundOptionsDialog, hInst);
\r
2046 DialogBox(hInst, MAKEINTRESOURCE(DLG_Sound), hwnd, (DLGPROC)lpProc);
\r
2047 FreeProcInstance(lpProc);
\r
2051 /*---------------------------------------------------------------------------*\
\r
2053 * Comm Port dialog functions
\r
2055 \*---------------------------------------------------------------------------*/
\r
2058 #define FLOW_NONE 0
\r
2059 #define FLOW_XOFF 1
\r
2060 #define FLOW_CTS 2
\r
2061 #define FLOW_DSR 3
\r
2065 ComboData cdPort[] = { {"None", PORT_NONE}, {"COM1", 1}, {"COM2", 2},
\r
2066 {"COM3", 3}, {"COM4", 4}, {NULL, 0} };
\r
2067 ComboData cdDataRate[] = { {"110", 110}, {"300", 300}, {"600", 600}, {"1200", 1200},
\r
2068 {"2400", 2400}, {"4800", 4800}, {"9600", 9600}, {"19200", 19200},
\r
2069 {"38400", 38400}, {NULL, 0} };
\r
2070 ComboData cdDataBits[] = { {"5", 5}, {"6", 6}, {"7", 7}, {"8", 8}, {NULL, 0} };
\r
2071 ComboData cdParity[] = { {"None", NOPARITY}, {"Odd", ODDPARITY}, {"Even", EVENPARITY},
\r
2072 {"Mark", MARKPARITY}, {"Space", SPACEPARITY}, {NULL, 0} };
\r
2073 ComboData cdStopBits[] = { {"1", ONESTOPBIT}, {"1.5", ONE5STOPBITS},
\r
2074 {"2", TWOSTOPBITS}, {NULL, 0} };
\r
2075 ComboData cdFlow[] = { {"None", FLOW_NONE}, {"Xoff/Xon", FLOW_XOFF}, {"CTS", FLOW_CTS},
\r
2076 {"DSR", FLOW_DSR}, {NULL, 0} };
\r
2080 ParseCommSettings(char *arg, DCB *dcb)
\r
2082 int dataRate, count;
\r
2083 char bits[MSG_SIZ], parity[MSG_SIZ], stopBits[MSG_SIZ], flow[MSG_SIZ];
\r
2085 count = sscanf(arg, "%d%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]",
\r
2086 &dataRate, bits, parity, stopBits, flow);
\r
2087 if (count != 5) goto cant_parse;
\r
2088 dcb->BaudRate = dataRate;
\r
2090 while (cd->label != NULL) {
\r
2091 if (StrCaseCmp(cd->label, bits) == 0) {
\r
2092 dcb->ByteSize = cd->value;
\r
2097 if (cd->label == NULL) goto cant_parse;
\r
2099 while (cd->label != NULL) {
\r
2100 if (StrCaseCmp(cd->label, parity) == 0) {
\r
2101 dcb->Parity = cd->value;
\r
2106 if (cd->label == NULL) goto cant_parse;
\r
2108 while (cd->label != NULL) {
\r
2109 if (StrCaseCmp(cd->label, stopBits) == 0) {
\r
2110 dcb->StopBits = cd->value;
\r
2116 if (cd->label == NULL) goto cant_parse;
\r
2117 while (cd->label != NULL) {
\r
2118 if (StrCaseCmp(cd->label, flow) == 0) {
\r
2119 switch (cd->value) {
\r
2121 dcb->fOutX = FALSE;
\r
2122 dcb->fOutxCtsFlow = FALSE;
\r
2123 dcb->fOutxDsrFlow = FALSE;
\r
2126 dcb->fOutX = FALSE;
\r
2127 dcb->fOutxCtsFlow = TRUE;
\r
2128 dcb->fOutxDsrFlow = FALSE;
\r
2131 dcb->fOutX = FALSE;
\r
2132 dcb->fOutxCtsFlow = FALSE;
\r
2133 dcb->fOutxDsrFlow = TRUE;
\r
2136 dcb->fOutX = TRUE;
\r
2137 dcb->fOutxCtsFlow = FALSE;
\r
2138 dcb->fOutxDsrFlow = FALSE;
\r
2145 if (cd->label == NULL) goto cant_parse;
\r
2148 ExitArgError("Can't parse com port settings", arg);
\r
2152 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
\r
2154 char *flow = "??", *parity = "??", *stopBits = "??";
\r
2158 while (cd->label != NULL) {
\r
2159 if (dcb->Parity == cd->value) {
\r
2160 parity = cd->label;
\r
2166 while (cd->label != NULL) {
\r
2167 if (dcb->StopBits == cd->value) {
\r
2168 stopBits = cd->label;
\r
2174 flow = cdFlow[FLOW_XOFF].label;
\r
2175 } else if (dcb->fOutxCtsFlow) {
\r
2176 flow = cdFlow[FLOW_CTS].label;
\r
2177 } else if (dcb->fOutxDsrFlow) {
\r
2178 flow = cdFlow[FLOW_DSR].label;
\r
2180 flow = cdFlow[FLOW_NONE].label;
\r
2182 fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name,
\r
2183 (int)dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow);
\r
2188 InitCombo(HANDLE hwndCombo, ComboData *cd)
\r
2190 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
2192 while (cd->label != NULL) {
\r
2193 SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) cd->label);
\r
2199 SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value)
\r
2204 while (cd->label != NULL) {
\r
2205 if (cd->value == value) {
\r
2206 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) i, (LPARAM) 0);
\r
2215 CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2217 char buf[MSG_SIZ];
\r
2224 switch (message) {
\r
2225 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2226 /* Center the dialog over the application window */
\r
2227 CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER));
\r
2228 /* Initialize the dialog items */
\r
2229 /* !! There should probably be some synchronization
\r
2230 in accessing hCommPort and dcb. Or does modal nature
\r
2231 of this dialog box do it for us?
\r
2233 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2234 InitCombo(hwndCombo, cdPort);
\r
2235 p = strrchr(appData.icsCommPort, '\\');
\r
2236 if (p++ == NULL) p = appData.icsCommPort;
\r
2237 if ((*p == '\0') ||
\r
2238 (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) p) == CB_ERR)) {
\r
2239 SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) "None");
\r
2241 EnableWindow(hwndCombo, hCommPort == NULL); /*!! don't allow change for now*/
\r
2243 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2244 InitCombo(hwndCombo, cdDataRate);
\r
2245 sprintf(buf, "%u", (int)dcb.BaudRate);
\r
2246 if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) {
\r
2247 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
2248 SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf);
\r
2251 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2252 InitCombo(hwndCombo, cdDataBits);
\r
2253 SelectComboValue(hwndCombo, cdDataBits, dcb.ByteSize);
\r
2255 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2256 InitCombo(hwndCombo, cdParity);
\r
2257 SelectComboValue(hwndCombo, cdParity, dcb.Parity);
\r
2259 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2260 InitCombo(hwndCombo, cdStopBits);
\r
2261 SelectComboValue(hwndCombo, cdStopBits, dcb.StopBits);
\r
2263 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2264 InitCombo(hwndCombo, cdFlow);
\r
2266 SelectComboValue(hwndCombo, cdFlow, FLOW_XOFF);
\r
2267 } else if (dcb.fOutxCtsFlow) {
\r
2268 SelectComboValue(hwndCombo, cdFlow, FLOW_CTS);
\r
2269 } else if (dcb.fOutxDsrFlow) {
\r
2270 SelectComboValue(hwndCombo, cdFlow, FLOW_DSR);
\r
2272 SelectComboValue(hwndCombo, cdFlow, FLOW_NONE);
\r
2276 case WM_COMMAND: /* message: received a command */
\r
2277 switch (LOWORD(wParam)) {
\r
2279 /* Read changed options from the dialog box */
\r
2281 /* !! Currently we can't change comm ports in midstream */
\r
2282 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2283 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2284 if (index == PORT_NONE) {
\r
2285 appData.icsCommPort = "";
\r
2286 if (hCommPort != NULL) {
\r
2287 CloseHandle(hCommPort);
\r
2290 EndDialog(hDlg, TRUE);
\r
2293 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2294 appData.icsCommPort = strdup(buf);
\r
2295 if (hCommPort != NULL) {
\r
2296 CloseHandle(hCommPort);
\r
2299 /* now what?? can't really do this; have to fix up the ChildProc
\r
2300 and InputSource records for the comm port that we gave to the
\r
2304 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2305 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2306 if (sscanf(buf, "%u", &value) != 1) {
\r
2307 MessageBox(hDlg, "Invalid data rate",
\r
2308 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2311 dcb.BaudRate = value;
\r
2313 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2314 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2315 dcb.ByteSize = cdDataBits[index].value;
\r
2317 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2318 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2319 dcb.Parity = cdParity[index].value;
\r
2321 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2322 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2323 dcb.StopBits = cdStopBits[index].value;
\r
2325 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2326 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2327 switch (cdFlow[index].value) {
\r
2329 dcb.fOutX = FALSE;
\r
2330 dcb.fOutxCtsFlow = FALSE;
\r
2331 dcb.fOutxDsrFlow = FALSE;
\r
2334 dcb.fOutX = FALSE;
\r
2335 dcb.fOutxCtsFlow = TRUE;
\r
2336 dcb.fOutxDsrFlow = FALSE;
\r
2339 dcb.fOutX = FALSE;
\r
2340 dcb.fOutxCtsFlow = FALSE;
\r
2341 dcb.fOutxDsrFlow = TRUE;
\r
2345 dcb.fOutxCtsFlow = FALSE;
\r
2346 dcb.fOutxDsrFlow = FALSE;
\r
2349 if (!SetCommState(hCommPort, (LPDCB) &dcb)) {
\r
2350 err = GetLastError();
\r
2351 switch(MessageBox(hDlg,
\r
2352 "Failed to set comm port state;\r\ninvalid options?",
\r
2353 "Option Error", MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {
\r
2355 DisplayFatalError("Failed to set comm port state", err, 1);
\r
2356 exit(1); /*is it ok to do this from here?*/
\r
2362 EndDialog(hDlg, TRUE);
\r
2367 EndDialog(hDlg, TRUE);
\r
2371 EndDialog(hDlg, FALSE);
\r
2383 CommPortOptionsPopup(HWND hwnd)
\r
2385 FARPROC lpProc = MakeProcInstance((FARPROC)CommPortOptionsDialog, hInst);
\r
2386 DialogBox(hInst, MAKEINTRESOURCE(DLG_CommPort), hwnd, (DLGPROC) lpProc);
\r
2387 FreeProcInstance(lpProc);
\r
2390 /*---------------------------------------------------------------------------*\
\r
2392 * Load Options dialog functions
\r
2394 \*---------------------------------------------------------------------------*/
\r
2397 SetLoadOptionEnables(HWND hDlg)
\r
2401 state = IsDlgButtonChecked(hDlg, OPT_Autostep);
\r
2402 EnableWindow(GetDlgItem(hDlg, OPT_ASTimeDelay), state);
\r
2403 EnableWindow(GetDlgItem(hDlg, OPT_AStext1), state);
\r
2407 LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2409 char buf[MSG_SIZ];
\r
2412 switch (message) {
\r
2413 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2414 /* Center the dialog over the application window */
\r
2415 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2416 /* Initialize the dialog items */
\r
2417 if (appData.timeDelay >= 0.0) {
\r
2418 CheckDlgButton(hDlg, OPT_Autostep, TRUE);
\r
2419 sprintf(buf, "%.2g", appData.timeDelay);
\r
2420 SetDlgItemText(hDlg, OPT_ASTimeDelay, buf);
\r
2422 CheckDlgButton(hDlg, OPT_Autostep, FALSE);
\r
2424 SetLoadOptionEnables(hDlg);
\r
2427 case WM_COMMAND: /* message: received a command */
\r
2428 switch (LOWORD(wParam)) {
\r
2430 /* Read changed options from the dialog box */
\r
2431 if (IsDlgButtonChecked(hDlg, OPT_Autostep)) {
\r
2432 GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ);
\r
2433 if (sscanf(buf, "%f", &fnumber) != 1) {
\r
2434 MessageBox(hDlg, "Invalid load game step rate",
\r
2435 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2438 appData.timeDelay = fnumber;
\r
2440 appData.timeDelay = (float) -1.0;
\r
2442 EndDialog(hDlg, TRUE);
\r
2446 EndDialog(hDlg, FALSE);
\r
2450 SetLoadOptionEnables(hDlg);
\r
2460 LoadOptionsPopup(HWND hwnd)
\r
2462 FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst);
\r
2463 DialogBox(hInst, MAKEINTRESOURCE(DLG_LoadOptions), hwnd, (DLGPROC) lpProc);
\r
2464 FreeProcInstance(lpProc);
\r
2467 /*---------------------------------------------------------------------------*\
\r
2469 * Save Options dialog functions
\r
2471 \*---------------------------------------------------------------------------*/
\r
2474 SetSaveOptionEnables(HWND hDlg)
\r
2478 state = IsDlgButtonChecked(hDlg, OPT_Autosave);
\r
2479 EnableWindow(GetDlgItem(hDlg, OPT_AVPrompt), state);
\r
2480 EnableWindow(GetDlgItem(hDlg, OPT_AVToFile), state);
\r
2481 if (state && !IsDlgButtonChecked(hDlg, OPT_AVPrompt) &&
\r
2482 !IsDlgButtonChecked(hDlg, OPT_AVToFile)) {
\r
2483 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2486 state = state && IsDlgButtonChecked(hDlg, OPT_AVToFile);
\r
2487 EnableWindow(GetDlgItem(hDlg, OPT_AVFilename), state);
\r
2488 EnableWindow(GetDlgItem(hDlg, OPT_AVBrowse), state);
\r
2492 SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2494 char buf[MSG_SIZ];
\r
2497 switch (message) {
\r
2498 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2499 /* Center the dialog over the application window */
\r
2500 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2501 /* Initialize the dialog items */
\r
2502 if (*appData.saveGameFile != NULLCHAR) {
\r
2503 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2504 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVToFile);
\r
2505 SetDlgItemText(hDlg, OPT_AVFilename, appData.saveGameFile);
\r
2506 } else if (appData.autoSaveGames) {
\r
2507 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2508 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2510 CheckDlgButton(hDlg, OPT_Autosave, (UINT) FALSE);
\r
2512 if (appData.oldSaveStyle) {
\r
2513 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_Old);
\r
2515 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_PGN);
\r
2517 CheckDlgButton( hDlg, OPT_OutOfBookInfo, appData.saveOutOfBookInfo );
\r
2518 SetSaveOptionEnables(hDlg);
\r
2521 case WM_COMMAND: /* message: received a command */
\r
2522 switch (LOWORD(wParam)) {
\r
2524 /* Read changed options from the dialog box */
\r
2525 if (IsDlgButtonChecked(hDlg, OPT_Autosave)) {
\r
2526 appData.autoSaveGames = TRUE;
\r
2527 if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) {
\r
2528 appData.saveGameFile = "";
\r
2529 } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ {
\r
2530 GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ);
\r
2531 if (*buf == NULLCHAR) {
\r
2532 MessageBox(hDlg, "Invalid save game file name",
\r
2533 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2536 if ((isalpha(buf[0]) && buf[1] == ':') ||
\r
2537 (buf[0] == '\\' && buf[1] == '\\')) {
\r
2538 appData.saveGameFile = strdup(buf);
\r
2540 char buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
2542 GetCurrentDirectory(MSG_SIZ, buf3);
\r
2543 SetCurrentDirectory(installDir);
\r
2544 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
2545 appData.saveGameFile = strdup(buf2);
\r
2547 appData.saveGameFile = strdup(buf);
\r
2549 SetCurrentDirectory(buf3);
\r
2553 appData.autoSaveGames = FALSE;
\r
2554 appData.saveGameFile = "";
\r
2556 appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old);
\r
2557 appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo );
\r
2558 EndDialog(hDlg, TRUE);
\r
2562 EndDialog(hDlg, FALSE);
\r
2565 case OPT_AVBrowse:
\r
2566 f = OpenFileDialog(hDlg, "a", NULL,
\r
2567 appData.oldSaveStyle ? "gam" : "pgn",
\r
2568 GAME_FILT, "Browse for Auto Save File",
\r
2572 SetDlgItemText(hDlg, OPT_AVFilename, buf);
\r
2577 SetSaveOptionEnables(hDlg);
\r
2586 SaveOptionsPopup(HWND hwnd)
\r
2588 FARPROC lpProc = MakeProcInstance((FARPROC)SaveOptionsDialog, hInst);
\r
2589 DialogBox(hInst, MAKEINTRESOURCE(DLG_SaveOptions), hwnd, (DLGPROC) lpProc);
\r
2590 FreeProcInstance(lpProc);
\r
2593 /*---------------------------------------------------------------------------*\
\r
2595 * Time Control Options dialog functions
\r
2597 \*---------------------------------------------------------------------------*/
\r
2600 SetTimeControlEnables(HWND hDlg)
\r
2604 state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves)
\r
2605 + 2*IsDlgButtonChecked(hDlg, OPT_TCUseFixed);
\r
2606 EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state == 1);
\r
2607 EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state == 1);
\r
2608 EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state == 1);
\r
2609 EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state == 1);
\r
2610 EnableWindow(GetDlgItem(hDlg, OPT_TCTime2), !state);
\r
2611 EnableWindow(GetDlgItem(hDlg, OPT_TCInc), !state);
\r
2612 EnableWindow(GetDlgItem(hDlg, OPT_TCitext1), !state);
\r
2613 EnableWindow(GetDlgItem(hDlg, OPT_TCitext2), !state);
\r
2614 EnableWindow(GetDlgItem(hDlg, OPT_TCitext3), !state);
\r
2615 EnableWindow(GetDlgItem(hDlg, OPT_TCFixed), state == 2);
\r
2616 EnableWindow(GetDlgItem(hDlg, OPT_TCftext), state == 2);
\r
2621 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2623 char buf[MSG_SIZ], *tc;
\r
2624 int mps, increment, odds1, odds2, st;
\r
2627 switch (message) {
\r
2628 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2629 /* Center the dialog over the application window */
\r
2630 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2631 /* Initialize the dialog items */
\r
2632 if (appData.clockMode && !appData.icsActive) {
\r
2634 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,
\r
2636 SetDlgItemInt(hDlg, OPT_TCFixed, searchTime, FALSE);
\r
2638 if (appData.timeIncrement == -1) {
\r
2639 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,
\r
2641 SetDlgItemText(hDlg, OPT_TCTime, appData.timeControl);
\r
2642 SetDlgItemInt(hDlg, OPT_TCMoves, appData.movesPerSession,
\r
2644 SetDlgItemText(hDlg, OPT_TCTime2, "");
\r
2645 SetDlgItemText(hDlg, OPT_TCInc, "");
\r
2647 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,
\r
2649 SetDlgItemText(hDlg, OPT_TCTime, "");
\r
2650 SetDlgItemText(hDlg, OPT_TCMoves, "");
\r
2651 SetDlgItemText(hDlg, OPT_TCTime2, appData.timeControl);
\r
2652 SetDlgItemInt(hDlg, OPT_TCInc, appData.timeIncrement, FALSE);
\r
2654 SetDlgItemInt(hDlg, OPT_TCOdds1, 1, FALSE);
\r
2655 SetDlgItemInt(hDlg, OPT_TCOdds2, 1, FALSE);
\r
2656 SetTimeControlEnables(hDlg);
\r
2660 case WM_COMMAND: /* message: received a command */
\r
2661 switch (LOWORD(wParam)) {
\r
2663 mps = appData.movesPerSession;
\r
2664 increment = appData.timeIncrement;
\r
2665 tc = appData.timeControl;
\r
2667 /* Read changed options from the dialog box */
\r
2668 if (IsDlgButtonChecked(hDlg, OPT_TCUseFixed)) {
\r
2669 st = GetDlgItemInt(hDlg, OPT_TCFixed, &ok, FALSE);
\r
2670 if (!ok || st <= 0) {
\r
2671 MessageBox(hDlg, "Invalid max time per move",
\r
2672 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2676 if (IsDlgButtonChecked(hDlg, OPT_TCUseMoves)) {
\r
2678 mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE);
\r
2679 if (!ok || mps <= 0) {
\r
2680 MessageBox(hDlg, "Invalid moves per time control",
\r
2681 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2684 GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ);
\r
2685 if (!ParseTimeControl(buf, increment, mps)) {
\r
2686 MessageBox(hDlg, "Invalid minutes per time control",
\r
2687 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2692 increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE);
\r
2693 if (!ok || increment < 0) {
\r
2694 MessageBox(hDlg, "Invalid increment",
\r
2695 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2698 GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ);
\r
2699 if (!ParseTimeControl(buf, increment, mps)) {
\r
2700 MessageBox(hDlg, "Invalid initial time",
\r
2701 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2706 odds1 = GetDlgItemInt(hDlg, OPT_TCOdds1, &ok, FALSE);
\r
2707 odds2 = GetDlgItemInt(hDlg, OPT_TCOdds2, &ok2, FALSE);
\r
2708 if (!ok || !ok2 || odds1 <= 0 || odds2 <= 0) {
\r
2709 MessageBox(hDlg, "Invalid time-odds factor",
\r
2710 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2714 appData.timeControl = strdup(tc);
\r
2715 appData.movesPerSession = mps;
\r
2716 appData.timeIncrement = increment;
\r
2717 appData.firstTimeOdds = first.timeOdds = odds1;
\r
2718 appData.secondTimeOdds = second.timeOdds = odds2;
\r
2719 Reset(TRUE, TRUE);
\r
2720 EndDialog(hDlg, TRUE);
\r
2724 EndDialog(hDlg, FALSE);
\r
2728 SetTimeControlEnables(hDlg);
\r
2737 TimeControlOptionsPopup(HWND hwnd)
\r
2739 if (gameMode != BeginningOfGame) {
\r
2740 DisplayError("Changing time control during a game is not implemented", 0);
\r
2742 FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst);
\r
2743 DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc);
\r
2744 FreeProcInstance(lpProc);
\r
2748 /*---------------------------------------------------------------------------*\
\r
2750 * Engine Options Dialog functions
\r
2752 \*---------------------------------------------------------------------------*/
\r
2753 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
2754 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
2756 #define INT_ABS( n ) ((n) >= 0 ? (n) : -(n))
\r
2758 LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2760 switch (message) {
\r
2761 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2763 /* Center the dialog over the application window */
\r
2764 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2766 /* Initialize the dialog items */
\r
2767 CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates);
\r
2768 CHECK_BOX(IDC_EpPonder, appData.ponderNextMove);
\r
2769 CHECK_BOX(IDC_EpShowThinking, appData.showThinking);
\r
2770 CHECK_BOX(IDC_EpHideThinkingHuman, appData.hideThinkingFromHuman);
\r
2772 CHECK_BOX(IDC_TestClaims, appData.testClaims);
\r
2773 CHECK_BOX(IDC_DetectMates, appData.checkMates);
\r
2774 CHECK_BOX(IDC_MaterialDraws, appData.materialDraws);
\r
2775 CHECK_BOX(IDC_TrivialDraws, appData.trivialDraws);
\r
2777 CHECK_BOX(IDC_ScoreAbs1, appData.firstScoreIsAbsolute);
\r
2778 CHECK_BOX(IDC_ScoreAbs2, appData.secondScoreIsAbsolute);
\r
2780 SetDlgItemInt( hDlg, IDC_EpDrawMoveCount, appData.adjudicateDrawMoves, TRUE );
\r
2781 SendDlgItemMessage( hDlg, IDC_EpDrawMoveCount, EM_SETSEL, 0, -1 );
\r
2783 SetDlgItemInt( hDlg, IDC_EpAdjudicationThreshold, INT_ABS(appData.adjudicateLossThreshold), TRUE );
\r
2784 SendDlgItemMessage( hDlg, IDC_EpAdjudicationThreshold, EM_SETSEL, 0, -1 );
\r
2786 SetDlgItemInt( hDlg, IDC_RuleMoves, appData.ruleMoves, TRUE );
\r
2787 SendDlgItemMessage( hDlg, IDC_RuleMoves, EM_SETSEL, 0, -1 );
\r
2789 SetDlgItemInt( hDlg, IDC_DrawRepeats, INT_ABS(appData.drawRepeats), TRUE );
\r
2790 SendDlgItemMessage( hDlg, IDC_DrawRepeats, EM_SETSEL, 0, -1 );
\r
2794 case WM_COMMAND: /* message: received a command */
\r
2795 switch (LOWORD(wParam)) {
\r
2797 /* Read changed options from the dialog box */
\r
2798 PeriodicUpdatesEvent( IS_CHECKED(IDC_EpPeriodicUpdates));
\r
2799 PonderNextMoveEvent( IS_CHECKED(IDC_EpPonder));
\r
2800 appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up
\r
2801 appData.showThinking = IS_CHECKED(IDC_EpShowThinking);
\r
2802 ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output
\r
2803 appData.testClaims = IS_CHECKED(IDC_TestClaims);
\r
2804 appData.checkMates = IS_CHECKED(IDC_DetectMates);
\r
2805 appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);
\r
2806 appData.trivialDraws = IS_CHECKED(IDC_TrivialDraws);
\r
2808 appData.adjudicateDrawMoves = GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, NULL, FALSE );
\r
2809 appData.adjudicateLossThreshold = - (int) GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, NULL, FALSE );
\r
2810 appData.ruleMoves = GetDlgItemInt(hDlg, IDC_RuleMoves, NULL, FALSE );
\r
2811 appData.drawRepeats = (int) GetDlgItemInt(hDlg, IDC_DrawRepeats, NULL, FALSE );
\r
2813 first.scoreIsAbsolute = appData.firstScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs1);
\r
2814 second.scoreIsAbsolute = appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2);
\r
2816 EndDialog(hDlg, TRUE);
\r
2820 EndDialog(hDlg, FALSE);
\r
2823 case IDC_EpDrawMoveCount:
\r
2824 case IDC_EpAdjudicationThreshold:
\r
2825 case IDC_DrawRepeats:
\r
2826 case IDC_RuleMoves:
\r
2827 if( HIWORD(wParam) == EN_CHANGE ) {
\r
2833 GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, &n1_ok, FALSE );
\r
2834 GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, &n2_ok, FALSE );
\r
2835 GetDlgItemInt(hDlg, IDC_RuleMoves, &n3_ok, FALSE );
\r
2836 GetDlgItemInt(hDlg, IDC_DrawRepeats, &n4_ok, FALSE );
\r
2838 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok && n4_ok ? TRUE : FALSE );
\r
2847 VOID EnginePlayOptionsPopup(HWND hwnd)
\r
2851 lpProc = MakeProcInstance((FARPROC)EnginePlayOptionsDialog, hInst);
\r
2852 DialogBox(hInst, MAKEINTRESOURCE(DLG_EnginePlayOptions), hwnd, (DLGPROC) lpProc);
\r
2853 FreeProcInstance(lpProc);
\r
2856 /*---------------------------------------------------------------------------*\
\r
2858 * UCI Options Dialog functions
\r
2860 \*---------------------------------------------------------------------------*/
\r
2861 static BOOL BrowseForFolder( const char * title, char * path )
\r
2863 BOOL result = FALSE;
\r
2865 LPITEMIDLIST pidl;
\r
2867 ZeroMemory( &bi, sizeof(bi) );
\r
2869 bi.lpszTitle = title == 0 ? "Choose Folder" : title;
\r
2870 bi.ulFlags = BIF_RETURNONLYFSDIRS;
\r
2872 pidl = SHBrowseForFolder( &bi );
\r
2875 IMalloc * imalloc = 0;
\r
2877 if( SHGetPathFromIDList( pidl, path ) ) {
\r
2881 if( SUCCEEDED( SHGetMalloc ( &imalloc ) ) ) {
\r
2882 imalloc->lpVtbl->Free(imalloc,pidl);
\r
2883 imalloc->lpVtbl->Release(imalloc);
\r
2890 LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2892 char buf[MAX_PATH];
\r
2895 switch (message) {
\r
2896 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2898 /* Center the dialog over the application window */
\r
2899 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2901 /* Initialize the dialog items */
\r
2902 SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir );
\r
2903 SetDlgItemInt( hDlg, IDC_HashSize, appData.defaultHashSize, TRUE );
\r
2904 SetDlgItemText( hDlg, IDC_PathToEGTB, appData.defaultPathEGTB );
\r
2905 SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE );
\r
2906 CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook );
\r
2907 SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook );
\r
2908 // [HGM] smp: input field for nr of cores:
\r
2909 SetDlgItemInt( hDlg, IDC_Cores, appData.smpCores, TRUE );
\r
2910 // [HGM] book: tick boxes for own book use
\r
2911 CheckDlgButton( hDlg, IDC_OwnBook1, (BOOL) appData.firstHasOwnBookUCI );
\r
2912 CheckDlgButton( hDlg, IDC_OwnBook2, (BOOL) appData.secondHasOwnBookUCI );
\r
2914 SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 );
\r
2918 case WM_COMMAND: /* message: received a command */
\r
2919 switch (LOWORD(wParam)) {
\r
2921 GetDlgItemText( hDlg, IDC_PolyglotDir, buf, sizeof(buf) );
\r
2922 appData.polyglotDir = strdup(buf);
\r
2923 appData.defaultHashSize = GetDlgItemInt(hDlg, IDC_HashSize, NULL, FALSE );
\r
2924 appData.defaultCacheSizeEGTB = GetDlgItemInt(hDlg, IDC_SizeOfEGTB, NULL, FALSE );
\r
2925 GetDlgItemText( hDlg, IDC_PathToEGTB, buf, sizeof(buf) );
\r
2926 appData.defaultPathEGTB = strdup(buf);
\r
2927 GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) );
\r
2928 appData.polyglotBook = strdup(buf);
\r
2929 appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook );
\r
2930 // [HGM] smp: get nr of cores:
\r
2931 oldCores = appData.smpCores;
\r
2932 appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE );
\r
2933 if(appData.smpCores != oldCores) NewSettingEvent(FALSE, "cores", appData.smpCores);
\r
2934 // [HGM] book: read tick boxes for own book use
\r
2935 appData.firstHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 );
\r
2936 appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 );
\r
2938 if(gameMode == BeginningOfGame) Reset(TRUE, TRUE);
\r
2939 EndDialog(hDlg, TRUE);
\r
2943 EndDialog(hDlg, FALSE);
\r
2946 case IDC_BrowseForBook:
\r
2948 char filter[] = {
\r
2949 'A','l','l',' ','F','i','l','e','s', 0,
\r
2951 'B','I','N',' ','F','i','l','e','s', 0,
\r
2952 '*','.','b','i','n', 0,
\r
2957 strcpy( buf, "" );
\r
2959 ZeroMemory( &ofn, sizeof(ofn) );
\r
2961 ofn.lStructSize = sizeof(ofn);
\r
2962 ofn.hwndOwner = hDlg;
\r
2963 ofn.hInstance = hInst;
\r
2964 ofn.lpstrFilter = filter;
\r
2965 ofn.lpstrFile = buf;
\r
2966 ofn.nMaxFile = sizeof(buf);
\r
2967 ofn.lpstrTitle = "Choose Book";
\r
2968 ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
\r
2970 if( GetOpenFileName( &ofn ) ) {
\r
2971 SetDlgItemText( hDlg, IDC_BookFile, buf );
\r
2976 case IDC_BrowseForPolyglotDir:
\r
2977 if( BrowseForFolder( "Choose Polyglot Directory", buf ) ) {
\r
2978 SetDlgItemText( hDlg, IDC_PolyglotDir, buf );
\r
2980 strcat( buf, "\\polyglot.exe" );
\r
2982 if( GetFileAttributes(buf) == 0xFFFFFFFF ) {
\r
2983 MessageBox( hDlg, "Polyglot was not found in the specified folder!", "Warning", MB_OK | MB_ICONWARNING );
\r
2988 case IDC_BrowseForEGTB:
\r
2989 if( BrowseForFolder( "Choose EGTB Directory:", buf ) ) {
\r
2990 SetDlgItemText( hDlg, IDC_PathToEGTB, buf );
\r
2994 case IDC_HashSize:
\r
2995 case IDC_SizeOfEGTB:
\r
2996 if( HIWORD(wParam) == EN_CHANGE ) {
\r
3000 GetDlgItemInt(hDlg, IDC_HashSize, &n1_ok, FALSE );
\r
3001 GetDlgItemInt(hDlg, IDC_SizeOfEGTB, &n2_ok, FALSE );
\r
3003 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok ? TRUE : FALSE );
\r
3012 VOID UciOptionsPopup(HWND hwnd)
\r
3016 lpProc = MakeProcInstance((FARPROC)UciOptionsDialog, hInst);
\r
3017 DialogBox(hInst, MAKEINTRESOURCE(DLG_OptionsUCI), hwnd, (DLGPROC) lpProc);
\r
3018 FreeProcInstance(lpProc);
\r