Changes to allow fonts with any charset (such as terminal)
[xboard.git] / winboard / woptions.c
old mode 100644 (file)
new mode 100755 (executable)
index cd0b029..aaab83b
@@ -1,9 +1,10 @@
 /*
  * woptions.c -- Options dialog box routines for WinBoard
- * $Id: woptions.c,v 2.1 2003/10/27 19:21:02 mann Exp $
  *
  * Copyright 2000,2009 Free Software Foundation, Inc.
  *
+ * Enhancements Copyright 2005 Alessandro Scotti
+ *
  * ------------------------------------------------------------------------
  *
  * GNU XBoard is free software: you can redistribute it and/or modify
@@ -63,6 +64,7 @@ extern HWND hwndConsole;
 extern char *defaultTextAttribs[];
 extern HWND commentDialog;
 extern HWND moveHistoryDialog;
+extern HWND engineOutputDialog;
 extern char installDir[];
 extern HWND hCommPort;    /* currently open comm port */
 extern DCB dcb;
@@ -221,12 +223,8 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN);
       appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);
       appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory);
-#if 0
-      ShowThinkingEvent(             IS_CHECKED(OPT_ShowThinking));
-#else
       appData.showThinking         = IS_CHECKED(OPT_ShowThinking);
       ShowThinkingEvent(); // [HGM] thinking: tests four options
-#endif
       appData.testLegality         = IS_CHECKED(OPT_TestLegality);
       appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);
 
@@ -371,38 +369,16 @@ PaintSampleSquare(
       oldBrushPiece = SelectObject(hdcMem, brushPiece);
       BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, 
             hdcTemp, 0, 0, 0x00B8074A);
-#if 0
-      /* Use pieceDetailColor for outline of white pieces */
-      SelectObject(hdcTemp, pieces[OUTLINE]);
-      SelectObject(hdcMem, brushPieceDetail);
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, 
-            hdcTemp, 0, 0, 0x00B8074A);
-#else
       /* Use black for outline of white pieces */
       SelectObject(hdcTemp, pieces[OUTLINE]);
       BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, 
             hdcTemp, 0, 0, SRCAND);
-#endif
     } else {
-#if 0
-      /* Use pieceDetailColor for details of black pieces */
-      /* Requires filled-in solid bitmaps (BLACK_PIECE class); the
-        WHITE_PIECE ones aren't always the right shape. */
-      oldBitmapTemp = SelectObject(hdcTemp, pieces[BLACK]);
-      oldBrushPiece = SelectObject(hdcMem, brushPieceDetail);
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, 
-            hdcTemp, 0, 0, 0x00B8074A);
-      SelectObject(hdcTemp, pieces[SOLID]);
-      SelectObject(hdcMem, brushPiece);
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, 
-            hdcTemp, 0, 0, 0x00B8074A);
-#else
       /* Use square color for details of black pieces */
       oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);
       oldBrushPiece = SelectObject(hdcMem, brushPiece);
       BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, 
             hdcTemp, 0, 0, 0x00B8074A);
-#endif
     }
     SelectObject(hdcMem, oldBrushPiece);
     SelectObject(hdcTemp, oldBitmapTemp);
@@ -795,7 +771,9 @@ VariantWhichRadio(HWND hDlg)
          (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle :
          (IsDlgButtonChecked(hDlg, OPT_Variant3Check) ? Variant3Check :
          (IsDlgButtonChecked(hDlg, OPT_VariantGreat) ? VariantGreat :
-          VariantNormal ))))))))))))))))))))))))));
+         (IsDlgButtonChecked(hDlg, OPT_VariantGiveaway) ? VariantGiveaway :
+         (IsDlgButtonChecked(hDlg, OPT_VariantTwilight) ? VariantTwilight :
+          VariantNormal ))))))))))))))))))))))))))));
 }
 
 LRESULT CALLBACK
@@ -885,9 +863,15 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     case VariantNoCastle:
       CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE);
       break;
-    case VariantGreat: // Note to self: must still make this button (and GiveAway too).
+    case VariantGreat:
       CheckDlgButton(hDlg, OPT_VariantGreat, TRUE);
       break;
+    case VariantGiveaway:
+      CheckDlgButton(hDlg, OPT_VariantGiveaway, TRUE);
+      break;
+    case VariantTwilight:
+      CheckDlgButton(hDlg, OPT_VariantTwilight, TRUE);
+      break;
     default: ;
     }
 
@@ -1026,6 +1010,7 @@ MyCreateFont(HWND hwnd, MyFont *font)
   font->mfp.italic = font->lf.lfItalic;
   font->mfp.underline = font->lf.lfUnderline;
   font->mfp.strikeout = font->lf.lfStrikeOut;
+  font->mfp.charset = font->lf.lfCharSet;
   strcpy(font->mfp.faceName, font->lf.lfFaceName);
   return TRUE;
 }
@@ -1037,7 +1022,7 @@ UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
   CHARFORMAT cf;
   cf.cbSize = sizeof(CHARFORMAT);
   cf.dwMask = 
-    CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;
+    CFM_COLOR|CFM_CHARSET|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;
   cf.crTextColor = mca->color;
   cf.dwEffects = mca->effects;
   strcpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName);
@@ -1281,7 +1266,9 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       appData.colorize =
        (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize);
 
-      if (!appData.colorize) {
+    ChangedConsoleFont();\r
+\r
+    if (!appData.colorize) {
        CHARFORMAT cf;
        COLORREF background = ParseColorName(COLOR_BKGD);
        /*
@@ -1291,7 +1278,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        cf.cbSize = sizeof(CHARFORMAT);
        cf.dwMask = CFM_COLOR;
        cf.crTextColor = ParseColorName(COLOR_NORMAL);
-
+\r
        SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, 
          EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
         SendDlgItemMessage(hwndConsole, OPT_ConsoleText, 
@@ -1480,21 +1467,6 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
   rectFormat.left   = center.x - (size.cx / 2) - 1;
   rectFormat.right  = center.x + (size.cx / 2) + 1;
 
-#if 0
-  fprintf(debugFP, "\nfont: %s\n"
-                   "center.x   %d, centerY %d\n"
-                  "size.cx    %d, size.cy %d\n"
-                  "client.top %d, bottom %d, left %d, right %d\n"
-                  "format.top %d, bottom %d, left %d, right %d\n",
-                  buf,
-                  center.x, center.y,
-                  size.cx, size.cy,
-                  rectClient.top, rectClient.bottom, rectClient.left,
-                  rectClient.right,
-                  rectFormat.top, rectFormat.bottom, rectFormat.left,
-                  rectFormat.right);
-#endif
-
   cf.cbSize = sizeof(CHARFORMAT);
   cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC;
   cf.dwEffects = 0;
@@ -1526,6 +1498,7 @@ CopyFont(MyFont *dest, const MyFont *src)
   dest->mfp.italic    = src->mfp.italic;
   dest->mfp.underline = src->mfp.underline;
   dest->mfp.strikeout = src->mfp.strikeout;
+  dest->mfp.charset   = src->mfp.charset;
   lstrcpy(dest->mfp.faceName, src->mfp.faceName);
   CreateFontInMF(dest);
 }
@@ -1626,7 +1599,17 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory,
          WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, 
          MAKELPARAM(TRUE, 0));
-       InvalidateRect(editTagsDialog, NULL, TRUE);
+        SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 );
+//     InvalidateRect(editTagsDialog, NULL, TRUE); // [HGM] this ws improperly cloned?
+      }
+
+      if( engineOutputDialog != NULL ) {
+       SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1,
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, 
+         MAKELPARAM(TRUE, 0));
+       SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo2,
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, 
+         MAKELPARAM(TRUE, 0));
       }
 
       if (hwndConsole) {
@@ -1898,6 +1881,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   SoundClass sc;
   ColorClass cc;
   SoundComboData *scd;
+  int oldMute;
 
   switch (message) {
   case WM_INITDIALOG:
@@ -1978,6 +1962,8 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        }
       }
 
+       mute = FALSE; // [HGM] mute: switch sounds automatically on if we select one
+      CheckMenuItem(GetMenu(hwndMain),IDM_MuteSounds,MF_BYCOMMAND|MF_UNCHECKED);
       ResetSoundComboData(soundComboData);
       EndDialog(hDlg, TRUE);
       return TRUE;
@@ -2007,7 +1993,9 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       tmp.name = strdup(SoundDialogGetName(hDlg, radio));
       tmp.data = NULL;
       MyLoadSound(&tmp);
+       oldMute = mute; mute = FALSE; // [HGM] mute: always sound when user presses play, ignorig mute setting
       MyPlaySound(&tmp);
+       mute = oldMute;
       if (tmp.data  != NULL) FreeResource(tmp.data); // technically obsolete fn, but tmp.data is NOT malloc'd mem
       if (tmp.name != NULL) free(tmp.name);
       return TRUE;
@@ -2770,12 +2758,8 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,
       PeriodicUpdatesEvent(          IS_CHECKED(IDC_EpPeriodicUpdates));
       PonderNextMoveEvent(           IS_CHECKED(IDC_EpPonder));
       appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up
-#if 0
-      ShowThinkingEvent(             IS_CHECKED(IDC_EpShowThinking));
-#else
       appData.showThinking   = IS_CHECKED(IDC_EpShowThinking);
       ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output
-#endif
       appData.testClaims    = IS_CHECKED(IDC_TestClaims);
       appData.checkMates    = IS_CHECKED(IDC_DetectMates);
       appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);