* WinBoard.c -- Windows NT front end to XBoard\r
*\r
* Copyright 1991 by Digital Equipment Corporation, Maynard,\r
- * Massachusetts. \r
+ * Massachusetts.\r
*\r
* Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,\r
- * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.\r
+ * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.\r
*\r
* Enhancements Copyright 2005 Alessandro Scotti\r
*\r
#include "help.h"\r
#include "wsnap.h"\r
\r
+#define SLASH '/'\r
+#define DATADIR "~~"\r
+\r
//void InitEngineUCI( const char * iniDir, ChessProgramState * cps );\r
\r
int myrandom(void);\r
#if __GNUC__ && !defined(_winmajor)\r
#define oldDialog 0 /* cygwin doesn't define _winmajor; mingw does */\r
#else\r
+\r
+\r
+\r
#if defined(_winmajor)\r
#define oldDialog (_winmajor < 4)\r
#else\r
OPT_ChooseTellColor, OPT_ChooseChallengeColor, OPT_ChooseRequestColor,\r
OPT_ChooseSeekColor, OPT_ChooseNormalColor, OPT_ChooseBackgroundColor,\r
OPT_DefaultColors, OPT_DontColorize, IDC_Boxes, GPB_Colors, GPB_Premove,\r
- GPB_General, GPB_Alarm }, \r
+ GPB_General, GPB_Alarm, OPT_AutoCreate }, \r
{ DLG_BoardOptions, IDOK, IDCANCEL, OPT_SizeTiny, OPT_SizeTeeny, OPT_SizeDinky,\r
OPT_SizePetite, OPT_SizeSlim, OPT_SizeSmall, OPT_SizeMediocre, OPT_SizeMiddling,\r
OPT_SizeAverage, OPT_SizeModerate, OPT_SizeMedium, OPT_SizeBulky, OPT_SizeLarge,\r
\r
/* Set by InitInstance, used by EnsureOnScreen */\r
int screenHeight, screenWidth;\r
+RECT screenGeometry;\r
\r
void\r
EnsureOnScreen(int *x, int *y, int minX, int minY)\r
{\r
// int gap = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION);\r
/* Be sure window at (x,y) is not off screen (or even mostly off screen) */\r
- if (*x > screenWidth - 32) *x = 0;\r
- if (*y > screenHeight - 32) *y = 0;\r
- if (*x < minX) *x = minX;\r
- if (*y < minY) *y = minY;\r
+ if (*x > screenGeometry.right - 32) *x = screenGeometry.left;\r
+ if (*y > screenGeometry.bottom - 32) *y = screenGeometry.top;\r
+ if (*x < screenGeometry.left + minX) *x = screenGeometry.left + minX;\r
+ if (*y < screenGeometry.top + minY) *y = screenGeometry.top + minY;\r
}\r
\r
VOID\r
}\r
}\r
\r
+#ifndef SM_CXVIRTUALSCREEN\r
+#define SM_CXVIRTUALSCREEN 78\r
+#endif\r
+#ifndef SM_CYVIRTUALSCREEN\r
+#define SM_CYVIRTUALSCREEN 79\r
+#endif\r
+#ifndef SM_XVIRTUALSCREEN \r
+#define SM_XVIRTUALSCREEN 76\r
+#endif\r
+#ifndef SM_YVIRTUALSCREEN \r
+#define SM_YVIRTUALSCREEN 77\r
+#endif\r
+\r
+VOID\r
+InitGeometry()\r
+{\r
+ screenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);\r
+ if( !screenHeight ) screenHeight = GetSystemMetrics(SM_CYSCREEN);\r
+ screenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);\r
+ if( !screenWidth ) screenWidth = GetSystemMetrics(SM_CXSCREEN);\r
+ screenGeometry.left = GetSystemMetrics(SM_XVIRTUALSCREEN);\r
+ screenGeometry.top = GetSystemMetrics(SM_YVIRTUALSCREEN);\r
+ screenGeometry.right = screenGeometry.left + screenWidth;\r
+ screenGeometry.bottom = screenGeometry.top + screenHeight;\r
+}\r
+\r
BOOL\r
InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine)\r
{\r
\r
if (SearchPath(NULL, "WinBoard.exe", NULL, MSG_SIZ, installDir, &filepart)) {\r
*filepart = NULLCHAR;\r
+ SetCurrentDirectory(installDir);\r
} else {\r
GetCurrentDirectory(MSG_SIZ, installDir);\r
}\r
gameInfo.boardWidth = gameInfo.boardHeight = 8; // [HGM] won't have open window otherwise\r
- screenWidth = screenHeight = 1000; // [HGM] placement: kludge to allow calling EnsureOnScreen from InitAppData\r
+ InitGeometry();\r
InitAppData(lpCmdLine); /* Get run-time parameters */\r
/* xboard, and older WinBoards, controlled the move sound with the\r
appData.ringBellAfterMoves option. In the current WinBoard, we\r
iconBlack = LoadIcon(hInstance, "icon_black");\r
iconCurrent = iconWhite;\r
InitDrawingColors();\r
- screenHeight = GetSystemMetrics(SM_CYSCREEN);\r
- screenWidth = GetSystemMetrics(SM_CXSCREEN);\r
+\r
+ InitPosition(0); // to set nr of ranks and files, which might be non-default through command-line args\r
for (ibs = (int) NUM_SIZES - 1; ibs >= 0; ibs--) {\r
/* Compute window size for each board size, and use the largest\r
size that fits on this screen as the default. */\r
p = q + 1;\r
} else {\r
q = mfp->faceName;\r
+\r
while (*p && !isdigit(*p)) {\r
*q++ = *p++;\r
if (q - mfp->faceName >= sizeof(mfp->faceName))\r
\r
/* [HGM] call with -2 uses old size (for if nr of files, ranks changes) */\r
if(boardSize == (BoardSize)(-2) ) boardSize = oldBoardSize;\r
+ if(boardSize == -1) return; // no size defined yet; abort (to allow early call of InitPosition)\r
oldBoardSize = boardSize;\r
\r
if(boardSize != SizeMiddling && boardSize != SizePetite && boardSize != SizeBulky && !appData.useFont)\r
boardSize = SizeMiddling;\r
}\r
}\r
- if(!appData.useFont && boardSize == SizePetite && (v == VariantShogi || v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite\r
+ if(!appData.useFont && boardSize == SizePetite && (v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite\r
\r
oldRect.left = wpMain.x; //[HGM] placement: remember previous window params\r
oldRect.top = wpMain.y;\r
HDC tmphdc;\r
HBITMAP hbm;\r
static char oldBorder[MSG_SIZ];\r
- int w = 600, h = 600;\r
+ int w = 600, h = 600, mode;\r
\r
if(strcmp(appData.border, oldBorder)) { // load new one when old one no longer valid\r
strncpy(oldBorder, appData.border, MSG_SIZ-1);\r
w = bi.bmWidth;\r
h = bi.bmHeight;\r
}\r
+ mode = SetStretchBltMode(hdc, COLORONCOLOR);\r
StretchBlt(hdc, boardRect.left, boardRect.top, boardRect.right - boardRect.left, \r
boardRect.bottom - boardRect.top, tmphdc, 0, 0, w, h, SRCCOPY);\r
+ SetStretchBltMode(hdc, mode);\r
SelectObject(tmphdc, hbm);\r
DeleteDC(tmphdc);\r
}\r
}\r
\r
shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status\r
+ controlKey = GetKeyState(VK_CONTROL) < 0; // [HGM] remember last shift status\r
\r
switch (message) {\r
case WM_LBUTTONDOWN:\r
FILE *f;\r
UINT number;\r
char fileTitle[MSG_SIZ];\r
- char buf[MSG_SIZ];\r
static SnapData sd;\r
static int peek=0;\r
\r
}\r
break;\r
\r
+ case IDM_CreateBook:\r
+ CreateBookEvent();\r
+ break;\r
+\r
case IDM_CopyGame:\r
CopyGameToClipboard();\r
break;\r
InitTextures();\r
if(new) InitDrawingColors();\r
fontBitmapSquareSize = 0; // request creation of new font pieces\r
- InitDrawingSizes(-2, 0);\r
+ InitDrawingSizes(boardSize, 0);\r
InvalidateRect(hwndMain, NULL, TRUE);\r
}\r