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 ShowThinkingEvent( IS_CHECKED(OPT_ShowThinking));
\r
218 appData.testLegality = IS_CHECKED(OPT_TestLegality);
\r
219 appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);
\r
220 appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN);
\r
221 appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory);
\r
222 appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);
\r
226 SetWindowPos(hwndMain, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
227 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
230 SetWindowPos(hwndConsole, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
231 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
234 if (!appData.highlightLastMove) {
\r
236 DrawPosition(FALSE, NULL);
\r
239 * for some reason the redraw seems smoother when we invalidate
\r
240 * the board rect after the call to EndDialog()
\r
242 EndDialog(hDlg, TRUE);
\r
244 if (oldShowButtonBar != appData.showButtonBar) {
\r
245 InitDrawingSizes(boardSize, 0);
\r
246 } else if ((oldShowCoords != appData.showCoords) ||
\r
247 (oldBlindfold != appData.blindfold)) {
\r
248 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
254 EndDialog(hDlg, FALSE);
\r
264 GeneralOptionsPopup(HWND hwnd)
\r
268 lpProc = MakeProcInstance((FARPROC)GeneralOptionsDialog, hInst);
\r
269 DialogBox(hInst, MAKEINTRESOURCE(DLG_GeneralOptions), hwnd,
\r
271 FreeProcInstance(lpProc);
\r
273 /*---------------------------------------------------------------------------*\
\r
275 * Board Options Dialog functions
\r
277 \*---------------------------------------------------------------------------*/
\r
279 const int SAMPLE_SQ_SIZE = 54;
\r
282 ChangeBoardSize(BoardSize newSize)
\r
284 if (newSize != boardSize) {
\r
285 boardSize = newSize;
\r
286 InitDrawingSizes(boardSize, 0);
\r
294 COLORREF squareColor,
\r
295 COLORREF pieceColor,
\r
296 COLORREF squareOutlineColor,
\r
297 COLORREF pieceDetailColor,
\r
303 HBRUSH brushSquare;
\r
304 HBRUSH brushSquareOutline;
\r
306 HBRUSH brushPieceDetail;
\r
307 HBRUSH oldBrushPiece;
\r
308 HBRUSH oldBrushSquare;
\r
309 HBITMAP oldBitmapMem;
\r
310 HBITMAP oldBitmapTemp;
\r
311 HBITMAP bufferBitmap;
\r
313 HDC hdcScreen, hdcMem, hdcTemp;
\r
315 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
318 const int SOLID = 0;
\r
319 const int WHITE = 1;
\r
320 const int OUTLINE = 2;
\r
321 const int BORDER = 4;
\r
323 InvalidateRect(hCtrl, NULL, TRUE);
\r
324 UpdateWindow(hCtrl);
\r
325 GetClientRect(hCtrl, &rect);
\r
326 x = rect.left + (BORDER / 2);
\r
327 y = rect.top + (BORDER / 2);
\r
328 hdcScreen = GetDC(hCtrl);
\r
329 hdcMem = CreateCompatibleDC(hdcScreen);
\r
330 hdcTemp = CreateCompatibleDC(hdcScreen);
\r
332 bufferBitmap = CreateCompatibleBitmap(hdcScreen, rect.right-rect.left+1,
\r
333 rect.bottom-rect.top+1);
\r
334 oldBitmapMem = SelectObject(hdcMem, bufferBitmap);
\r
336 SelectPalette(hdcMem, hPal, FALSE);
\r
338 brushSquare = CreateSolidBrush(squareColor);
\r
339 brushSquareOutline = CreateSolidBrush(squareOutlineColor);
\r
340 brushPiece = CreateSolidBrush(pieceColor);
\r
341 brushPieceDetail = CreateSolidBrush(pieceDetailColor);
\r
344 * first draw the rectangle
\r
346 pen = CreatePen(PS_SOLID, BORDER, squareOutlineColor);
\r
347 oldPen = (HPEN) SelectObject(hdcMem, pen);
\r
348 oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare);
\r
349 Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);
\r
352 * now draw the piece
\r
355 oldBitmapTemp = SelectObject(hdcTemp, pieces[OUTLINE]);
\r
356 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0,
\r
357 isWhitePiece ? SRCCOPY : NOTSRCCOPY);
\r
358 SelectObject(hdcTemp, oldBitmapTemp);
\r
360 if (isWhitePiece) {
\r
361 oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]);
\r
362 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
363 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
364 hdcTemp, 0, 0, 0x00B8074A);
\r
366 /* Use pieceDetailColor for outline of white pieces */
\r
367 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
368 SelectObject(hdcMem, brushPieceDetail);
\r
369 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
370 hdcTemp, 0, 0, 0x00B8074A);
\r
372 /* Use black for outline of white pieces */
\r
373 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
374 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
375 hdcTemp, 0, 0, SRCAND);
\r
379 /* Use pieceDetailColor for details of black pieces */
\r
380 /* Requires filled-in solid bitmaps (BLACK_PIECE class); the
\r
381 WHITE_PIECE ones aren't always the right shape. */
\r
382 oldBitmapTemp = SelectObject(hdcTemp, pieces[BLACK]);
\r
383 oldBrushPiece = SelectObject(hdcMem, brushPieceDetail);
\r
384 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
385 hdcTemp, 0, 0, 0x00B8074A);
\r
386 SelectObject(hdcTemp, pieces[SOLID]);
\r
387 SelectObject(hdcMem, brushPiece);
\r
388 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
389 hdcTemp, 0, 0, 0x00B8074A);
\r
391 /* Use square color for details of black pieces */
\r
392 oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);
\r
393 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
394 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
395 hdcTemp, 0, 0, 0x00B8074A);
\r
398 SelectObject(hdcMem, oldBrushPiece);
\r
399 SelectObject(hdcTemp, oldBitmapTemp);
\r
402 * copy the memory dc to the screen
\r
404 SelectObject(hdcMem, bufferBitmap);
\r
405 BitBlt(hdcScreen, rect.left, rect.top,
\r
406 rect.right - rect.left,
\r
407 rect.bottom - rect.top,
\r
408 hdcMem, rect.left, rect.top, SRCCOPY);
\r
409 SelectObject(hdcMem, oldBitmapMem);
\r
413 SelectObject(hdcMem, oldBrushPiece);
\r
414 SelectObject(hdcMem, oldPen);
\r
415 DeleteObject(brushPiece);
\r
416 DeleteObject(brushPieceDetail);
\r
417 DeleteObject(brushSquare);
\r
418 DeleteObject(brushSquareOutline);
\r
422 ReleaseDC(hCtrl, hdcScreen);
\r
427 PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color)
\r
430 HBRUSH brush, oldBrush;
\r
432 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
434 hdc = GetDC(hCtrl);
\r
435 InvalidateRect(hCtrl, NULL, TRUE);
\r
436 UpdateWindow(hCtrl);
\r
437 GetClientRect(hCtrl, &rect);
\r
438 brush = CreateSolidBrush(color);
\r
439 oldBrush = (HBRUSH)SelectObject(hdc, brush);
\r
440 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
\r
441 SelectObject(hdc, oldBrush);
\r
442 DeleteObject(brush);
\r
443 ReleaseDC(hCtrl, hdc);
\r
448 SetBoardOptionEnables(HWND hDlg)
\r
450 if (IsDlgButtonChecked(hDlg, OPT_Monochrome)) {
\r
451 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_HIDE);
\r
452 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_HIDE);
\r
453 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_HIDE);
\r
454 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_HIDE);
\r
456 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), FALSE);
\r
457 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), FALSE);
\r
458 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), FALSE);
\r
459 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), FALSE);
\r
461 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_SHOW);
\r
462 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_SHOW);
\r
463 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_SHOW);
\r
464 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_SHOW);
\r
466 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), TRUE);
\r
467 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), TRUE);
\r
468 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), TRUE);
\r
469 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), TRUE);
\r
474 BoardOptionsWhichRadio(HWND hDlg)
\r
476 return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny :
\r
477 (IsDlgButtonChecked(hDlg, OPT_SizeTeeny) ? SizeTeeny :
\r
478 (IsDlgButtonChecked(hDlg, OPT_SizeDinky) ? SizeDinky :
\r
479 (IsDlgButtonChecked(hDlg, OPT_SizePetite) ? SizePetite :
\r
480 (IsDlgButtonChecked(hDlg, OPT_SizeSlim) ? SizeSlim :
\r
481 (IsDlgButtonChecked(hDlg, OPT_SizeSmall) ? SizeSmall :
\r
482 (IsDlgButtonChecked(hDlg, OPT_SizeMediocre) ? SizeMediocre :
\r
483 (IsDlgButtonChecked(hDlg, OPT_SizeMiddling) ? SizeMiddling :
\r
484 (IsDlgButtonChecked(hDlg, OPT_SizeAverage) ? SizeAverage :
\r
485 (IsDlgButtonChecked(hDlg, OPT_SizeModerate) ? SizeModerate :
\r
486 (IsDlgButtonChecked(hDlg, OPT_SizeMedium) ? SizeMedium :
\r
487 (IsDlgButtonChecked(hDlg, OPT_SizeBulky) ? SizeBulky :
\r
488 (IsDlgButtonChecked(hDlg, OPT_SizeLarge) ? SizeLarge :
\r
489 (IsDlgButtonChecked(hDlg, OPT_SizeBig) ? SizeBig :
\r
490 (IsDlgButtonChecked(hDlg, OPT_SizeHuge) ? SizeHuge :
\r
491 (IsDlgButtonChecked(hDlg, OPT_SizeGiant) ? SizeGiant :
\r
492 (IsDlgButtonChecked(hDlg, OPT_SizeColossal) ? SizeColossal :
\r
493 SizeTitanic )))))))))))))))));
\r
497 BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
499 static Boolean mono, white, flip;
\r
500 static BoardSize size;
\r
501 static COLORREF lsc, dsc, wpc, bpc, hsc, phc;
\r
502 static HBITMAP pieces[3];
\r
505 case WM_INITDIALOG: /* message: initialize dialog box */
\r
506 /* Center the dialog over the application window */
\r
507 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
508 /* Initialize the dialog items */
\r
509 switch (boardSize) {
\r
511 CheckDlgButton(hDlg, OPT_SizeTiny, TRUE);
\r
514 CheckDlgButton(hDlg, OPT_SizeTeeny, TRUE);
\r
517 CheckDlgButton(hDlg, OPT_SizeDinky, TRUE);
\r
520 CheckDlgButton(hDlg, OPT_SizePetite, TRUE);
\r
523 CheckDlgButton(hDlg, OPT_SizeSlim, TRUE);
\r
526 CheckDlgButton(hDlg, OPT_SizeSmall, TRUE);
\r
529 CheckDlgButton(hDlg, OPT_SizeMediocre, TRUE);
\r
532 CheckDlgButton(hDlg, OPT_SizeMiddling, TRUE);
\r
535 CheckDlgButton(hDlg, OPT_SizeAverage, TRUE);
\r
538 CheckDlgButton(hDlg, OPT_SizeModerate, TRUE);
\r
541 CheckDlgButton(hDlg, OPT_SizeMedium, TRUE);
\r
544 CheckDlgButton(hDlg, OPT_SizeBulky, TRUE);
\r
547 CheckDlgButton(hDlg, OPT_SizeLarge, TRUE);
\r
550 CheckDlgButton(hDlg, OPT_SizeBig, TRUE);
\r
553 CheckDlgButton(hDlg, OPT_SizeHuge, TRUE);
\r
556 CheckDlgButton(hDlg, OPT_SizeGiant, TRUE);
\r
559 CheckDlgButton(hDlg, OPT_SizeColossal, TRUE);
\r
562 CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE);
\r
565 if (appData.monoMode)
\r
566 CheckDlgButton(hDlg, OPT_Monochrome, TRUE);
\r
568 if (appData.allWhite)
\r
569 CheckDlgButton(hDlg, OPT_AllWhite, TRUE);
\r
571 if (appData.upsideDown)
\r
572 CheckDlgButton(hDlg, OPT_UpsideDown, TRUE);
\r
574 pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s");
\r
575 pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w");
\r
576 pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o");
\r
578 lsc = lightSquareColor;
\r
579 dsc = darkSquareColor;
\r
580 wpc = whitePieceColor;
\r
581 bpc = blackPieceColor;
\r
582 hsc = highlightSquareColor;
\r
583 phc = premoveHighlightColor;
\r
584 mono = appData.monoMode;
\r
585 white= appData.allWhite;
\r
586 flip = appData.upsideDown;
\r
589 SetBoardOptionEnables(hDlg);
\r
593 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
594 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
595 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
596 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
597 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
598 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
599 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
600 TRUE, mono, pieces);
\r
601 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
602 FALSE, mono, pieces);
\r
606 case WM_COMMAND: /* message: received a command */
\r
607 switch (LOWORD(wParam)) {
\r
610 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
611 * then ChangeBoardSize() does not take effect, although the new
\r
612 * boardSize is saved. Go figure...
\r
614 EndDialog(hDlg, TRUE);
\r
616 size = BoardOptionsWhichRadio(hDlg);
\r
619 * did any settings change?
\r
621 if (size != boardSize) {
\r
622 ChangeBoardSize(size);
\r
625 if ((mono != appData.monoMode) ||
\r
626 (lsc != lightSquareColor) ||
\r
627 (dsc != darkSquareColor) ||
\r
628 (wpc != whitePieceColor) ||
\r
629 (bpc != blackPieceColor) ||
\r
630 (hsc != highlightSquareColor) ||
\r
631 (flip != appData.upsideDown) ||
\r
632 (white != appData.allWhite) ||
\r
633 (phc != premoveHighlightColor)) {
\r
635 lightSquareColor = lsc;
\r
636 darkSquareColor = dsc;
\r
637 whitePieceColor = wpc;
\r
638 blackPieceColor = bpc;
\r
639 highlightSquareColor = hsc;
\r
640 premoveHighlightColor = phc;
\r
641 appData.monoMode = mono;
\r
642 appData.allWhite = white;
\r
643 appData.upsideDown = flip;
\r
645 InitDrawingColors();
\r
646 InitDrawingSizes(boardSize, 0);
\r
647 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
649 DeleteObject(pieces[0]);
\r
650 DeleteObject(pieces[1]);
\r
651 DeleteObject(pieces[2]);
\r
655 DeleteObject(pieces[0]);
\r
656 DeleteObject(pieces[1]);
\r
657 DeleteObject(pieces[2]);
\r
658 EndDialog(hDlg, FALSE);
\r
661 case OPT_ChooseLightSquareColor:
\r
662 if (ChangeColor(hDlg, &lsc))
\r
663 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
664 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
665 TRUE, mono, pieces);
\r
668 case OPT_ChooseDarkSquareColor:
\r
669 if (ChangeColor(hDlg, &dsc))
\r
670 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
671 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
672 FALSE, mono, pieces);
\r
675 case OPT_ChooseWhitePieceColor:
\r
676 if (ChangeColor(hDlg, &wpc))
\r
677 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
678 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
679 TRUE, mono, pieces);
\r
682 case OPT_ChooseBlackPieceColor:
\r
683 if (ChangeColor(hDlg, &bpc))
\r
684 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
685 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
686 FALSE, mono, pieces);
\r
689 case OPT_ChooseHighlightSquareColor:
\r
690 if (ChangeColor(hDlg, &hsc))
\r
691 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
692 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
693 TRUE, mono, pieces);
\r
696 case OPT_ChoosePremoveHighlightColor:
\r
697 if (ChangeColor(hDlg, &phc))
\r
698 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
699 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
700 FALSE, mono, pieces);
\r
703 case OPT_DefaultBoardColors:
\r
704 lsc = ParseColorName(LIGHT_SQUARE_COLOR);
\r
705 dsc = ParseColorName(DARK_SQUARE_COLOR);
\r
706 wpc = ParseColorName(WHITE_PIECE_COLOR);
\r
707 bpc = ParseColorName(BLACK_PIECE_COLOR);
\r
708 hsc = ParseColorName(HIGHLIGHT_SQUARE_COLOR);
\r
709 phc = ParseColorName(PREMOVE_HIGHLIGHT_COLOR);
\r
713 CheckDlgButton(hDlg, OPT_Monochrome, FALSE);
\r
714 CheckDlgButton(hDlg, OPT_AllWhite, FALSE);
\r
715 CheckDlgButton(hDlg, OPT_UpsideDown, FALSE);
\r
716 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
717 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
718 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
719 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
720 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
721 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
722 SetBoardOptionEnables(hDlg);
\r
723 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
724 TRUE, mono, pieces);
\r
725 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
726 FALSE, mono, pieces);
\r
729 case OPT_Monochrome:
\r
731 SetBoardOptionEnables(hDlg);
\r
736 SetBoardOptionEnables(hDlg);
\r
739 case OPT_UpsideDown:
\r
741 SetBoardOptionEnables(hDlg);
\r
751 BoardOptionsPopup(HWND hwnd)
\r
753 FARPROC lpProc = MakeProcInstance((FARPROC)BoardOptionsDialog, hInst);
\r
754 DialogBox(hInst, MAKEINTRESOURCE(DLG_BoardOptions), hwnd,
\r
756 FreeProcInstance(lpProc);
\r
760 VariantWhichRadio(HWND hDlg)
\r
762 return (IsDlgButtonChecked(hDlg, OPT_VariantFairy) ? VariantFairy :
\r
763 (IsDlgButtonChecked(hDlg, OPT_VariantGothic) ? VariantGothic :
\r
764 (IsDlgButtonChecked(hDlg, OPT_VariantCrazyhouse) ? VariantCrazyhouse :
\r
765 (IsDlgButtonChecked(hDlg, OPT_VariantBughouse) ? VariantBughouse :
\r
766 (IsDlgButtonChecked(hDlg, OPT_VariantCourier) ? VariantCourier :
\r
767 (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :
\r
768 (IsDlgButtonChecked(hDlg, OPT_VariantShogi) ? VariantShogi :
\r
769 (IsDlgButtonChecked(hDlg, OPT_VariantXiangqi) ? VariantXiangqi :
\r
770 (IsDlgButtonChecked(hDlg, OPT_VariantCapablanca) ? VariantCapablanca :
\r
771 (IsDlgButtonChecked(hDlg, OPT_VariantTwoKings) ? VariantTwoKings :
\r
772 (IsDlgButtonChecked(hDlg, OPT_VariantKnightmate) ? VariantKnightmate :
\r
773 (IsDlgButtonChecked(hDlg, OPT_VariantLosers) ? VariantLosers :
\r
774 (IsDlgButtonChecked(hDlg, OPT_VariantSuicide) ? VariantSuicide :
\r
775 (IsDlgButtonChecked(hDlg, OPT_VariantAtomic) ? VariantAtomic :
\r
776 (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :
\r
777 (IsDlgButtonChecked(hDlg, OPT_VariantFRC) ? VariantFischeRandom :
\r
778 (IsDlgButtonChecked(hDlg, OPT_VariantCylinder) ? VariantCylinder :
\r
779 (IsDlgButtonChecked(hDlg, OPT_VariantFalcon) ? VariantFalcon :
\r
780 VariantNormal ))))))))))))))))));
\r
784 NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
786 static Boolean mono;
\r
787 static VariantClass v;
\r
788 static COLORREF lsc, dsc, wpc, bpc, hsc, phc;
\r
789 static HBITMAP pieces[3];
\r
790 static int n1_ok, n2_ok, n3_ok;
\r
793 case WM_INITDIALOG: /* message: initialize dialog box */
\r
794 /* Center the dialog over the application window */
\r
795 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
796 /* Initialize the dialog items */
\r
797 switch (gameInfo.variant) {
\r
798 case VariantNormal:
\r
799 CheckDlgButton(hDlg, OPT_VariantNormal, TRUE);
\r
801 case VariantCrazyhouse:
\r
802 CheckDlgButton(hDlg, OPT_VariantCrazyhouse, TRUE);
\r
804 case VariantBughouse:
\r
805 CheckDlgButton(hDlg, OPT_VariantBughouse, TRUE);
\r
808 CheckDlgButton(hDlg, OPT_VariantShogi, TRUE);
\r
810 case VariantXiangqi:
\r
811 CheckDlgButton(hDlg, OPT_VariantXiangqi, TRUE);
\r
813 case VariantCapablanca:
\r
814 CheckDlgButton(hDlg, OPT_VariantCapablanca, TRUE);
\r
816 case VariantGothic:
\r
817 CheckDlgButton(hDlg, OPT_VariantGothic, TRUE);
\r
819 case VariantCourier:
\r
820 CheckDlgButton(hDlg, OPT_VariantCourier, TRUE);
\r
822 case VariantKnightmate:
\r
823 CheckDlgButton(hDlg, OPT_VariantKnightmate, TRUE);
\r
825 case VariantTwoKings:
\r
826 CheckDlgButton(hDlg, OPT_VariantTwoKings, TRUE);
\r
829 CheckDlgButton(hDlg, OPT_VariantFairy, TRUE);
\r
831 case VariantAtomic:
\r
832 CheckDlgButton(hDlg, OPT_VariantAtomic, TRUE);
\r
834 case VariantSuicide:
\r
835 CheckDlgButton(hDlg, OPT_VariantSuicide, TRUE);
\r
837 case VariantLosers:
\r
838 CheckDlgButton(hDlg, OPT_VariantLosers, TRUE);
\r
840 case VariantShatranj:
\r
841 CheckDlgButton(hDlg, OPT_VariantShatranj, TRUE);
\r
843 case VariantFischeRandom:
\r
844 CheckDlgButton(hDlg, OPT_VariantFRC, TRUE);
\r
848 SetDlgItemInt( hDlg, IDC_Files, -1, TRUE );
\r
849 SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 );
\r
851 SetDlgItemInt( hDlg, IDC_Ranks, -1, TRUE );
\r
852 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
854 SetDlgItemInt( hDlg, IDC_Holdings, -1, TRUE );
\r
855 SendDlgItemMessage( hDlg, IDC_Ranks, EM_SETSEL, 0, -1 );
\r
857 n1_ok = n2_ok = n3_ok = FALSE;
\r
861 case WM_COMMAND: /* message: received a command */
\r
862 switch (LOWORD(wParam)) {
\r
865 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
866 * then ChangeBoardSize() does not take effect, although the new
\r
867 * boardSize is saved. Go figure...
\r
869 EndDialog(hDlg, TRUE);
\r
871 v = VariantWhichRadio(hDlg);
\r
873 gameInfo.variant = v;
\r
874 appData.variant = VariantName(v);
\r
876 appData.NrFiles = (int) GetDlgItemInt(hDlg, IDC_Files, NULL, FALSE );
\r
877 appData.NrRanks = (int) GetDlgItemInt(hDlg, IDC_Ranks, NULL, FALSE );
\r
878 appData.holdingsSize = (int) GetDlgItemInt(hDlg, IDC_Holdings, NULL, FALSE );
\r
880 if(!n1_ok) appData.NrFiles = -1;
\r
881 if(!n2_ok) appData.NrRanks = -1;
\r
882 if(!n3_ok) appData.holdingsSize = -1;
\r
884 startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */
\r
885 appData.pieceToCharTable = NULL;
\r
891 EndDialog(hDlg, FALSE);
\r
897 if( HIWORD(wParam) == EN_CHANGE ) {
\r
899 GetDlgItemInt(hDlg, IDC_Files, &n1_ok, FALSE );
\r
900 GetDlgItemInt(hDlg, IDC_Ranks, &n2_ok, FALSE );
\r
901 GetDlgItemInt(hDlg, IDC_Holdings, &n3_ok, FALSE );
\r
903 /*EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok ? TRUE : FALSE );*/
\r
914 NewVariantPopup(HWND hwnd)
\r
916 FARPROC lpProc = MakeProcInstance((FARPROC)NewVariantDialog, hInst);
\r
917 DialogBox(hInst, MAKEINTRESOURCE(DLG_NewVariant), hwnd,
\r
919 FreeProcInstance(lpProc);
\r
922 /*---------------------------------------------------------------------------*\
\r
924 * ICS Options Dialog functions
\r
926 \*---------------------------------------------------------------------------*/
\r
929 MyCreateFont(HWND hwnd, MyFont *font)
\r
934 /* Initialize members of the CHOOSEFONT structure. */
\r
935 cf.lStructSize = sizeof(CHOOSEFONT);
\r
936 cf.hwndOwner = hwnd;
\r
937 cf.hDC = (HDC)NULL;
\r
938 cf.lpLogFont = &font->lf;
\r
940 cf.Flags = CF_SCREENFONTS|/*CF_ANSIONLY|*/CF_INITTOLOGFONTSTRUCT;
\r
941 cf.rgbColors = RGB(0,0,0);
\r
943 cf.lpfnHook = (LPCFHOOKPROC)NULL;
\r
944 cf.lpTemplateName = (LPSTR)NULL;
\r
945 cf.hInstance = (HINSTANCE) NULL;
\r
946 cf.lpszStyle = (LPSTR)NULL;
\r
947 cf.nFontType = SCREEN_FONTTYPE;
\r
951 /* Display the CHOOSEFONT common-dialog box. */
\r
952 if (!ChooseFont(&cf)) {
\r
956 /* Create a logical font based on the user's */
\r
957 /* selection and return a handle identifying */
\r
959 hf = CreateFontIndirect(cf.lpLogFont);
\r
965 font->mfp.pointSize = (float) (cf.iPointSize / 10.0);
\r
966 font->mfp.bold = (font->lf.lfWeight >= FW_BOLD);
\r
967 font->mfp.italic = font->lf.lfItalic;
\r
968 font->mfp.underline = font->lf.lfUnderline;
\r
969 font->mfp.strikeout = font->lf.lfStrikeOut;
\r
970 strcpy(font->mfp.faceName, font->lf.lfFaceName);
\r
976 UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
\r
979 cf.cbSize = sizeof(CHARFORMAT);
\r
981 CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;
\r
982 cf.crTextColor = mca->color;
\r
983 cf.dwEffects = mca->effects;
\r
984 strcpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName);
\r
986 * The 20.0 below is in fact documented. yHeight is expressed in twips.
\r
987 * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT.
\r
990 cf.yHeight = (int)(font[boardSize][CONSOLE_FONT]->mfp.pointSize * 20.0 + 0.5);
\r
991 cf.bCharSet = DEFAULT_CHARSET; /* should be ignored anyway */
\r
992 cf.bPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
\r
993 SendDlgItemMessage(hDlg, id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
997 ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
999 static MyColorizeAttribs mca;
\r
1000 static ColorClass cc;
\r
1001 COLORREF background = (COLORREF)0;
\r
1003 switch (message) {
\r
1004 case WM_INITDIALOG:
\r
1005 cc = (ColorClass)lParam;
\r
1006 mca = colorizeAttribs[cc];
\r
1007 /* Center the dialog over the application window */
\r
1008 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1009 /* Initialize the dialog items */
\r
1010 CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0);
\r
1011 CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0);
\r
1012 CheckDlgButton(hDlg, OPT_Underline, (mca.effects & CFE_UNDERLINE) != 0);
\r
1013 CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0);
\r
1015 /* get the current background color from the parent window */
\r
1016 SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND,
\r
1017 (WPARAM)WM_USER_GetConsoleBackground,
\r
1018 (LPARAM)&background);
\r
1020 /* set the background color */
\r
1021 SendDlgItemMessage(hDlg, OPT_Sample, EM_SETBKGNDCOLOR, FALSE, background);
\r
1023 SetDlgItemText(hDlg, OPT_Sample, mca.name);
\r
1024 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1027 case WM_COMMAND: /* message: received a command */
\r
1028 switch (LOWORD(wParam)) {
\r
1030 /* Read changed options from the dialog box */
\r
1031 colorizeAttribs[cc] = mca;
\r
1032 textAttribs[cc].color = mca.color;
\r
1033 textAttribs[cc].effects = mca.effects;
\r
1034 Colorize(currentColorClass, TRUE);
\r
1035 if (cc == ColorNormal) {
\r
1037 cf.cbSize = sizeof(CHARFORMAT);
\r
1038 cf.dwMask = CFM_COLOR;
\r
1039 cf.crTextColor = mca.color;
\r
1040 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1041 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1043 EndDialog(hDlg, TRUE);
\r
1047 EndDialog(hDlg, FALSE);
\r
1050 case OPT_ChooseColor:
\r
1051 ChangeColor(hDlg, &mca.color);
\r
1052 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1057 (IsDlgButtonChecked(hDlg, OPT_Bold) ? CFE_BOLD : 0) |
\r
1058 (IsDlgButtonChecked(hDlg, OPT_Italic) ? CFE_ITALIC : 0) |
\r
1059 (IsDlgButtonChecked(hDlg, OPT_Underline) ? CFE_UNDERLINE : 0) |
\r
1060 (IsDlgButtonChecked(hDlg, OPT_Strikeout) ? CFE_STRIKEOUT : 0);
\r
1061 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
1070 ColorizeTextPopup(HWND hwnd, ColorClass cc)
\r
1074 lpProc = MakeProcInstance((FARPROC)ColorizeTextDialog, hInst);
\r
1075 DialogBoxParam(hInst, MAKEINTRESOURCE(DLG_Colorize),
\r
1076 hwnd, (DLGPROC)lpProc, (LPARAM) cc);
\r
1077 FreeProcInstance(lpProc);
\r
1081 SetIcsOptionEnables(HWND hDlg)
\r
1083 #define ENABLE_DLG_ITEM(x,y) EnableWindow(GetDlgItem(hDlg,(x)), (y))
\r
1085 UINT state = IsDlgButtonChecked(hDlg, OPT_Premove);
\r
1086 ENABLE_DLG_ITEM(OPT_PremoveWhite, state);
\r
1087 ENABLE_DLG_ITEM(OPT_PremoveWhiteText, state);
\r
1088 ENABLE_DLG_ITEM(OPT_PremoveBlack, state);
\r
1089 ENABLE_DLG_ITEM(OPT_PremoveBlackText, state);
\r
1091 ENABLE_DLG_ITEM(OPT_IcsAlarmTime, IsDlgButtonChecked(hDlg, OPT_IcsAlarm));
\r
1093 #undef ENABLE_DLG_ITEM
\r
1098 IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1100 char buf[MSG_SIZ];
\r
1103 static COLORREF cbc;
\r
1104 static MyColorizeAttribs *mca;
\r
1105 COLORREF *colorref;
\r
1107 switch (message) {
\r
1108 case WM_INITDIALOG: /* message: initialize dialog box */
\r
1110 mca = colorizeAttribs;
\r
1112 for (i=0; i < NColorClasses - 1; i++) {
\r
1113 mca[i].color = textAttribs[i].color;
\r
1114 mca[i].effects = textAttribs[i].effects;
\r
1116 cbc = consoleBackgroundColor;
\r
1118 /* Center the dialog over the application window */
\r
1119 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1121 /* Initialize the dialog items */
\r
1122 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
1124 CHECK_BOX(OPT_AutoComment, appData.autoComment);
\r
1125 CHECK_BOX(OPT_AutoObserve, appData.autoObserve);
\r
1126 CHECK_BOX(OPT_GetMoveList, appData.getMoveList);
\r
1127 CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing);
\r
1128 CHECK_BOX(OPT_QuietPlay, appData.quietPlay);
\r
1129 CHECK_BOX(OPT_Premove, appData.premove);
\r
1130 CHECK_BOX(OPT_PremoveWhite, appData.premoveWhite);
\r
1131 CHECK_BOX(OPT_PremoveBlack, appData.premoveBlack);
\r
1132 CHECK_BOX(OPT_IcsAlarm, appData.icsAlarm);
\r
1133 CHECK_BOX(OPT_DontColorize, !appData.colorize);
\r
1137 sprintf(buf, "%d", appData.icsAlarmTime / 1000);
\r
1138 SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);
\r
1139 SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);
\r
1140 SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);
\r
1142 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1143 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1144 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1145 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1146 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1147 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1148 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1149 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1150 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1151 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1153 SetDlgItemText(hDlg, OPT_SampleShout, mca[ColorShout].name);
\r
1154 SetDlgItemText(hDlg, OPT_SampleSShout, mca[ColorSShout].name);
\r
1155 SetDlgItemText(hDlg, OPT_SampleChannel1, mca[ColorChannel1].name);
\r
1156 SetDlgItemText(hDlg, OPT_SampleChannel, mca[ColorChannel].name);
\r
1157 SetDlgItemText(hDlg, OPT_SampleKibitz, mca[ColorKibitz].name);
\r
1158 SetDlgItemText(hDlg, OPT_SampleTell, mca[ColorTell].name);
\r
1159 SetDlgItemText(hDlg, OPT_SampleChallenge, mca[ColorChallenge].name);
\r
1160 SetDlgItemText(hDlg, OPT_SampleRequest, mca[ColorRequest].name);
\r
1161 SetDlgItemText(hDlg, OPT_SampleSeek, mca[ColorSeek].name);
\r
1162 SetDlgItemText(hDlg, OPT_SampleNormal, mca[ColorNormal].name);
\r
1164 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1165 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1166 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1167 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1168 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1169 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1170 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1171 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1172 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1173 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1175 SetIcsOptionEnables(hDlg);
\r
1178 case WM_COMMAND: /* message: received a command */
\r
1179 switch (LOWORD(wParam)) {
\r
1181 case WM_USER_GetConsoleBackground:
\r
1182 /* the ColorizeTextDialog needs the current background color */
\r
1183 colorref = (COLORREF *)lParam;
\r
1188 /* Read changed options from the dialog box */
\r
1189 GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ);
\r
1190 if (sscanf(buf, "%d", &number) != 1 || (number < 0)){
\r
1191 MessageBox(hDlg, "Invalid ICS Alarm Time",
\r
1192 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
1196 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
1198 appData.icsAlarm = IS_CHECKED(OPT_IcsAlarm);
\r
1199 appData.premove = IS_CHECKED(OPT_Premove);
\r
1200 appData.premoveWhite = IS_CHECKED(OPT_PremoveWhite);
\r
1201 appData.premoveBlack = IS_CHECKED(OPT_PremoveBlack);
\r
1202 appData.autoComment = IS_CHECKED(OPT_AutoComment);
\r
1203 appData.autoObserve = IS_CHECKED(OPT_AutoObserve);
\r
1204 appData.getMoveList = IS_CHECKED(OPT_GetMoveList);
\r
1205 appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing);
\r
1206 appData.quietPlay = IS_CHECKED(OPT_QuietPlay);
\r
1210 appData.icsAlarmTime = number * 1000;
\r
1211 GetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText, 5);
\r
1212 GetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText, 5);
\r
1214 if (appData.localLineEditing) {
\r
1222 appData.colorize =
\r
1223 (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize);
\r
1225 if (!appData.colorize) {
\r
1227 COLORREF background = ParseColorName(COLOR_BKGD);
\r
1229 SetDefaultTextAttribs();
\r
1230 Colorize(currentColorClass);
\r
1232 cf.cbSize = sizeof(CHARFORMAT);
\r
1233 cf.dwMask = CFM_COLOR;
\r
1234 cf.crTextColor = ParseColorName(COLOR_NORMAL);
\r
1236 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1237 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1238 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1239 EM_SETBKGNDCOLOR, FALSE, background);
\r
1240 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1241 EM_SETBKGNDCOLOR, FALSE, background);
\r
1244 if (cbc != consoleBackgroundColor) {
\r
1245 consoleBackgroundColor = cbc;
\r
1246 if (appData.colorize) {
\r
1247 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1248 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1249 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1250 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1254 for (i=0; i < NColorClasses - 1; i++) {
\r
1255 textAttribs[i].color = mca[i].color;
\r
1256 textAttribs[i].effects = mca[i].effects;
\r
1259 EndDialog(hDlg, TRUE);
\r
1263 EndDialog(hDlg, FALSE);
\r
1266 case OPT_ChooseShoutColor:
\r
1267 ColorizeTextPopup(hDlg, ColorShout);
\r
1268 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1271 case OPT_ChooseSShoutColor:
\r
1272 ColorizeTextPopup(hDlg, ColorSShout);
\r
1273 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1276 case OPT_ChooseChannel1Color:
\r
1277 ColorizeTextPopup(hDlg, ColorChannel1);
\r
1278 UpdateSampleText(hDlg, OPT_SampleChannel1,
\r
1279 &colorizeAttribs[ColorChannel1]);
\r
1282 case OPT_ChooseChannelColor:
\r
1283 ColorizeTextPopup(hDlg, ColorChannel);
\r
1284 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1287 case OPT_ChooseKibitzColor:
\r
1288 ColorizeTextPopup(hDlg, ColorKibitz);
\r
1289 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1292 case OPT_ChooseTellColor:
\r
1293 ColorizeTextPopup(hDlg, ColorTell);
\r
1294 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1297 case OPT_ChooseChallengeColor:
\r
1298 ColorizeTextPopup(hDlg, ColorChallenge);
\r
1299 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1302 case OPT_ChooseRequestColor:
\r
1303 ColorizeTextPopup(hDlg, ColorRequest);
\r
1304 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1307 case OPT_ChooseSeekColor:
\r
1308 ColorizeTextPopup(hDlg, ColorSeek);
\r
1309 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1312 case OPT_ChooseNormalColor:
\r
1313 ColorizeTextPopup(hDlg, ColorNormal);
\r
1314 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1317 case OPT_ChooseBackgroundColor:
\r
1318 if (ChangeColor(hDlg, &cbc)) {
\r
1319 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1320 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1321 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1322 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1323 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1324 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1325 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1326 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1327 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1328 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1332 case OPT_DefaultColors:
\r
1333 for (i=0; i < NColorClasses - 1; i++)
\r
1334 ParseAttribs(&mca[i].color,
\r
1336 defaultTextAttribs[i]);
\r
1338 cbc = ParseColorName(COLOR_BKGD);
\r
1339 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1340 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1341 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1342 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1343 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1344 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1345 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1346 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1347 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1348 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1350 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1351 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1352 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1353 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1354 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1355 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1356 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1357 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1358 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1359 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1363 SetIcsOptionEnables(hDlg);
\r
1372 IcsOptionsPopup(HWND hwnd)
\r
1374 FARPROC lpProc = MakeProcInstance((FARPROC)IcsOptionsDialog, hInst);
\r
1375 DialogBox(hInst, MAKEINTRESOURCE(DLG_IcsOptions), hwnd,
\r
1376 (DLGPROC) lpProc);
\r
1377 FreeProcInstance(lpProc);
\r
1380 /*---------------------------------------------------------------------------*\
\r
1382 * Fonts Dialog functions
\r
1384 \*---------------------------------------------------------------------------*/
\r
1387 SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
\r
1389 char buf[MSG_SIZ];
\r
1394 RECT rectClient, rectFormat;
\r
1399 len = sprintf(buf, "%.0f pt. %s%s%s\n",
\r
1400 mf->mfp.pointSize, mf->mfp.faceName,
\r
1401 mf->mfp.bold ? " bold" : "",
\r
1402 mf->mfp.italic ? " italic" : "");
\r
1403 SetDlgItemText(hwnd, id, buf);
\r
1405 hControl = GetDlgItem(hwnd, id);
\r
1406 hdc = GetDC(hControl);
\r
1407 SetMapMode(hdc, MM_TEXT); /* 1 pixel == 1 logical unit */
\r
1408 oldFont = SelectObject(hdc, mf->hf);
\r
1410 /* get number of logical units necessary to display font name */
\r
1411 GetTextExtentPoint32(hdc, buf, len, &size);
\r
1413 /* calculate formatting rectangle in the rich edit control.
\r
1414 * May be larger or smaller than the actual control.
\r
1416 GetClientRect(hControl, &rectClient);
\r
1417 center.x = (rectClient.left + rectClient.right) / 2;
\r
1418 center.y = (rectClient.top + rectClient.bottom) / 2;
\r
1419 rectFormat.top = center.y - (size.cy / 2) - 1;
\r
1420 rectFormat.bottom = center.y + (size.cy / 2) + 1;
\r
1421 rectFormat.left = center.x - (size.cx / 2) - 1;
\r
1422 rectFormat.right = center.x + (size.cx / 2) + 1;
\r
1425 fprintf(debugFP, "\nfont: %s\n"
\r
1426 "center.x %d, centerY %d\n"
\r
1427 "size.cx %d, size.cy %d\n"
\r
1428 "client.top %d, bottom %d, left %d, right %d\n"
\r
1429 "format.top %d, bottom %d, left %d, right %d\n",
\r
1431 center.x, center.y,
\r
1433 rectClient.top, rectClient.bottom, rectClient.left,
\r
1435 rectFormat.top, rectFormat.bottom, rectFormat.left,
\r
1436 rectFormat.right);
\r
1439 cf.cbSize = sizeof(CHARFORMAT);
\r
1440 cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC;
\r
1442 if (mf->lf.lfWeight == FW_BOLD) cf.dwEffects |= CFE_BOLD;
\r
1443 if (mf->lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
\r
1444 strcpy(cf.szFaceName, mf->mfp.faceName);
\r
1446 * yHeight is expressed in twips. A twip is 1/20 of a font's point
\r
1447 * size. See documentation of CHARFORMAT. --msw
\r
1449 cf.yHeight = (int)(mf->mfp.pointSize * 20.0 + 0.5);
\r
1450 cf.bCharSet = mf->lf.lfCharSet;
\r
1451 cf.bPitchAndFamily = mf->lf.lfPitchAndFamily;
\r
1453 /* format the text in the rich edit control */
\r
1454 SendMessage(hControl, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf);
\r
1455 SendMessage(hControl, EM_SETRECT, (WPARAM)0, (LPARAM) &rectFormat);
\r
1458 SelectObject(hdc, oldFont);
\r
1459 ReleaseDC(hControl, hdc);
\r
1463 CopyFont(MyFont *dest, const MyFont *src)
\r
1465 dest->mfp.pointSize = src->mfp.pointSize;
\r
1466 dest->mfp.bold = src->mfp.bold;
\r
1467 dest->mfp.italic = src->mfp.italic;
\r
1468 dest->mfp.underline = src->mfp.underline;
\r
1469 dest->mfp.strikeout = src->mfp.strikeout;
\r
1470 lstrcpy(dest->mfp.faceName, src->mfp.faceName);
\r
1471 CreateFontInMF(dest);
\r
1476 FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1478 static MyFont workFont[NUM_FONTS];
\r
1479 static BOOL firstPaint;
\r
1483 switch (message) {
\r
1484 case WM_INITDIALOG:
\r
1486 /* copy the current font settings into a working copy */
\r
1487 for (i=0; i < NUM_FONTS; i++)
\r
1488 CopyFont(&workFont[i], font[boardSize][i]);
\r
1490 if (!appData.icsActive)
\r
1491 EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE);
\r
1493 firstPaint = TRUE; /* see rant below */
\r
1495 /* If I don't call SetFocus(), the dialog won't respond to the keyboard
\r
1496 * when first drawn. Why is this the only dialog that behaves this way? Is
\r
1497 * is the WM_PAINT stuff below?? Sigh...
\r
1499 SetFocus(GetDlgItem(hDlg, IDOK));
\r
1503 /* This should not be necessary. However, if SetSampleFontText() is called
\r
1504 * in response to WM_INITDIALOG, the strings are not properly centered in
\r
1505 * the controls when the dialog first appears. I can't figure out why, so
\r
1506 * this is the workaround. --msw
\r
1509 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1510 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1511 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1512 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1513 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1514 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1515 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1516 firstPaint = FALSE;
\r
1520 case WM_COMMAND: /* message: received a command */
\r
1521 switch (LOWORD(wParam)) {
\r
1524 /* again, it seems to avoid redraw problems if we call EndDialog first */
\r
1525 EndDialog(hDlg, FALSE);
\r
1527 /* copy modified settings back to the fonts array */
\r
1528 for (i=0; i < NUM_FONTS; i++)
\r
1529 CopyFont(font[boardSize][i], &workFont[i]);
\r
1531 /* a sad necessity due to the original design of having a separate
\r
1532 * console font, tags font, and comment font for each board size. IMHO
\r
1533 * these fonts should not be dependent on the current board size. I'm
\r
1534 * running out of time, so I am doing this hack rather than redesign the
\r
1535 * data structure. Besides, I think if I redesigned the data structure, I
\r
1536 * might break backwards compatibility with old winboard.ini files.
\r
1539 for (i=0; i < NUM_SIZES; i++) {
\r
1540 CopyFont(font[i][EDITTAGS_FONT], &workFont[EDITTAGS_FONT]);
\r
1541 CopyFont(font[i][CONSOLE_FONT], &workFont[CONSOLE_FONT]);
\r
1542 CopyFont(font[i][COMMENT_FONT], &workFont[COMMENT_FONT]);
\r
1543 CopyFont(font[i][MOVEHISTORY_FONT], &workFont[MOVEHISTORY_FONT]);
\r
1545 /* end sad necessity */
\r
1547 InitDrawingSizes(boardSize, 0);
\r
1548 InvalidateRect(hwndMain, NULL, TRUE);
\r
1550 if (commentDialog) {
\r
1551 SendDlgItemMessage(commentDialog, OPT_CommentText,
\r
1552 WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf,
\r
1553 MAKELPARAM(TRUE, 0));
\r
1554 GetClientRect(GetDlgItem(commentDialog, OPT_CommentText), &rect);
\r
1555 InvalidateRect(commentDialog, &rect, TRUE);
\r
1558 if (editTagsDialog) {
\r
1559 SendDlgItemMessage(editTagsDialog, OPT_TagsText,
\r
1560 WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf,
\r
1561 MAKELPARAM(TRUE, 0));
\r
1562 GetClientRect(GetDlgItem(editTagsDialog, OPT_TagsText), &rect);
\r
1563 InvalidateRect(editTagsDialog, &rect, TRUE);
\r
1566 if( moveHistoryDialog != NULL ) {
\r
1567 SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory,
\r
1568 WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,
\r
1569 MAKELPARAM(TRUE, 0));
\r
1570 InvalidateRect(editTagsDialog, NULL, TRUE);
\r
1573 if (hwndConsole) {
\r
1574 ChangedConsoleFont();
\r
1577 for (i=0; i<NUM_FONTS; i++)
\r
1578 DeleteObject(&workFont[i].hf);
\r
1583 for (i=0; i<NUM_FONTS; i++)
\r
1584 DeleteObject(&workFont[i].hf);
\r
1585 EndDialog(hDlg, FALSE);
\r
1588 case OPT_ChooseClockFont:
\r
1589 MyCreateFont(hDlg, &workFont[CLOCK_FONT]);
\r
1590 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1593 case OPT_ChooseMessageFont:
\r
1594 MyCreateFont(hDlg, &workFont[MESSAGE_FONT]);
\r
1595 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1598 case OPT_ChooseCoordFont:
\r
1599 MyCreateFont(hDlg, &workFont[COORD_FONT]);
\r
1600 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1603 case OPT_ChooseTagFont:
\r
1604 MyCreateFont(hDlg, &workFont[EDITTAGS_FONT]);
\r
1605 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1608 case OPT_ChooseCommentsFont:
\r
1609 MyCreateFont(hDlg, &workFont[COMMENT_FONT]);
\r
1610 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1613 case OPT_ChooseConsoleFont:
\r
1614 MyCreateFont(hDlg, &workFont[CONSOLE_FONT]);
\r
1615 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1618 case OPT_ChooseMoveHistoryFont:
\r
1619 MyCreateFont(hDlg, &workFont[MOVEHISTORY_FONT]);
\r
1620 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1623 case OPT_DefaultFonts:
\r
1624 for (i=0; i<NUM_FONTS; i++) {
\r
1625 DeleteObject(&workFont[i].hf);
\r
1626 ParseFontName(font[boardSize][i]->def, &workFont[i].mfp);
\r
1627 CreateFontInMF(&workFont[i]);
\r
1629 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1630 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1631 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1632 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1633 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1634 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1635 SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);
\r
1643 FontsOptionsPopup(HWND hwnd)
\r
1645 FARPROC lpProc = MakeProcInstance((FARPROC)FontOptionsDialog, hInst);
\r
1646 DialogBox(hInst, MAKEINTRESOURCE(DLG_Fonts), hwnd,
\r
1647 (DLGPROC) lpProc);
\r
1648 FreeProcInstance(lpProc);
\r
1651 /*---------------------------------------------------------------------------*\
\r
1653 * Sounds Dialog functions
\r
1655 \*---------------------------------------------------------------------------*/
\r
1658 SoundComboData soundComboData[] = {
\r
1661 {"ICS Alarm", NULL},
\r
1662 {"ICS Win", NULL},
\r
1663 {"ICS Loss", NULL},
\r
1664 {"ICS Draw", NULL},
\r
1665 {"ICS Unfinished", NULL},
\r
1667 {"SShout/CShout", NULL},
\r
1668 {"Channel 1", NULL},
\r
1669 {"Channel", NULL},
\r
1672 {"Challenge", NULL},
\r
1673 {"Request", NULL},
\r
1680 InitSoundComboData(SoundComboData *scd)
\r
1686 /* copy current sound settings to combo array */
\r
1688 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1689 scd[sc].name = strdup(sounds[sc].name);
\r
1691 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1692 index = (int)cc + (int)NSoundClasses;
\r
1693 scd[index].name = strdup(textAttribs[cc].sound.name);
\r
1699 ResetSoundComboData(SoundComboData *scd)
\r
1701 while (scd->label) {
\r
1702 if (scd->name != NULL) {
\r
1711 InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
\r
1716 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
1718 /* send the labels to the combo box */
\r
1719 while (scd->label) {
\r
1720 err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label);
\r
1721 if (err != cnt++) {
\r
1722 sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n",
\r
1724 MessageBox(NULL, buf, NULL, MB_OK);
\r
1728 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
1732 SoundDialogWhichRadio(HWND hDlg)
\r
1734 if (IsDlgButtonChecked(hDlg, OPT_NoSound)) return OPT_NoSound;
\r
1735 if (IsDlgButtonChecked(hDlg, OPT_DefaultBeep)) return OPT_DefaultBeep;
\r
1736 if (IsDlgButtonChecked(hDlg, OPT_BuiltInSound)) return OPT_BuiltInSound;
\r
1737 if (IsDlgButtonChecked(hDlg, OPT_WavFile)) return OPT_WavFile;
\r
1742 SoundDialogSetEnables(HWND hDlg, int radio)
\r
1744 EnableWindow(GetDlgItem(hDlg, OPT_BuiltInSoundName),
\r
1745 radio == OPT_BuiltInSound);
\r
1746 EnableWindow(GetDlgItem(hDlg, OPT_WavFileName), radio == OPT_WavFile);
\r
1747 EnableWindow(GetDlgItem(hDlg, OPT_BrowseSound), radio == OPT_WavFile);
\r
1751 SoundDialogGetName(HWND hDlg, int radio)
\r
1753 static char buf[MSG_SIZ], buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
1754 char *dummy, *ret;
\r
1759 case OPT_DefaultBeep:
\r
1761 case OPT_BuiltInSound:
\r
1763 GetDlgItemText(hDlg, OPT_BuiltInSoundName, buf + 1, sizeof(buf) - 1);
\r
1766 GetDlgItemText(hDlg, OPT_WavFileName, buf, sizeof(buf));
\r
1767 GetCurrentDirectory(MSG_SIZ, buf3);
\r
1768 SetCurrentDirectory(installDir);
\r
1769 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
1774 SetCurrentDirectory(buf3);
\r
1780 DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
\r
1784 * I think it's best to clear the combo and edit boxes. It looks stupid
\r
1785 * to have a value from another sound event sitting there grayed out.
\r
1787 SetDlgItemText(hDlg, OPT_WavFileName, "");
\r
1788 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1790 if (appData.debugMode)
\r
1791 fprintf(debugFP, "DisplaySelectedSound(,,'%s'):\n", name);
\r
1792 switch (name[0]) {
\r
1794 radio = OPT_NoSound;
\r
1797 if (name[1] == NULLCHAR) {
\r
1798 radio = OPT_DefaultBeep;
\r
1800 radio = OPT_WavFile;
\r
1801 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1805 if (name[1] == NULLCHAR) {
\r
1806 radio = OPT_NoSound;
\r
1808 radio = OPT_BuiltInSound;
\r
1809 if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1,
\r
1810 (LPARAM) (name + 1)) == CB_ERR) {
\r
1811 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1812 SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1));
\r
1817 radio = OPT_WavFile;
\r
1818 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1821 SoundDialogSetEnables(hDlg, radio);
\r
1822 CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio);
\r
1826 char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES;
\r
1829 SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1831 static HWND hSoundCombo;
\r
1832 static DWORD index;
\r
1833 static HWND hBISN;
\r
1837 char buf[MSG_SIZ];
\r
1841 SoundComboData *scd;
\r
1843 switch (message) {
\r
1844 case WM_INITDIALOG:
\r
1845 /* Center the dialog over the application window */
\r
1846 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1848 /* Initialize the built-in sounds combo */
\r
1849 hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName);
\r
1850 InitComboStrings(hBISN, builtInSoundNames);
\r
1852 /* Initialize the sound events combo */
\r
1854 InitSoundComboData(soundComboData);
\r
1855 hSoundCombo = GetDlgItem(hDlg, CBO_Sounds);
\r
1856 InitSoundCombo(hSoundCombo, soundComboData);
\r
1858 /* update the dialog */
\r
1859 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1862 case WM_COMMAND: /* message: received a command */
\r
1864 if (((HWND)lParam == hSoundCombo) &&
\r
1865 (HIWORD(wParam) == CBN_SELCHANGE)) {
\r
1867 * the user has selected a new sound event. We must store the name for
\r
1868 * the previously selected event, then retrieve the name for the
\r
1869 * newly selected event and update the dialog.
\r
1871 radio = SoundDialogWhichRadio(hDlg);
\r
1872 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1874 if (strcmp(newName, soundComboData[index].name) != 0) {
\r
1875 free(soundComboData[index].name);
\r
1876 soundComboData[index].name = newName;
\r
1881 /* now get the settings for the newly selected event */
\r
1882 index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
\r
1883 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1887 switch (LOWORD(wParam)) {
\r
1890 * save the name for the currently selected sound event
\r
1892 radio = SoundDialogWhichRadio(hDlg);
\r
1893 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1895 if (strcmp(soundComboData[index].name, newName) != 0) {
\r
1896 free(soundComboData[index].name);
\r
1897 soundComboData[index].name = newName;
\r
1903 /* save all the sound names that changed and load the sounds */
\r
1905 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1906 if (strcmp(soundComboData[sc].name, sounds[sc].name) != 0) {
\r
1907 free(sounds[sc].name);
\r
1908 sounds[sc].name = strdup(soundComboData[sc].name);
\r
1909 MyLoadSound(&sounds[sc]);
\r
1912 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1913 index = (int)cc + (int)NSoundClasses;
\r
1914 if (strcmp(soundComboData[index].name,
\r
1915 textAttribs[cc].sound.name) != 0) {
\r
1916 free(textAttribs[cc].sound.name);
\r
1917 textAttribs[cc].sound.name = strdup(soundComboData[index].name);
\r
1918 MyLoadSound(&textAttribs[cc].sound);
\r
1922 ResetSoundComboData(soundComboData);
\r
1923 EndDialog(hDlg, TRUE);
\r
1927 ResetSoundComboData(soundComboData);
\r
1928 EndDialog(hDlg, FALSE);
\r
1931 case OPT_DefaultSounds:
\r
1932 /* can't use SetDefaultSounds() because we need to be able to "undo" if
\r
1933 * user selects "Cancel" later on. So we do it the hard way here.
\r
1935 scd = &soundComboData[0];
\r
1936 while (scd->label != NULL) {
\r
1937 if (scd->name != NULL) free(scd->name);
\r
1938 scd->name = strdup("");
\r
1941 free(soundComboData[(int)SoundBell].name);
\r
1942 soundComboData[(int)SoundBell].name = strdup(SOUND_BELL);
\r
1943 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1946 case OPT_PlaySound:
\r
1947 radio = SoundDialogWhichRadio(hDlg);
\r
1948 tmp.name = strdup(SoundDialogGetName(hDlg, radio));
\r
1950 MyLoadSound(&tmp);
\r
1951 MyPlaySound(&tmp);
\r
1952 if (tmp.data != NULL) free(tmp.data);
\r
1953 if (tmp.name != NULL) free(tmp.name);
\r
1956 case OPT_BrowseSound:
\r
1957 f = OpenFileDialog(hDlg, FALSE, NULL, "wav", SOUND_FILT,
\r
1958 "Browse for Sound File", NULL, NULL, buf);
\r
1961 SetDlgItemText(hDlg, OPT_WavFileName, buf);
\r
1966 radio = SoundDialogWhichRadio(hDlg);
\r
1967 SoundDialogSetEnables(hDlg, radio);
\r
1976 VOID SoundOptionsPopup(HWND hwnd)
\r
1980 lpProc = MakeProcInstance((FARPROC)SoundOptionsDialog, hInst);
\r
1981 DialogBox(hInst, MAKEINTRESOURCE(DLG_Sound), hwnd, (DLGPROC)lpProc);
\r
1982 FreeProcInstance(lpProc);
\r
1986 /*---------------------------------------------------------------------------*\
\r
1988 * Comm Port dialog functions
\r
1990 \*---------------------------------------------------------------------------*/
\r
1993 #define FLOW_NONE 0
\r
1994 #define FLOW_XOFF 1
\r
1995 #define FLOW_CTS 2
\r
1996 #define FLOW_DSR 3
\r
2000 ComboData cdPort[] = { {"None", PORT_NONE}, {"COM1", 1}, {"COM2", 2},
\r
2001 {"COM3", 3}, {"COM4", 4}, {NULL, 0} };
\r
2002 ComboData cdDataRate[] = { {"110", 110}, {"300", 300}, {"600", 600}, {"1200", 1200},
\r
2003 {"2400", 2400}, {"4800", 4800}, {"9600", 9600}, {"19200", 19200},
\r
2004 {"38400", 38400}, {NULL, 0} };
\r
2005 ComboData cdDataBits[] = { {"5", 5}, {"6", 6}, {"7", 7}, {"8", 8}, {NULL, 0} };
\r
2006 ComboData cdParity[] = { {"None", NOPARITY}, {"Odd", ODDPARITY}, {"Even", EVENPARITY},
\r
2007 {"Mark", MARKPARITY}, {"Space", SPACEPARITY}, {NULL, 0} };
\r
2008 ComboData cdStopBits[] = { {"1", ONESTOPBIT}, {"1.5", ONE5STOPBITS},
\r
2009 {"2", TWOSTOPBITS}, {NULL, 0} };
\r
2010 ComboData cdFlow[] = { {"None", FLOW_NONE}, {"Xoff/Xon", FLOW_XOFF}, {"CTS", FLOW_CTS},
\r
2011 {"DSR", FLOW_DSR}, {NULL, 0} };
\r
2015 ParseCommSettings(char *arg, DCB *dcb)
\r
2017 int dataRate, count;
\r
2018 char bits[MSG_SIZ], parity[MSG_SIZ], stopBits[MSG_SIZ], flow[MSG_SIZ];
\r
2020 count = sscanf(arg, "%d%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]",
\r
2021 &dataRate, bits, parity, stopBits, flow);
\r
2022 if (count != 5) goto cant_parse;
\r
2023 dcb->BaudRate = dataRate;
\r
2025 while (cd->label != NULL) {
\r
2026 if (StrCaseCmp(cd->label, bits) == 0) {
\r
2027 dcb->ByteSize = cd->value;
\r
2032 if (cd->label == NULL) goto cant_parse;
\r
2034 while (cd->label != NULL) {
\r
2035 if (StrCaseCmp(cd->label, parity) == 0) {
\r
2036 dcb->Parity = cd->value;
\r
2041 if (cd->label == NULL) goto cant_parse;
\r
2043 while (cd->label != NULL) {
\r
2044 if (StrCaseCmp(cd->label, stopBits) == 0) {
\r
2045 dcb->StopBits = cd->value;
\r
2051 if (cd->label == NULL) goto cant_parse;
\r
2052 while (cd->label != NULL) {
\r
2053 if (StrCaseCmp(cd->label, flow) == 0) {
\r
2054 switch (cd->value) {
\r
2056 dcb->fOutX = FALSE;
\r
2057 dcb->fOutxCtsFlow = FALSE;
\r
2058 dcb->fOutxDsrFlow = FALSE;
\r
2061 dcb->fOutX = FALSE;
\r
2062 dcb->fOutxCtsFlow = TRUE;
\r
2063 dcb->fOutxDsrFlow = FALSE;
\r
2066 dcb->fOutX = FALSE;
\r
2067 dcb->fOutxCtsFlow = FALSE;
\r
2068 dcb->fOutxDsrFlow = TRUE;
\r
2071 dcb->fOutX = TRUE;
\r
2072 dcb->fOutxCtsFlow = FALSE;
\r
2073 dcb->fOutxDsrFlow = FALSE;
\r
2080 if (cd->label == NULL) goto cant_parse;
\r
2083 ExitArgError("Can't parse com port settings", arg);
\r
2087 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
\r
2089 char *flow = "??", *parity = "??", *stopBits = "??";
\r
2093 while (cd->label != NULL) {
\r
2094 if (dcb->Parity == cd->value) {
\r
2095 parity = cd->label;
\r
2101 while (cd->label != NULL) {
\r
2102 if (dcb->StopBits == cd->value) {
\r
2103 stopBits = cd->label;
\r
2109 flow = cdFlow[FLOW_XOFF].label;
\r
2110 } else if (dcb->fOutxCtsFlow) {
\r
2111 flow = cdFlow[FLOW_CTS].label;
\r
2112 } else if (dcb->fOutxDsrFlow) {
\r
2113 flow = cdFlow[FLOW_DSR].label;
\r
2115 flow = cdFlow[FLOW_NONE].label;
\r
2117 fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name,
\r
2118 dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow);
\r
2123 InitCombo(HANDLE hwndCombo, ComboData *cd)
\r
2125 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
2127 while (cd->label != NULL) {
\r
2128 SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) cd->label);
\r
2134 SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value)
\r
2139 while (cd->label != NULL) {
\r
2140 if (cd->value == value) {
\r
2141 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) i, (LPARAM) 0);
\r
2150 CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2152 char buf[MSG_SIZ];
\r
2159 switch (message) {
\r
2160 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2161 /* Center the dialog over the application window */
\r
2162 CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER));
\r
2163 /* Initialize the dialog items */
\r
2164 /* !! There should probably be some synchronization
\r
2165 in accessing hCommPort and dcb. Or does modal nature
\r
2166 of this dialog box do it for us?
\r
2168 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2169 InitCombo(hwndCombo, cdPort);
\r
2170 p = strrchr(appData.icsCommPort, '\\');
\r
2171 if (p++ == NULL) p = appData.icsCommPort;
\r
2172 if ((*p == '\0') ||
\r
2173 (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) p) == CB_ERR)) {
\r
2174 SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) "None");
\r
2176 EnableWindow(hwndCombo, hCommPort == NULL); /*!! don't allow change for now*/
\r
2178 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2179 InitCombo(hwndCombo, cdDataRate);
\r
2180 sprintf(buf, "%u", dcb.BaudRate);
\r
2181 if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) {
\r
2182 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
2183 SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf);
\r
2186 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2187 InitCombo(hwndCombo, cdDataBits);
\r
2188 SelectComboValue(hwndCombo, cdDataBits, dcb.ByteSize);
\r
2190 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2191 InitCombo(hwndCombo, cdParity);
\r
2192 SelectComboValue(hwndCombo, cdParity, dcb.Parity);
\r
2194 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2195 InitCombo(hwndCombo, cdStopBits);
\r
2196 SelectComboValue(hwndCombo, cdStopBits, dcb.StopBits);
\r
2198 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2199 InitCombo(hwndCombo, cdFlow);
\r
2201 SelectComboValue(hwndCombo, cdFlow, FLOW_XOFF);
\r
2202 } else if (dcb.fOutxCtsFlow) {
\r
2203 SelectComboValue(hwndCombo, cdFlow, FLOW_CTS);
\r
2204 } else if (dcb.fOutxDsrFlow) {
\r
2205 SelectComboValue(hwndCombo, cdFlow, FLOW_DSR);
\r
2207 SelectComboValue(hwndCombo, cdFlow, FLOW_NONE);
\r
2211 case WM_COMMAND: /* message: received a command */
\r
2212 switch (LOWORD(wParam)) {
\r
2214 /* Read changed options from the dialog box */
\r
2216 /* !! Currently we can't change comm ports in midstream */
\r
2217 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2218 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2219 if (index == PORT_NONE) {
\r
2220 appData.icsCommPort = "";
\r
2221 if (hCommPort != NULL) {
\r
2222 CloseHandle(hCommPort);
\r
2225 EndDialog(hDlg, TRUE);
\r
2228 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2229 appData.icsCommPort = strdup(buf);
\r
2230 if (hCommPort != NULL) {
\r
2231 CloseHandle(hCommPort);
\r
2234 /* now what?? can't really do this; have to fix up the ChildProc
\r
2235 and InputSource records for the comm port that we gave to the
\r
2239 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2240 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2241 if (sscanf(buf, "%u", &value) != 1) {
\r
2242 MessageBox(hDlg, "Invalid data rate",
\r
2243 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2246 dcb.BaudRate = value;
\r
2248 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2249 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2250 dcb.ByteSize = cdDataBits[index].value;
\r
2252 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2253 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2254 dcb.Parity = cdParity[index].value;
\r
2256 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2257 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2258 dcb.StopBits = cdStopBits[index].value;
\r
2260 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2261 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2262 switch (cdFlow[index].value) {
\r
2264 dcb.fOutX = FALSE;
\r
2265 dcb.fOutxCtsFlow = FALSE;
\r
2266 dcb.fOutxDsrFlow = FALSE;
\r
2269 dcb.fOutX = FALSE;
\r
2270 dcb.fOutxCtsFlow = TRUE;
\r
2271 dcb.fOutxDsrFlow = FALSE;
\r
2274 dcb.fOutX = FALSE;
\r
2275 dcb.fOutxCtsFlow = FALSE;
\r
2276 dcb.fOutxDsrFlow = TRUE;
\r
2280 dcb.fOutxCtsFlow = FALSE;
\r
2281 dcb.fOutxDsrFlow = FALSE;
\r
2284 if (!SetCommState(hCommPort, (LPDCB) &dcb)) {
\r
2285 err = GetLastError();
\r
2286 switch(MessageBox(hDlg,
\r
2287 "Failed to set comm port state;\r\ninvalid options?",
\r
2288 "Option Error", MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {
\r
2290 DisplayFatalError("Failed to set comm port state", err, 1);
\r
2291 exit(1); /*is it ok to do this from here?*/
\r
2297 EndDialog(hDlg, TRUE);
\r
2302 EndDialog(hDlg, TRUE);
\r
2306 EndDialog(hDlg, FALSE);
\r
2318 CommPortOptionsPopup(HWND hwnd)
\r
2320 FARPROC lpProc = MakeProcInstance((FARPROC)CommPortOptionsDialog, hInst);
\r
2321 DialogBox(hInst, MAKEINTRESOURCE(DLG_CommPort), hwnd, (DLGPROC) lpProc);
\r
2322 FreeProcInstance(lpProc);
\r
2325 /*---------------------------------------------------------------------------*\
\r
2327 * Load Options dialog functions
\r
2329 \*---------------------------------------------------------------------------*/
\r
2332 SetLoadOptionEnables(HWND hDlg)
\r
2336 state = IsDlgButtonChecked(hDlg, OPT_Autostep);
\r
2337 EnableWindow(GetDlgItem(hDlg, OPT_ASTimeDelay), state);
\r
2338 EnableWindow(GetDlgItem(hDlg, OPT_AStext1), state);
\r
2342 LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2344 char buf[MSG_SIZ];
\r
2347 switch (message) {
\r
2348 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2349 /* Center the dialog over the application window */
\r
2350 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2351 /* Initialize the dialog items */
\r
2352 if (appData.timeDelay >= 0.0) {
\r
2353 CheckDlgButton(hDlg, OPT_Autostep, TRUE);
\r
2354 sprintf(buf, "%.2g", appData.timeDelay);
\r
2355 SetDlgItemText(hDlg, OPT_ASTimeDelay, buf);
\r
2357 CheckDlgButton(hDlg, OPT_Autostep, FALSE);
\r
2359 SetLoadOptionEnables(hDlg);
\r
2362 case WM_COMMAND: /* message: received a command */
\r
2363 switch (LOWORD(wParam)) {
\r
2365 /* Read changed options from the dialog box */
\r
2366 if (IsDlgButtonChecked(hDlg, OPT_Autostep)) {
\r
2367 GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ);
\r
2368 if (sscanf(buf, "%f", &fnumber) != 1) {
\r
2369 MessageBox(hDlg, "Invalid load game step rate",
\r
2370 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2373 appData.timeDelay = fnumber;
\r
2375 appData.timeDelay = (float) -1.0;
\r
2377 EndDialog(hDlg, TRUE);
\r
2381 EndDialog(hDlg, FALSE);
\r
2385 SetLoadOptionEnables(hDlg);
\r
2395 LoadOptionsPopup(HWND hwnd)
\r
2397 FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst);
\r
2398 DialogBox(hInst, MAKEINTRESOURCE(DLG_LoadOptions), hwnd, (DLGPROC) lpProc);
\r
2399 FreeProcInstance(lpProc);
\r
2402 /*---------------------------------------------------------------------------*\
\r
2404 * Save Options dialog functions
\r
2406 \*---------------------------------------------------------------------------*/
\r
2409 SetSaveOptionEnables(HWND hDlg)
\r
2413 state = IsDlgButtonChecked(hDlg, OPT_Autosave);
\r
2414 EnableWindow(GetDlgItem(hDlg, OPT_AVPrompt), state);
\r
2415 EnableWindow(GetDlgItem(hDlg, OPT_AVToFile), state);
\r
2416 if (state && !IsDlgButtonChecked(hDlg, OPT_AVPrompt) &&
\r
2417 !IsDlgButtonChecked(hDlg, OPT_AVToFile)) {
\r
2418 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2421 state = state && IsDlgButtonChecked(hDlg, OPT_AVToFile);
\r
2422 EnableWindow(GetDlgItem(hDlg, OPT_AVFilename), state);
\r
2423 EnableWindow(GetDlgItem(hDlg, OPT_AVBrowse), state);
\r
2427 SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2429 char buf[MSG_SIZ];
\r
2432 switch (message) {
\r
2433 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2434 /* Center the dialog over the application window */
\r
2435 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2436 /* Initialize the dialog items */
\r
2437 if (*appData.saveGameFile != NULLCHAR) {
\r
2438 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2439 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVToFile);
\r
2440 SetDlgItemText(hDlg, OPT_AVFilename, appData.saveGameFile);
\r
2441 } else if (appData.autoSaveGames) {
\r
2442 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2443 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2445 CheckDlgButton(hDlg, OPT_Autosave, (UINT) FALSE);
\r
2447 if (appData.oldSaveStyle) {
\r
2448 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_Old);
\r
2450 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_PGN);
\r
2452 CheckDlgButton( hDlg, OPT_OutOfBookInfo, appData.saveOutOfBookInfo );
\r
2453 SetSaveOptionEnables(hDlg);
\r
2456 case WM_COMMAND: /* message: received a command */
\r
2457 switch (LOWORD(wParam)) {
\r
2459 /* Read changed options from the dialog box */
\r
2460 if (IsDlgButtonChecked(hDlg, OPT_Autosave)) {
\r
2461 appData.autoSaveGames = TRUE;
\r
2462 if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) {
\r
2463 appData.saveGameFile = "";
\r
2464 } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ {
\r
2465 GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ);
\r
2466 if (*buf == NULLCHAR) {
\r
2467 MessageBox(hDlg, "Invalid save game file name",
\r
2468 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2471 if ((isalpha(buf[0]) && buf[1] == ':') ||
\r
2472 (buf[0] == '\\' && buf[1] == '\\')) {
\r
2473 appData.saveGameFile = strdup(buf);
\r
2475 char buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
2477 GetCurrentDirectory(MSG_SIZ, buf3);
\r
2478 SetCurrentDirectory(installDir);
\r
2479 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
2480 appData.saveGameFile = strdup(buf2);
\r
2482 appData.saveGameFile = strdup(buf);
\r
2484 SetCurrentDirectory(buf3);
\r
2488 appData.autoSaveGames = FALSE;
\r
2489 appData.saveGameFile = "";
\r
2491 appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old);
\r
2492 appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo );
\r
2493 EndDialog(hDlg, TRUE);
\r
2497 EndDialog(hDlg, FALSE);
\r
2500 case OPT_AVBrowse:
\r
2501 f = OpenFileDialog(hDlg, TRUE, NULL,
\r
2502 appData.oldSaveStyle ? "gam" : "pgn",
\r
2503 GAME_FILT, "Browse for Auto Save File",
\r
2507 SetDlgItemText(hDlg, OPT_AVFilename, buf);
\r
2512 SetSaveOptionEnables(hDlg);
\r
2521 SaveOptionsPopup(HWND hwnd)
\r
2523 FARPROC lpProc = MakeProcInstance((FARPROC)SaveOptionsDialog, hInst);
\r
2524 DialogBox(hInst, MAKEINTRESOURCE(DLG_SaveOptions), hwnd, (DLGPROC) lpProc);
\r
2525 FreeProcInstance(lpProc);
\r
2528 /*---------------------------------------------------------------------------*\
\r
2530 * Time Control Options dialog functions
\r
2532 \*---------------------------------------------------------------------------*/
\r
2535 SetTimeControlEnables(HWND hDlg)
\r
2539 state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves);
\r
2540 EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state);
\r
2541 EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state);
\r
2542 EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state);
\r
2543 EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state);
\r
2544 EnableWindow(GetDlgItem(hDlg, OPT_TCTime2), !state);
\r
2545 EnableWindow(GetDlgItem(hDlg, OPT_TCInc), !state);
\r
2546 EnableWindow(GetDlgItem(hDlg, OPT_TCitext1), !state);
\r
2547 EnableWindow(GetDlgItem(hDlg, OPT_TCitext2), !state);
\r
2548 EnableWindow(GetDlgItem(hDlg, OPT_TCitext3), !state);
\r
2553 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2555 char buf[MSG_SIZ];
\r
2556 int mps, increment;
\r
2559 switch (message) {
\r
2560 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2561 /* Center the dialog over the application window */
\r
2562 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2563 /* Initialize the dialog items */
\r
2564 if (appData.clockMode && !appData.icsActive) {
\r
2565 if (appData.timeIncrement == -1) {
\r
2566 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,
\r
2568 SetDlgItemText(hDlg, OPT_TCTime, appData.timeControl);
\r
2569 SetDlgItemInt(hDlg, OPT_TCMoves, appData.movesPerSession,
\r
2571 SetDlgItemText(hDlg, OPT_TCTime2, "");
\r
2572 SetDlgItemText(hDlg, OPT_TCInc, "");
\r
2574 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,
\r
2576 SetDlgItemText(hDlg, OPT_TCTime, "");
\r
2577 SetDlgItemText(hDlg, OPT_TCMoves, "");
\r
2578 SetDlgItemText(hDlg, OPT_TCTime2, appData.timeControl);
\r
2579 SetDlgItemInt(hDlg, OPT_TCInc, appData.timeIncrement, FALSE);
\r
2581 SetTimeControlEnables(hDlg);
\r
2585 case WM_COMMAND: /* message: received a command */
\r
2586 switch (LOWORD(wParam)) {
\r
2588 /* Read changed options from the dialog box */
\r
2589 if (IsDlgButtonChecked(hDlg, OPT_TCUseMoves)) {
\r
2591 mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE);
\r
2592 if (!ok || mps <= 0) {
\r
2593 MessageBox(hDlg, "Invalid moves per time control",
\r
2594 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2597 GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ);
\r
2598 if (!ParseTimeControl(buf, increment, mps)) {
\r
2599 MessageBox(hDlg, "Invalid minutes per time control",
\r
2600 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2604 increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE);
\r
2605 mps = appData.movesPerSession;
\r
2606 if (!ok || increment < 0) {
\r
2607 MessageBox(hDlg, "Invalid increment",
\r
2608 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2611 GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ);
\r
2612 if (!ParseTimeControl(buf, increment, mps)) {
\r
2613 MessageBox(hDlg, "Invalid initial time",
\r
2614 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2618 appData.timeControl = strdup(buf);
\r
2619 appData.movesPerSession = mps;
\r
2620 appData.timeIncrement = increment;
\r
2621 Reset(TRUE, TRUE);
\r
2622 EndDialog(hDlg, TRUE);
\r
2626 EndDialog(hDlg, FALSE);
\r
2630 SetTimeControlEnables(hDlg);
\r
2639 TimeControlOptionsPopup(HWND hwnd)
\r
2641 if (gameMode != BeginningOfGame) {
\r
2642 DisplayError("Changing time control during a game is not implemented", 0);
\r
2644 FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst);
\r
2645 DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc);
\r
2646 FreeProcInstance(lpProc);
\r
2650 /*---------------------------------------------------------------------------*\
\r
2652 * Engine Options Dialog functions
\r
2654 \*---------------------------------------------------------------------------*/
\r
2655 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
2656 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
2658 #define INT_ABS( n ) ((n) >= 0 ? (n) : -(n))
\r
2660 LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2662 switch (message) {
\r
2663 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2665 /* Center the dialog over the application window */
\r
2666 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2668 /* Initialize the dialog items */
\r
2669 CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates);
\r
2670 CHECK_BOX(IDC_EpPonder, appData.ponderNextMove);
\r
2671 CHECK_BOX(IDC_EpShowThinking, appData.showThinking);
\r
2672 CHECK_BOX(IDC_EpHideThinkingHuman, appData.hideThinkingFromHuman);
\r
2674 CHECK_BOX(IDC_TestClaims, appData.testClaims);
\r
2675 CHECK_BOX(IDC_DetectMates, appData.checkMates);
\r
2676 CHECK_BOX(IDC_MaterialDraws, appData.materialDraws);
\r
2677 CHECK_BOX(IDC_TrivialDraws, appData.trivialDraws);
\r
2679 SetDlgItemInt( hDlg, IDC_EpDrawMoveCount, appData.adjudicateDrawMoves, TRUE );
\r
2680 SendDlgItemMessage( hDlg, IDC_EpDrawMoveCount, EM_SETSEL, 0, -1 );
\r
2682 SetDlgItemInt( hDlg, IDC_EpAdjudicationThreshold, INT_ABS(appData.adjudicateLossThreshold), TRUE );
\r
2683 SendDlgItemMessage( hDlg, IDC_EpAdjudicationThreshold, EM_SETSEL, 0, -1 );
\r
2685 SetDlgItemInt( hDlg, IDC_RuleMoves, appData.ruleMoves, TRUE );
\r
2686 SendDlgItemMessage( hDlg, IDC_RuleMoves, EM_SETSEL, 0, -1 );
\r
2688 SetDlgItemInt( hDlg, IDC_DrawRepeats, INT_ABS(appData.drawRepeats), TRUE );
\r
2689 SendDlgItemMessage( hDlg, IDC_DrawRepeats, EM_SETSEL, 0, -1 );
\r
2693 case WM_COMMAND: /* message: received a command */
\r
2694 switch (LOWORD(wParam)) {
\r
2696 /* Read changed options from the dialog box */
\r
2697 PeriodicUpdatesEvent( IS_CHECKED(IDC_EpPeriodicUpdates));
\r
2698 PonderNextMoveEvent( IS_CHECKED(IDC_EpPonder));
\r
2699 ShowThinkingEvent( IS_CHECKED(IDC_EpShowThinking));
\r
2700 appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman);
\r
2701 appData.testClaims = IS_CHECKED(IDC_TestClaims);
\r
2702 appData.checkMates = IS_CHECKED(IDC_DetectMates);
\r
2703 appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);
\r
2704 appData.trivialDraws = IS_CHECKED(IDC_TrivialDraws);
\r
2706 appData.adjudicateDrawMoves = GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, NULL, FALSE );
\r
2707 appData.adjudicateLossThreshold = - (int) GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, NULL, FALSE );
\r
2708 appData.ruleMoves = GetDlgItemInt(hDlg, IDC_RuleMoves, NULL, FALSE );
\r
2709 appData.drawRepeats = (int) GetDlgItemInt(hDlg, IDC_DrawRepeats, NULL, FALSE );
\r
2711 EndDialog(hDlg, TRUE);
\r
2715 EndDialog(hDlg, FALSE);
\r
2718 case IDC_EpDrawMoveCount:
\r
2719 case IDC_EpAdjudicationThreshold:
\r
2720 case IDC_DrawRepeats:
\r
2721 case IDC_RuleMoves:
\r
2722 if( HIWORD(wParam) == EN_CHANGE ) {
\r
2728 GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, &n1_ok, FALSE );
\r
2729 GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, &n2_ok, FALSE );
\r
2730 GetDlgItemInt(hDlg, IDC_RuleMoves, &n3_ok, FALSE );
\r
2731 GetDlgItemInt(hDlg, IDC_DrawRepeats, &n4_ok, FALSE );
\r
2733 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok && n3_ok && n4_ok ? TRUE : FALSE );
\r
2742 VOID EnginePlayOptionsPopup(HWND hwnd)
\r
2746 lpProc = MakeProcInstance((FARPROC)EnginePlayOptionsDialog, hInst);
\r
2747 DialogBox(hInst, MAKEINTRESOURCE(DLG_EnginePlayOptions), hwnd, (DLGPROC) lpProc);
\r
2748 FreeProcInstance(lpProc);
\r
2751 /*---------------------------------------------------------------------------*\
\r
2753 * UCI Options Dialog functions
\r
2755 \*---------------------------------------------------------------------------*/
\r
2756 static BOOL BrowseForFolder( const char * title, char * path )
\r
2758 BOOL result = FALSE;
\r
2760 LPITEMIDLIST pidl;
\r
2762 ZeroMemory( &bi, sizeof(bi) );
\r
2764 bi.lpszTitle = title == 0 ? "Choose Folder" : title;
\r
2765 bi.ulFlags = BIF_RETURNONLYFSDIRS;
\r
2767 pidl = SHBrowseForFolder( &bi );
\r
2770 IMalloc * imalloc = 0;
\r
2772 if( SHGetPathFromIDList( pidl, path ) ) {
\r
2776 if( SUCCEEDED( SHGetMalloc ( &imalloc ) ) ) {
\r
2777 imalloc->lpVtbl->Free(imalloc,pidl);
\r
2778 imalloc->lpVtbl->Release(imalloc);
\r
2785 LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2787 char buf[MAX_PATH];
\r
2789 switch (message) {
\r
2790 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2792 /* Center the dialog over the application window */
\r
2793 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2795 /* Initialize the dialog items */
\r
2796 SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir );
\r
2797 SetDlgItemInt( hDlg, IDC_HashSize, appData.defaultHashSize, TRUE );
\r
2798 SetDlgItemText( hDlg, IDC_PathToEGTB, appData.defaultPathEGTB );
\r
2799 SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE );
\r
2800 CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook );
\r
2801 SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook );
\r
2803 SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 );
\r
2807 case WM_COMMAND: /* message: received a command */
\r
2808 switch (LOWORD(wParam)) {
\r
2810 GetDlgItemText( hDlg, IDC_PolyglotDir, buf, sizeof(buf) );
\r
2811 appData.polyglotDir = strdup(buf);
\r
2812 appData.defaultHashSize = GetDlgItemInt(hDlg, IDC_HashSize, NULL, FALSE );
\r
2813 appData.defaultCacheSizeEGTB = GetDlgItemInt(hDlg, IDC_SizeOfEGTB, NULL, FALSE );
\r
2814 GetDlgItemText( hDlg, IDC_PathToEGTB, buf, sizeof(buf) );
\r
2815 appData.defaultPathEGTB = strdup(buf);
\r
2816 GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) );
\r
2817 appData.polyglotBook = strdup(buf);
\r
2818 appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook );
\r
2820 EndDialog(hDlg, TRUE);
\r
2824 EndDialog(hDlg, FALSE);
\r
2827 case IDC_BrowseForBook:
\r
2829 char filter[] = {
\r
2830 'A','l','l',' ','F','i','l','e','s', 0,
\r
2832 'B','I','N',' ','F','i','l','e','s', 0,
\r
2833 '*','.','b','i','n', 0,
\r
2838 strcpy( buf, "" );
\r
2840 ZeroMemory( &ofn, sizeof(ofn) );
\r
2842 ofn.lStructSize = sizeof(ofn);
\r
2843 ofn.hwndOwner = hDlg;
\r
2844 ofn.hInstance = hInst;
\r
2845 ofn.lpstrFilter = filter;
\r
2846 ofn.lpstrFile = buf;
\r
2847 ofn.nMaxFile = sizeof(buf);
\r
2848 ofn.lpstrTitle = "Choose Book";
\r
2849 ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
\r
2851 if( GetOpenFileName( &ofn ) ) {
\r
2852 SetDlgItemText( hDlg, IDC_BookFile, buf );
\r
2857 case IDC_BrowseForPolyglotDir:
\r
2858 if( BrowseForFolder( "Choose Polyglot Directory", buf ) ) {
\r
2859 SetDlgItemText( hDlg, IDC_PolyglotDir, buf );
\r
2861 strcat( buf, "\\polyglot.exe" );
\r
2863 if( GetFileAttributes(buf) == 0xFFFFFFFF ) {
\r
2864 MessageBox( hDlg, "Polyglot was not found in the specified folder!", "Warning", MB_OK | MB_ICONWARNING );
\r
2869 case IDC_BrowseForEGTB:
\r
2870 if( BrowseForFolder( "Choose EGTB Directory:", buf ) ) {
\r
2871 SetDlgItemText( hDlg, IDC_PathToEGTB, buf );
\r
2875 case IDC_HashSize:
\r
2876 case IDC_SizeOfEGTB:
\r
2877 if( HIWORD(wParam) == EN_CHANGE ) {
\r
2881 GetDlgItemInt(hDlg, IDC_HashSize, &n1_ok, FALSE );
\r
2882 GetDlgItemInt(hDlg, IDC_SizeOfEGTB, &n2_ok, FALSE );
\r
2884 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok ? TRUE : FALSE );
\r
2893 VOID UciOptionsPopup(HWND hwnd)
\r
2897 lpProc = MakeProcInstance((FARPROC)UciOptionsDialog, hInst);
\r
2898 DialogBox(hInst, MAKEINTRESOURCE(DLG_OptionsUCI), hwnd, (DLGPROC) lpProc);
\r
2899 FreeProcInstance(lpProc);
\r