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 $
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
31 #include "winboard.h"
\r
32 #include "backend.h"
\r
33 #include "woptions.h"
\r
34 #include "defaults.h"
\r
35 #include "wedittags.h"
\r
36 #include <richedit.h>
\r
43 /* Imports from winboard.c */
\r
45 extern MyFont *font[NUM_SIZES][NUM_FONTS];
\r
46 extern HINSTANCE hInst; /* current instance */
\r
47 extern HWND hwndMain; /* root window*/
\r
48 extern BOOLEAN alwaysOnTop;
\r
49 extern RECT boardRect;
\r
50 extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor,
\r
51 blackPieceColor, highlightSquareColor, premoveHighlightColor;
\r
52 extern HPALETTE hPal;
\r
53 extern BoardSize boardSize;
\r
54 extern COLORREF consoleBackgroundColor;
\r
55 extern MyColorizeAttribs colorizeAttribs[]; /* do I need the size? */
\r
56 extern MyTextAttribs textAttribs[];
\r
57 extern MySound sounds[];
\r
58 extern ColorClass currentColorClass;
\r
59 extern HWND hwndConsole;
\r
60 extern char *defaultTextAttribs[];
\r
61 extern HWND commentDialog;
\r
62 extern char installDir[];
\r
63 extern HWND hCommPort; /* currently open comm port */
\r
65 extern BOOLEAN chessProgram;
\r
79 /* module prototypes */
\r
81 LRESULT CALLBACK GeneralOptions(HWND, UINT, WPARAM, LPARAM);
\r
82 LRESULT CALLBACK BoardOptions(HWND, UINT, WPARAM, LPARAM);
\r
83 LRESULT CALLBACK IcsOptions(HWND, UINT, WPARAM, LPARAM);
\r
84 LRESULT CALLBACK FontOptions(HWND, UINT, WPARAM, LPARAM);
\r
85 LRESULT CALLBACK CommPortOptions(HWND, UINT, WPARAM, LPARAM);
\r
86 LRESULT CALLBACK LoadOptions(HWND, UINT, WPARAM, LPARAM);
\r
87 LRESULT CALLBACK SaveOptions(HWND, UINT, WPARAM, LPARAM);
\r
88 LRESULT CALLBACK TimeControl(HWND, UINT, WPARAM, LPARAM);
\r
89 VOID ChangeBoardSize(BoardSize newSize);
\r
90 VOID PaintSampleSquare(
\r
93 COLORREF squareColor,
\r
94 COLORREF pieceColor,
\r
95 COLORREF squareOutlineColor,
\r
96 COLORREF pieceDetailColor,
\r
101 VOID PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color);
\r
102 VOID SetBoardOptionEnables(HWND hDlg);
\r
103 BoardSize BoardOptionsWhichRadio(HWND hDlg);
\r
104 BOOL APIENTRY MyCreateFont(HWND hwnd, MyFont *font);
\r
105 VOID UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca);
\r
106 LRESULT CALLBACK ColorizeTextDialog(HWND , UINT, WPARAM, LPARAM);
\r
107 VOID ColorizeTextPopup(HWND hwnd, ColorClass cc);
\r
108 VOID SetIcsOptionEnables(HWND hDlg);
\r
109 VOID SetSampleFontText(HWND hwnd, int id, const MyFont *mf);
\r
110 VOID CopyFont(MyFont *dest, const MyFont *src);
\r
111 void InitSoundComboData(SoundComboData *scd);
\r
112 void ResetSoundComboData(SoundComboData *scd);
\r
113 void InitSoundCombo(HWND hwndCombo, SoundComboData *scd);
\r
114 int SoundDialogWhichRadio(HWND hDlg);
\r
115 VOID SoundDialogSetEnables(HWND hDlg, int radio);
\r
116 char * SoundDialogGetName(HWND hDlg, int radio);
\r
117 void DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name);
\r
118 VOID ParseCommSettings(char *arg, DCB *dcb);
\r
119 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb);
\r
120 void InitCombo(HANDLE hwndCombo, ComboData *cd);
\r
121 void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value);
\r
122 VOID SetLoadOptionEnables(HWND hDlg);
\r
123 VOID SetSaveOptionEnables(HWND hDlg);
\r
124 VOID SetTimeControlEnables(HWND hDlg);
\r
126 /*---------------------------------------------------------------------------*\
\r
128 * General Options Dialog functions
\r
130 \*---------------------------------------------------------------------------*/
\r
134 GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
136 static Boolean oldShowCoords;
\r
137 static Boolean oldBlindfold;
\r
138 static Boolean oldShowButtonBar;
\r
141 case WM_INITDIALOG: /* message: initialize dialog box */
\r
142 oldShowCoords = appData.showCoords;
\r
143 oldBlindfold = appData.blindfold;
\r
144 oldShowButtonBar = appData.showButtonBar;
\r
146 /* Center the dialog over the application window */
\r
147 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
149 /* Initialize the dialog items */
\r
150 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
152 CHECK_BOX(OPT_AlwaysOnTop, alwaysOnTop);
\r
153 CHECK_BOX(OPT_AlwaysQueen, appData.alwaysPromoteToQueen);
\r
154 CHECK_BOX(OPT_AnimateDragging, appData.animateDragging);
\r
155 CHECK_BOX(OPT_AnimateMoving, appData.animate);
\r
156 CHECK_BOX(OPT_AutoFlag, appData.autoCallFlag);
\r
157 CHECK_BOX(OPT_AutoFlipView, appData.autoFlipView);
\r
158 CHECK_BOX(OPT_AutoRaiseBoard, appData.autoRaiseBoard);
\r
159 CHECK_BOX(OPT_Blindfold, appData.blindfold);
\r
160 CHECK_BOX(OPT_HighlightDragging, appData.highlightDragging);
\r
161 CHECK_BOX(OPT_HighlightLastMove, appData.highlightLastMove);
\r
162 CHECK_BOX(OPT_PeriodicUpdates, appData.periodicUpdates);
\r
163 CHECK_BOX(OPT_PonderNextMove, appData.ponderNextMove);
\r
164 CHECK_BOX(OPT_PopupExitMessage, appData.popupExitMessage);
\r
165 CHECK_BOX(OPT_PopupMoveErrors, appData.popupMoveErrors);
\r
166 CHECK_BOX(OPT_ShowButtonBar, appData.showButtonBar);
\r
167 CHECK_BOX(OPT_ShowCoordinates, appData.showCoords);
\r
168 CHECK_BOX(OPT_ShowThinking, appData.showThinking);
\r
169 CHECK_BOX(OPT_TestLegality, appData.testLegality);
\r
170 CHECK_BOX(OPT_HideThinkFromHuman, appData.hideThinkingFromHuman);
171 CHECK_BOX(OPT_SaveExtPGN, appData.saveExtendedInfoInPGN);
172 CHECK_BOX(OPT_ExtraInfoInMoveHistory, appData.showEvalInMoveHistory);
173 CHECK_BOX(OPT_HighlightMoveArrow, appData.highlightMoveWithArrow);
177 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlag),
\r
178 appData.icsActive || !appData.noChessProgram);
\r
179 EnableWindow(GetDlgItem(hDlg, OPT_AutoFlipView),
\r
180 appData.icsActive || !appData.noChessProgram);
\r
181 EnableWindow(GetDlgItem(hDlg, OPT_PonderNextMove),
\r
182 !appData.noChessProgram);
\r
183 EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates),
\r
184 !appData.noChessProgram && !appData.icsActive);
\r
185 EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking),
\r
186 !appData.noChessProgram);
\r
190 case WM_COMMAND: /* message: received a command */
\r
191 switch (LOWORD(wParam)) {
\r
193 /* Read changed options from the dialog box */
\r
195 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
197 alwaysOnTop = IS_CHECKED(OPT_AlwaysOnTop);
\r
198 appData.alwaysPromoteToQueen = IS_CHECKED(OPT_AlwaysQueen);
\r
199 appData.animateDragging = IS_CHECKED(OPT_AnimateDragging);
\r
200 appData.animate = IS_CHECKED(OPT_AnimateMoving);
\r
201 appData.autoCallFlag = IS_CHECKED(OPT_AutoFlag);
\r
202 appData.autoFlipView = IS_CHECKED(OPT_AutoFlipView);
\r
203 appData.autoRaiseBoard = IS_CHECKED(OPT_AutoRaiseBoard);
\r
204 appData.blindfold = IS_CHECKED(OPT_Blindfold);
\r
205 appData.highlightDragging = IS_CHECKED(OPT_HighlightDragging);
\r
206 appData.highlightLastMove = IS_CHECKED(OPT_HighlightLastMove);
\r
207 PeriodicUpdatesEvent( IS_CHECKED(OPT_PeriodicUpdates));
\r
208 PonderNextMoveEvent( IS_CHECKED(OPT_PonderNextMove));
\r
209 appData.popupExitMessage = IS_CHECKED(OPT_PopupExitMessage);
\r
210 appData.popupMoveErrors = IS_CHECKED(OPT_PopupMoveErrors);
\r
211 appData.showButtonBar = IS_CHECKED(OPT_ShowButtonBar);
\r
212 appData.showCoords = IS_CHECKED(OPT_ShowCoordinates);
\r
213 ShowThinkingEvent( IS_CHECKED(OPT_ShowThinking));
\r
214 appData.testLegality = IS_CHECKED(OPT_TestLegality);
\r
215 appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);
216 appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN);
217 appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory);
218 appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);
222 SetWindowPos(hwndMain, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
223 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
226 SetWindowPos(hwndConsole, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
\r
227 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
\r
230 if (!appData.highlightLastMove) {
\r
232 DrawPosition(FALSE, NULL);
\r
235 * for some reason the redraw seems smoother when we invalidate
\r
236 * the board rect after the call to EndDialog()
\r
238 EndDialog(hDlg, TRUE);
\r
240 if (oldShowButtonBar != appData.showButtonBar) {
\r
241 InitDrawingSizes(boardSize, 0);
\r
242 } else if ((oldShowCoords != appData.showCoords) ||
\r
243 (oldBlindfold != appData.blindfold)) {
\r
244 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
250 EndDialog(hDlg, FALSE);
\r
260 GeneralOptionsPopup(HWND hwnd)
\r
264 lpProc = MakeProcInstance((FARPROC)GeneralOptionsDialog, hInst);
\r
265 DialogBox(hInst, MAKEINTRESOURCE(DLG_GeneralOptions), hwnd,
\r
267 FreeProcInstance(lpProc);
\r
269 /*---------------------------------------------------------------------------*\
\r
271 * Board Options Dialog functions
\r
273 \*---------------------------------------------------------------------------*/
\r
275 const int SAMPLE_SQ_SIZE = 54;
\r
278 ChangeBoardSize(BoardSize newSize)
\r
280 if (newSize != boardSize) {
\r
281 boardSize = newSize;
\r
282 InitDrawingSizes(boardSize, 0);
\r
290 COLORREF squareColor,
\r
291 COLORREF pieceColor,
\r
292 COLORREF squareOutlineColor,
\r
293 COLORREF pieceDetailColor,
\r
299 HBRUSH brushSquare;
\r
300 HBRUSH brushSquareOutline;
\r
302 HBRUSH brushPieceDetail;
\r
303 HBRUSH oldBrushPiece;
\r
304 HBRUSH oldBrushSquare;
\r
305 HBITMAP oldBitmapMem;
\r
306 HBITMAP oldBitmapTemp;
\r
307 HBITMAP bufferBitmap;
\r
309 HDC hdcScreen, hdcMem, hdcTemp;
\r
311 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
314 const int SOLID = 0;
\r
315 const int WHITE = 1;
\r
316 const int OUTLINE = 2;
\r
317 const int BORDER = 4;
\r
319 InvalidateRect(hCtrl, NULL, TRUE);
\r
320 UpdateWindow(hCtrl);
\r
321 GetClientRect(hCtrl, &rect);
\r
322 x = rect.left + (BORDER / 2);
\r
323 y = rect.top + (BORDER / 2);
\r
324 hdcScreen = GetDC(hCtrl);
\r
325 hdcMem = CreateCompatibleDC(hdcScreen);
\r
326 hdcTemp = CreateCompatibleDC(hdcScreen);
\r
328 bufferBitmap = CreateCompatibleBitmap(hdcScreen, rect.right-rect.left+1,
\r
329 rect.bottom-rect.top+1);
\r
330 oldBitmapMem = SelectObject(hdcMem, bufferBitmap);
\r
332 SelectPalette(hdcMem, hPal, FALSE);
\r
334 brushSquare = CreateSolidBrush(squareColor);
\r
335 brushSquareOutline = CreateSolidBrush(squareOutlineColor);
\r
336 brushPiece = CreateSolidBrush(pieceColor);
\r
337 brushPieceDetail = CreateSolidBrush(pieceDetailColor);
\r
340 * first draw the rectangle
\r
342 pen = CreatePen(PS_SOLID, BORDER, squareOutlineColor);
\r
343 oldPen = (HPEN) SelectObject(hdcMem, pen);
\r
344 oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare);
\r
345 Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);
\r
348 * now draw the piece
\r
351 oldBitmapTemp = SelectObject(hdcTemp, pieces[OUTLINE]);
\r
352 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, hdcTemp, 0, 0,
\r
353 isWhitePiece ? SRCCOPY : NOTSRCCOPY);
\r
354 SelectObject(hdcTemp, oldBitmapTemp);
\r
356 if (isWhitePiece) {
\r
357 oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]);
\r
358 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
359 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
360 hdcTemp, 0, 0, 0x00B8074A);
\r
362 /* Use pieceDetailColor for outline of white pieces */
\r
363 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
364 SelectObject(hdcMem, brushPieceDetail);
\r
365 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
366 hdcTemp, 0, 0, 0x00B8074A);
\r
368 /* Use black for outline of white pieces */
\r
369 SelectObject(hdcTemp, pieces[OUTLINE]);
\r
370 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
371 hdcTemp, 0, 0, SRCAND);
\r
375 /* Use pieceDetailColor for details of black pieces */
\r
376 /* Requires filled-in solid bitmaps (BLACK_PIECE class); the
\r
377 WHITE_PIECE ones aren't always the right shape. */
\r
378 oldBitmapTemp = SelectObject(hdcTemp, pieces[BLACK]);
\r
379 oldBrushPiece = SelectObject(hdcMem, brushPieceDetail);
\r
380 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
381 hdcTemp, 0, 0, 0x00B8074A);
\r
382 SelectObject(hdcTemp, pieces[SOLID]);
\r
383 SelectObject(hdcMem, brushPiece);
\r
384 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
385 hdcTemp, 0, 0, 0x00B8074A);
\r
387 /* Use square color for details of black pieces */
\r
388 oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);
\r
389 oldBrushPiece = SelectObject(hdcMem, brushPiece);
\r
390 BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,
\r
391 hdcTemp, 0, 0, 0x00B8074A);
\r
394 SelectObject(hdcMem, oldBrushPiece);
\r
395 SelectObject(hdcTemp, oldBitmapTemp);
\r
398 * copy the memory dc to the screen
\r
400 SelectObject(hdcMem, bufferBitmap);
\r
401 BitBlt(hdcScreen, rect.left, rect.top,
\r
402 rect.right - rect.left,
\r
403 rect.bottom - rect.top,
\r
404 hdcMem, rect.left, rect.top, SRCCOPY);
\r
405 SelectObject(hdcMem, oldBitmapMem);
\r
409 SelectObject(hdcMem, oldBrushPiece);
\r
410 SelectObject(hdcMem, oldPen);
\r
411 DeleteObject(brushPiece);
\r
412 DeleteObject(brushPieceDetail);
\r
413 DeleteObject(brushSquare);
\r
414 DeleteObject(brushSquareOutline);
\r
418 ReleaseDC(hCtrl, hdcScreen);
\r
423 PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color)
\r
426 HBRUSH brush, oldBrush;
\r
428 HWND hCtrl = GetDlgItem(hwnd, ctrlid);
\r
430 hdc = GetDC(hCtrl);
\r
431 InvalidateRect(hCtrl, NULL, TRUE);
\r
432 UpdateWindow(hCtrl);
\r
433 GetClientRect(hCtrl, &rect);
\r
434 brush = CreateSolidBrush(color);
\r
435 oldBrush = (HBRUSH)SelectObject(hdc, brush);
\r
436 Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
\r
437 SelectObject(hdc, oldBrush);
\r
438 DeleteObject(brush);
\r
439 ReleaseDC(hCtrl, hdc);
\r
444 SetBoardOptionEnables(HWND hDlg)
\r
446 if (IsDlgButtonChecked(hDlg, OPT_Monochrome)) {
\r
447 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_HIDE);
\r
448 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_HIDE);
\r
449 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_HIDE);
\r
450 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_HIDE);
\r
452 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), FALSE);
\r
453 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), FALSE);
\r
454 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), FALSE);
\r
455 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), FALSE);
\r
457 ShowWindow(GetDlgItem(hDlg, OPT_LightSquareColor), SW_SHOW);
\r
458 ShowWindow(GetDlgItem(hDlg, OPT_DarkSquareColor), SW_SHOW);
\r
459 ShowWindow(GetDlgItem(hDlg, OPT_WhitePieceColor), SW_SHOW);
\r
460 ShowWindow(GetDlgItem(hDlg, OPT_BlackPieceColor), SW_SHOW);
\r
462 EnableWindow(GetDlgItem(hDlg, OPT_ChooseLightSquareColor), TRUE);
\r
463 EnableWindow(GetDlgItem(hDlg, OPT_ChooseDarkSquareColor), TRUE);
\r
464 EnableWindow(GetDlgItem(hDlg, OPT_ChooseWhitePieceColor), TRUE);
\r
465 EnableWindow(GetDlgItem(hDlg, OPT_ChooseBlackPieceColor), TRUE);
\r
470 BoardOptionsWhichRadio(HWND hDlg)
\r
472 return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny :
\r
473 (IsDlgButtonChecked(hDlg, OPT_SizeTeeny) ? SizeTeeny :
\r
474 (IsDlgButtonChecked(hDlg, OPT_SizeDinky) ? SizeDinky :
\r
475 (IsDlgButtonChecked(hDlg, OPT_SizePetite) ? SizePetite :
\r
476 (IsDlgButtonChecked(hDlg, OPT_SizeSlim) ? SizeSlim :
\r
477 (IsDlgButtonChecked(hDlg, OPT_SizeSmall) ? SizeSmall :
\r
478 (IsDlgButtonChecked(hDlg, OPT_SizeMediocre) ? SizeMediocre :
\r
479 (IsDlgButtonChecked(hDlg, OPT_SizeMiddling) ? SizeMiddling :
\r
480 (IsDlgButtonChecked(hDlg, OPT_SizeAverage) ? SizeAverage :
\r
481 (IsDlgButtonChecked(hDlg, OPT_SizeModerate) ? SizeModerate :
\r
482 (IsDlgButtonChecked(hDlg, OPT_SizeMedium) ? SizeMedium :
\r
483 (IsDlgButtonChecked(hDlg, OPT_SizeBulky) ? SizeBulky :
\r
484 (IsDlgButtonChecked(hDlg, OPT_SizeLarge) ? SizeLarge :
\r
485 (IsDlgButtonChecked(hDlg, OPT_SizeBig) ? SizeBig :
\r
486 (IsDlgButtonChecked(hDlg, OPT_SizeHuge) ? SizeHuge :
\r
487 (IsDlgButtonChecked(hDlg, OPT_SizeGiant) ? SizeGiant :
\r
488 (IsDlgButtonChecked(hDlg, OPT_SizeColossal) ? SizeColossal :
\r
489 SizeTitanic )))))))))))))))));
\r
493 BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
495 static Boolean mono;
\r
496 static BoardSize size;
\r
497 static COLORREF lsc, dsc, wpc, bpc, hsc, phc;
\r
498 static HBITMAP pieces[3];
\r
501 case WM_INITDIALOG: /* message: initialize dialog box */
\r
502 /* Center the dialog over the application window */
\r
503 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
504 /* Initialize the dialog items */
\r
505 switch (boardSize) {
\r
507 CheckDlgButton(hDlg, OPT_SizeTiny, TRUE);
\r
510 CheckDlgButton(hDlg, OPT_SizeTeeny, TRUE);
\r
513 CheckDlgButton(hDlg, OPT_SizeDinky, TRUE);
\r
516 CheckDlgButton(hDlg, OPT_SizePetite, TRUE);
\r
519 CheckDlgButton(hDlg, OPT_SizeSlim, TRUE);
\r
522 CheckDlgButton(hDlg, OPT_SizeSmall, TRUE);
\r
525 CheckDlgButton(hDlg, OPT_SizeMediocre, TRUE);
\r
528 CheckDlgButton(hDlg, OPT_SizeMiddling, TRUE);
\r
531 CheckDlgButton(hDlg, OPT_SizeAverage, TRUE);
\r
534 CheckDlgButton(hDlg, OPT_SizeModerate, TRUE);
\r
537 CheckDlgButton(hDlg, OPT_SizeMedium, TRUE);
\r
540 CheckDlgButton(hDlg, OPT_SizeBulky, TRUE);
\r
543 CheckDlgButton(hDlg, OPT_SizeLarge, TRUE);
\r
546 CheckDlgButton(hDlg, OPT_SizeBig, TRUE);
\r
549 CheckDlgButton(hDlg, OPT_SizeHuge, TRUE);
\r
552 CheckDlgButton(hDlg, OPT_SizeGiant, TRUE);
\r
555 CheckDlgButton(hDlg, OPT_SizeColossal, TRUE);
\r
558 CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE);
\r
561 if (appData.monoMode)
\r
562 CheckDlgButton(hDlg, OPT_Monochrome, TRUE);
\r
564 pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s");
\r
565 pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w");
\r
566 pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o");
\r
568 lsc = lightSquareColor;
\r
569 dsc = darkSquareColor;
\r
570 wpc = whitePieceColor;
\r
571 bpc = blackPieceColor;
\r
572 hsc = highlightSquareColor;
\r
573 phc = premoveHighlightColor;
\r
574 mono = appData.monoMode;
\r
577 SetBoardOptionEnables(hDlg);
\r
581 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
582 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
583 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
584 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
585 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
586 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
587 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
588 TRUE, mono, pieces);
\r
589 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
590 FALSE, mono, pieces);
\r
594 case WM_COMMAND: /* message: received a command */
\r
595 switch (LOWORD(wParam)) {
\r
598 * if we call EndDialog() after the call to ChangeBoardSize(),
\r
599 * then ChangeBoardSize() does not take effect, although the new
\r
600 * boardSize is saved. Go figure...
\r
602 EndDialog(hDlg, TRUE);
\r
604 size = BoardOptionsWhichRadio(hDlg);
\r
607 * did any settings change?
\r
609 if (size != boardSize) {
\r
610 ChangeBoardSize(size);
\r
613 if ((mono != appData.monoMode) ||
\r
614 (lsc != lightSquareColor) ||
\r
615 (dsc != darkSquareColor) ||
\r
616 (wpc != whitePieceColor) ||
\r
617 (bpc != blackPieceColor) ||
\r
618 (hsc != highlightSquareColor) ||
\r
619 (phc != premoveHighlightColor)) {
\r
621 lightSquareColor = lsc;
\r
622 darkSquareColor = dsc;
\r
623 whitePieceColor = wpc;
\r
624 blackPieceColor = bpc;
\r
625 highlightSquareColor = hsc;
\r
626 premoveHighlightColor = phc;
\r
627 appData.monoMode = mono;
\r
629 InitDrawingColors();
\r
630 InitDrawingSizes(boardSize, 0);
\r
631 InvalidateRect(hwndMain, &boardRect, FALSE);
\r
633 DeleteObject(pieces[0]);
\r
634 DeleteObject(pieces[1]);
\r
635 DeleteObject(pieces[2]);
\r
639 DeleteObject(pieces[0]);
\r
640 DeleteObject(pieces[1]);
\r
641 DeleteObject(pieces[2]);
\r
642 EndDialog(hDlg, FALSE);
\r
645 case OPT_ChooseLightSquareColor:
\r
646 if (ChangeColor(hDlg, &lsc))
\r
647 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
648 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
649 TRUE, mono, pieces);
\r
652 case OPT_ChooseDarkSquareColor:
\r
653 if (ChangeColor(hDlg, &dsc))
\r
654 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
655 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
656 FALSE, mono, pieces);
\r
659 case OPT_ChooseWhitePieceColor:
\r
660 if (ChangeColor(hDlg, &wpc))
\r
661 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
662 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
663 TRUE, mono, pieces);
\r
666 case OPT_ChooseBlackPieceColor:
\r
667 if (ChangeColor(hDlg, &bpc))
\r
668 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
669 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
670 FALSE, mono, pieces);
\r
673 case OPT_ChooseHighlightSquareColor:
\r
674 if (ChangeColor(hDlg, &hsc))
\r
675 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
676 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
677 TRUE, mono, pieces);
\r
680 case OPT_ChoosePremoveHighlightColor:
\r
681 if (ChangeColor(hDlg, &phc))
\r
682 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
683 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
684 FALSE, mono, pieces);
\r
687 case OPT_DefaultBoardColors:
\r
688 lsc = ParseColorName(LIGHT_SQUARE_COLOR);
\r
689 dsc = ParseColorName(DARK_SQUARE_COLOR);
\r
690 wpc = ParseColorName(WHITE_PIECE_COLOR);
\r
691 bpc = ParseColorName(BLACK_PIECE_COLOR);
\r
692 hsc = ParseColorName(HIGHLIGHT_SQUARE_COLOR);
\r
693 phc = ParseColorName(PREMOVE_HIGHLIGHT_COLOR);
\r
695 CheckDlgButton(hDlg, OPT_Monochrome, FALSE);
\r
696 PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);
\r
697 PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);
\r
698 PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);
\r
699 PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);
\r
700 PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);
\r
701 PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);
\r
702 SetBoardOptionEnables(hDlg);
\r
703 PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,
\r
704 TRUE, mono, pieces);
\r
705 PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,
\r
706 FALSE, mono, pieces);
\r
709 case OPT_Monochrome:
\r
711 SetBoardOptionEnables(hDlg);
\r
721 BoardOptionsPopup(HWND hwnd)
\r
723 FARPROC lpProc = MakeProcInstance((FARPROC)BoardOptionsDialog, hInst);
\r
724 DialogBox(hInst, MAKEINTRESOURCE(DLG_BoardOptions), hwnd,
\r
726 FreeProcInstance(lpProc);
\r
729 /*---------------------------------------------------------------------------*\
\r
731 * ICS Options Dialog functions
\r
733 \*---------------------------------------------------------------------------*/
\r
736 MyCreateFont(HWND hwnd, MyFont *font)
\r
741 /* Initialize members of the CHOOSEFONT structure. */
\r
742 cf.lStructSize = sizeof(CHOOSEFONT);
\r
743 cf.hwndOwner = hwnd;
\r
744 cf.hDC = (HDC)NULL;
\r
745 cf.lpLogFont = &font->lf;
\r
747 cf.Flags = CF_SCREENFONTS|/*CF_ANSIONLY|*/CF_INITTOLOGFONTSTRUCT;
\r
748 cf.rgbColors = RGB(0,0,0);
\r
750 cf.lpfnHook = (LPCFHOOKPROC)NULL;
\r
751 cf.lpTemplateName = (LPSTR)NULL;
\r
752 cf.hInstance = (HINSTANCE) NULL;
\r
753 cf.lpszStyle = (LPSTR)NULL;
\r
754 cf.nFontType = SCREEN_FONTTYPE;
\r
758 /* Display the CHOOSEFONT common-dialog box. */
\r
759 if (!ChooseFont(&cf)) {
\r
763 /* Create a logical font based on the user's */
\r
764 /* selection and return a handle identifying */
\r
766 hf = CreateFontIndirect(cf.lpLogFont);
\r
772 font->mfp.pointSize = (float) (cf.iPointSize / 10.0);
\r
773 font->mfp.bold = (font->lf.lfWeight >= FW_BOLD);
\r
774 font->mfp.italic = font->lf.lfItalic;
\r
775 font->mfp.underline = font->lf.lfUnderline;
\r
776 font->mfp.strikeout = font->lf.lfStrikeOut;
\r
777 strcpy(font->mfp.faceName, font->lf.lfFaceName);
\r
783 UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
\r
786 cf.cbSize = sizeof(CHARFORMAT);
\r
788 CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;
\r
789 cf.crTextColor = mca->color;
\r
790 cf.dwEffects = mca->effects;
\r
791 strcpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName);
\r
793 * The 20.0 below is in fact documented. yHeight is expressed in twips.
\r
794 * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT.
\r
797 cf.yHeight = (int)(font[boardSize][CONSOLE_FONT]->mfp.pointSize * 20.0 + 0.5);
\r
798 cf.bCharSet = DEFAULT_CHARSET; /* should be ignored anyway */
\r
799 cf.bPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
\r
800 SendDlgItemMessage(hDlg, id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
804 ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
806 static MyColorizeAttribs mca;
\r
807 static ColorClass cc;
\r
808 COLORREF background = (COLORREF)0;
\r
811 case WM_INITDIALOG:
\r
812 cc = (ColorClass)lParam;
\r
813 mca = colorizeAttribs[cc];
\r
814 /* Center the dialog over the application window */
\r
815 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
816 /* Initialize the dialog items */
\r
817 CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0);
\r
818 CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0);
\r
819 CheckDlgButton(hDlg, OPT_Underline, (mca.effects & CFE_UNDERLINE) != 0);
\r
820 CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0);
\r
822 /* get the current background color from the parent window */
\r
823 SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND,
\r
824 (WPARAM)WM_USER_GetConsoleBackground,
\r
825 (LPARAM)&background);
\r
827 /* set the background color */
\r
828 SendDlgItemMessage(hDlg, OPT_Sample, EM_SETBKGNDCOLOR, FALSE, background);
\r
830 SetDlgItemText(hDlg, OPT_Sample, mca.name);
\r
831 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
834 case WM_COMMAND: /* message: received a command */
\r
835 switch (LOWORD(wParam)) {
\r
837 /* Read changed options from the dialog box */
\r
838 colorizeAttribs[cc] = mca;
\r
839 textAttribs[cc].color = mca.color;
\r
840 textAttribs[cc].effects = mca.effects;
\r
841 Colorize(currentColorClass, TRUE);
\r
842 if (cc == ColorNormal) {
\r
844 cf.cbSize = sizeof(CHARFORMAT);
\r
845 cf.dwMask = CFM_COLOR;
\r
846 cf.crTextColor = mca.color;
\r
847 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
848 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
850 EndDialog(hDlg, TRUE);
\r
854 EndDialog(hDlg, FALSE);
\r
857 case OPT_ChooseColor:
\r
858 ChangeColor(hDlg, &mca.color);
\r
859 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
864 (IsDlgButtonChecked(hDlg, OPT_Bold) ? CFE_BOLD : 0) |
\r
865 (IsDlgButtonChecked(hDlg, OPT_Italic) ? CFE_ITALIC : 0) |
\r
866 (IsDlgButtonChecked(hDlg, OPT_Underline) ? CFE_UNDERLINE : 0) |
\r
867 (IsDlgButtonChecked(hDlg, OPT_Strikeout) ? CFE_STRIKEOUT : 0);
\r
868 UpdateSampleText(hDlg, OPT_Sample, &mca);
\r
877 ColorizeTextPopup(HWND hwnd, ColorClass cc)
\r
881 lpProc = MakeProcInstance((FARPROC)ColorizeTextDialog, hInst);
\r
882 DialogBoxParam(hInst, MAKEINTRESOURCE(DLG_Colorize),
\r
883 hwnd, (DLGPROC)lpProc, (LPARAM) cc);
\r
884 FreeProcInstance(lpProc);
\r
888 SetIcsOptionEnables(HWND hDlg)
\r
890 #define ENABLE_DLG_ITEM(x,y) EnableWindow(GetDlgItem(hDlg,(x)), (y))
\r
892 UINT state = IsDlgButtonChecked(hDlg, OPT_Premove);
\r
893 ENABLE_DLG_ITEM(OPT_PremoveWhite, state);
\r
894 ENABLE_DLG_ITEM(OPT_PremoveWhiteText, state);
\r
895 ENABLE_DLG_ITEM(OPT_PremoveBlack, state);
\r
896 ENABLE_DLG_ITEM(OPT_PremoveBlackText, state);
\r
898 ENABLE_DLG_ITEM(OPT_IcsAlarmTime, IsDlgButtonChecked(hDlg, OPT_IcsAlarm));
\r
900 #undef ENABLE_DLG_ITEM
\r
905 IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
910 static COLORREF cbc;
\r
911 static MyColorizeAttribs *mca;
\r
912 COLORREF *colorref;
\r
915 case WM_INITDIALOG: /* message: initialize dialog box */
\r
917 mca = colorizeAttribs;
\r
919 for (i=0; i < NColorClasses - 1; i++) {
\r
920 mca[i].color = textAttribs[i].color;
\r
921 mca[i].effects = textAttribs[i].effects;
\r
923 cbc = consoleBackgroundColor;
\r
925 /* Center the dialog over the application window */
\r
926 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
928 /* Initialize the dialog items */
\r
929 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
\r
931 CHECK_BOX(OPT_AutoComment, appData.autoComment);
\r
932 CHECK_BOX(OPT_AutoObserve, appData.autoObserve);
\r
933 CHECK_BOX(OPT_GetMoveList, appData.getMoveList);
\r
934 CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing);
\r
935 CHECK_BOX(OPT_QuietPlay, appData.quietPlay);
\r
936 CHECK_BOX(OPT_Premove, appData.premove);
\r
937 CHECK_BOX(OPT_PremoveWhite, appData.premoveWhite);
\r
938 CHECK_BOX(OPT_PremoveBlack, appData.premoveBlack);
\r
939 CHECK_BOX(OPT_IcsAlarm, appData.icsAlarm);
\r
940 CHECK_BOX(OPT_DontColorize, !appData.colorize);
\r
944 sprintf(buf, "%d", appData.icsAlarmTime / 1000);
\r
945 SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);
\r
946 SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);
\r
947 SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);
\r
949 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
950 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
951 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
952 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
953 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
954 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
955 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
956 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
957 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
958 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
960 SetDlgItemText(hDlg, OPT_SampleShout, mca[ColorShout].name);
\r
961 SetDlgItemText(hDlg, OPT_SampleSShout, mca[ColorSShout].name);
\r
962 SetDlgItemText(hDlg, OPT_SampleChannel1, mca[ColorChannel1].name);
\r
963 SetDlgItemText(hDlg, OPT_SampleChannel, mca[ColorChannel].name);
\r
964 SetDlgItemText(hDlg, OPT_SampleKibitz, mca[ColorKibitz].name);
\r
965 SetDlgItemText(hDlg, OPT_SampleTell, mca[ColorTell].name);
\r
966 SetDlgItemText(hDlg, OPT_SampleChallenge, mca[ColorChallenge].name);
\r
967 SetDlgItemText(hDlg, OPT_SampleRequest, mca[ColorRequest].name);
\r
968 SetDlgItemText(hDlg, OPT_SampleSeek, mca[ColorSeek].name);
\r
969 SetDlgItemText(hDlg, OPT_SampleNormal, mca[ColorNormal].name);
\r
971 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
972 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
973 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
974 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
975 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
976 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
977 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
978 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
979 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
980 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
982 SetIcsOptionEnables(hDlg);
\r
985 case WM_COMMAND: /* message: received a command */
\r
986 switch (LOWORD(wParam)) {
\r
988 case WM_USER_GetConsoleBackground:
\r
989 /* the ColorizeTextDialog needs the current background color */
\r
990 colorref = (COLORREF *)lParam;
\r
995 /* Read changed options from the dialog box */
\r
996 GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ);
\r
997 if (sscanf(buf, "%d", &number) != 1 || (number < 0)){
\r
998 MessageBox(hDlg, "Invalid ICS Alarm Time",
\r
999 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
1003 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
\r
1005 appData.icsAlarm = IS_CHECKED(OPT_IcsAlarm);
\r
1006 appData.premove = IS_CHECKED(OPT_Premove);
\r
1007 appData.premoveWhite = IS_CHECKED(OPT_PremoveWhite);
\r
1008 appData.premoveBlack = IS_CHECKED(OPT_PremoveBlack);
\r
1009 appData.autoComment = IS_CHECKED(OPT_AutoComment);
\r
1010 appData.autoObserve = IS_CHECKED(OPT_AutoObserve);
\r
1011 appData.getMoveList = IS_CHECKED(OPT_GetMoveList);
\r
1012 appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing);
\r
1013 appData.quietPlay = IS_CHECKED(OPT_QuietPlay);
\r
1017 appData.icsAlarmTime = number * 1000;
\r
1018 GetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText, 5);
\r
1019 GetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText, 5);
\r
1021 if (appData.localLineEditing) {
\r
1029 appData.colorize =
\r
1030 (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize);
\r
1032 if (!appData.colorize) {
\r
1034 COLORREF background = ParseColorName(COLOR_BKGD);
\r
1036 SetDefaultTextAttribs();
\r
1037 Colorize(currentColorClass);
\r
1039 cf.cbSize = sizeof(CHARFORMAT);
\r
1040 cf.dwMask = CFM_COLOR;
\r
1041 cf.crTextColor = ParseColorName(COLOR_NORMAL);
\r
1043 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1044 EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
\r
1045 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1046 EM_SETBKGNDCOLOR, FALSE, background);
\r
1047 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1048 EM_SETBKGNDCOLOR, FALSE, background);
\r
1051 if (cbc != consoleBackgroundColor) {
\r
1052 consoleBackgroundColor = cbc;
\r
1053 if (appData.colorize) {
\r
1054 SendDlgItemMessage(hwndConsole, OPT_ConsoleText,
\r
1055 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1056 SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,
\r
1057 EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);
\r
1061 for (i=0; i < NColorClasses - 1; i++) {
\r
1062 textAttribs[i].color = mca[i].color;
\r
1063 textAttribs[i].effects = mca[i].effects;
\r
1066 EndDialog(hDlg, TRUE);
\r
1070 EndDialog(hDlg, FALSE);
\r
1073 case OPT_ChooseShoutColor:
\r
1074 ColorizeTextPopup(hDlg, ColorShout);
\r
1075 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1078 case OPT_ChooseSShoutColor:
\r
1079 ColorizeTextPopup(hDlg, ColorSShout);
\r
1080 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1083 case OPT_ChooseChannel1Color:
\r
1084 ColorizeTextPopup(hDlg, ColorChannel1);
\r
1085 UpdateSampleText(hDlg, OPT_SampleChannel1,
\r
1086 &colorizeAttribs[ColorChannel1]);
\r
1089 case OPT_ChooseChannelColor:
\r
1090 ColorizeTextPopup(hDlg, ColorChannel);
\r
1091 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1094 case OPT_ChooseKibitzColor:
\r
1095 ColorizeTextPopup(hDlg, ColorKibitz);
\r
1096 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1099 case OPT_ChooseTellColor:
\r
1100 ColorizeTextPopup(hDlg, ColorTell);
\r
1101 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1104 case OPT_ChooseChallengeColor:
\r
1105 ColorizeTextPopup(hDlg, ColorChallenge);
\r
1106 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1109 case OPT_ChooseRequestColor:
\r
1110 ColorizeTextPopup(hDlg, ColorRequest);
\r
1111 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1114 case OPT_ChooseSeekColor:
\r
1115 ColorizeTextPopup(hDlg, ColorSeek);
\r
1116 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1119 case OPT_ChooseNormalColor:
\r
1120 ColorizeTextPopup(hDlg, ColorNormal);
\r
1121 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1124 case OPT_ChooseBackgroundColor:
\r
1125 if (ChangeColor(hDlg, &cbc)) {
\r
1126 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1127 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1128 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1129 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1130 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1131 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1132 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1133 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1134 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1135 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1139 case OPT_DefaultColors:
\r
1140 for (i=0; i < NColorClasses - 1; i++)
\r
1141 ParseAttribs(&mca[i].color,
\r
1143 defaultTextAttribs[i]);
\r
1145 cbc = ParseColorName(COLOR_BKGD);
\r
1146 SendDlgItemMessage(hDlg, OPT_SampleShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1147 SendDlgItemMessage(hDlg, OPT_SampleSShout, EM_SETBKGNDCOLOR, 0, cbc);
\r
1148 SendDlgItemMessage(hDlg, OPT_SampleChannel1, EM_SETBKGNDCOLOR, 0, cbc);
\r
1149 SendDlgItemMessage(hDlg, OPT_SampleChannel, EM_SETBKGNDCOLOR, 0, cbc);
\r
1150 SendDlgItemMessage(hDlg, OPT_SampleKibitz, EM_SETBKGNDCOLOR, 0, cbc);
\r
1151 SendDlgItemMessage(hDlg, OPT_SampleTell, EM_SETBKGNDCOLOR, 0, cbc);
\r
1152 SendDlgItemMessage(hDlg, OPT_SampleChallenge, EM_SETBKGNDCOLOR, 0, cbc);
\r
1153 SendDlgItemMessage(hDlg, OPT_SampleRequest, EM_SETBKGNDCOLOR, 0, cbc);
\r
1154 SendDlgItemMessage(hDlg, OPT_SampleSeek, EM_SETBKGNDCOLOR, 0, cbc);
\r
1155 SendDlgItemMessage(hDlg, OPT_SampleNormal, EM_SETBKGNDCOLOR, 0, cbc);
\r
1157 UpdateSampleText(hDlg, OPT_SampleShout, &mca[ColorShout]);
\r
1158 UpdateSampleText(hDlg, OPT_SampleSShout, &mca[ColorSShout]);
\r
1159 UpdateSampleText(hDlg, OPT_SampleChannel1, &mca[ColorChannel1]);
\r
1160 UpdateSampleText(hDlg, OPT_SampleChannel, &mca[ColorChannel]);
\r
1161 UpdateSampleText(hDlg, OPT_SampleKibitz, &mca[ColorKibitz]);
\r
1162 UpdateSampleText(hDlg, OPT_SampleTell, &mca[ColorTell]);
\r
1163 UpdateSampleText(hDlg, OPT_SampleChallenge, &mca[ColorChallenge]);
\r
1164 UpdateSampleText(hDlg, OPT_SampleRequest, &mca[ColorRequest]);
\r
1165 UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);
\r
1166 UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);
\r
1170 SetIcsOptionEnables(hDlg);
\r
1179 IcsOptionsPopup(HWND hwnd)
\r
1181 FARPROC lpProc = MakeProcInstance((FARPROC)IcsOptionsDialog, hInst);
\r
1182 DialogBox(hInst, MAKEINTRESOURCE(DLG_IcsOptions), hwnd,
\r
1183 (DLGPROC) lpProc);
\r
1184 FreeProcInstance(lpProc);
\r
1187 /*---------------------------------------------------------------------------*\
\r
1189 * Fonts Dialog functions
\r
1191 \*---------------------------------------------------------------------------*/
\r
1194 SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
\r
1196 char buf[MSG_SIZ];
\r
1201 RECT rectClient, rectFormat;
\r
1206 len = sprintf(buf, "%.0f pt. %s%s%s\n",
\r
1207 mf->mfp.pointSize, mf->mfp.faceName,
\r
1208 mf->mfp.bold ? " bold" : "",
\r
1209 mf->mfp.italic ? " italic" : "");
\r
1210 SetDlgItemText(hwnd, id, buf);
\r
1212 hControl = GetDlgItem(hwnd, id);
\r
1213 hdc = GetDC(hControl);
\r
1214 SetMapMode(hdc, MM_TEXT); /* 1 pixel == 1 logical unit */
\r
1215 oldFont = SelectObject(hdc, mf->hf);
\r
1217 /* get number of logical units necessary to display font name */
\r
1218 GetTextExtentPoint32(hdc, buf, len, &size);
\r
1220 /* calculate formatting rectangle in the rich edit control.
\r
1221 * May be larger or smaller than the actual control.
\r
1223 GetClientRect(hControl, &rectClient);
\r
1224 center.x = (rectClient.left + rectClient.right) / 2;
\r
1225 center.y = (rectClient.top + rectClient.bottom) / 2;
\r
1226 rectFormat.top = center.y - (size.cy / 2) - 1;
\r
1227 rectFormat.bottom = center.y + (size.cy / 2) + 1;
\r
1228 rectFormat.left = center.x - (size.cx / 2) - 1;
\r
1229 rectFormat.right = center.x + (size.cx / 2) + 1;
\r
1232 fprintf(debugFP, "\nfont: %s\n"
\r
1233 "center.x %d, centerY %d\n"
\r
1234 "size.cx %d, size.cy %d\n"
\r
1235 "client.top %d, bottom %d, left %d, right %d\n"
\r
1236 "format.top %d, bottom %d, left %d, right %d\n",
\r
1238 center.x, center.y,
\r
1240 rectClient.top, rectClient.bottom, rectClient.left,
\r
1242 rectFormat.top, rectFormat.bottom, rectFormat.left,
\r
1243 rectFormat.right);
\r
1246 cf.cbSize = sizeof(CHARFORMAT);
\r
1247 cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC;
\r
1249 if (mf->lf.lfWeight == FW_BOLD) cf.dwEffects |= CFE_BOLD;
\r
1250 if (mf->lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
\r
1251 strcpy(cf.szFaceName, mf->mfp.faceName);
\r
1253 * yHeight is expressed in twips. A twip is 1/20 of a font's point
\r
1254 * size. See documentation of CHARFORMAT. --msw
\r
1256 cf.yHeight = (int)(mf->mfp.pointSize * 20.0 + 0.5);
\r
1257 cf.bCharSet = mf->lf.lfCharSet;
\r
1258 cf.bPitchAndFamily = mf->lf.lfPitchAndFamily;
\r
1260 /* format the text in the rich edit control */
\r
1261 SendMessage(hControl, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf);
\r
1262 SendMessage(hControl, EM_SETRECT, (WPARAM)0, (LPARAM) &rectFormat);
\r
1265 SelectObject(hdc, oldFont);
\r
1266 ReleaseDC(hControl, hdc);
\r
1270 CopyFont(MyFont *dest, const MyFont *src)
\r
1272 dest->mfp.pointSize = src->mfp.pointSize;
\r
1273 dest->mfp.bold = src->mfp.bold;
\r
1274 dest->mfp.italic = src->mfp.italic;
\r
1275 dest->mfp.underline = src->mfp.underline;
\r
1276 dest->mfp.strikeout = src->mfp.strikeout;
\r
1277 lstrcpy(dest->mfp.faceName, src->mfp.faceName);
\r
1278 CreateFontInMF(dest);
\r
1283 FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1285 static MyFont workFont[NUM_FONTS];
\r
1286 static BOOL firstPaint;
\r
1290 switch (message) {
\r
1291 case WM_INITDIALOG:
\r
1293 /* copy the current font settings into a working copy */
\r
1294 for (i=0; i < NUM_FONTS; i++)
\r
1295 CopyFont(&workFont[i], font[boardSize][i]);
\r
1297 if (!appData.icsActive)
\r
1298 EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE);
\r
1300 firstPaint = TRUE; /* see rant below */
\r
1302 /* If I don't call SetFocus(), the dialog won't respond to the keyboard
\r
1303 * when first drawn. Why is this the only dialog that behaves this way? Is
\r
1304 * is the WM_PAINT stuff below?? Sigh...
\r
1306 SetFocus(GetDlgItem(hDlg, IDOK));
\r
1310 /* This should not be necessary. However, if SetSampleFontText() is called
\r
1311 * in response to WM_INITDIALOG, the strings are not properly centered in
\r
1312 * the controls when the dialog first appears. I can't figure out why, so
\r
1313 * this is the workaround. --msw
\r
1316 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1317 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1318 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1319 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1320 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1321 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1322 firstPaint = FALSE;
\r
1326 case WM_COMMAND: /* message: received a command */
\r
1327 switch (LOWORD(wParam)) {
\r
1330 /* again, it seems to avoid redraw problems if we call EndDialog first */
\r
1331 EndDialog(hDlg, FALSE);
\r
1333 /* copy modified settings back to the fonts array */
\r
1334 for (i=0; i < NUM_FONTS; i++)
\r
1335 CopyFont(font[boardSize][i], &workFont[i]);
\r
1337 /* a sad necessity due to the original design of having a separate
\r
1338 * console font, tags font, and comment font for each board size. IMHO
\r
1339 * these fonts should not be dependent on the current board size. I'm
\r
1340 * running out of time, so I am doing this hack rather than redesign the
\r
1341 * data structure. Besides, I think if I redesigned the data structure, I
\r
1342 * might break backwards compatibility with old winboard.ini files.
\r
1345 for (i=0; i < NUM_SIZES; i++) {
\r
1346 CopyFont(font[i][EDITTAGS_FONT], &workFont[EDITTAGS_FONT]);
\r
1347 CopyFont(font[i][CONSOLE_FONT], &workFont[CONSOLE_FONT]);
\r
1348 CopyFont(font[i][COMMENT_FONT], &workFont[COMMENT_FONT]);
\r
1350 /* end sad necessity */
\r
1352 InitDrawingSizes(boardSize, 0);
\r
1353 InvalidateRect(hwndMain, NULL, TRUE);
\r
1355 if (commentDialog) {
\r
1356 SendDlgItemMessage(commentDialog, OPT_CommentText,
\r
1357 WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf,
\r
1358 MAKELPARAM(TRUE, 0));
\r
1359 GetClientRect(GetDlgItem(commentDialog, OPT_CommentText), &rect);
\r
1360 InvalidateRect(commentDialog, &rect, TRUE);
\r
1363 if (editTagsDialog) {
\r
1364 SendDlgItemMessage(editTagsDialog, OPT_TagsText,
\r
1365 WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf,
\r
1366 MAKELPARAM(TRUE, 0));
\r
1367 GetClientRect(GetDlgItem(editTagsDialog, OPT_TagsText), &rect);
\r
1368 InvalidateRect(editTagsDialog, &rect, TRUE);
\r
1371 if (hwndConsole) {
\r
1372 ChangedConsoleFont();
\r
1375 for (i=0; i<NUM_FONTS; i++)
\r
1376 DeleteObject(&workFont[i].hf);
\r
1381 for (i=0; i<NUM_FONTS; i++)
\r
1382 DeleteObject(&workFont[i].hf);
\r
1383 EndDialog(hDlg, FALSE);
\r
1386 case OPT_ChooseClockFont:
\r
1387 MyCreateFont(hDlg, &workFont[CLOCK_FONT]);
\r
1388 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1391 case OPT_ChooseMessageFont:
\r
1392 MyCreateFont(hDlg, &workFont[MESSAGE_FONT]);
\r
1393 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1396 case OPT_ChooseCoordFont:
\r
1397 MyCreateFont(hDlg, &workFont[COORD_FONT]);
\r
1398 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1401 case OPT_ChooseTagFont:
\r
1402 MyCreateFont(hDlg, &workFont[EDITTAGS_FONT]);
\r
1403 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1406 case OPT_ChooseCommentsFont:
\r
1407 MyCreateFont(hDlg, &workFont[COMMENT_FONT]);
\r
1408 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1411 case OPT_ChooseConsoleFont:
\r
1412 MyCreateFont(hDlg, &workFont[CONSOLE_FONT]);
\r
1413 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1416 case OPT_DefaultFonts:
\r
1417 for (i=0; i<NUM_FONTS; i++) {
\r
1418 DeleteObject(&workFont[i].hf);
\r
1419 ParseFontName(font[boardSize][i]->def, &workFont[i].mfp);
\r
1420 CreateFontInMF(&workFont[i]);
\r
1422 SetSampleFontText(hDlg, OPT_SampleClockFont, &workFont[CLOCK_FONT]);
\r
1423 SetSampleFontText(hDlg, OPT_SampleMessageFont, &workFont[MESSAGE_FONT]);
\r
1424 SetSampleFontText(hDlg, OPT_SampleCoordFont, &workFont[COORD_FONT]);
\r
1425 SetSampleFontText(hDlg, OPT_SampleTagFont, &workFont[EDITTAGS_FONT]);
\r
1426 SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);
\r
1427 SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);
\r
1435 FontsOptionsPopup(HWND hwnd)
\r
1437 FARPROC lpProc = MakeProcInstance((FARPROC)FontOptionsDialog, hInst);
\r
1438 DialogBox(hInst, MAKEINTRESOURCE(DLG_Fonts), hwnd,
\r
1439 (DLGPROC) lpProc);
\r
1440 FreeProcInstance(lpProc);
\r
1443 /*---------------------------------------------------------------------------*\
\r
1445 * Sounds Dialog functions
\r
1447 \*---------------------------------------------------------------------------*/
\r
1450 SoundComboData soundComboData[] = {
\r
1453 {"ICS Alarm", NULL},
\r
1454 {"ICS Win", NULL},
\r
1455 {"ICS Loss", NULL},
\r
1456 {"ICS Draw", NULL},
\r
1457 {"ICS Unfinished", NULL},
\r
1459 {"SShout/CShout", NULL},
\r
1460 {"Channel 1", NULL},
\r
1461 {"Channel", NULL},
\r
1464 {"Challenge", NULL},
\r
1465 {"Request", NULL},
\r
1472 InitSoundComboData(SoundComboData *scd)
\r
1478 /* copy current sound settings to combo array */
\r
1480 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1481 scd[sc].name = strdup(sounds[sc].name);
\r
1483 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1484 index = (int)cc + (int)NSoundClasses;
\r
1485 scd[index].name = strdup(textAttribs[cc].sound.name);
\r
1491 ResetSoundComboData(SoundComboData *scd)
\r
1493 while (scd->label) {
\r
1494 if (scd->name != NULL) {
\r
1503 InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
\r
1508 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
1510 /* send the labels to the combo box */
\r
1511 while (scd->label) {
\r
1512 err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label);
\r
1513 if (err != cnt++) {
\r
1514 sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n",
\r
1516 MessageBox(NULL, buf, NULL, MB_OK);
\r
1520 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
1524 SoundDialogWhichRadio(HWND hDlg)
\r
1526 if (IsDlgButtonChecked(hDlg, OPT_NoSound)) return OPT_NoSound;
\r
1527 if (IsDlgButtonChecked(hDlg, OPT_DefaultBeep)) return OPT_DefaultBeep;
\r
1528 if (IsDlgButtonChecked(hDlg, OPT_BuiltInSound)) return OPT_BuiltInSound;
\r
1529 if (IsDlgButtonChecked(hDlg, OPT_WavFile)) return OPT_WavFile;
\r
1534 SoundDialogSetEnables(HWND hDlg, int radio)
\r
1536 EnableWindow(GetDlgItem(hDlg, OPT_BuiltInSoundName),
\r
1537 radio == OPT_BuiltInSound);
\r
1538 EnableWindow(GetDlgItem(hDlg, OPT_WavFileName), radio == OPT_WavFile);
\r
1539 EnableWindow(GetDlgItem(hDlg, OPT_BrowseSound), radio == OPT_WavFile);
\r
1543 SoundDialogGetName(HWND hDlg, int radio)
\r
1545 static char buf[MSG_SIZ], buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
1546 char *dummy, *ret;
\r
1551 case OPT_DefaultBeep:
\r
1553 case OPT_BuiltInSound:
\r
1555 GetDlgItemText(hDlg, OPT_BuiltInSoundName, buf + 1, sizeof(buf) - 1);
\r
1558 GetDlgItemText(hDlg, OPT_WavFileName, buf, sizeof(buf));
\r
1559 GetCurrentDirectory(MSG_SIZ, buf3);
\r
1560 SetCurrentDirectory(installDir);
\r
1561 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
1566 SetCurrentDirectory(buf3);
\r
1572 DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
\r
1576 * I think it's best to clear the combo and edit boxes. It looks stupid
\r
1577 * to have a value from another sound event sitting there grayed out.
\r
1579 SetDlgItemText(hDlg, OPT_WavFileName, "");
\r
1580 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1582 if (appData.debugMode)
\r
1583 fprintf(debugFP, "DisplaySelectedSound(,,'%s'):\n", name);
\r
1584 switch (name[0]) {
\r
1586 radio = OPT_NoSound;
\r
1589 if (name[1] == NULLCHAR) {
\r
1590 radio = OPT_DefaultBeep;
\r
1592 radio = OPT_WavFile;
\r
1593 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1597 if (name[1] == NULLCHAR) {
\r
1598 radio = OPT_NoSound;
\r
1600 radio = OPT_BuiltInSound;
\r
1601 if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1,
\r
1602 (LPARAM) (name + 1)) == CB_ERR) {
\r
1603 SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1604 SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1));
\r
1609 radio = OPT_WavFile;
\r
1610 SetDlgItemText(hDlg, OPT_WavFileName, name);
\r
1613 SoundDialogSetEnables(hDlg, radio);
\r
1614 CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio);
\r
1618 char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES;
\r
1621 SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1623 static HWND hSoundCombo;
\r
1624 static DWORD index;
\r
1625 static HWND hBISN;
\r
1629 char buf[MSG_SIZ];
\r
1633 SoundComboData *scd;
\r
1635 switch (message) {
\r
1636 case WM_INITDIALOG:
\r
1637 /* Center the dialog over the application window */
\r
1638 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
1640 /* Initialize the built-in sounds combo */
\r
1641 hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName);
\r
1642 InitComboStrings(hBISN, builtInSoundNames);
\r
1644 /* Initialize the sound events combo */
\r
1646 InitSoundComboData(soundComboData);
\r
1647 hSoundCombo = GetDlgItem(hDlg, CBO_Sounds);
\r
1648 InitSoundCombo(hSoundCombo, soundComboData);
\r
1650 /* update the dialog */
\r
1651 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1654 case WM_COMMAND: /* message: received a command */
\r
1656 if (((HWND)lParam == hSoundCombo) &&
\r
1657 (HIWORD(wParam) == CBN_SELCHANGE)) {
\r
1659 * the user has selected a new sound event. We must store the name for
\r
1660 * the previously selected event, then retrieve the name for the
\r
1661 * newly selected event and update the dialog.
\r
1663 radio = SoundDialogWhichRadio(hDlg);
\r
1664 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1666 if (strcmp(newName, soundComboData[index].name) != 0) {
\r
1667 free(soundComboData[index].name);
\r
1668 soundComboData[index].name = newName;
\r
1673 /* now get the settings for the newly selected event */
\r
1674 index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
\r
1675 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1679 switch (LOWORD(wParam)) {
\r
1682 * save the name for the currently selected sound event
\r
1684 radio = SoundDialogWhichRadio(hDlg);
\r
1685 newName = strdup(SoundDialogGetName(hDlg, radio));
\r
1687 if (strcmp(soundComboData[index].name, newName) != 0) {
\r
1688 free(soundComboData[index].name);
\r
1689 soundComboData[index].name = newName;
\r
1695 /* save all the sound names that changed and load the sounds */
\r
1697 for ( sc = (SoundClass)0; sc < NSoundClasses; sc++) {
\r
1698 if (strcmp(soundComboData[sc].name, sounds[sc].name) != 0) {
\r
1699 free(sounds[sc].name);
\r
1700 sounds[sc].name = strdup(soundComboData[sc].name);
\r
1701 MyLoadSound(&sounds[sc]);
\r
1704 for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {
\r
1705 index = (int)cc + (int)NSoundClasses;
\r
1706 if (strcmp(soundComboData[index].name,
\r
1707 textAttribs[cc].sound.name) != 0) {
\r
1708 free(textAttribs[cc].sound.name);
\r
1709 textAttribs[cc].sound.name = strdup(soundComboData[index].name);
\r
1710 MyLoadSound(&textAttribs[cc].sound);
\r
1714 ResetSoundComboData(soundComboData);
\r
1715 EndDialog(hDlg, TRUE);
\r
1719 ResetSoundComboData(soundComboData);
\r
1720 EndDialog(hDlg, FALSE);
\r
1723 case OPT_DefaultSounds:
\r
1724 /* can't use SetDefaultSounds() because we need to be able to "undo" if
\r
1725 * user selects "Cancel" later on. So we do it the hard way here.
\r
1727 scd = &soundComboData[0];
\r
1728 while (scd->label != NULL) {
\r
1729 if (scd->name != NULL) free(scd->name);
\r
1730 scd->name = strdup("");
\r
1733 free(soundComboData[(int)SoundBell].name);
\r
1734 soundComboData[(int)SoundBell].name = strdup(SOUND_BELL);
\r
1735 DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);
\r
1738 case OPT_PlaySound:
\r
1739 radio = SoundDialogWhichRadio(hDlg);
\r
1740 tmp.name = strdup(SoundDialogGetName(hDlg, radio));
\r
1742 MyLoadSound(&tmp);
\r
1743 MyPlaySound(&tmp);
\r
1744 if (tmp.data != NULL) free(tmp.data);
\r
1745 if (tmp.name != NULL) free(tmp.name);
\r
1748 case OPT_BrowseSound:
\r
1749 f = OpenFileDialog(hDlg, FALSE, NULL, "wav", SOUND_FILT,
\r
1750 "Browse for Sound File", NULL, NULL, buf);
\r
1753 SetDlgItemText(hDlg, OPT_WavFileName, buf);
\r
1758 radio = SoundDialogWhichRadio(hDlg);
\r
1759 SoundDialogSetEnables(hDlg, radio);
\r
1768 VOID SoundOptionsPopup(HWND hwnd)
\r
1772 lpProc = MakeProcInstance((FARPROC)SoundOptionsDialog, hInst);
\r
1773 DialogBox(hInst, MAKEINTRESOURCE(DLG_Sound), hwnd, (DLGPROC)lpProc);
\r
1774 FreeProcInstance(lpProc);
\r
1778 /*---------------------------------------------------------------------------*\
\r
1780 * Comm Port dialog functions
\r
1782 \*---------------------------------------------------------------------------*/
\r
1785 #define FLOW_NONE 0
\r
1786 #define FLOW_XOFF 1
\r
1787 #define FLOW_CTS 2
\r
1788 #define FLOW_DSR 3
\r
1792 ComboData cdPort[] = { {"None", PORT_NONE}, {"COM1", 1}, {"COM2", 2},
\r
1793 {"COM3", 3}, {"COM4", 4}, {NULL, 0} };
\r
1794 ComboData cdDataRate[] = { {"110", 110}, {"300", 300}, {"600", 600}, {"1200", 1200},
\r
1795 {"2400", 2400}, {"4800", 4800}, {"9600", 9600}, {"19200", 19200},
\r
1796 {"38400", 38400}, {NULL, 0} };
\r
1797 ComboData cdDataBits[] = { {"5", 5}, {"6", 6}, {"7", 7}, {"8", 8}, {NULL, 0} };
\r
1798 ComboData cdParity[] = { {"None", NOPARITY}, {"Odd", ODDPARITY}, {"Even", EVENPARITY},
\r
1799 {"Mark", MARKPARITY}, {"Space", SPACEPARITY}, {NULL, 0} };
\r
1800 ComboData cdStopBits[] = { {"1", ONESTOPBIT}, {"1.5", ONE5STOPBITS},
\r
1801 {"2", TWOSTOPBITS}, {NULL, 0} };
\r
1802 ComboData cdFlow[] = { {"None", FLOW_NONE}, {"Xoff/Xon", FLOW_XOFF}, {"CTS", FLOW_CTS},
\r
1803 {"DSR", FLOW_DSR}, {NULL, 0} };
\r
1807 ParseCommSettings(char *arg, DCB *dcb)
\r
1809 int dataRate, count;
\r
1810 char bits[MSG_SIZ], parity[MSG_SIZ], stopBits[MSG_SIZ], flow[MSG_SIZ];
\r
1812 count = sscanf(arg, "%d%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]%*[, ]%[^, ]",
\r
1813 &dataRate, bits, parity, stopBits, flow);
\r
1814 if (count != 5) goto cant_parse;
\r
1815 dcb->BaudRate = dataRate;
\r
1817 while (cd->label != NULL) {
\r
1818 if (StrCaseCmp(cd->label, bits) == 0) {
\r
1819 dcb->ByteSize = cd->value;
\r
1824 if (cd->label == NULL) goto cant_parse;
\r
1826 while (cd->label != NULL) {
\r
1827 if (StrCaseCmp(cd->label, parity) == 0) {
\r
1828 dcb->Parity = cd->value;
\r
1833 if (cd->label == NULL) goto cant_parse;
\r
1835 while (cd->label != NULL) {
\r
1836 if (StrCaseCmp(cd->label, stopBits) == 0) {
\r
1837 dcb->StopBits = cd->value;
\r
1843 if (cd->label == NULL) goto cant_parse;
\r
1844 while (cd->label != NULL) {
\r
1845 if (StrCaseCmp(cd->label, flow) == 0) {
\r
1846 switch (cd->value) {
\r
1848 dcb->fOutX = FALSE;
\r
1849 dcb->fOutxCtsFlow = FALSE;
\r
1850 dcb->fOutxDsrFlow = FALSE;
\r
1853 dcb->fOutX = FALSE;
\r
1854 dcb->fOutxCtsFlow = TRUE;
\r
1855 dcb->fOutxDsrFlow = FALSE;
\r
1858 dcb->fOutX = FALSE;
\r
1859 dcb->fOutxCtsFlow = FALSE;
\r
1860 dcb->fOutxDsrFlow = TRUE;
\r
1863 dcb->fOutX = TRUE;
\r
1864 dcb->fOutxCtsFlow = FALSE;
\r
1865 dcb->fOutxDsrFlow = FALSE;
\r
1872 if (cd->label == NULL) goto cant_parse;
\r
1875 ExitArgError("Can't parse com port settings", arg);
\r
1879 VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
\r
1881 char *flow = "??", *parity = "??", *stopBits = "??";
\r
1885 while (cd->label != NULL) {
\r
1886 if (dcb->Parity == cd->value) {
\r
1887 parity = cd->label;
\r
1893 while (cd->label != NULL) {
\r
1894 if (dcb->StopBits == cd->value) {
\r
1895 stopBits = cd->label;
\r
1901 flow = cdFlow[FLOW_XOFF].label;
\r
1902 } else if (dcb->fOutxCtsFlow) {
\r
1903 flow = cdFlow[FLOW_CTS].label;
\r
1904 } else if (dcb->fOutxDsrFlow) {
\r
1905 flow = cdFlow[FLOW_DSR].label;
\r
1907 flow = cdFlow[FLOW_NONE].label;
\r
1909 fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name,
\r
1910 dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow);
\r
1915 InitCombo(HANDLE hwndCombo, ComboData *cd)
\r
1917 SendMessage(hwndCombo, CB_RESETCONTENT, 0, 0);
\r
1919 while (cd->label != NULL) {
\r
1920 SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) cd->label);
\r
1926 SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value)
\r
1931 while (cd->label != NULL) {
\r
1932 if (cd->value == value) {
\r
1933 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) i, (LPARAM) 0);
\r
1942 CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
1944 char buf[MSG_SIZ];
\r
1951 switch (message) {
\r
1952 case WM_INITDIALOG: /* message: initialize dialog box */
\r
1953 /* Center the dialog over the application window */
\r
1954 CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER));
\r
1955 /* Initialize the dialog items */
\r
1956 /* !! There should probably be some synchronization
\r
1957 in accessing hCommPort and dcb. Or does modal nature
\r
1958 of this dialog box do it for us?
\r
1960 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
1961 InitCombo(hwndCombo, cdPort);
\r
1962 p = strrchr(appData.icsCommPort, '\\');
\r
1963 if (p++ == NULL) p = appData.icsCommPort;
\r
1964 if ((*p == '\0') ||
\r
1965 (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) p) == CB_ERR)) {
\r
1966 SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) "None");
\r
1968 EnableWindow(hwndCombo, hCommPort == NULL); /*!! don't allow change for now*/
\r
1970 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
1971 InitCombo(hwndCombo, cdDataRate);
\r
1972 sprintf(buf, "%u", dcb.BaudRate);
\r
1973 if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) {
\r
1974 SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);
\r
1975 SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf);
\r
1978 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
1979 InitCombo(hwndCombo, cdDataBits);
\r
1980 SelectComboValue(hwndCombo, cdDataBits, dcb.ByteSize);
\r
1982 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
1983 InitCombo(hwndCombo, cdParity);
\r
1984 SelectComboValue(hwndCombo, cdParity, dcb.Parity);
\r
1986 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
1987 InitCombo(hwndCombo, cdStopBits);
\r
1988 SelectComboValue(hwndCombo, cdStopBits, dcb.StopBits);
\r
1990 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
1991 InitCombo(hwndCombo, cdFlow);
\r
1993 SelectComboValue(hwndCombo, cdFlow, FLOW_XOFF);
\r
1994 } else if (dcb.fOutxCtsFlow) {
\r
1995 SelectComboValue(hwndCombo, cdFlow, FLOW_CTS);
\r
1996 } else if (dcb.fOutxDsrFlow) {
\r
1997 SelectComboValue(hwndCombo, cdFlow, FLOW_DSR);
\r
1999 SelectComboValue(hwndCombo, cdFlow, FLOW_NONE);
\r
2003 case WM_COMMAND: /* message: received a command */
\r
2004 switch (LOWORD(wParam)) {
\r
2006 /* Read changed options from the dialog box */
\r
2008 /* !! Currently we can't change comm ports in midstream */
\r
2009 hwndCombo = GetDlgItem(hDlg, OPT_Port);
\r
2010 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2011 if (index == PORT_NONE) {
\r
2012 appData.icsCommPort = "";
\r
2013 if (hCommPort != NULL) {
\r
2014 CloseHandle(hCommPort);
\r
2017 EndDialog(hDlg, TRUE);
\r
2020 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2021 appData.icsCommPort = strdup(buf);
\r
2022 if (hCommPort != NULL) {
\r
2023 CloseHandle(hCommPort);
\r
2026 /* now what?? can't really do this; have to fix up the ChildProc
\r
2027 and InputSource records for the comm port that we gave to the
\r
2031 hwndCombo = GetDlgItem(hDlg, OPT_DataRate);
\r
2032 SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);
\r
2033 if (sscanf(buf, "%u", &value) != 1) {
\r
2034 MessageBox(hDlg, "Invalid data rate",
\r
2035 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2038 dcb.BaudRate = value;
\r
2040 hwndCombo = GetDlgItem(hDlg, OPT_Bits);
\r
2041 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2042 dcb.ByteSize = cdDataBits[index].value;
\r
2044 hwndCombo = GetDlgItem(hDlg, OPT_Parity);
\r
2045 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2046 dcb.Parity = cdParity[index].value;
\r
2048 hwndCombo = GetDlgItem(hDlg, OPT_StopBits);
\r
2049 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2050 dcb.StopBits = cdStopBits[index].value;
\r
2052 hwndCombo = GetDlgItem(hDlg, OPT_Flow);
\r
2053 index = SendMessage(hwndCombo, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
\r
2054 switch (cdFlow[index].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
2072 dcb.fOutxCtsFlow = FALSE;
\r
2073 dcb.fOutxDsrFlow = FALSE;
\r
2076 if (!SetCommState(hCommPort, (LPDCB) &dcb)) {
\r
2077 err = GetLastError();
\r
2078 switch(MessageBox(hDlg,
\r
2079 "Failed to set comm port state;\r\ninvalid options?",
\r
2080 "Option Error", MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {
\r
2082 DisplayFatalError("Failed to set comm port state", err, 1);
\r
2083 exit(1); /*is it ok to do this from here?*/
\r
2089 EndDialog(hDlg, TRUE);
\r
2094 EndDialog(hDlg, TRUE);
\r
2098 EndDialog(hDlg, FALSE);
\r
2110 CommPortOptionsPopup(HWND hwnd)
\r
2112 FARPROC lpProc = MakeProcInstance((FARPROC)CommPortOptionsDialog, hInst);
\r
2113 DialogBox(hInst, MAKEINTRESOURCE(DLG_CommPort), hwnd, (DLGPROC) lpProc);
\r
2114 FreeProcInstance(lpProc);
\r
2117 /*---------------------------------------------------------------------------*\
\r
2119 * Load Options dialog functions
\r
2121 \*---------------------------------------------------------------------------*/
\r
2124 SetLoadOptionEnables(HWND hDlg)
\r
2128 state = IsDlgButtonChecked(hDlg, OPT_Autostep);
\r
2129 EnableWindow(GetDlgItem(hDlg, OPT_ASTimeDelay), state);
\r
2130 EnableWindow(GetDlgItem(hDlg, OPT_AStext1), state);
\r
2134 LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2136 char buf[MSG_SIZ];
\r
2139 switch (message) {
\r
2140 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2141 /* Center the dialog over the application window */
\r
2142 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2143 /* Initialize the dialog items */
\r
2144 if (appData.timeDelay >= 0.0) {
\r
2145 CheckDlgButton(hDlg, OPT_Autostep, TRUE);
\r
2146 sprintf(buf, "%.2g", appData.timeDelay);
\r
2147 SetDlgItemText(hDlg, OPT_ASTimeDelay, buf);
\r
2149 CheckDlgButton(hDlg, OPT_Autostep, FALSE);
\r
2151 SetLoadOptionEnables(hDlg);
\r
2154 case WM_COMMAND: /* message: received a command */
\r
2155 switch (LOWORD(wParam)) {
\r
2157 /* Read changed options from the dialog box */
\r
2158 if (IsDlgButtonChecked(hDlg, OPT_Autostep)) {
\r
2159 GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ);
\r
2160 if (sscanf(buf, "%f", &fnumber) != 1) {
\r
2161 MessageBox(hDlg, "Invalid load game step rate",
\r
2162 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2165 appData.timeDelay = fnumber;
\r
2167 appData.timeDelay = (float) -1.0;
\r
2169 EndDialog(hDlg, TRUE);
\r
2173 EndDialog(hDlg, FALSE);
\r
2177 SetLoadOptionEnables(hDlg);
\r
2187 LoadOptionsPopup(HWND hwnd)
\r
2189 FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst);
\r
2190 DialogBox(hInst, MAKEINTRESOURCE(DLG_LoadOptions), hwnd, (DLGPROC) lpProc);
\r
2191 FreeProcInstance(lpProc);
\r
2194 /*---------------------------------------------------------------------------*\
\r
2196 * Save Options dialog functions
\r
2198 \*---------------------------------------------------------------------------*/
\r
2201 SetSaveOptionEnables(HWND hDlg)
\r
2205 state = IsDlgButtonChecked(hDlg, OPT_Autosave);
\r
2206 EnableWindow(GetDlgItem(hDlg, OPT_AVPrompt), state);
\r
2207 EnableWindow(GetDlgItem(hDlg, OPT_AVToFile), state);
\r
2208 if (state && !IsDlgButtonChecked(hDlg, OPT_AVPrompt) &&
\r
2209 !IsDlgButtonChecked(hDlg, OPT_AVToFile)) {
\r
2210 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2213 state = state && IsDlgButtonChecked(hDlg, OPT_AVToFile);
\r
2214 EnableWindow(GetDlgItem(hDlg, OPT_AVFilename), state);
\r
2215 EnableWindow(GetDlgItem(hDlg, OPT_AVBrowse), state);
\r
2219 SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2221 char buf[MSG_SIZ];
\r
2224 switch (message) {
\r
2225 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2226 /* Center the dialog over the application window */
\r
2227 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2228 /* Initialize the dialog items */
\r
2229 if (*appData.saveGameFile != NULLCHAR) {
\r
2230 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2231 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVToFile);
\r
2232 SetDlgItemText(hDlg, OPT_AVFilename, appData.saveGameFile);
\r
2233 } else if (appData.autoSaveGames) {
\r
2234 CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);
\r
2235 CheckRadioButton(hDlg, OPT_AVPrompt, OPT_AVToFile, OPT_AVPrompt);
\r
2237 CheckDlgButton(hDlg, OPT_Autosave, (UINT) FALSE);
\r
2239 if (appData.oldSaveStyle) {
\r
2240 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_Old);
\r
2242 CheckRadioButton(hDlg, OPT_PGN, OPT_Old, OPT_PGN);
\r
2244 CheckDlgButton( hDlg, OPT_OutOfBookInfo, appData.saveOutOfBookInfo );
2245 SetSaveOptionEnables(hDlg);
\r
2248 case WM_COMMAND: /* message: received a command */
\r
2249 switch (LOWORD(wParam)) {
\r
2251 /* Read changed options from the dialog box */
\r
2252 if (IsDlgButtonChecked(hDlg, OPT_Autosave)) {
\r
2253 appData.autoSaveGames = TRUE;
\r
2254 if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) {
\r
2255 appData.saveGameFile = "";
\r
2256 } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ {
\r
2257 GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ);
\r
2258 if (*buf == NULLCHAR) {
\r
2259 MessageBox(hDlg, "Invalid save game file name",
\r
2260 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2263 if ((isalpha(buf[0]) && buf[1] == ':') ||
\r
2264 (buf[0] == '\\' && buf[1] == '\\')) {
\r
2265 appData.saveGameFile = strdup(buf);
\r
2267 char buf2[MSG_SIZ], buf3[MSG_SIZ];
\r
2269 GetCurrentDirectory(MSG_SIZ, buf3);
\r
2270 SetCurrentDirectory(installDir);
\r
2271 if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {
\r
2272 appData.saveGameFile = strdup(buf2);
\r
2274 appData.saveGameFile = strdup(buf);
\r
2276 SetCurrentDirectory(buf3);
\r
2280 appData.autoSaveGames = FALSE;
\r
2281 appData.saveGameFile = "";
\r
2283 appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old);
\r
2284 appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo );
2285 EndDialog(hDlg, TRUE);
\r
2289 EndDialog(hDlg, FALSE);
\r
2292 case OPT_AVBrowse:
\r
2293 f = OpenFileDialog(hDlg, TRUE, NULL,
\r
2294 appData.oldSaveStyle ? "gam" : "pgn",
\r
2295 GAME_FILT, "Browse for Auto Save File",
\r
2299 SetDlgItemText(hDlg, OPT_AVFilename, buf);
\r
2304 SetSaveOptionEnables(hDlg);
\r
2313 SaveOptionsPopup(HWND hwnd)
\r
2315 FARPROC lpProc = MakeProcInstance((FARPROC)SaveOptionsDialog, hInst);
\r
2316 DialogBox(hInst, MAKEINTRESOURCE(DLG_SaveOptions), hwnd, (DLGPROC) lpProc);
\r
2317 FreeProcInstance(lpProc);
\r
2320 /*---------------------------------------------------------------------------*\
\r
2322 * Time Control Options dialog functions
\r
2324 \*---------------------------------------------------------------------------*/
\r
2327 SetTimeControlEnables(HWND hDlg)
\r
2331 state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves);
\r
2332 EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state);
\r
2333 EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state);
\r
2334 EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state);
\r
2335 EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state);
\r
2336 EnableWindow(GetDlgItem(hDlg, OPT_TCTime2), !state);
\r
2337 EnableWindow(GetDlgItem(hDlg, OPT_TCInc), !state);
\r
2338 EnableWindow(GetDlgItem(hDlg, OPT_TCitext1), !state);
\r
2339 EnableWindow(GetDlgItem(hDlg, OPT_TCitext2), !state);
\r
2340 EnableWindow(GetDlgItem(hDlg, OPT_TCitext3), !state);
\r
2345 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
2347 char buf[MSG_SIZ];
\r
2348 int mps, increment;
\r
2351 switch (message) {
\r
2352 case WM_INITDIALOG: /* message: initialize dialog box */
\r
2353 /* Center the dialog over the application window */
\r
2354 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
\r
2355 /* Initialize the dialog items */
\r
2356 if (appData.clockMode && !appData.icsActive) {
\r
2357 if (appData.timeIncrement == -1) {
\r
2358 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,
\r
2360 SetDlgItemText(hDlg, OPT_TCTime, appData.timeControl);
\r
2361 SetDlgItemInt(hDlg, OPT_TCMoves, appData.movesPerSession,
\r
2363 SetDlgItemText(hDlg, OPT_TCTime2, "");
\r
2364 SetDlgItemText(hDlg, OPT_TCInc, "");
\r
2366 CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,
\r
2368 SetDlgItemText(hDlg, OPT_TCTime, "");
\r
2369 SetDlgItemText(hDlg, OPT_TCMoves, "");
\r
2370 SetDlgItemText(hDlg, OPT_TCTime2, appData.timeControl);
\r
2371 SetDlgItemInt(hDlg, OPT_TCInc, appData.timeIncrement, FALSE);
\r
2373 SetTimeControlEnables(hDlg);
\r
2377 case WM_COMMAND: /* message: received a command */
\r
2378 switch (LOWORD(wParam)) {
\r
2380 /* Read changed options from the dialog box */
\r
2381 if (IsDlgButtonChecked(hDlg, OPT_TCUseMoves)) {
\r
2383 mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE);
\r
2384 if (!ok || mps <= 0) {
\r
2385 MessageBox(hDlg, "Invalid moves per time control",
\r
2386 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2389 GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ);
\r
2390 if (!ParseTimeControl(buf, increment, mps)) {
\r
2391 MessageBox(hDlg, "Invalid minutes per time control",
\r
2392 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2396 increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE);
\r
2397 mps = appData.movesPerSession;
\r
2398 if (!ok || increment < 0) {
\r
2399 MessageBox(hDlg, "Invalid increment",
\r
2400 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2403 GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ);
\r
2404 if (!ParseTimeControl(buf, increment, mps)) {
\r
2405 MessageBox(hDlg, "Invalid initial time",
\r
2406 "Option Error", MB_OK|MB_ICONEXCLAMATION);
\r
2410 appData.timeControl = strdup(buf);
\r
2411 appData.movesPerSession = mps;
\r
2412 appData.timeIncrement = increment;
\r
2413 Reset(TRUE, TRUE);
\r
2414 EndDialog(hDlg, TRUE);
\r
2418 EndDialog(hDlg, FALSE);
\r
2422 SetTimeControlEnables(hDlg);
\r
2431 TimeControlOptionsPopup(HWND hwnd)
\r
2433 if (gameMode != BeginningOfGame) {
\r
2434 DisplayError("Changing time control during a game is not implemented", 0);
\r
2436 FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst);
\r
2437 DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc);
\r
2438 FreeProcInstance(lpProc);
\r
2442 /*---------------------------------------------------------------------------*\
2444 * Engine Options Dialog functions
2446 \*---------------------------------------------------------------------------*/
2447 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))
2448 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))
2450 #define INT_ABS( n ) ((n) >= 0 ? (n) : -(n))
2452 LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
2455 case WM_INITDIALOG: /* message: initialize dialog box */
2457 /* Center the dialog over the application window */
2458 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
2460 /* Initialize the dialog items */
2461 CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates);
2462 CHECK_BOX(IDC_EpPonder, appData.ponderNextMove);
2463 CHECK_BOX(IDC_EpShowThinking, appData.showThinking);
2464 CHECK_BOX(IDC_EpHideThinkingHuman, appData.hideThinkingFromHuman);
2466 SetDlgItemInt( hDlg, IDC_EpDrawMoveCount, appData.adjudicateDrawMoves, TRUE );
2467 SendDlgItemMessage( hDlg, IDC_EpDrawMoveCount, EM_SETSEL, 0, -1 );
2469 SetDlgItemInt( hDlg, IDC_EpAdjudicationThreshold, INT_ABS(appData.adjudicateLossThreshold), TRUE );
2470 SendDlgItemMessage( hDlg, IDC_EpAdjudicationThreshold, EM_SETSEL, 0, -1 );
2474 case WM_COMMAND: /* message: received a command */
2475 switch (LOWORD(wParam)) {
2477 /* Read changed options from the dialog box */
2478 PeriodicUpdatesEvent( IS_CHECKED(IDC_EpPeriodicUpdates));
2479 PonderNextMoveEvent( IS_CHECKED(IDC_EpPonder));
2480 ShowThinkingEvent( IS_CHECKED(IDC_EpShowThinking));
2481 appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman);
2483 appData.adjudicateDrawMoves = GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, NULL, FALSE );
2484 appData.adjudicateLossThreshold = - (int) GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, NULL, FALSE );
2486 EndDialog(hDlg, TRUE);
2490 EndDialog(hDlg, FALSE);
2493 case IDC_EpDrawMoveCount:
2494 case IDC_EpAdjudicationThreshold:
2495 if( HIWORD(wParam) == EN_CHANGE ) {
2499 GetDlgItemInt(hDlg, IDC_EpDrawMoveCount, &n1_ok, FALSE );
2500 GetDlgItemInt(hDlg, IDC_EpAdjudicationThreshold, &n2_ok, FALSE );
2502 EnableWindow( GetDlgItem(hDlg, IDOK), n1_ok && n2_ok ? TRUE : FALSE );
2511 VOID EnginePlayOptionsPopup(HWND hwnd)
2515 lpProc = MakeProcInstance((FARPROC)EnginePlayOptionsDialog, hInst);
2516 DialogBox(hInst, MAKEINTRESOURCE(DLG_EnginePlayOptions), hwnd, (DLGPROC) lpProc);
2517 FreeProcInstance(lpProc);