2 * woptions.c -- Options dialog box routines for WinBoard
\r
3 * $Id: woptions.c,v 2.1 2003/10/27 19:21:02 mann Exp $
\r
5 * Copyright 2000 Free Software Foundation, Inc.
\r
7 * ------------------------------------------------------------------------
\r
8 * This program is free software; you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation; either version 2 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License
\r
19 * along with this program; if not, write to the Free Software
\r
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
\r
21 * ------------------------------------------------------------------------
\r
26 #include <windows.h> /* required for all Windows applications */
\r
29 #include <shlobj.h> /* [AS] Requires NT 4.0 or Win95 */
\r
32 #include "winboard.h"
\r
33 #include "backend.h"
\r
34 #include "woptions.h"
\r
35 #include "defaults.h"
\r
36 #include "wedittags.h"
\r
37 #include <richedit.h>
\r
44 /* Imports from winboard.c */
\r
46 extern MyFont *font[NUM_SIZES][NUM_FONTS];
\r
47 extern HINSTANCE hInst; /* current instance */
\r
48 extern HWND hwndMain; /* root window*/
\r
49 extern BOOLEAN alwaysOnTop;
\r
50 extern RECT boardRect;
\r
51 extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor,
\r
52 blackPieceColor, highlightSquareColor, premoveHighlightColor;
\r
53 extern HPALETTE hPal;
\r
54 extern BoardSize boardSize;
\r
55 extern COLORREF consoleBackgroundColor;
\r
56 extern MyColorizeAttribs colorizeAttribs[]; /* do I need the size? */
\r
57 extern MyTextAttribs textAttribs[];
\r
58 extern MySound sounds[];
\r
59 extern ColorClass currentColorClass;
\r
60 extern HWND hwndConsole;
\r
61 extern char *defaultTextAttribs[];
\r
62 extern HWND commentDialog;
\r
63 extern HWND moveHistoryDialog;
\r
64 extern char installDir[];
\r
65 extern HWND hCommPort; /* currently open comm port */
\r
67 extern BOOLEAN chessProgram;
\r
68 extern startedFromPositionFile; /* [HGM] loadPos */
\r
82 /* module prototypes */
\r
84 LRESULT CALLBACK GeneralOptions(HWND, UINT, WPARAM, LPARAM);
\r
85 LRESULT CALLBACK BoardOptions(HWND, UINT, WPARAM, LPARAM);
\r
86 LRESULT CALLBACK NewVariant(HWND, UINT, WPARAM, LPARAM);
\r
87 LRESULT CALLBACK IcsOptions(HWND, UINT, WPARAM, LPARAM);
\r
88 LRESULT CALLBACK FontOptions(HWND, UINT, WPARAM, LPARAM);
\r
89 LRESULT CALLBACK CommPortOptions(HWND, UINT, WPARAM, LPARAM);
\r
90 LRESULT CALLBACK LoadOptions(HWND, UINT, WPARAM, LPARAM);
\r
91 LRESULT CALLBACK SaveOptions(HWND, UINT, WPARAM, LPARAM);
\r
92 LRESULT CALLBACK TimeControl(HWND, UINT, WPARAM, LPARAM);
\r
93 VOID ChangeBoardSize(BoardSize newSize);
\r
94 VOID PaintSampleSquare(
\r
97 COLORREF squareColor,
\r
98 COLORREF pieceColor,
\r
99 COLORREF squareOutlineColor,
\r
100 COLORREF pieceDetailColor,
\r
105 VOID PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color);
\r
106 VOID SetBoardOptionEnables(HWND hDlg);
\r
107 BoardSize BoardOptionsWhichRadio(HWND hDlg);
\r
108 BOOL APIENTRY MyCreateFont(HWND hwnd, MyFont *font);
\r
109 VOID UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca);
\r
110 LRESULT CALLBACK ColorizeTextDialog(HWND , UINT, WPARAM, LPARAM);
\r
111 VOID ColorizeTextPopup(HWND hwnd, ColorClass cc);
\r
112 VOID SetIcsOptionEnables(HWND hDlg);
\r
113 VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf);
\r
114 VOID CopyFont(MyFont *dest, const MyFont *src);
\r
115 void InitSoundComboData(SoundComboData *scd);
\r
116 void ResetSoundComboData(SoundComboData *scd);
\r
117 void InitSoundCombo(HWND hwndCombo, SoundComboData *scd);
\r
118 int SoundDialogWhichRadio(HWND hDlg);
\r
119 VOID SoundDialogSetEnables(HWND hDlg, int radio);
\r
120 char * SoundDialogGetName(HWND hDlg, int radio);
\r
121 void DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name);
\r
122 VOID ParseCommSettings(char *arg, DCB *dcb);
\r
123 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb);
\r
124 void InitCombo(HANDLE hwndCombo, ComboData *cd);
\r
125 void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value);
\r
126 VOID SetLoadOptionEnables(HWND hDlg);
\r
127 VOID SetSaveOptionEnables(HWND hDlg);
\r
128 VOID SetTimeControlEnables(HWND hDlg);
\r
130 /*---------------------------------------------------------------------------*\
\r
132 * General Options Dialog functions
\r
134 \*---------------------------------------------------------------------------*/
\r
138 GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
140 static Boolean oldShowCoords;
\r
141 static Boolean oldBlindfold;
\r
142 static Boolean oldShowButtonBar;
\r
145 case WM_INITDIALOG: /* message: initialize dialog box */
\r
146 oldShowCoords = appData.showCoords;
\r
147 oldBlindfold = appData.blindfold;
\r
148 oldShowButtonBar = appData.showButtonBar;
\r
150 /* Center the dialog over the application window */
\r
151 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
153 /* Initialize the dialog items */
\r
154 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
156 CHECK_BOX(OPT_AlwaysOnTop, alwaysOnTop);
\r
157 CHECK_BOX(OPT_AlwaysQueen, appData.alwaysPromoteToQueen);
\r
158 CHECK_BOX(OPT_AnimateDragging, appData.animateDragging);
\r
159 CHECK_BOX(OPT_AnimateMoving, appData.animate);
\r
160 CHECK_BOX(OPT_AutoFlag, appData.autoCallFlag);
\r
161 CHECK_BOX(OPT_AutoFlipView, appData.autoFlipView);
\r
162 CHECK_BOX(OPT_AutoRaiseBoard, appData.autoRaiseBoard);
\r
163 CHECK_BOX(OPT_Blindfold, appData.blindfold);
\r
164 CHECK_BOX(OPT_HighlightDragging, appData.highlightDragging);
\r
165 CHECK_BOX(OPT_HighlightLastMove, appData.highlightLastMove);
\r
166 CHECK_BOX(OPT_PeriodicUpdates, appData.periodicUpdates);
\r
167 CHECK_BOX(OPT_PonderNextMove, appData.ponderNextMove);
\r
168 CHECK_BOX(OPT_PopupExitMessage, appData.popupExitMessage);
\r
169 CHECK_BOX(OPT_PopupMoveErrors, appData.popupMoveErrors);
\r
170 CHECK_BOX(OPT_ShowButtonBar, appData.showButtonBar);
\r
171 CHECK_BOX(OPT_ShowCoordinates, appData.showCoords);
\r
172 CHECK_BOX(OPT_ShowThinking, appData.showThinking);
\r
173 CHECK_BOX(OPT_TestLegality, appData.testLegality);
\r
174 CHECK_BOX(OPT_HideThinkFromHuman, appData.hideThinkingFromHuman);
\r
175 CHECK_BOX(OPT_SaveExtPGN, appData.saveExtendedInfoInPGN);
\r
176 CHECK_BOX(OPT_ExtraInfoInMoveHistory, appData.showEvalInMoveHistory);
\r
177 CHECK_BOX(OPT_HighlightMoveArrow, appData.highlightMoveWithArrow);
\r
181 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlag),
\r
182 appData.icsActive || !appData.noChessProgram);
\r
183 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlipView),
\r
184 appData.icsActive || !appData.noChessProgram);
\r
185 EnableWindow(GetDlgItem(hDlg, OPT_PonderNextMove),
\r
186 !appData.noChessProgram);
\r
187 EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates),
\r
188 !appData.noChessProgram && !appData.icsActive);
\r
189 EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking),
\r
190 !appData.noChessProgram);
\r
194 case WM_COMMAND: /* message: received a command */
\r
195 switch (LOWORD(wParam)) {
\r
197 /* Read changed options from the dialog box */
\r
199 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
201 alwaysOnTop = IS_CHECKED(OPT_AlwaysOnTop);
\r
202 appData.alwaysPromoteToQueen = IS_CHECKED(OPT_AlwaysQueen);
\r
203 appData.animateDragging = IS_CHECKED(OPT_AnimateDragging);
\r
204 appData.animate = IS_CHECKED(OPT_AnimateMoving);
\r
205 appData.autoCallFlag = IS_CHECKED(OPT_AutoFlag);
\r
206 appData.autoFlipView = IS_CHECKED(OPT_AutoFlipView);
\r
207 appData.autoRaiseBoard = IS_CHECKED(OPT_AutoRaiseBoard);
\r
208 appData.blindfold = IS_CHECKED(OPT_Blindfold);
\r
209 appData.highlightDragging = IS_CHECKED(OPT_HighlightDragging);
\r
210 appData.highlightLastMove = IS_CHECKED(OPT_HighlightLastMove);
\r
211 PeriodicUpdatesEvent( IS_CHECKED(OPT_PeriodicUpdates));
\r
212 PonderNextMoveEvent( IS_CHECKED(OPT_PonderNextMove));
\r
213 appData.popupExitMessage = IS_CHECKED(OPT_PopupExitMessage);
\r
214 appData.popupMoveErrors = IS_CHECKED(OPT_PopupMoveErrors);
\r
215 appData.showButtonBar = IS_CHECKED(OPT_ShowButtonBar);
\r
216 appData.showCoords = IS_CHECKED(OPT_ShowCoordinates);
\r
217 // [HGM] thinking: next three moved up
\r
218 appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN);
\r
219 appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);
\r
220 appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory);
\r
222 ShowThinkingEvent( IS_CHECKED(OPT_ShowThinking));
\r
224 appData.showThinking = IS_CHECKED(OPT_ShowThinking);
\r
225 ShowThinkingEvent(); // [HGM] thinking: tests four options
\r
227 appData.testLegality = IS_CHECKED(OPT_TestLegality);
\r
228 appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);
\r
232 SetWindowPos(hwndMain, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
233 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
236 SetWindowPos(hwndConsole, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
237 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
240 if (!appData.highlightLastMove) {
\r
242 DrawPosition(FALSE, NULL);
\r
245 * for some reason the redraw seems smoother when we invalidate
\r
246 * the board rect after the call to EndDialog()
\r
248 EndDialog(hDlg, TRUE);
\r
250 if (oldShowButtonBar != appData.showButtonBar) {
\r
251 InitDrawingSizes(boardSize, 0);
\r
252 } else if ((oldShowCoords != appData.showCoords) ||
\r
253 (oldBlindfold != appData.blindfold)) {
\r
254 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
260 EndDialog(hDlg, FALSE);
\r
270 GeneralOptionsPopup(HWND hwnd)
\r
274 lpProc = MakeProcInstance((FARPROC)GeneralOptionsDialog, hInst);
\r
275 DialogBox(hInst, MAKEINTRESOURCE(DLG_GeneralOptions), hwnd,
\r
277 FreeProcInstance(lpProc);
\r
279 /*---------------------------------------------------------------------------*\
\r
281 * Board Options Dialog functions
\r
283 \*---------------------------------------------------------------------------*/
\r
285 const int SAMPLE_SQ_SIZE = 54;
\r
288 ChangeBoardSize(BoardSize newSize)
\r
290 if (newSize != boardSize) {
\r
291 boardSize = newSize;
\r
292 InitDrawingSizes(boardSize, 0);
\r
300 COLORREF squareColor,
\r
301 COLORREF pieceColor,
\r
302 COLORREF squareOutlineColor,
\r
303 COLORREF pieceDetailColor,
\r
309 HBRUSH brushSquare;
\r
310 HBRUSH brushSquareOutline;
\r
312 HBRUSH brushPieceDetail;
\r
313 HBRUSH oldBrushPiece;
\r
314 HBRUSH oldBrushSquare;
\r
315 HBITMAP oldBitmapMem;
\r
316 HBITMAP oldBitmapTemp;
\r
317 HBITMAP bufferBitmap;
\r
319 HDC hdcScreen, hdcMem, hdcTemp;
\r
321 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
324 const int SOLID = 0;
\r
325 const int WHITE = 1;
\r
326 const int OUTLINE = 2;
\r
327 const int BORDER = 4;
\r
329 InvalidateRect(hCtrl, NULL, TRUE);
\r
330 UpdateWindow(hCtrl);
\r
331 GetClientRect(hCtrl, &rect);
\r
332 x = rect.left + (BORDER / 2);
\r
333 y = rect.top + (BORDER / 2);
\r
334 hdcScreen = GetDC(hCtrl);
\r
335 hdcMem = CreateCompatibleDC(hdcScreen);
\r
336 hdcTemp = CreateCompatibleDC(hdcScreen);
\r
338 bufferBitmap = CreateCompatibleBitmap(hdcScreen, rect.right-rect.left+1,
\r
339 rect.bottom-rect.top+1);
\r
340 oldBitmapMem = SelectObject(hdcMem, bufferBitmap);
\r
342 SelectPalette(hdcMem, hPal, FALSE);
\r
344 brushSquare = CreateSolidBrush(squareColor);
\r
345 brushSquareOutline = CreateSolidBrush(squareOutlineColor);
\r
346 brushPiece = CreateSolidBrush(pieceColor);
\r
347 brushPieceDetail = CreateSolidBrush(pieceDetailColor);
\r
350 * first draw the rectangle
\r
352 pen = CreatePen(PS_SOLID, BORDER, squareOutlineColor);
\r
353 oldPen = (HPEN) SelectObject(hdcMem, pen);
\r
354 oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare);
\r
355 Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);
\r
358 * now draw the piece
\r
361 oldBitmapTemp = SelectObject(hdcTemp, pieces[OUTLINE]);
\r
362 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0,
\r
363 isWhitePiece ? SRCCOPY : NOTSRCCOPY);
\r
364 SelectObject(hdcTemp, oldBitmapTemp);
\r
366 if (isWhitePiece) {
\r
367 oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]);
\r
368 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
369 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
370 hdcTemp, 0, 0, 0x00B8074A);
\r
372 /* Use pieceDetailColor for outline of white pieces */
\r
373 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
374 SelectObject(hdcMem, brushPieceDetail);
\r
375 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
376 hdcTemp, 0, 0, 0x00B8074A);
\r
378 /* Use black for outline of white pieces */
\r
379 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
380 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
381 hdcTemp, 0, 0, SRCAND);
\r
385 /* Use pieceDetailColor for details of black pieces */
\r
386 /* Requires filled-in solid bitmaps (BLACK_PIECE class); the
\r
387 WHITE_PIECE ones aren't always the right shape. */
\r
388 oldBitmapTemp = SelectObject(hdcTemp, pieces[BLACK]);
\r
389 oldBrushPiece = SelectObject(hdcMem, brushPieceDetail);
\r
390 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
391 hdcTemp, 0, 0, 0x00B8074A);
\r
392 SelectObject(hdcTemp, pieces[SOLID]);
\r
393 SelectObject(hdcMem, brushPiece);
\r
394 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
395 hdcTemp, 0, 0, 0x00B8074A);
\r
397 /* Use square color for details of black pieces */
\r
398 oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);
\r
399 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
400 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
401 hdcTemp, 0, 0, 0x00B8074A);
\r
404 SelectObject(hdcMem, oldBrushPiece);
\r
405 SelectObject(hdcTemp, oldBitmapTemp);
\r
408 * copy the memory dc to the screen
\r
410 SelectObject(hdcMem, bufferBitmap);
\r
411 BitBlt(hdcScreen, rect.left, rect.top,
\r
412 rect.right - rect.left,
\r
413 rect.bottom - rect.top,
\r
414 hdcMem, rect.left, rect.top, SRCCOPY);
\r
415 SelectObject(hdcMem, oldBitmapMem);
\r
419 SelectObject(hdcMem, oldBrushPiece);
\r
420 SelectObject(hdcMem, oldPen);
\r
421 DeleteObject(brushPiece);
\r
422 DeleteObject(brushPieceDetail);
\r
423 DeleteObject(brushSquare);
\r
424 DeleteObject(brushSquareOutline);
\r
428 ReleaseDC(hCtrl, hdcScreen);
\r
433 PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color)
\r
436 HBRUSH brush, oldBrush;
\r
438 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
440 hdc = GetDC(hCtrl);
\r
441 InvalidateRect(hCtrl, NULL, TRUE);
\r
442 UpdateWindow(hCtrl);
\r
443 GetClientRect(hCtrl, &rect);
\r
444 brush = CreateSolidBrush(color);
\r
445 oldBrush = (HBRUSH)SelectObject(hdc, brush);
\r
446 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
\r
447 SelectObject(hdc, oldBrush);
\r
448 DeleteObject(brush);
\r
449 ReleaseDC(hCtrl, hdc);
\r
454 SetBoardOptionEnables(HWND hDlg)
\r
456 if (IsDlgButtonChecked(hDlg, OPT_Monochrome)) {
\r
457 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_HIDE);
\r
458 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_HIDE);
\r
459 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_HIDE);
\r
460 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_HIDE);
\r
462 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), FALSE);
\r
463 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), FALSE);
\r
464 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), FALSE);
\r
465 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), FALSE);
\r
467 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_SHOW);
\r
468 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_SHOW);
\r
469 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_SHOW);
\r
470 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_SHOW);
\r
472 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), TRUE);
\r
473 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), TRUE);
\r
474 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), TRUE);
\r
475 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), TRUE);
\r
480 BoardOptionsWhichRadio(HWND hDlg)
\r
482 return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny :
\r
483 (IsDlgButtonChecked(hDlg, OPT_SizeTeeny) ? SizeTeeny :
\r
484 (IsDlgButtonChecked(hDlg, OPT_SizeDinky) ? SizeDinky :
\r
485 (IsDlgButtonChecked(hDlg, OPT_SizePetite) ? SizePetite :
\r
486 (IsDlgButtonChecked(hDlg, OPT_SizeSlim) ? SizeSlim :
\r
487 (IsDlgButtonChecked(hDlg, OPT_SizeSmall) ? SizeSmall :
\r
488 (IsDlgButtonChecked(hDlg, OPT_SizeMediocre) ? SizeMediocre :
\r
489 (IsDlgButtonChecked(hDlg, OPT_SizeMiddling) ? SizeMiddling :
\r
490 (IsDlgButtonChecked(hDlg, OPT_SizeAverage) ? SizeAverage :
\r
491 (IsDlgButtonChecked(hDlg, OPT_SizeModerate) ? SizeModerate :
\r
492 (IsDlgButtonChecked(hDlg, OPT_SizeMedium) ? SizeMedium :
\r
493 (IsDlgButtonChecked(hDlg, OPT_SizeBulky) ? SizeBulky :
\r
494 (IsDlgButtonChecked(hDlg, OPT_SizeLarge) ? SizeLarge :
\r
495 (IsDlgButtonChecked(hDlg, OPT_SizeBig) ? SizeBig :
\r
496 (IsDlgButtonChecked(hDlg, OPT_SizeHuge) ? SizeHuge :
\r
497 (IsDlgButtonChecked(hDlg, OPT_SizeGiant) ? SizeGiant :
\r
498 (IsDlgButtonChecked(hDlg, OPT_SizeColossal) ? SizeColossal :
\r
499 SizeTitanic )))))))))))))))));
\r
503 BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
505 static Boolean mono, white, flip;
\r
506 static BoardSize size;
\r
507 static COLORREF lsc, dsc, wpc, bpc, hsc, phc;
\r
508 static HBITMAP pieces[3];
\r
511 case WM_INITDIALOG: /* message: initialize dialog box */
\r
512 /* Center the dialog over the application window */
\r
513 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
514 /* Initialize the dialog items */
\r
515 switch (boardSize) {
\r
517 CheckDlgButton(hDlg, OPT_SizeTiny, TRUE);
\r
520 CheckDlgButton(hDlg, OPT_SizeTeeny, TRUE);
\r
523 CheckDlgButton(hDlg, OPT_SizeDinky, TRUE);
\r
526 CheckDlgButton(hDlg, OPT_SizePetite, TRUE);
\r
529 CheckDlgButton(hDlg, OPT_SizeSlim, TRUE);
\r
532 CheckDlgButton(hDlg, OPT_SizeSmall, TRUE);
\r
535 CheckDlgButton(hDlg, OPT_SizeMediocre, TRUE);
\r
538 CheckDlgButton(hDlg, OPT_SizeMiddling, TRUE);
\r
541 CheckDlgButton(hDlg, OPT_SizeAverage, TRUE);
\r
544 CheckDlgButton(hDlg, OPT_SizeModerate, TRUE);
\r
547 CheckDlgButton(hDlg, OPT_SizeMedium, TRUE);
\r
550 CheckDlgButton(hDlg, OPT_SizeBulky, TRUE);
\r
553 CheckDlgButton(hDlg, OPT_SizeLarge, TRUE);
\r
556 CheckDlgButton(hDlg, OPT_SizeBig, TRUE);
\r
559 CheckDlgButton(hDlg, OPT_SizeHuge, TRUE);
\r
562 CheckDlgButton(hDlg, OPT_SizeGiant, TRUE);
\r
565 CheckDlgButton(hDlg, OPT_SizeColossal, TRUE);
\r
568 CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE);
\r
571 if (appData.monoMode)
\r
572 CheckDlgButton(hDlg, OPT_Monochrome, TRUE);
\r
574 if (appData.allWhite)
\r
575 CheckDlgButton(hDlg, OPT_AllWhite, TRUE);
\r
577 if (appData.upsideDown)
\r
578 CheckDlgButton(hDlg, OPT_UpsideDown, TRUE);
\r
580 pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s");
\r
581 pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w");
\r
582 pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o");
\r
584 lsc = lightSquareColor;
\r
585 dsc = darkSquareColor;
\r
586 wpc = whitePieceColor;
\r
587 bpc = blackPieceColor;
\r
588 hsc = highlightSquareColor;
\r
589 phc = premoveHighlightColor;
\r
590 mono = appData.monoMode;
\r
591 white= appData.allWhite;
\r
592 flip = appData.upsideDown;
\r
595 SetBoardOptionEnables(hDlg);
\r
599 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
600 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
601 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
602 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
603 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
604 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
605 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
606 TRUE, mono, pieces);
\r
607 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
608 FALSE, mono, pieces);
\r
612 case WM_COMMAND: /* message: received a command */
\r
613 switch (LOWORD(wParam)) {
\r
616 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
617 * then ChangeBoardSize() does not take effect, although the new
\r
618 * boardSize is saved. Go figure...
\r
620 EndDialog(hDlg, TRUE);
\r
622 size = BoardOptionsWhichRadio(hDlg);
\r
625 * did any settings change?
\r
627 if (size != boardSize) {
\r
628 ChangeBoardSize(size);
\r
631 if ((mono != appData.monoMode) ||
\r
632 (lsc != lightSquareColor) ||
\r
633 (dsc != darkSquareColor) ||
\r
634 (wpc != whitePieceColor) ||
\r
635 (bpc != blackPieceColor) ||
\r
636 (hsc != highlightSquareColor) ||
\r
637 (flip != appData.upsideDown) ||
\r
638 (white != appData.allWhite) ||
\r
639 (phc != premoveHighlightColor)) {
\r
641 lightSquareColor = lsc;
\r
642 darkSquareColor = dsc;
\r
643 whitePieceColor = wpc;
\r
644 blackPieceColor = bpc;
\r
645 highlightSquareColor = hsc;
\r
646 premoveHighlightColor = phc;
\r
647 appData.monoMode = mono;
\r
648 appData.allWhite = white;
\r
649 appData.upsideDown = flip;
\r
651 InitDrawingColors();
\r
652 InitDrawingSizes(boardSize, 0);
\r
653 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
655 DeleteObject(pieces[0]);
\r
656 DeleteObject(pieces[1]);
\r
657 DeleteObject(pieces[2]);
\r
661 DeleteObject(pieces[0]);
\r
662 DeleteObject(pieces[1]);
\r
663 DeleteObject(pieces[2]);
\r
664 EndDialog(hDlg, FALSE);
\r
667 case OPT_ChooseLightSquareColor:
\r
668 if (ChangeColor(hDlg, &lsc))
\r
669 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
670 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
671 TRUE, mono, pieces);
\r
674 case OPT_ChooseDarkSquareColor:
\r
675 if (ChangeColor(hDlg, &dsc))
\r
676 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
677 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
678 FALSE, mono, pieces);
\r
681 case OPT_ChooseWhitePieceColor:
\r
682 if (ChangeColor(hDlg, &wpc))
\r
683 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
684 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
685 TRUE, mono, pieces);
\r
688 case OPT_ChooseBlackPieceColor:
\r
689 if (ChangeColor(hDlg, &bpc))
\r
690 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
691 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
692 FALSE, mono, pieces);
\r
695 case OPT_ChooseHighlightSquareColor:
\r
696 if (ChangeColor(hDlg, &hsc))
\r
697 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
698 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
699 TRUE, mono, pieces);
\r
702 case OPT_ChoosePremoveHighlightColor:
\r
703 if (ChangeColor(hDlg, &phc))
\r
704 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
705 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
706 FALSE, mono, pieces);
\r
709 case OPT_DefaultBoardColors:
\r
710 lsc = ParseColorName(LIGHT_SQUARE_COLOR);
\r
711 dsc = ParseColorName(DARK_SQUARE_COLOR);
\r
712 wpc = ParseColorName(WHITE_PIECE_COLOR);
\r
713 bpc = ParseColorName(BLACK_PIECE_COLOR);
\r
714 hsc = ParseColorName(HIGHLIGHT_SQUARE_COLOR);
\r
715 phc = ParseColorName(PREMOVE_HIGHLIGHT_COLOR);
\r
719 CheckDlgButton(hDlg, OPT_Monochrome, FALSE);
\r
720 CheckDlgButton(hDlg, OPT_AllWhite, FALSE);
\r
721 CheckDlgButton(hDlg, OPT_UpsideDown, FALSE);
\r
722 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
723 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
724 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
725 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
726 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
727 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
728 SetBoardOptionEnables(hDlg);
\r
729 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
730 TRUE, mono, pieces);
\r
731 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
732 FALSE, mono, pieces);
\r
735 case OPT_Monochrome:
\r
737 SetBoardOptionEnables(hDlg);
\r
742 SetBoardOptionEnables(hDlg);
\r
745 case OPT_UpsideDown:
\r
747 SetBoardOptionEnables(hDlg);
\r
757 BoardOptionsPopup(HWND hwnd)
\r
759 FARPROC lpProc = MakeProcInstance((FARPROC)BoardOptionsDialog, hInst);
\r
760 DialogBox(hInst, MAKEINTRESOURCE(DLG_BoardOptions), hwnd,
\r
762 FreeProcInstance(lpProc);
\r
766 VariantWhichRadio(HWND hDlg)
\r
768 return (IsDlgButtonChecked(hDlg, OPT_VariantFairy) ? VariantFairy :
\r
769 (IsDlgButtonChecked(hDlg, OPT_VariantGothic) ? VariantGothic :
\r
770 (IsDlgButtonChecked(hDlg, OPT_VariantCrazyhouse) ? VariantCrazyhouse :
\r
771 (IsDlgButtonChecked(hDlg, OPT_VariantBughouse) ? VariantBughouse :
\r
772 (IsDlgButtonChecked(hDlg, OPT_VariantCourier) ? VariantCourier :
\r
773 (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :
\r
774 (IsDlgButtonChecked(hDlg, OPT_VariantShogi) ? VariantShogi :
\r
775 (IsDlgButtonChecked(hDlg, OPT_VariantXiangqi) ? VariantXiangqi :
\r
776 (IsDlgButtonChecked(hDlg, OPT_VariantCapablanca) ? VariantCapablanca :
\r
777 (IsDlgButtonChecked(hDlg, OPT_VariantTwoKings) ? VariantTwoKings :
\r
778 (IsDlgButtonChecked(hDlg, OPT_VariantKnightmate) ? VariantKnightmate :
\r
779 (IsDlgButtonChecked(hDlg, OPT_VariantLosers) ? VariantLosers :
\r
780 (IsDlgButtonChecked(hDlg, OPT_VariantSuicide) ? VariantSuicide :
\r
781 (IsDlgButtonChecked(hDlg, OPT_VariantAtomic) ? VariantAtomic :
\r
782 (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :
\r
783 (IsDlgButtonChecked(hDlg, OPT_VariantFRC) ? VariantFischeRandom :
\r
784 (IsDlgButtonChecked(hDlg, OPT_VariantCylinder) ? VariantCylinder :
\r
785 (IsDlgButtonChecked(hDlg, OPT_VariantFalcon) ? VariantFalcon :
\r
786 (IsDlgButtonChecked(hDlg, OPT_VariantCRC) ? VariantCapaRandom :
\r
787 (IsDlgButtonChecked(hDlg, OPT_VariantSuper) ? VariantSuper :
\r
788 (IsDlgButtonChecked(hDlg, OPT_VariantBerolina) ? VariantBerolina :
\r
789 (IsDlgButtonChecked(hDlg, OPT_VariantJanus) ? VariantJanus :
\r
790 (IsDlgButtonChecked(hDlg, OPT_VariantWildcastle) ? VariantWildCastle :
\r
791 (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle :
\r
792 VariantNormal ))))))))))))))))))))))));
\r
796 NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
798 static Boolean mono;
\r
799 static VariantClass v;
\r
800 static COLORREF lsc, dsc, wpc, bpc, hsc, phc;
\r
801 static HBITMAP pieces[3];
\r
802 static int n1_ok, n2_ok, n3_ok;
\r
805 case WM_INITDIALOG: /* message: initialize dialog box */
\r
806 /* Center the dialog over the application window */
\r
807 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
808 /* Initialize the dialog items */
\r
809 switch (gameInfo.variant) {
\r
810 case VariantNormal:
\r
811 CheckDlgButton(hDlg, OPT_VariantNormal, TRUE);
\r
813 case VariantCrazyhouse:
\r
814 CheckDlgButton(hDlg, OPT_VariantCrazyhouse, TRUE);
\r
816 case VariantBughouse:
\r
817 CheckDlgButton(hDlg, OPT_VariantBughouse, TRUE);
\r
820 CheckDlgButton(hDlg, OPT_VariantShogi, TRUE);
\r
822 case VariantXiangqi:
\r
823 CheckDlgButton(hDlg, OPT_VariantXiangqi, TRUE);
\r
825 case VariantCapablanca:
\r
826 CheckDlgButton(hDlg, OPT_VariantCapablanca, TRUE);
\r
828 case VariantGothic:
\r
829 CheckDlgButton(hDlg, OPT_VariantGothic, TRUE);
\r
831 case VariantCourier:
\r
832 CheckDlgButton(hDlg, OPT_VariantCourier, TRUE);
\r
834 case VariantKnightmate:
\r
835 CheckDlgButton(hDlg, OPT_VariantKnightmate, TRUE);
\r
837 case VariantTwoKings:
\r
838 CheckDlgButton(hDlg, OPT_VariantTwoKings, TRUE);
\r
841 CheckDlgButton(hDlg, OPT_VariantFairy, TRUE);
\r
843 case VariantAtomic:
\r
844 CheckDlgButton(hDlg, OPT_VariantAtomic, TRUE);
\r
846 case VariantSuicide:
\r
847 CheckDlgButton(hDlg, OPT_VariantSuicide, TRUE);
\r
849 case VariantLosers:
\r
850 CheckDlgButton(hDlg, OPT_VariantLosers, TRUE);
\r
852 case VariantShatranj:
\r
853 CheckDlgButton(hDlg, OPT_VariantShatranj, TRUE);
\r
855 case VariantFischeRandom:
\r
856 CheckDlgButton(hDlg, OPT_VariantFRC, TRUE);
\r
858 case VariantCapaRandom:
\r
859 CheckDlgButton(hDlg, OPT_VariantCRC, TRUE);
\r
861 case VariantFalcon:
\r
862 CheckDlgButton(hDlg, OPT_VariantFalcon, TRUE);
\r
864 case VariantCylinder:
\r
865 CheckDlgButton(hDlg, OPT_VariantCylinder, TRUE);
\r
867 case Variant3Check:
\r
869 CheckDlgButton(hDlg, OPT_VariantSuper, TRUE);
\r
871 case VariantBerolina:
\r
872 CheckDlgButton(hDlg, OPT_VariantBerolina, TRUE);
\r
875 CheckDlgButton(hDlg, OPT_VariantJanus, TRUE);
\r
877 case VariantWildCastle:
\r
878 CheckDlgButton(hDlg, OPT_VariantWildcastle, TRUE);
\r
880 case VariantNoCastle:
\r
881 CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE);
\r
885 SetDlgItemInt( hDlg, IDC_Files, -1, TRUE );
\r
886 SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 );
\r
888 SetDlgItemInt( hDlg, IDC_Ranks, -1, TRUE );
\r
889 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
891 SetDlgItemInt( hDlg, IDC_Holdings, -1, TRUE );
\r
892 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
894 n1_ok = n2_ok = n3_ok = FALSE;
\r
898 case WM_COMMAND: /* message: received a command */
\r
899 switch (LOWORD(wParam)) {
\r
902 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
903 * then ChangeBoardSize() does not take effect, although the new
\r
904 * boardSize is saved. Go figure...
\r
906 EndDialog(hDlg, TRUE);
\r
908 v = VariantWhichRadio(hDlg);
\r
909 if(!appData.noChessProgram) { char *name = VariantName(v), buf[MSG_SIZ];
\r
910 if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) {
\r
911 /* [HGM] in protocol 2 we check if variant is suported by engine */
\r
912 sprintf(buf, "Variant %s not supported by %s", name, first.tidy);
\r
913 DisplayError(buf, 0);
\r
914 return TRUE; /* treat as "Cancel" if first engine does not support it */
\r
916 if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) {
\r
917 sprintf(buf, "Warning: second engine (%s) does not support this!", second.tidy);
\r
918 DisplayError(buf, 0); /* use of second engine is optional; only warn user */
\r
922 gameInfo.variant = v;
\r
923 appData.variant = VariantName(v);
\r
925 appData.NrFiles = (int) GetDlgItemInt(hDlg, IDC_Files, NULL, FALSE );
\r
926 appData.NrRanks = (int) GetDlgItemInt(hDlg, IDC_Ranks, NULL, FALSE );
\r
927 appData.holdingsSize = (int) GetDlgItemInt(hDlg, IDC_Holdings, NULL, FALSE );
\r
929 if(!n1_ok) appData.NrFiles = -1;
\r
930 if(!n2_ok) appData.NrRanks = -1;
\r
931 if(!n3_ok) appData.holdingsSize = -1;
\r
933 shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */
\r
934 startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */
\r
935 appData.pieceToCharTable = NULL;
\r
941 EndDialog(hDlg, FALSE);
\r
947 if( HIWORD(wParam) == EN_CHANGE ) {
\r
949 GetDlgItemInt(hDlg, IDC_Files, &n1_ok, FALSE );
\r
950 GetDlgItemInt(hDlg, IDC_Ranks, &n2_ok, FALSE );
\r
951 GetDlgItemInt(hDlg, IDC_Holdings, &n3_ok, FALSE );
\r
953 /*EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok ? TRUE : FALSE );*/
\r
964 NewVariantPopup(HWND hwnd)
\r
966 FARPROC lpProc = MakeProcInstance((FARPROC)NewVariantDialog, hInst);
\r
967 DialogBox(hInst, MAKEINTRESOURCE(DLG_NewVariant), hwnd,
\r
969 FreeProcInstance(lpProc);
\r
972 /*---------------------------------------------------------------------------*\
\r
974 * ICS Options Dialog functions
\r
976 \*---------------------------------------------------------------------------*/
\r
979 MyCreateFont(HWND hwnd, MyFont *font)
\r
984 /* Initialize members of the CHOOSEFONT structure. */
\r
985 cf.lStructSize = sizeof(CHOOSEFONT);
\r
986 cf.hwndOwner = hwnd;
\r
987 cf.hDC = (HDC)NULL;
\r
988 cf.lpLogFont = &font->lf;
\r
990 cf.Flags = CF_SCREENFONTS|/*CF_ANSIONLY|*/CF_INITTOLOGFONTSTRUCT;
\r
991 cf.rgbColors = RGB(0,0,0);
\r
993 cf.lpfnHook = (LPCFHOOKPROC)NULL;
\r
994 cf.lpTemplateName = (LPSTR)NULL;
\r
995 cf.hInstance = (HINSTANCE) NULL;
\r
996 cf.lpszStyle = (LPSTR)NULL;
\r
997 cf.nFontType = SCREEN_FONTTYPE;
\r
1001 /* Display the CHOOSEFONT common-dialog box. */
\r
1002 if (!ChooseFont(&cf)) {
\r
1006 /* Create a logical font based on the user's */
\r
1007 /* selection and return a handle identifying */
\r
1009 hf = CreateFontIndirect(cf.lpLogFont);
\r
1015 font->mfp.pointSize = (float) (cf.iPointSize / 10.0);
\r
1016 font->mfp.bold = (font->lf.lfWeight >= FW_BOLD);
\r
1017 font->mfp.italic = font->lf.lfItalic;
\r
1018 font->mfp.underline = font->lf.lfUnderline;
\r
1019 font->mfp.strikeout = font->lf.lfStrikeOut;
\r
1020 strcpy(font->mfp.faceName, font->lf.lfFaceName);
\r
1026 UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
\r
1029 cf.cbSize = sizeof(CHARFORMAT);
\r
1031 CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;
\r
1032 cf.crTextColor = mca->color;
\r
1033 cf.dwEffects = mca->effects;
\r
1034 strcpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName);
\r
1036 * The 20.0 below is in fact documented. yHeight is expressed in twips.
\r
1037 * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT.
\r
1040 cf.yHeight = (int)(font[boardSize][CONSOLE_FONT]->mfp.pointSize * 20.0 + 0.5);
\r
1041 cf.bCharSet = DEFAULT_CHARSET; /* should be ignored anyway */
\r
1042 cf.bPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
\r
1043 SendDlgItemMessage(hDlg, id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1047 ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1049 static MyColorizeAttribs mca;
\r
1050 static ColorClass cc;
\r
1051 COLORREF background = (COLORREF)0;
\r
1053 switch (message) {
\r
1054 case WM_INITDIALOG:
\r
1055 cc = (ColorClass)lParam;
\r
1056 mca = colorizeAttribs[cc];
\r
1057 /* Center the dialog over the application window */
\r
1058 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1059 /* Initialize the dialog items */
\r
1060 CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0);
\r
1061 CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0);
\r
1062 CheckDlgButton(hDlg, OPT_Underline, (mca.effects & CFE_UNDERLINE) != 0);
\r
1063 CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0);
\r
1065 /* get the current background color from the parent window */
\r
1066 SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND,
\r
1067 (WPARAM)WM_USER_GetConsoleBackground,
\r
1068 (LPARAM)&background);
\r
1070 /* set the background color */
\r
1071 SendDlgItemMessage(hDlg, OPT_Sample, EM_SETBKGNDCOLOR, FALSE, background);
\r
1073 SetDlgItemText(hDlg, OPT_Sample, mca.name);
\r
1074 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1077 case WM_COMMAND: /* message: received a command */
\r
1078 switch (LOWORD(wParam)) {
\r
1080 /* Read changed options from the dialog box */
\r
1081 colorizeAttribs[cc] = mca;
\r
1082 textAttribs[cc].color = mca.color;
\r
1083 textAttribs[cc].effects = mca.effects;
\r
1084 Colorize(currentColorClass, TRUE);
\r
1085 if (cc == ColorNormal) {
\r
1087 cf.cbSize = sizeof(CHARFORMAT);
\r
1088 cf.dwMask = CFM_COLOR;
\r
1089 cf.crTextColor = mca.color;
\r
1090 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1091 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1093 EndDialog(hDlg, TRUE);
\r
1097 EndDialog(hDlg, FALSE);
\r
1100 case OPT_ChooseColor:
\r
1101 ChangeColor(hDlg, &mca.color);
\r
1102 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1107 (IsDlgButtonChecked(hDlg, OPT_Bold) ? CFE_BOLD : 0) |
\r
1108 (IsDlgButtonChecked(hDlg, OPT_Italic) ? CFE_ITALIC : 0) |
\r
1109 (IsDlgButtonChecked(hDlg, OPT_Underline) ? CFE_UNDERLINE : 0) |
\r
1110 (IsDlgButtonChecked(hDlg, OPT_Strikeout) ? CFE_STRIKEOUT : 0);
\r
1111 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1120 ColorizeTextPopup(HWND hwnd, ColorClass cc)
\r
1124 lpProc = MakeProcInstance((FARPROC)ColorizeTextDialog, hInst);
\r
1125 DialogBoxParam(hInst, MAKEINTRESOURCE(DLG_Colorize),
\r
1126 hwnd, (DLGPROC)lpProc, (LPARAM) cc);
\r
1127 FreeProcInstance(lpProc);
\r
1131 SetIcsOptionEnables(HWND hDlg)
\r
1133 #define ENABLE_DLG_ITEM(x,y) EnableWindow(GetDlgItem(hDlg,(x)), (y))
\r
1135 UINT state = IsDlgButtonChecked(hDlg, OPT_Premove);
\r
1136 ENABLE_DLG_ITEM(OPT_PremoveWhite, state);
\r
1137 ENABLE_DLG_ITEM(OPT_PremoveWhiteText, state);
\r
1138 ENABLE_DLG_ITEM(OPT_PremoveBlack, state);
\r
1139 ENABLE_DLG_ITEM(OPT_PremoveBlackText, state);
\r
1141 ENABLE_DLG_ITEM(OPT_IcsAlarmTime, IsDlgButtonChecked(hDlg, OPT_IcsAlarm));
\r
1143 #undef ENABLE_DLG_ITEM
\r
1148 IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1150 char buf[MSG_SIZ];
\r
1153 static COLORREF cbc;
\r
1154 static MyColorizeAttribs *mca;
\r
1155 COLORREF *colorref;
\r
1157 switch (message) {
\r
1158 case WM_INITDIALOG: /* message: initialize dialog box */
\r
1160 mca = colorizeAttribs;
\r
1162 for (i=0; i < NColorClasses - 1; i++) {
\r
1163 mca[i].color = textAttribs[i].color;
\r
1164 mca[i].effects = textAttribs[i].effects;
\r
1166 cbc = consoleBackgroundColor;
\r
1168 /* Center the dialog over the application window */
\r
1169 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1171 /* Initialize the dialog items */
\r
1172 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
1174 CHECK_BOX(OPT_AutoComment, appData.autoComment);
\r
1175 CHECK_BOX(OPT_AutoObserve, appData.autoObserve);
\r
1176 CHECK_BOX(OPT_GetMoveList, appData.getMoveList);
\r
1177 CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing);
\r
1178 CHECK_BOX(OPT_QuietPlay, appData.quietPlay);
\r
1179 CHECK_BOX(OPT_Premove, appData.premove);
\r
1180 CHECK_BOX(OPT_PremoveWhite, appData.premoveWhite);
\r
1181 CHECK_BOX(OPT_PremoveBlack, appData.premoveBlack);
\r
1182 CHECK_BOX(OPT_IcsAlarm, appData.icsAlarm);
\r
1183 CHECK_BOX(OPT_DontColorize, !appData.colorize);
\r
1187 sprintf(buf, "%d", appData.icsAlarmTime / 1000);
\r
1188 SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);
\r
1189 SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);
\r
1190 SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);
\r
1192 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1193 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1194 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1195 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1196 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1197 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1198 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1199 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1200 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1201 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1203 SetDlgItemText(hDlg, OPT_SampleShout, mca[ColorShout].name);
\r
1204 SetDlgItemText(hDlg, OPT_SampleSShout, mca[ColorSShout].name);
\r
1205 SetDlgItemText(hDlg, OPT_SampleChannel1, mca[ColorChannel1].name);
\r
1206 SetDlgItemText(hDlg, OPT_SampleChannel, mca[ColorChannel].name);
\r
1207 SetDlgItemText(hDlg, OPT_SampleKibitz, mca[ColorKibitz].name);
\r
1208 SetDlgItemText(hDlg, OPT_SampleTell, mca[ColorTell].name);
\r
1209 SetDlgItemText(hDlg, OPT_SampleChallenge, mca[ColorChallenge].name);
\r
1210 SetDlgItemText(hDlg, OPT_SampleRequest, mca[ColorRequest].name);
\r
1211 SetDlgItemText(hDlg, OPT_SampleSeek, mca[ColorSeek].name);
\r
1212 SetDlgItemText(hDlg, OPT_SampleNormal, mca[ColorNormal].name);
\r
1214 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1215 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1216 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1217 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1218 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1219 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1220 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1221 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1222 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1223 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1225 SetIcsOptionEnables(hDlg);
\r
1228 case WM_COMMAND: /* message: received a command */
\r
1229 switch (LOWORD(wParam)) {
\r
1231 case WM_USER_GetConsoleBackground:
\r
1232 /* the ColorizeTextDialog needs the current background color */
\r
1233 colorref = (COLORREF *)lParam;
\r
1238 /* Read changed options from the dialog box */
\r
1239 GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ);
\r
1240 if (sscanf(buf, "%d", &number) != 1 || (number < 0)){
\r
1241 MessageBox(hDlg, "Invalid ICS Alarm Time",
\r
1242 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
1246 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
1248 appData.icsAlarm = IS_CHECKED(OPT_IcsAlarm);
\r
1249 appData.premove = IS_CHECKED(OPT_Premove);
\r
1250 appData.premoveWhite = IS_CHECKED(OPT_PremoveWhite);
\r
1251 appData.premoveBlack = IS_CHECKED(OPT_PremoveBlack);
\r
1252 appData.autoComment = IS_CHECKED(OPT_AutoComment);
\r
1253 appData.autoObserve = IS_CHECKED(OPT_AutoObserve);
\r
1254 appData.getMoveList = IS_CHECKED(OPT_GetMoveList);
\r
1255 appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing);
\r
1256 appData.quietPlay = IS_CHECKED(OPT_QuietPlay);
\r
1260 appData.icsAlarmTime = number * 1000;
\r
1261 GetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText, 5);
\r
1262 GetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText, 5);
\r
1264 if (appData.localLineEditing) {
\r
1272 appData.colorize =
\r
1273 (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize);
\r
1275 if (!appData.colorize) {
\r
1277 COLORREF background = ParseColorName(COLOR_BKGD);
\r
1279 SetDefaultTextAttribs();
\r
1280 Colorize(currentColorClass);
\r
1282 cf.cbSize = sizeof(CHARFORMAT);
\r
1283 cf.dwMask = CFM_COLOR;
\r
1284 cf.crTextColor = ParseColorName(COLOR_NORMAL);
\r
1286 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1287 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1288 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1289 EM_SETBKGNDCOLOR, FALSE, background);
\r
1290 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1291 EM_SETBKGNDCOLOR, FALSE, background);
\r
1294 if (cbc != consoleBackgroundColor) {
\r
1295 consoleBackgroundColor = cbc;
\r
1296 if (appData.colorize) {
\r
1297 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1298 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1299 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1300 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1304 for (i=0; i < NColorClasses - 1; i++) {
\r
1305 textAttribs[i].color = mca[i].color;
\r
1306 textAttribs[i].effects = mca[i].effects;
\r
1309 EndDialog(hDlg, TRUE);
\r
1313 EndDialog(hDlg, FALSE);
\r
1316 case OPT_ChooseShoutColor:
\r
1317 ColorizeTextPopup(hDlg, ColorShout);
\r
1318 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1321 case OPT_ChooseSShoutColor:
\r
1322 ColorizeTextPopup(hDlg, ColorSShout);
\r
1323 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1326 case OPT_ChooseChannel1Color:
\r
1327 ColorizeTextPopup(hDlg, ColorChannel1);
\r
1328 UpdateSampleText(hDlg, OPT_SampleChannel1,
\r
1329 &colorizeAttribs[ColorChannel1]);
\r
1332 case OPT_ChooseChannelColor:
\r
1333 ColorizeTextPopup(hDlg, ColorChannel);
\r
1334 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1337 case OPT_ChooseKibitzColor:
\r
1338 ColorizeTextPopup(hDlg, ColorKibitz);
\r
1339 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1342 case OPT_ChooseTellColor:
\r
1343 ColorizeTextPopup(hDlg, ColorTell);
\r
1344 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1347 case OPT_ChooseChallengeColor:
\r
1348 ColorizeTextPopup(hDlg, ColorChallenge);
\r
1349 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1352 case OPT_ChooseRequestColor:
\r
1353 ColorizeTextPopup(hDlg, ColorRequest);
\r
1354 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1357 case OPT_ChooseSeekColor:
\r
1358 ColorizeTextPopup(hDlg, ColorSeek);
\r
1359 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1362 case OPT_ChooseNormalColor:
\r
1363 ColorizeTextPopup(hDlg, ColorNormal);
\r
1364 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1367 case OPT_ChooseBackgroundColor:
\r
1368 if (ChangeColor(hDlg, &cbc)) {
\r
1369 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1370 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1371 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1372 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1373 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1374 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1375 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1376 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1377 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1378 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1382 case OPT_DefaultColors:
\r
1383 for (i=0; i < NColorClasses - 1; i++)
\r
1384 ParseAttribs(&mca[i].color,
\r
1386 defaultTextAttribs[i]);
\r
1388 cbc = ParseColorName(COLOR_BKGD);
\r
1389 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1390 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1391 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1392 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1393 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1394 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1395 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1396 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1397 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1398 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1400 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1401 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1402 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1403 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1404 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1405 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1406 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1407 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1408 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1409 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1413 SetIcsOptionEnables(hDlg);
\r
1422 IcsOptionsPopup(HWND hwnd)
\r
1424 FARPROC lpProc = MakeProcInstance((FARPROC)IcsOptionsDialog, hInst);
\r
1425 DialogBox(hInst, MAKEINTRESOURCE(DLG_IcsOptions), hwnd,
\r
1426 (DLGPROC) lpProc);
\r
1427 FreeProcInstance(lpProc);
\r
1430 /*---------------------------------------------------------------------------*\
\r
1432 * Fonts Dialog functions
\r
1434 \*---------------------------------------------------------------------------*/
\r
1437 SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
\r
1439 char buf[MSG_SIZ];
\r
1444 RECT rectClient, rectFormat;
\r
1449 len = sprintf(buf, "%.0f pt. %s%s%s\n",
\r
1450 mf->mfp.pointSize, mf->mfp.faceName,
\r
1451 mf->mfp.bold ? " bold" : "",
\r
1452 mf->mfp.italic ? " italic" : "");
\r
1453 SetDlgItemText(hwnd, id, buf);
\r
1455 hControl = GetDlgItem(hwnd, id);
\r
1456 hdc = GetDC(hControl);
\r
1457 SetMapMode(hdc, MM_TEXT); /* 1 pixel == 1 logical unit */
\r
1458 oldFont = SelectObject(hdc, mf->hf);
\r
1460 /* get number of logical units necessary to display font name */
\r
1461 GetTextExtentPoint32(hdc, buf, len, &size);
\r
1463 /* calculate formatting rectangle in the rich edit control.
\r
1464 * May be larger or smaller than the actual control.
\r
1466 GetClientRect(hControl, &rectClient);
\r
1467 center.x = (rectClient.left + rectClient.right) / 2;
\r
1468 center.y = (rectClient.top + rectClient.bottom) / 2;
\r
1469 rectFormat.top = center.y - (size.cy / 2) - 1;
\r
1470 rectFormat.bottom = center.y + (size.cy / 2) + 1;
\r
1471 rectFormat.left = center.x - (size.cx / 2) - 1;
\r
1472 rectFormat.right = center.x + (size.cx / 2) + 1;
\r
1475 fprintf(debugFP, "\nfont: %s\n"
\r
1476 "center.x %d, centerY %d\n"
\r
1477 "size.cx %d, size.cy %d\n"
\r
1478 "client.top %d, bottom %d, left %d, right %d\n"
\r
1479 "format.top %d, bottom %d, left %d, right %d\n",
\r
1481 center.x, center.y,
\r
1483 rectClient.top, rectClient.bottom, rectClient.left,
\r
1485 rectFormat.top, rectFormat.bottom, rectFormat.left,
\r
1486 rectFormat.right);
\r
1489 cf.cbSize = sizeof(CHARFORMAT);
\r
1490 cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC;
\r
1492 if (mf->lf.lfWeight == FW_BOLD) cf.dwEffects |= CFE_BOLD;
\r
1493 if (mf->lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
\r
1494 strcpy(cf.szFaceName, mf->mfp.faceName);
\r
1496 * yHeight is expressed in twips. A twip is 1/20 of a font's point
\r
1497 * size. See documentation of CHARFORMAT. --msw
\r
1499 cf.yHeight = (int)(mf->mfp.pointSize * 20.0 + 0.5);
\r
1500 cf.bCharSet = mf->lf.lfCharSet;
\r
1501 cf.bPitchAndFamily = mf->lf.lfPitchAndFamily;
\r
1503 /* format the text in the rich edit control */
\r
1504 SendMessage(hControl, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf);
\r
1505 SendMessage(hControl, EM_SETRECT, (WPARAM)0, (LPARAM) &rectFormat);
\r
1508 SelectObject(hdc, oldFont);
\r
1509 ReleaseDC(hControl, hdc);
\r
1513 CopyFont(MyFont *dest, const MyFont *src)
\r
1515 dest->mfp.pointSize = src->mfp.pointSize;
\r
1516 dest->mfp.bold = src->mfp.bold;
\r
1517 dest->mfp.italic = src->mfp.italic;
\r
1518 dest->mfp.underline = src->mfp.underline;
\r
1519 dest->mfp.strikeout = src->mfp.strikeout;
\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 InvalidateRect(editTagsDialog, NULL, TRUE);
\r
1623 if (hwndConsole) {
\r
1624 ChangedConsoleFont();
\r
1627 for (i=0; i<NUM_FONTS; i++)
\r
1628 DeleteObject(&workFont[i].hf);
\r
1633 for (i=0; i<NUM_FONTS; i++)
\r
1634 DeleteObject(&workFont[i].hf);
\r
1635 EndDialog(hDlg, FALSE);
\r
1638 case OPT_ChooseClockFont:
\r
1639 MyCreateFont(hDlg, &workFont[CLOCK_FONT]);
\r
1640 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1643 case OPT_ChooseMessageFont:
\r
1644 MyCreateFont(hDlg, &workFont[MESSAGE_FONT]);
\r
1645 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1648 case OPT_ChooseCoordFont:
\r
1649 MyCreateFont(hDlg, &workFont[COORD_FONT]);
\r
1650 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1653 case OPT_ChooseTagFont:
\r
1654 MyCreateFont(hDlg, &workFont[EDITTAGS_FONT]);
\r
1655 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1658 case OPT_ChooseCommentsFont:
\r
1659 MyCreateFont(hDlg, &workFont[COMMENT_FONT]);
\r
1660 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1663 case OPT_ChooseConsoleFont:
\r
1664 MyCreateFont(hDlg, &workFont[CONSOLE_FONT]);
\r
1665 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1668 case OPT_ChooseMoveHistoryFont:
\r
1669 MyCreateFont(hDlg, &workFont[MOVEHISTORY_FONT]);
\r
1670 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1673 case OPT_DefaultFonts:
\r
1674 for (i=0; i<NUM_FONTS; i++) {
\r
1675 DeleteObject(&workFont[i].hf);
\r
1676 ParseFontName(font[boardSize][i]->def, &workFont[i].mfp);
\r
1677 CreateFontInMF(&workFont[i]);
\r
1679 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1680 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1681 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1682 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1683 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1684 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1685 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1693 FontsOptionsPopup(HWND hwnd)
\r
1695 FARPROC lpProc = MakeProcInstance((FARPROC)FontOptionsDialog, hInst);
\r
1696 DialogBox(hInst, MAKEINTRESOURCE(DLG_Fonts), hwnd,
\r
1697 (DLGPROC) lpProc);
\r
1698 FreeProcInstance(lpProc);
\r
1701 /*---------------------------------------------------------------------------*\
\r
1703 * Sounds Dialog functions
\r
1705 \*---------------------------------------------------------------------------*/
\r
1708 SoundComboData soundComboData[] = {
\r
1711 {"ICS Alarm", NULL},
\r
1712 {"ICS Win", NULL},
\r
1713 {"ICS Loss", NULL},
\r
1714 {"ICS Draw", NULL},
\r
1715 {"ICS Unfinished", NULL},
\r
1717 {"SShout/CShout", NULL},
\r
1718 {"Channel 1", NULL},
\r
1719 {"Channel", NULL},
\r
1722 {"Challenge", NULL},
\r
1723 {"Request", NULL},
\r
1730 InitSoundComboData(SoundComboData *scd)
\r
1736 /* copy current sound settings to combo array */
\r
1738 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1739 scd[sc].name = strdup(sounds[sc].name);
\r
1741 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1742 index = (int)cc + (int)NSoundClasses;
\r
1743 scd[index].name = strdup(textAttribs[cc].sound.name);
\r
1749 ResetSoundComboData(SoundComboData *scd)
\r
1751 while (scd->label) {
\r
1752 if (scd->name != NULL) {
\r
1761 InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
\r
1766 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
1768 /* send the labels to the combo box */
\r
1769 while (scd->label) {
\r
1770 err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label);
\r
1771 if (err != cnt++) {
\r
1772 sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n",
\r
1774 MessageBox(NULL, buf, NULL, MB_OK);
\r
1778 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
1782 SoundDialogWhichRadio(HWND hDlg)
\r
1784 if (IsDlgButtonChecked(hDlg, OPT_NoSound)) return OPT_NoSound;
\r
1785 if (IsDlgButtonChecked(hDlg, OPT_DefaultBeep)) return OPT_DefaultBeep;
\r
1786 if (IsDlgButtonChecked(hDlg, OPT_BuiltInSound)) return OPT_BuiltInSound;
\r
1787 if (IsDlgButtonChecked(hDlg, OPT_WavFile)) return OPT_WavFile;
\r
1792 SoundDialogSetEnables(HWND hDlg, int radio)
\r
1794 EnableWindow(GetDlgItem(hDlg, OPT_BuiltInSoundName),
\r
1795 radio == OPT_BuiltInSound);
\r
1796 EnableWindow(GetDlgItem(hDlg, OPT_WavFileName), radio == OPT_WavFile);
\r
1797 EnableWindow(GetDlgItem(hDlg, OPT_BrowseSound), radio == OPT_WavFile);
\r
1801 SoundDialogGetName(HWND hDlg, int radio)
\r
1803 static char buf[MSG_SIZ], buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
1804 char *dummy, *ret;
\r
1809 case OPT_DefaultBeep:
\r
1811 case OPT_BuiltInSound:
\r
1813 GetDlgItemText(hDlg, OPT_BuiltInSoundName, buf + 1, sizeof(buf) - 1);
\r
1816 GetDlgItemText(hDlg, OPT_WavFileName, buf, sizeof(buf));
\r
1817 GetCurrentDirectory(MSG_SIZ, buf3);
\r
1818 SetCurrentDirectory(installDir);
\r
1819 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
1824 SetCurrentDirectory(buf3);
\r
1830 DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
\r
1834 * I think it's best to clear the combo and edit boxes. It looks stupid
\r
1835 * to have a value from another sound event sitting there grayed out.
\r
1837 SetDlgItemText(hDlg, OPT_WavFileName, "");
\r
1838 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1840 if (appData.debugMode)
\r
1841 fprintf(debugFP, "DisplaySelectedSound(,,'%s'):\n", name);
\r
1842 switch (name[0]) {
\r
1844 radio = OPT_NoSound;
\r
1847 if (name[1] == NULLCHAR) {
\r
1848 radio = OPT_DefaultBeep;
\r
1850 radio = OPT_WavFile;
\r
1851 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1855 if (name[1] == NULLCHAR) {
\r
1856 radio = OPT_NoSound;
\r
1858 radio = OPT_BuiltInSound;
\r
1859 if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1,
\r
1860 (LPARAM) (name + 1)) == CB_ERR) {
\r
1861 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1862 SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1));
\r
1867 radio = OPT_WavFile;
\r
1868 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1871 SoundDialogSetEnables(hDlg, radio);
\r
1872 CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio);
\r
1876 char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES;
\r
1879 SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1881 static HWND hSoundCombo;
\r
1882 static DWORD index;
\r
1883 static HWND hBISN;
\r
1887 char buf[MSG_SIZ];
\r
1891 SoundComboData *scd;
\r
1893 switch (message) {
\r
1894 case WM_INITDIALOG:
\r
1895 /* Center the dialog over the application window */
\r
1896 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1898 /* Initialize the built-in sounds combo */
\r
1899 hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName);
\r
1900 InitComboStrings(hBISN, builtInSoundNames);
\r
1902 /* Initialize the sound events combo */
\r
1904 InitSoundComboData(soundComboData);
\r
1905 hSoundCombo = GetDlgItem(hDlg, CBO_Sounds);
\r
1906 InitSoundCombo(hSoundCombo, soundComboData);
\r
1908 /* update the dialog */
\r
1909 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1912 case WM_COMMAND: /* message: received a command */
\r
1914 if (((HWND)lParam == hSoundCombo) &&
\r
1915 (HIWORD(wParam) == CBN_SELCHANGE)) {
\r
1917 * the user has selected a new sound event. We must store the name for
\r
1918 * the previously selected event, then retrieve the name for the
\r
1919 * newly selected event and update the dialog.
\r
1921 radio = SoundDialogWhichRadio(hDlg);
\r
1922 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1924 if (strcmp(newName, soundComboData[index].name) != 0) {
\r
1925 free(soundComboData[index].name);
\r
1926 soundComboData[index].name = newName;
\r
1931 /* now get the settings for the newly selected event */
\r
1932 index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
\r
1933 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1937 switch (LOWORD(wParam)) {
\r
1940 * save the name for the currently selected sound event
\r
1942 radio = SoundDialogWhichRadio(hDlg);
\r
1943 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1945 if (strcmp(soundComboData[index].name, newName) != 0) {
\r
1946 free(soundComboData[index].name);
\r
1947 soundComboData[index].name = newName;
\r
1953 /* save all the sound names that changed and load the sounds */
\r
1955 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1956 if (strcmp(soundComboData[sc].name, sounds[sc].name) != 0) {
\r
1957 free(sounds[sc].name);
\r
1958 sounds[sc].name = strdup(soundComboData[sc].name);
\r
1959 MyLoadSound(&sounds[sc]);
\r
1962 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1963 index = (int)cc + (int)NSoundClasses;
\r
1964 if (strcmp(soundComboData[index].name,
\r
1965 textAttribs[cc].sound.name) != 0) {
\r
1966 free(textAttribs[cc].sound.name);
\r
1967 textAttribs[cc].sound.name = strdup(soundComboData[index].name);
\r
1968 MyLoadSound(&textAttribs[cc].sound);
\r
1972 ResetSoundComboData(soundComboData);
\r
1973 EndDialog(hDlg, TRUE);
\r
1977 ResetSoundComboData(soundComboData);
\r
1978 EndDialog(hDlg, FALSE);
\r
1981 case OPT_DefaultSounds:
\r
1982 /* can't use SetDefaultSounds() because we need to be able to "undo" if
\r
1983 * user selects "Cancel" later on. So we do it the hard way here.
\r
1985 scd = &soundComboData[0];
\r
1986 while (scd->label != NULL) {
\r
1987 if (scd->name != NULL) free(scd->name);
\r
1988 scd->name = strdup("");
\r
1991 free(soundComboData[(int)SoundBell].name);
\r
1992 soundComboData[(int)SoundBell].name = strdup(SOUND_BELL);
\r
1993 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1996 case OPT_PlaySound:
\r
1997 radio = SoundDialogWhichRadio(hDlg);
\r
1998 tmp.name = strdup(SoundDialogGetName(hDlg, radio));
\r
2000 MyLoadSound(&tmp);
\r
2001 MyPlaySound(&tmp);
\r
2002 if (tmp.data != NULL) free(tmp.data);
\r
2003 if (tmp.name != NULL) free(tmp.name);
\r
2006 case OPT_BrowseSound:
\r
2007 f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT,
\r
2008 "Browse for Sound File", NULL, NULL, buf);
\r
2011 SetDlgItemText(hDlg, OPT_WavFileName, buf);
\r
2016 radio = SoundDialogWhichRadio(hDlg);
\r
2017 SoundDialogSetEnables(hDlg, radio);
\r
2026 VOID SoundOptionsPopup(HWND hwnd)
\r
2030 lpProc = MakeProcInstance((FARPROC)SoundOptionsDialog, hInst);
\r
2031 DialogBox(hInst, MAKEINTRESOURCE(DLG_Sound), hwnd, (DLGPROC)lpProc);
\r
2032 FreeProcInstance(lpProc);
\r
2036 /*---------------------------------------------------------------------------*\
\r
2038 * Comm Port dialog functions
\r
2040 \*---------------------------------------------------------------------------*/
\r
2043 #define FLOW_NONE 0
\r
2044 #define FLOW_XOFF 1
\r
2045 #define FLOW_CTS 2
\r
2046 #define FLOW_DSR 3
\r
2050 ComboData cdPort[] = { {"None", PORT_NONE}, {"COM1", 1}, {"COM2", 2},
\r
2051 {"COM3", 3}, {"COM4", 4}, {NULL, 0} };
\r
2052 ComboData cdDataRate[] = { {"110", 110}, {"300", 300}, {"600", 600}, {"1200", 1200},
\r
2053 {"2400", 2400}, {"4800", 4800}, {"9600", 9600}, {"19200", 19200},
\r
2054 {"38400", 38400}, {NULL, 0} };
\r
2055 ComboData cdDataBits[] = { {"5", 5}, {"6", 6}, {"7", 7}, {"8", 8}, {NULL, 0} };
\r
2056 ComboData cdParity[] = { {"None", NOPARITY}, {"Odd", ODDPARITY}, {"Even", EVENPARITY},
\r
2057 {"Mark", MARKPARITY}, {"Space", SPACEPARITY}, {NULL, 0} };
\r
2058 ComboData cdStopBits[] = { {"1", ONESTOPBIT}, {"1.5", ONE5STOPBITS},
\r
2059 {"2", TWOSTOPBITS}, {NULL, 0} };
\r
2060 ComboData cdFlow[] = { {"None", FLOW_NONE}, {"Xoff/Xon", FLOW_XOFF}, {"CTS", FLOW_CTS},
\r
2061 {"DSR", FLOW_DSR}, {NULL, 0} };
\r
2065 ParseCommSettings(char *arg, DCB *dcb)
\r
2067 int dataRate, count;
\r
2068 char bits[MSG_SIZ], parity[MSG_SIZ], stopBits[MSG_SIZ], flow[MSG_SIZ];
\r
2070 count = sscanf(arg, "%d%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]",
\r
2071 &dataRate, bits, parity, stopBits, flow);
\r
2072 if (count != 5) goto cant_parse;
\r
2073 dcb->BaudRate = dataRate;
\r
2075 while (cd->label != NULL) {
\r
2076 if (StrCaseCmp(cd->label, bits) == 0) {
\r
2077 dcb->ByteSize = cd->value;
\r
2082 if (cd->label == NULL) goto cant_parse;
\r
2084 while (cd->label != NULL) {
\r
2085 if (StrCaseCmp(cd->label, parity) == 0) {
\r
2086 dcb->Parity = cd->value;
\r
2091 if (cd->label == NULL) goto cant_parse;
\r
2093 while (cd->label != NULL) {
\r
2094 if (StrCaseCmp(cd->label, stopBits) == 0) {
\r
2095 dcb->StopBits = cd->value;
\r
2101 if (cd->label == NULL) goto cant_parse;
\r
2102 while (cd->label != NULL) {
\r
2103 if (StrCaseCmp(cd->label, flow) == 0) {
\r
2104 switch (cd->value) {
\r
2106 dcb->fOutX = FALSE;
\r
2107 dcb->fOutxCtsFlow = FALSE;
\r
2108 dcb->fOutxDsrFlow = FALSE;
\r
2111 dcb->fOutX = FALSE;
\r
2112 dcb->fOutxCtsFlow = TRUE;
\r
2113 dcb->fOutxDsrFlow = FALSE;
\r
2116 dcb->fOutX = FALSE;
\r
2117 dcb->fOutxCtsFlow = FALSE;
\r
2118 dcb->fOutxDsrFlow = TRUE;
\r
2121 dcb->fOutX = TRUE;
\r
2122 dcb->fOutxCtsFlow = FALSE;
\r
2123 dcb->fOutxDsrFlow = FALSE;
\r
2130 if (cd->label == NULL) goto cant_parse;
\r
2133 ExitArgError("Can't parse com port settings", arg);
\r
2137 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
\r
2139 char *flow = "??", *parity = "??", *stopBits = "??";
\r
2143 while (cd->label != NULL) {
\r
2144 if (dcb->Parity == cd->value) {
\r
2145 parity = cd->label;
\r
2151 while (cd->label != NULL) {
\r
2152 if (dcb->StopBits == cd->value) {
\r
2153 stopBits = cd->label;
\r
2159 flow = cdFlow[FLOW_XOFF].label;
\r
2160 } else if (dcb->fOutxCtsFlow) {
\r
2161 flow = cdFlow[FLOW_CTS].label;
\r
2162 } else if (dcb->fOutxDsrFlow) {
\r
2163 flow = cdFlow[FLOW_DSR].label;
\r
2165 flow = cdFlow[FLOW_NONE].label;
\r
2167 fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name,
\r
2168 dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow);
\r
2173 InitCombo(HANDLE hwndCombo, ComboData *cd)
\r
2175 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
2177 while (cd->label != NULL) {
\r
2178 SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) cd->label);
\r
2184 SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value)
\r
2189 while (cd->label != NULL) {
\r
2190 if (cd->value == value) {
\r
2191 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) i, (LPARAM) 0);
\r
2200 CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2202 char buf[MSG_SIZ];
\r
2209 switch (message) {
\r
2210 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2211 /* Center the dialog over the application window */
\r
2212 CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER));
\r
2213 /* Initialize the dialog items */
\r
2214 /* !! There should probably be some synchronization
\r
2215 in accessing hCommPort and dcb. Or does modal nature
\r
2216 of this dialog box do it for us?
\r
2218 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2219 InitCombo(hwndCombo, cdPort);
\r
2220 p = strrchr(appData.icsCommPort, '\\');
\r
2221 if (p++ == NULL) p = appData.icsCommPort;
\r
2222 if ((*p == '\0') ||
\r
2223 (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) p) == CB_ERR)) {
\r
2224 SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) "None");
\r
2226 EnableWindow(hwndCombo, hCommPort == NULL); /*!! don't allow change for now*/
\r
2228 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2229 InitCombo(hwndCombo, cdDataRate);
\r
2230 sprintf(buf, "%u", dcb.BaudRate);
\r
2231 if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) {
\r
2232 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
2233 SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf);
\r
2236 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2237 InitCombo(hwndCombo, cdDataBits);
\r
2238 SelectComboValue(hwndCombo, cdDataBits, dcb.ByteSize);
\r
2240 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2241 InitCombo(hwndCombo, cdParity);
\r
2242 SelectComboValue(hwndCombo, cdParity, dcb.Parity);
\r
2244 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2245 InitCombo(hwndCombo, cdStopBits);
\r
2246 SelectComboValue(hwndCombo, cdStopBits, dcb.StopBits);
\r
2248 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2249 InitCombo(hwndCombo, cdFlow);
\r
2251 SelectComboValue(hwndCombo, cdFlow, FLOW_XOFF);
\r
2252 } else if (dcb.fOutxCtsFlow) {
\r
2253 SelectComboValue(hwndCombo, cdFlow, FLOW_CTS);
\r
2254 } else if (dcb.fOutxDsrFlow) {
\r
2255 SelectComboValue(hwndCombo, cdFlow, FLOW_DSR);
\r
2257 SelectComboValue(hwndCombo, cdFlow, FLOW_NONE);
\r
2261 case WM_COMMAND: /* message: received a command */
\r
2262 switch (LOWORD(wParam)) {
\r
2264 /* Read changed options from the dialog box */
\r
2266 /* !! Currently we can't change comm ports in midstream */
\r
2267 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2268 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2269 if (index == PORT_NONE) {
\r
2270 appData.icsCommPort = "";
\r
2271 if (hCommPort != NULL) {
\r
2272 CloseHandle(hCommPort);
\r
2275 EndDialog(hDlg, TRUE);
\r
2278 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2279 appData.icsCommPort = strdup(buf);
\r
2280 if (hCommPort != NULL) {
\r
2281 CloseHandle(hCommPort);
\r
2284 /* now what?? can't really do this; have to fix up the ChildProc
\r
2285 and InputSource records for the comm port that we gave to the
\r
2289 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2290 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2291 if (sscanf(buf, "%u", &value) != 1) {
\r
2292 MessageBox(hDlg, "Invalid data rate",
\r
2293 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2296 dcb.BaudRate = value;
\r
2298 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2299 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2300 dcb.ByteSize = cdDataBits[index].value;
\r
2302 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2303 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2304 dcb.Parity = cdParity[index].value;
\r
2306 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2307 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2308 dcb.StopBits = cdStopBits[index].value;
\r
2310 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2311 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2312 switch (cdFlow[index].value) {
\r
2314 dcb.fOutX = FALSE;
\r
2315 dcb.fOutxCtsFlow = FALSE;
\r
2316 dcb.fOutxDsrFlow = FALSE;
\r
2319 dcb.fOutX = FALSE;
\r
2320 dcb.fOutxCtsFlow = TRUE;
\r
2321 dcb.fOutxDsrFlow = FALSE;
\r
2324 dcb.fOutX = FALSE;
\r
2325 dcb.fOutxCtsFlow = FALSE;
\r
2326 dcb.fOutxDsrFlow = TRUE;
\r
2330 dcb.fOutxCtsFlow = FALSE;
\r
2331 dcb.fOutxDsrFlow = FALSE;
\r
2334 if (!SetCommState(hCommPort, (LPDCB) &dcb)) {
\r
2335 err = GetLastError();
\r
2336 switch(MessageBox(hDlg,
\r
2337 "Failed to set comm port state;\r\ninvalid options?",
\r
2338 "Option Error", MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {
\r
2340 DisplayFatalError("Failed to set comm port state", err, 1);
\r
2341 exit(1); /*is it ok to do this from here?*/
\r
2347 EndDialog(hDlg, TRUE);
\r
2352 EndDialog(hDlg, TRUE);
\r
2356 EndDialog(hDlg, FALSE);
\r
2368 CommPortOptionsPopup(HWND hwnd)
\r
2370 FARPROC lpProc = MakeProcInstance((FARPROC)CommPortOptionsDialog, hInst);
\r
2371 DialogBox(hInst, MAKEINTRESOURCE(DLG_CommPort), hwnd, (DLGPROC) lpProc);
\r
2372 FreeProcInstance(lpProc);
\r
2375 /*---------------------------------------------------------------------------*\
\r
2377 * Load Options dialog functions
\r
2379 \*---------------------------------------------------------------------------*/
\r
2382 SetLoadOptionEnables(HWND hDlg)
\r
2386 state = IsDlgButtonChecked(hDlg, OPT_Autostep);
\r
2387 EnableWindow(GetDlgItem(hDlg, OPT_ASTimeDelay), state);
\r
2388 EnableWindow(GetDlgItem(hDlg, OPT_AStext1), state);
\r
2392 LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2394 char buf[MSG_SIZ];
\r
2397 switch (message) {
\r
2398 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2399 /* Center the dialog over the application window */
\r
2400 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2401 /* Initialize the dialog items */
\r
2402 if (appData.timeDelay >= 0.0) {
\r
2403 CheckDlgButton(hDlg, OPT_Autostep, TRUE);
\r
2404 sprintf(buf, "%.2g", appData.timeDelay);
\r
2405 SetDlgItemText(hDlg, OPT_ASTimeDelay, buf);
\r
2407 CheckDlgButton(hDlg, OPT_Autostep, FALSE);
\r
2409 SetLoadOptionEnables(hDlg);
\r
2412 case WM_COMMAND: /* message: received a command */
\r
2413 switch (LOWORD(wParam)) {
\r
2415 /* Read changed options from the dialog box */
\r
2416 if (IsDlgButtonChecked(hDlg, OPT_Autostep)) {
\r
2417 GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ);
\r
2418 if (sscanf(buf, "%f", &fnumber) != 1) {
\r
2419 MessageBox(hDlg, "Invalid load game step rate",
\r
2420 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2423 appData.timeDelay = fnumber;
\r
2425 appData.timeDelay = (float) -1.0;
\r
2427 EndDialog(hDlg, TRUE);
\r
2431 EndDialog(hDlg, FALSE);
\r
2435 SetLoadOptionEnables(hDlg);
\r
2445 LoadOptionsPopup(HWND hwnd)
\r
2447 FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst);
\r
2448 DialogBox(hInst, MAKEINTRESOURCE(DLG_LoadOptions), hwnd, (DLGPROC) lpProc);
\r
2449 FreeProcInstance(lpProc);
\r
2452 /*---------------------------------------------------------------------------*\
\r
2454 * Save Options dialog functions
\r
2456 \*---------------------------------------------------------------------------*/
\r
2459 SetSaveOptionEnables(HWND hDlg)
\r
2463 state = IsDlgButtonChecked(hDlg, OPT_Autosave);
\r
2464 EnableWindow(GetDlgItem(hDlg, OPT_AVPrompt), state);
\r
2465 EnableWindow(GetDlgItem(hDlg, OPT_AVToFile), state);
\r
2466 if (state && !IsDlgButtonChecked(hDlg, OPT_AVPrompt) &&
\r
2467 !IsDlgButtonChecked(hDlg, OPT_AVToFile)) {
\r
2468 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2471 state = state && IsDlgButtonChecked(hDlg, OPT_AVToFile);
\r
2472 EnableWindow(GetDlgItem(hDlg, OPT_AVFilename), state);
\r
2473 EnableWindow(GetDlgItem(hDlg, OPT_AVBrowse), state);
\r
2477 SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2479 char buf[MSG_SIZ];
\r
2482 switch (message) {
\r
2483 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2484 /* Center the dialog over the application window */
\r
2485 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2486 /* Initialize the dialog items */
\r
2487 if (*appData.saveGameFile != NULLCHAR) {
\r
2488 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2489 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVToFile);
\r
2490 SetDlgItemText(hDlg, OPT_AVFilename, appData.saveGameFile);
\r
2491 } else if (appData.autoSaveGames) {
\r
2492 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2493 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2495 CheckDlgButton(hDlg, OPT_Autosave, (UINT) FALSE);
\r
2497 if (appData.oldSaveStyle) {
\r
2498 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_Old);
\r
2500 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_PGN);
\r
2502 CheckDlgButton( hDlg, OPT_OutOfBookInfo, appData.saveOutOfBookInfo );
\r
2503 SetSaveOptionEnables(hDlg);
\r
2506 case WM_COMMAND: /* message: received a command */
\r
2507 switch (LOWORD(wParam)) {
\r
2509 /* Read changed options from the dialog box */
\r
2510 if (IsDlgButtonChecked(hDlg, OPT_Autosave)) {
\r
2511 appData.autoSaveGames = TRUE;
\r
2512 if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) {
\r
2513 appData.saveGameFile = "";
\r
2514 } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ {
\r
2515 GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ);
\r
2516 if (*buf == NULLCHAR) {
\r
2517 MessageBox(hDlg, "Invalid save game file name",
\r
2518 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2521 if ((isalpha(buf[0]) && buf[1] == ':') ||
\r
2522 (buf[0] == '\\' && buf[1] == '\\')) {
\r
2523 appData.saveGameFile = strdup(buf);
\r
2525 char buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
2527 GetCurrentDirectory(MSG_SIZ, buf3);
\r
2528 SetCurrentDirectory(installDir);
\r
2529 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
2530 appData.saveGameFile = strdup(buf2);
\r
2532 appData.saveGameFile = strdup(buf);
\r
2534 SetCurrentDirectory(buf3);
\r
2538 appData.autoSaveGames = FALSE;
\r
2539 appData.saveGameFile = "";
\r
2541 appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old);
\r
2542 appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo );
\r
2543 EndDialog(hDlg, TRUE);
\r
2547 EndDialog(hDlg, FALSE);
\r
2550 case OPT_AVBrowse:
\r
2551 f = OpenFileDialog(hDlg, "a", NULL,
\r
2552 appData.oldSaveStyle ? "gam" : "pgn",
\r
2553 GAME_FILT, "Browse for Auto Save File",
\r
2557 SetDlgItemText(hDlg, OPT_AVFilename, buf);
\r
2562 SetSaveOptionEnables(hDlg);
\r
2571 SaveOptionsPopup(HWND hwnd)
\r
2573 FARPROC lpProc = MakeProcInstance((FARPROC)SaveOptionsDialog, hInst);
\r
2574 DialogBox(hInst, MAKEINTRESOURCE(DLG_SaveOptions), hwnd, (DLGPROC) lpProc);
\r
2575 FreeProcInstance(lpProc);
\r
2578 /*---------------------------------------------------------------------------*\
\r
2580 * Time Control Options dialog functions
\r
2582 \*---------------------------------------------------------------------------*/
\r
2585 SetTimeControlEnables(HWND hDlg)
\r
2589 state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves);
\r
2590 EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state);
\r
2591 EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state);
\r
2592 EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state);
\r
2593 EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state);
\r
2594 EnableWindow(GetDlgItem(hDlg, OPT_TCTime2), !state);
\r
2595 EnableWindow(GetDlgItem(hDlg, OPT_TCInc), !state);
\r
2596 EnableWindow(GetDlgItem(hDlg, OPT_TCitext1), !state);
\r
2597 EnableWindow(GetDlgItem(hDlg, OPT_TCitext2), !state);
\r
2598 EnableWindow(GetDlgItem(hDlg, OPT_TCitext3), !state);
\r
2603 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2605 char buf[MSG_SIZ];
\r
2606 int mps, increment, odds1, odds2;
\r
2609 switch (message) {
\r
2610 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2611 /* Center the dialog over the application window */
\r
2612 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2613 /* Initialize the dialog items */
\r
2614 if (appData.clockMode && !appData.icsActive) {
\r
2615 if (appData.timeIncrement == -1) {
\r
2616 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,
\r
2618 SetDlgItemText(hDlg, OPT_TCTime, appData.timeControl);
\r
2619 SetDlgItemInt(hDlg, OPT_TCMoves, appData.movesPerSession,
\r
2621 SetDlgItemText(hDlg, OPT_TCTime2, "");
\r
2622 SetDlgItemText(hDlg, OPT_TCInc, "");
\r
2624 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,
\r
2626 SetDlgItemText(hDlg, OPT_TCTime, "");
\r
2627 SetDlgItemText(hDlg, OPT_TCMoves, "");
\r
2628 SetDlgItemText(hDlg, OPT_TCTime2, appData.timeControl);
\r
2629 SetDlgItemInt(hDlg, OPT_TCInc, appData.timeIncrement, FALSE);
\r
2631 SetDlgItemInt(hDlg, OPT_TCOdds1, 1, FALSE);
\r
2632 SetDlgItemInt(hDlg, OPT_TCOdds2, 1, FALSE);
\r
2633 SetTimeControlEnables(hDlg);
\r
2637 case WM_COMMAND: /* message: received a command */
\r
2638 switch (LOWORD(wParam)) {
\r
2640 /* Read changed options from the dialog box */
\r
2641 if (IsDlgButtonChecked(hDlg, OPT_TCUseMoves)) {
\r
2643 mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE);
\r
2644 if (!ok || mps <= 0) {
\r
2645 MessageBox(hDlg, "Invalid moves per time control",
\r
2646 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2649 GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ);
\r
2650 if (!ParseTimeControl(buf, increment, mps)) {
\r
2651 MessageBox(hDlg, "Invalid minutes per time control",
\r
2652 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2656 increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE);
\r
2657 mps = appData.movesPerSession;
\r
2658 if (!ok || increment < 0) {
\r
2659 MessageBox(hDlg, "Invalid increment",
\r
2660 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2663 GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ);
\r
2664 if (!ParseTimeControl(buf, increment, mps)) {
\r
2665 MessageBox(hDlg, "Invalid initial time",
\r
2666 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2670 odds1 = GetDlgItemInt(hDlg, OPT_TCOdds1, &ok, FALSE);
\r
2671 odds2 = GetDlgItemInt(hDlg, OPT_TCOdds2, &ok2, FALSE);
\r
2672 if (!ok || !ok2 || odds1 <= 0 || odds2 <= 0) {
\r
2673 MessageBox(hDlg, "Invalid time-odds factor",
\r
2674 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2677 appData.timeControl = strdup(buf);
\r
2678 appData.movesPerSession = mps;
\r
2679 appData.timeIncrement = increment;
\r
2680 appData.firstTimeOdds = first.timeOdds = odds1;
\r
2681 appData.secondTimeOdds = second.timeOdds = odds2;
\r
2682 Reset(TRUE, TRUE);
\r
2683 EndDialog(hDlg, TRUE);
\r
2687 EndDialog(hDlg, FALSE);
\r
2691 SetTimeControlEnables(hDlg);
\r
2700 TimeControlOptionsPopup(HWND hwnd)
\r
2702 if (gameMode != BeginningOfGame) {
\r
2703 DisplayError("Changing time control during a game is not implemented", 0);
\r
2705 FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst);
\r
2706 DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc);
\r
2707 FreeProcInstance(lpProc);
\r
2711 /*---------------------------------------------------------------------------*\
\r
2713 * Engine Options Dialog functions
\r
2715 \*---------------------------------------------------------------------------*/
\r
2716 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
2717 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
2719 #define INT_ABS( n ) ((n) >= 0 ? (n) : -(n))
\r
2721 LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2723 switch (message) {
\r
2724 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2726 /* Center the dialog over the application window */
\r
2727 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2729 /* Initialize the dialog items */
\r
2730 CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates);
\r
2731 CHECK_BOX(IDC_EpPonder, appData.ponderNextMove);
\r
2732 CHECK_BOX(IDC_EpShowThinking, appData.showThinking);
\r
2733 CHECK_BOX(IDC_EpHideThinkingHuman, appData.hideThinkingFromHuman);
\r
2735 CHECK_BOX(IDC_TestClaims, appData.testClaims);
\r
2736 CHECK_BOX(IDC_DetectMates, appData.checkMates);
\r
2737 CHECK_BOX(IDC_MaterialDraws, appData.materialDraws);
\r
2738 CHECK_BOX(IDC_TrivialDraws, appData.trivialDraws);
\r
2740 CHECK_BOX(IDC_ScoreAbs1, appData.firstScoreIsAbsolute);
\r
2741 CHECK_BOX(IDC_ScoreAbs2, appData.secondScoreIsAbsolute);
\r
2743 SetDlgItemInt( hDlg, IDC_EpDrawMoveCount, appData.adjudicateDrawMoves, TRUE );
\r
2744 SendDlgItemMessage( hDlg, IDC_EpDrawMoveCount, EM_SETSEL, 0, -1 );
\r
2746 SetDlgItemInt( hDlg, IDC_EpAdjudicationThreshold, INT_ABS(appData.adjudicateLossThreshold), TRUE );
\r
2747 SendDlgItemMessage( hDlg, IDC_EpAdjudicationThreshold, EM_SETSEL, 0, -1 );
\r
2749 SetDlgItemInt( hDlg, IDC_RuleMoves, appData.ruleMoves, TRUE );
\r
2750 SendDlgItemMessage( hDlg, IDC_RuleMoves, EM_SETSEL, 0, -1 );
\r
2752 SetDlgItemInt( hDlg, IDC_DrawRepeats, INT_ABS(appData.drawRepeats), TRUE );
\r
2753 SendDlgItemMessage( hDlg, IDC_DrawRepeats, EM_SETSEL, 0, -1 );
\r
2757 case WM_COMMAND: /* message: received a command */
\r
2758 switch (LOWORD(wParam)) {
\r
2760 /* Read changed options from the dialog box */
\r
2761 PeriodicUpdatesEvent( IS_CHECKED(IDC_EpPeriodicUpdates));
\r
2762 PonderNextMoveEvent( IS_CHECKED(IDC_EpPonder));
\r
2763 appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up
\r
2765 ShowThinkingEvent( IS_CHECKED(IDC_EpShowThinking));
\r
2767 appData.showThinking = IS_CHECKED(IDC_EpShowThinking);
\r
2768 ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output
\r
2770 appData.testClaims = IS_CHECKED(IDC_TestClaims);
\r
2771 appData.checkMates = IS_CHECKED(IDC_DetectMates);
\r
2772 appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);
\r
2773 appData.trivialDraws = IS_CHECKED(IDC_TrivialDraws);
\r
2775 appData.adjudicateDrawMoves = GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, NULL, FALSE );
\r
2776 appData.adjudicateLossThreshold = - (int) GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, NULL, FALSE );
\r
2777 appData.ruleMoves = GetDlgItemInt(hDlg, IDC_RuleMoves, NULL, FALSE );
\r
2778 appData.drawRepeats = (int) GetDlgItemInt(hDlg, IDC_DrawRepeats, NULL, FALSE );
\r
2780 appData.firstScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs1);
\r
2781 appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2);
\r
2783 EndDialog(hDlg, TRUE);
\r
2787 EndDialog(hDlg, FALSE);
\r
2790 case IDC_EpDrawMoveCount:
\r
2791 case IDC_EpAdjudicationThreshold:
\r
2792 case IDC_DrawRepeats:
\r
2793 case IDC_RuleMoves:
\r
2794 if( HIWORD(wParam) == EN_CHANGE ) {
\r
2800 GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, &n1_ok, FALSE );
\r
2801 GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, &n2_ok, FALSE );
\r
2802 GetDlgItemInt(hDlg, IDC_RuleMoves, &n3_ok, FALSE );
\r
2803 GetDlgItemInt(hDlg, IDC_DrawRepeats, &n4_ok, FALSE );
\r
2805 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok && n4_ok ? TRUE : FALSE );
\r
2814 VOID EnginePlayOptionsPopup(HWND hwnd)
\r
2818 lpProc = MakeProcInstance((FARPROC)EnginePlayOptionsDialog, hInst);
\r
2819 DialogBox(hInst, MAKEINTRESOURCE(DLG_EnginePlayOptions), hwnd, (DLGPROC) lpProc);
\r
2820 FreeProcInstance(lpProc);
\r
2823 /*---------------------------------------------------------------------------*\
\r
2825 * UCI Options Dialog functions
\r
2827 \*---------------------------------------------------------------------------*/
\r
2828 static BOOL BrowseForFolder( const char * title, char * path )
\r
2830 BOOL result = FALSE;
\r
2832 LPITEMIDLIST pidl;
\r
2834 ZeroMemory( &bi, sizeof(bi) );
\r
2836 bi.lpszTitle = title == 0 ? "Choose Folder" : title;
\r
2837 bi.ulFlags = BIF_RETURNONLYFSDIRS;
\r
2839 pidl = SHBrowseForFolder( &bi );
\r
2842 IMalloc * imalloc = 0;
\r
2844 if( SHGetPathFromIDList( pidl, path ) ) {
\r
2848 if( SUCCEEDED( SHGetMalloc ( &imalloc ) ) ) {
\r
2849 imalloc->lpVtbl->Free(imalloc,pidl);
\r
2850 imalloc->lpVtbl->Release(imalloc);
\r
2857 LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2859 char buf[MAX_PATH];
\r
2862 switch (message) {
\r
2863 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2865 /* Center the dialog over the application window */
\r
2866 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2868 /* Initialize the dialog items */
\r
2869 SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir );
\r
2870 SetDlgItemInt( hDlg, IDC_HashSize, appData.defaultHashSize, TRUE );
\r
2871 SetDlgItemText( hDlg, IDC_PathToEGTB, appData.defaultPathEGTB );
\r
2872 SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE );
\r
2873 CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook );
\r
2874 SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook );
\r
2875 // [HGM] smp: input field for nr of cores:
\r
2876 SetDlgItemInt( hDlg, IDC_Cores, appData.smpCores, TRUE );
\r
2877 // [HGM] book: tick boxes for own book use
\r
2878 CheckDlgButton( hDlg, IDC_OwnBook1, (BOOL) appData.firstHasOwnBookUCI );
\r
2879 CheckDlgButton( hDlg, IDC_OwnBook2, (BOOL) appData.secondHasOwnBookUCI );
\r
2881 SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 );
\r
2885 case WM_COMMAND: /* message: received a command */
\r
2886 switch (LOWORD(wParam)) {
\r
2888 GetDlgItemText( hDlg, IDC_PolyglotDir, buf, sizeof(buf) );
\r
2889 appData.polyglotDir = strdup(buf);
\r
2890 appData.defaultHashSize = GetDlgItemInt(hDlg, IDC_HashSize, NULL, FALSE );
\r
2891 appData.defaultCacheSizeEGTB = GetDlgItemInt(hDlg, IDC_SizeOfEGTB, NULL, FALSE );
\r
2892 GetDlgItemText( hDlg, IDC_PathToEGTB, buf, sizeof(buf) );
\r
2893 appData.defaultPathEGTB = strdup(buf);
\r
2894 GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) );
\r
2895 appData.polyglotBook = strdup(buf);
\r
2896 appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook );
\r
2897 // [HGM] smp: get nr of cores:
\r
2898 oldCores = appData.smpCores;
\r
2899 appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE );
\r
2900 if(appData.smpCores != oldCores) NewSettingEvent(FALSE, "cores", appData.smpCores);
\r
2901 // [HGM] book: read tick boxes for own book use
\r
2902 appData.firstHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 );
\r
2903 appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 );
\r
2905 if(gameMode == BeginningOfGame) Reset(TRUE, TRUE);
\r
2906 EndDialog(hDlg, TRUE);
\r
2910 EndDialog(hDlg, FALSE);
\r
2913 case IDC_BrowseForBook:
\r
2915 char filter[] = {
\r
2916 'A','l','l',' ','F','i','l','e','s', 0,
\r
2918 'B','I','N',' ','F','i','l','e','s', 0,
\r
2919 '*','.','b','i','n', 0,
\r
2924 strcpy( buf, "" );
\r
2926 ZeroMemory( &ofn, sizeof(ofn) );
\r
2928 ofn.lStructSize = sizeof(ofn);
\r
2929 ofn.hwndOwner = hDlg;
\r
2930 ofn.hInstance = hInst;
\r
2931 ofn.lpstrFilter = filter;
\r
2932 ofn.lpstrFile = buf;
\r
2933 ofn.nMaxFile = sizeof(buf);
\r
2934 ofn.lpstrTitle = "Choose Book";
\r
2935 ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
\r
2937 if( GetOpenFileName( &ofn ) ) {
\r
2938 SetDlgItemText( hDlg, IDC_BookFile, buf );
\r
2943 case IDC_BrowseForPolyglotDir:
\r
2944 if( BrowseForFolder( "Choose Polyglot Directory", buf ) ) {
\r
2945 SetDlgItemText( hDlg, IDC_PolyglotDir, buf );
\r
2947 strcat( buf, "\\polyglot.exe" );
\r
2949 if( GetFileAttributes(buf) == 0xFFFFFFFF ) {
\r
2950 MessageBox( hDlg, "Polyglot was not found in the specified folder!", "Warning", MB_OK | MB_ICONWARNING );
\r
2955 case IDC_BrowseForEGTB:
\r
2956 if( BrowseForFolder( "Choose EGTB Directory:", buf ) ) {
\r
2957 SetDlgItemText( hDlg, IDC_PathToEGTB, buf );
\r
2961 case IDC_HashSize:
\r
2962 case IDC_SizeOfEGTB:
\r
2963 if( HIWORD(wParam) == EN_CHANGE ) {
\r
2967 GetDlgItemInt(hDlg, IDC_HashSize, &n1_ok, FALSE );
\r
2968 GetDlgItemInt(hDlg, IDC_SizeOfEGTB, &n2_ok, FALSE );
\r
2970 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok ? TRUE : FALSE );
\r
2979 VOID UciOptionsPopup(HWND hwnd)
\r
2983 lpProc = MakeProcInstance((FARPROC)UciOptionsDialog, hInst);
\r
2984 DialogBox(hInst, MAKEINTRESOURCE(DLG_OptionsUCI), hwnd, (DLGPROC) lpProc);
\r
2985 FreeProcInstance(lpProc);
\r