X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=e5df6db5ece130782ae3e1a773cc42ac17c143e2;hb=47b01ac7b7d35856fae5bef60de3255e8f0d4ae5;hp=1c41752fdb4f59b4bb47ebbf55a06378190f3ecc;hpb=f7324da94fc4494b39e66ba20e8d4d4d011fb73e;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 1c41752..e5df6db 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -187,6 +187,7 @@ Boolean alwaysOnTop = FALSE; RECT boardRect; COLORREF lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor, highlightSquareColor, premoveHighlightColor; +COLORREF markerColor[8] = { 0x00FFFF, 0x0000FF, 0x00FF00, 0xFF0000, 0xFFFF00, 0xFF00FF, 0xFFFFFF, 0x000000 }; HPALETTE hPal; ColorClass currentColorClass; @@ -197,7 +198,7 @@ static HBITMAP pieceBitmap[3][(int) BlackPawn]; /* [HGM] nr of bitmaps referred static HBRUSH lightSquareBrush, darkSquareBrush, blackSquareBrush, /* [HGM] for band between board and holdings */ explodeBrush, /* [HGM] atomic */ - markerBrush, /* [HGM] markers */ + markerBrush[8], /* [HGM] markers */ whitePieceBrush, blackPieceBrush, iconBkgndBrush /*, outlineBrush*/; static POINT gridEndpoints[(BOARD_RANKS + BOARD_FILES + 2) * 2]; static DWORD gridVertexCounts[BOARD_RANKS + BOARD_FILES + 2]; @@ -222,6 +223,7 @@ static struct { int x; int y; int mode; } backTextureSquareInfo[BOARD_RANKS][BOA #if __GNUC__ && !defined(_winmajor) #define oldDialog 0 /* cygwin doesn't define _winmajor; mingw does */ #else + #if defined(_winmajor) #define oldDialog (_winmajor < 4) #else @@ -1117,6 +1119,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) InitDrawingColors(); screenHeight = GetSystemMetrics(SM_CYSCREEN); screenWidth = GetSystemMetrics(SM_CXSCREEN); + InitPosition(0); // to set nr of ranks and files, which might be non-default through command-line args for (ibs = (int) NUM_SIZES - 1; ibs >= 0; ibs--) { /* Compute window size for each board size, and use the largest size that fits on this screen as the default. */ @@ -2162,6 +2165,7 @@ InsertInPalette(COLORREF color) VOID InitDrawingColors() { + int i; if (pLogPal == NULL) { /* Allocate enough memory for a logical palette with * PALETTESIZE entries and set the size and version fields @@ -2193,8 +2197,9 @@ InitDrawingColors() blackPieceBrush = CreateSolidBrush(blackPieceColor); iconBkgndBrush = CreateSolidBrush(GetSysColor(COLOR_BACKGROUND)); explodeBrush = CreateSolidBrush(highlightSquareColor); // [HGM] atomic - markerBrush = CreateSolidBrush(premoveHighlightColor); // [HGM] markers - /* [AS] Force rendering of the font-based pieces */ + for(i=0; i<8;i++) markerBrush[i] = CreateSolidBrush(markerColor[i]); // [HGM] markers + + /* [AS] Force rendering of the font-based pieces */ if( fontBitmapSquareSize > 0 ) { fontBitmapSquareSize = 0; } @@ -2259,6 +2264,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) /* [HGM] call with -2 uses old size (for if nr of files, ranks changes) */ if(boardSize == (BoardSize)(-2) ) boardSize = oldBoardSize; + if(boardSize == -1) return; // no size defined yet; abort (to allow early call of InitPosition) oldBoardSize = boardSize; if(boardSize != SizeMiddling && boardSize != SizePetite && boardSize != SizeBulky && !appData.useFont) @@ -2273,7 +2279,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) boardSize = SizeMiddling; } } - if(!appData.useFont && boardSize == SizePetite && (v == VariantShogi || v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite + if(!appData.useFont && boardSize == SizePetite && (v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite oldRect.left = wpMain.x; //[HGM] placement: remember previous window params oldRect.top = wpMain.y; @@ -3244,6 +3250,7 @@ BOOL HasHighlightInfo() } return result; + } BOOL IsDrawArrowEnabled() @@ -3435,6 +3442,7 @@ DrawBoardOnDC(HDC hdc, Board board, HDC tmphdc) DisplayHoldingsCount(hdc, x, y, flipView, (int) board[row][column]); else if( column == BOARD_RGHT) /* right align */ DisplayHoldingsCount(hdc, x, y, !flipView, (int) board[row][column]); + else if( piece == DarkSquare) DisplayHoldingsCount(hdc, x, y, 0, 0); else if (appData.monoMode) { if (piece == EmptySquare) { @@ -3617,7 +3625,7 @@ void DrawSeekDot(int x, int y, int color) { int square = color & 0x80; HBRUSH oldBrush = SelectObject(hdcSeek, - color == 0 ? markerBrush : color == 1 ? darkSquareBrush : explodeBrush); + color == 0 ? markerBrush[1] : color == 1 ? darkSquareBrush : explodeBrush); color &= 0x7F; if(square) Rectangle(hdcSeek, boardRect.left+x - squareSize/9, boardRect.top+y - squareSize/9, @@ -3910,8 +3918,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) for (row = 0; row < BOARD_HEIGHT; row++) { for (column = 0; column < BOARD_WIDTH; column++) { if (marker[row][column]) { // marker changes only occur with full repaint! - HBRUSH oldBrush = SelectObject(hdcmem, - marker[row][column] == 2 ? markerBrush : explodeBrush); + HBRUSH oldBrush = SelectObject(hdcmem, markerBrush[marker[row][column]-1]); SquareToPos(row, column, &x, &y); Ellipse(hdcmem, x + squareSize/4, y + squareSize/4, x + 3*squareSize/4, y + 3*squareSize/4); @@ -4297,7 +4304,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) dragInfo.pos = pt; } if (appData.highlightDragging) { - SetHighlights(fromX, fromY, x, y); + HoverEvent(highlightInfo.sq[1].x, highlightInfo.sq[1].y, x, y); if( IsDrawArrowEnabled() && (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) ) { full_repaint = TRUE; } @@ -4755,6 +4762,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) nnew = RealizePalette(hdc); if (nnew > 0) { paletteChanged = TRUE; + InvalidateRect(hwnd, &boardRect, FALSE); } ReleaseDC(hwnd, hdc); @@ -10033,6 +10041,6 @@ ActivateTheme (int new) InitTextures(); if(new) InitDrawingColors(); fontBitmapSquareSize = 0; // request creation of new font pieces - InitDrawingSizes(-2, 0); + InitDrawingSizes(boardSize, 0); InvalidateRect(hwndMain, NULL, TRUE); }