Move MarkMenuItem to xoptions.c
[xboard.git] / xboard.c
index 3b97fca..6bc77cc 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -275,8 +275,6 @@ int xtVersion = XtSpecificationRelease;
 int xScreen;
 Display *xDisplay;
 Window xBoardWindow;
-Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor,
-  highlightSquareColor, premoveHighlightColor;       // used in graphics
 Pixel lowTimeWarningColor, dialogColor, buttonColor; // used in widgets
 Pixmap iconPixmap, wIconPixmap, bIconPixmap, xMarkPixmap;
 Widget shellWidget, formWidget, boardWidget, titleWidget, dropMenu, menuBarWidget;
@@ -911,12 +909,6 @@ MakeColors ()
 {   // [HGM] taken out of main(), so it can be called from BoardOptions dialog
     int forceMono = False;
 
-    forceMono |= MakeOneColor(appData.lightSquareColor, &lightSquareColor);
-    forceMono |= MakeOneColor(appData.darkSquareColor, &darkSquareColor);
-    forceMono |= MakeOneColor(appData.whitePieceColor, &whitePieceColor);
-    forceMono |= MakeOneColor(appData.blackPieceColor, &blackPieceColor);
-    forceMono |= MakeOneColor(appData.highlightSquareColor, &highlightSquareColor);
-    forceMono |= MakeOneColor(appData.premoveHighlightColor, &premoveHighlightColor);
     if (appData.lowTimeWarning)
        forceMono |= MakeOneColor(appData.lowTimeWarningColor, &lowTimeWarningColor);
     if(appData.dialogColor[0]) MakeOneColor(appData.dialogColor, &dialogColor);
@@ -1261,6 +1253,8 @@ main (int argc, char **argv)
 #else
                                                clockFontStruct);
 #endif
+    InitDrawingHandle(optList + W_BOARD);
+    currBoard        = &optList[W_BOARD];
     boardWidget      = optList[W_BOARD].handle;
     menuBarWidget    = optList[W_MENU].handle;
     dropMenu         = optList[W_DROP].handle;
@@ -1315,12 +1309,13 @@ main (int argc, char **argv)
     XtGetValues(shellWidget, shellArgs, 2);
     shellArgs[4].value = shellArgs[2].value = w;
     shellArgs[5].value = shellArgs[3].value = h;
-    if(!CreateAnyPieces()) XtSetValues(shellWidget, &shellArgs[2], 4);
+//    XtSetValues(shellWidget, &shellArgs[2], 4);
     marginW =  w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
     marginH =  h - boardHeight;
 
     CatchDeleteWindow(shellWidget, "QuitProc");
 
+    CreateAnyPieces();
     CreateGrid();
 
     if(appData.logoSize)
@@ -1587,18 +1582,6 @@ ReadBitmap (Pixmap *pm, String name, unsigned char bits[], u_int wreq, u_int hre
 }
 
 void
-MarkMenuItem (char *menuRef, int state)
-{
-    MenuItem *item = MenuNameToItem(menuRef);
-
-    if(item) {
-       Arg args[2];
-       XtSetArg(args[0], XtNleftBitmap, state ? xMarkPixmap : None);
-       XtSetValues(item->handle, args, 1);
-    }
-}
-
-void
 EnableNamedMenuItem (char *menuRef, int state)
 {
     MenuItem *item = MenuNameToItem(menuRef);
@@ -1668,7 +1651,6 @@ SetupDropMenu ()
     }
 }
 
-
 static void
 do_flash_delay (unsigned long msec)
 {
@@ -1730,17 +1712,20 @@ CoDrag (Widget sh, WindowPlacement *wp)
 void
 ReSize (WindowPlacement *wp)
 {
-       int sqx, sqy;
+       int sqx, sqy, w, h;
        if(wp->width == wpMain.width && wp->height == wpMain.height) return; // not sized
        sqx = (wp->width  - lineGap - marginW) / BOARD_WIDTH - lineGap;
        sqy = (wp->height - lineGap - marginH) / BOARD_HEIGHT - lineGap;
        if(sqy < sqx) sqx = sqy;
        if(sqx != squareSize) {
            squareSize = sqx; // adopt new square size
-           NewSurfaces();
            CreatePNGPieces(); // make newly scaled pieces
            InitDrawingSizes(0, 0); // creates grid etc.
-       }
+       } else ResizeBoardWindow(BOARD_WIDTH * (squareSize + lineGap) + lineGap, BOARD_HEIGHT * (squareSize + lineGap) + lineGap, 0);
+       w = BOARD_WIDTH * (squareSize + lineGap) + lineGap;
+       h = BOARD_HEIGHT * (squareSize + lineGap) + lineGap;
+       if(optList[W_BOARD].max   > w) optList[W_BOARD].max = w;
+       if(optList[W_BOARD].value > h) optList[W_BOARD].value = h;
 }
 
 static XtIntervalId delayedDragID = 0;
@@ -1774,7 +1759,7 @@ DelayedDrag ()
 {
     if(delayedDragID) XtRemoveTimeOut(delayedDragID); // cancel pending
     delayedDragID =
-      XtAppAddTimeOut(appContext, 100, (XtTimerCallbackProc) DragProc, (XtPointer) 0); // and schedule new one 50 msec later
+      XtAppAddTimeOut(appContext, 200, (XtTimerCallbackProc) DragProc, (XtPointer) 0); // and schedule new one 50 msec later
 }
 
 void
@@ -1905,7 +1890,7 @@ ModeHighlight ()
     /* Maybe all the enables should be handled here, not just this one */
     EnableNamedMenuItem("Mode.Training", gameMode == Training || gameMode == PlayFromGameFile);
 
-    DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
+    DisplayLogos(&optList[W_WHITE-1], &optList[W_BLACK+1]);
 }
 
 
@@ -2553,7 +2538,7 @@ UpdateLogos (int displ)
     if(optList[W_WHITE-1].handle == NULL) return;
     LoadLogo(&first, 0, 0);
     LoadLogo(&second, 1, appData.icsActive);
-    if(displ) DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
+    if(displ) DisplayLogos(&optList[W_WHITE-1], &optList[W_BLACK+1]);
     return;
 }