X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=6c5d0eeab93d5c43af9a24d79920ee0cccaff1e8;hb=e833cd22af38d0042dd3e5e6ccf7914fb18cf767;hp=bbd8563add2b30379186c6d2f08094391ebfbb45;hpb=bf368bef696bee3555a370ac8ff88418e1f5c498;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index bbd8563..6c5d0ee 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -494,7 +494,7 @@ void ThawUI() DrawMenuBar(hwndMain); } -static int fromX = -1, fromY = -1, toX, toY; // [HGM] moved upstream, so JAWS can use them +/*static*/ int fromX = -1, fromY = -1, toX, toY; // [HGM] moved upstream, so JAWS can use them /* JAWS preparation patch (WinBoard for the sight impaired). Define required insertions as empty */ #ifdef JAWS @@ -1105,10 +1105,6 @@ ArgDescriptor argDescriptors[] = { { "autoraise", ArgTrue, (LPVOID) &appData.autoRaiseBoard, FALSE }, { "xautoraise", ArgFalse, (LPVOID) &appData.autoRaiseBoard, FALSE }, { "-autoraise", ArgFalse, (LPVOID) &appData.autoRaiseBoard, FALSE }, -#if 0 - { "cmailGameName", ArgString, (LPVOID) &appData.cmailGameName, FALSE }, - { "cmail", ArgString, (LPVOID) &appData.cmailGameName, FALSE }, -#endif { "alwaysPromoteToQueen", ArgBoolean, (LPVOID) &appData.alwaysPromoteToQueen, TRUE }, { "queen", ArgTrue, (LPVOID) &appData.alwaysPromoteToQueen, FALSE }, { "xqueen", ArgFalse, (LPVOID) &appData.alwaysPromoteToQueen, FALSE }, @@ -3040,57 +3036,10 @@ void CreatePiecesFromFont() /* Create bitmaps */ hfont_old = SelectObject( hdc, hPieceFont ); -#if 0 - CreatePieceMaskFromFont( hdc_window, hdc, PM_WP ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WN ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WB ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WR ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WQ ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WK ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BP ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BN ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BB ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BR ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BQ ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BK ); - - CreatePieceMaskFromFont( hdc_window, hdc, PM_WA ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WC ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WF ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WH ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WE ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WW ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WU ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WO ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WG ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WM ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WSG ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WV ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WAB ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WD ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WL ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_WS ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BA ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BC ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BF ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BH ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BE ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BW ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BU ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BO ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BG ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BM ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BSG ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BV ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BAB ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BD ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BL ); - CreatePieceMaskFromFont( hdc_window, hdc, PM_BS ); -#else for(i=(int)WhitePawn; i<(int)EmptySquare; i++) /* [HGM] made a loop for this */ if(PieceToChar((ChessSquare)i) != '.') /* skip unused pieces */ CreatePieceMaskFromFont( hdc_window, hdc, i ); -#endif + SelectObject( hdc, hfont_old ); fontBitmapSquareSize = squareSize; @@ -3886,35 +3835,13 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, 0x00B8074A); else BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A); -#if 0 - /* Use black piece color for outline of white pieces */ - /* Not sure this looks really good (though xboard does it). - Maybe better to have another selectable color, default black */ - SelectObject(hdc, blackPieceBrush); /* could have own brush */ - SelectObject(tmphdc, PieceBitmap(piece, OUTLINE_PIECE)); - BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A); -#else /* Use black for outline of white pieces */ SelectObject(tmphdc, PieceBitmap(piece, OUTLINE_PIECE)); if(appData.upsideDown && color==flipView) StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, SRCAND); else BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, SRCAND); -#endif } else { -#if 0 - /* Use white piece color for details of black pieces */ - /* Requires filled-in solid bitmaps (BLACK_PIECE class); the - WHITE_PIECE ones aren't always the right shape. */ - /* Not sure this looks really good (though xboard does it). - Maybe better to have another selectable color, default medium gray? */ - oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, BLACK_PIECE)); - oldBrush = SelectObject(hdc, whitePieceBrush); /* could have own brush */ - BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A); - SelectObject(tmphdc, PieceBitmap(piece, SOLID_PIECE)); - SelectObject(hdc, blackPieceBrush); - BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A); -#else /* Use square color for details of black pieces */ oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, SOLID_PIECE)); oldBrush = SelectObject(hdc, blackPieceBrush); @@ -3922,7 +3849,6 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, StretchBlt(hdc, x+tmpSize, y+tmpSize, -tmpSize, -tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, 0x00B8074A); else BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A); -#endif } SelectObject(hdc, oldBrush); SelectObject(tmphdc, oldBitmap); @@ -4459,17 +4385,6 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) fullrepaint = TRUE; } -#if 0 - if( fullrepaint ) { - static int repaint_count = 0; - char buf[128]; - - repaint_count++; - sprintf( buf, "FULL repaint: %d\n", repaint_count ); - OutputDebugString( buf ); - } -#endif - if (board == NULL) { if (!lastReqValid) { return; @@ -4499,35 +4414,6 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) releaseDC = FALSE; } -#if 0 - fprintf(debugFP, "*******************************\n" - "repaint = %s\n" - "dragInfo.from (%d,%d)\n" - "dragInfo.start (%d,%d)\n" - "dragInfo.pos (%d,%d)\n" - "dragInfo.lastpos (%d,%d)\n", - repaint ? "TRUE" : "FALSE", - dragInfo.from.x, dragInfo.from.y, - dragInfo.start.x, dragInfo.start.y, - dragInfo.pos.x, dragInfo.pos.y, - dragInfo.lastpos.x, dragInfo.lastpos.y); - fprintf(debugFP, "prev: "); - for (row = 0; row < BOARD_HEIGHT; row++) { - for (column = 0; column < BOARD_WIDTH; column++) { - fprintf(debugFP, "%d ", lastDrawn[row][column]); - } - } - fprintf(debugFP, "\n"); - fprintf(debugFP, "board: "); - for (row = 0; row < BOARD_HEIGHT; row++) { - for (column = 0; column < BOARD_WIDTH; column++) { - fprintf(debugFP, "%d ", board[row][column]); - } - } - fprintf(debugFP, "\n"); - fflush(debugFP); -#endif - /* Create some work-DCs */ hdcmem = CreateCompatibleDC(hdc); tmphdc = CreateCompatibleDC(hdc); @@ -4817,7 +4703,6 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) GetDIBits(tmphdc,bufferBitmap,0,b.bmHeight,pData,(BITMAPINFO*)&bih,DIB_RGB_COLORS); // fprintf(diagFile, "%8x\n", (int) pData); -#if 1 wb = b.bmWidthBytes; // count colors for(i=0; i>2; i++) { @@ -4865,7 +4750,6 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) // write bitmap data for(i=0; i UserMoveEvent requires two calls now, to make sure move is legal before showing promotion popup */ - moveType = UserMoveTest(fromX, fromY, toX, toY, NULLCHAR); + moveType = UserMoveTest(fromX, fromY, toX, toY, NULLCHAR, FALSE); if(moveType == AmbiguousMove) { /* [HGM] Edit-Position move executed */ fromX = fromY = -1; ClearHighlights(); DrawPosition(FALSE, boards[currentMove]); break; } else - if(moveType != ImpossibleMove) { - if(moveType == IllegalMove) { - ; - } else + if(moveType != ImpossibleMove && moveType != Comment) { /* [HGM] We use PromotionToKnight in Shogi to indicate frorced promotion */ if (moveType == WhitePromotionKnight || moveType == BlackPromotionKnight || ((moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && @@ -5155,9 +5036,11 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) DrawPosition(FALSE, boards[currentMove]); boards[currentMove][fromY][fromX] = p; // take back, but display stays boards[currentMove][toY][toX] = q; + DisplayMessage("Select piece from holdings", ""); } else PromotionPopup(hwnd); - } else { /* not a promotion */ + goto noClear; + } else { // not a promotion. Move can be illegal if testLegality off, and should be made then. if (appData.animate || appData.highlightLastMove) { SetHighlights(fromX, fromY, toX, toY); } else { @@ -5170,14 +5053,16 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } } fromX = fromY = -1; + noClear: break; } - if (gotPremove) { + if (gotPremove && moveType != Comment) { SetPremoveHighlights(fromX, fromY, toX, toY); - DrawPosition(forceFullRepaint || FALSE, NULL); +// DrawPosition(forceFullRepaint || FALSE, NULL); } else ClearHighlights(); fromX = fromY = -1; DrawPosition(forceFullRepaint || FALSE, NULL); + if(moveType != Comment) break; } /* First downclick, or restart on a square with same color piece */ if (!frozen && OKToStartUserMove(x, y)) { @@ -5225,7 +5110,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) toY = y; saveAnimate = appData.animate; /* sorry, Hawk :) */ appData.animate = appData.animate && !appData.animateDragging; - moveType = UserMoveTest(fromX, fromY, toX, toY, NULLCHAR); + moveType = UserMoveTest(fromX, fromY, toX, toY, NULLCHAR, TRUE); if(moveType == AmbiguousMove) { /* [HGM] Edit-Position move executed */ fromX = fromY = -1; ClearHighlights(); @@ -5253,6 +5138,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) boards[currentMove][fromY][fromX] = p; // take back, but display stays boards[currentMove][toY][toX] = q; appData.animate = saveAnimate; + DisplayMessage("Select piece from holdings", ""); break; } else PromotionPopup(hwnd); /* [HGM] Popup now calls FinishMove */ @@ -5354,16 +5240,6 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) else MenuPopup(hwnd, pt, LoadMenu(hInst, "WhitePieceMenu"), -1); } else { /* message == WM_RBUTTONDOWN */ -#if 0 - if (buttonCount == 3) { - if (wParam & MK_SHIFT) - MenuPopup(hwnd, pt, LoadMenu(hInst, "WhitePieceMenu"), -1); - else - MenuPopup(hwnd, pt, LoadMenu(hInst, "BlackPieceMenu"), -1); - } else { - MenuPopup(hwnd, pt, LoadMenu(hInst, "PieceMenu"), -1); - } -#else /* Just have one menu, on the right button. Windows users don't think to try the middle one, and sometimes other software steals it, or it doesn't really exist. */ @@ -5371,7 +5247,6 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) MenuPopup(hwnd, pt, LoadMenu(hInst, "PieceMenu"), -1); else MenuPopup(hwnd, pt, LoadMenu(hInst, "ShogiPieceMenu"), -1); -#endif } break; case IcsPlayingWhite: @@ -5696,11 +5571,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) nnew = RealizePalette(hdc); if (nnew > 0) { paletteChanged = TRUE; -#if 0 - UpdateColors(hdc); -#else - InvalidateRect(hwnd, &boardRect, FALSE);/*faster!*/ -#endif + InvalidateRect(hwnd, &boardRect, FALSE); } ReleaseDC(hwnd, hdc); } @@ -6737,13 +6608,6 @@ MyPlaySound(MySound *ms) /* Don't print an error: this can happen innocently if the sound driver is busy; for instance, if another instance of WinBoard is playing a sound at about the same time. */ -#if 0 - if (!ok) { - char buf[MSG_SIZ]; - sprintf(buf, "Error playing sound %s", ms->name); - DisplayError(buf, GetLastError()); - } -#endif return ok; } @@ -8241,8 +8105,25 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) static int sizeX, sizeY; int newSizeX, newSizeY; MINMAXINFO *mmi; + WORD wMask; switch (message) { + case WM_NOTIFY: + if (((NMHDR*)lParam)->code == EN_LINK) + { + ENLINK *pLink = (ENLINK*)lParam; + if (pLink->msg == WM_LBUTTONUP) + { + TEXTRANGE tr; + + tr.chrg = pLink->chrg; + tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin); + SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW); + free(tr.lpstrText); + } + } + break; case WM_INITDIALOG: /* message: initialize dialog box */ hwndConsole = hDlg; hText = GetDlgItem(hDlg, OPT_ConsoleText); @@ -8274,7 +8155,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) wp.rcNormalPosition.bottom = wpConsole.y + wpConsole.height; SetWindowPlacement(hDlg, &wp); } -#if 1 + // [HGM] Chessknight's change 2004-07-13 else { /* Determine Defaults */ WINDOWPLACEMENT wp; @@ -8293,7 +8174,12 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) wp.rcNormalPosition.bottom = wpConsole.y + wpConsole.height; SetWindowPlacement(hDlg, &wp); } -#endif + + // Allow hText to highlight URLs and send notifications on them + wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L); + SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK); + SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L); + return FALSE; case WM_SETFOCUS: @@ -9645,6 +9531,7 @@ CommentPopUp(char *title, char *str) { HWND hwnd = GetActiveWindow(); EitherCommentPopUp(0, title, str, FALSE); + SAY(str); SetActiveWindow(hwnd); } @@ -11008,15 +10895,6 @@ Tween(start, mid, finish, factor, frames, nFrames) void HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current ) { -#if 0 - char buf[256]; - - sprintf( buf, "HistorySet: first=%d, last=%d, current=%d (%s)\n", - first, last, current, current >= 0 ? movelist[current] : "n/a" ); - - OutputDebugString( buf ); -#endif - MoveHistorySet( movelist, first, last, current, pvInfoList ); EvalGraphSet( first, last, current, pvInfoList ); @@ -11024,14 +10902,5 @@ HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current ) void SetProgramStats( FrontEndProgramStats * stats ) { -#if 0 - char buf[1024]; - - sprintf( buf, "SetStats for %d: depth=%d, nodes=%lu, score=%5.2f, time=%5.2f, pv=%s\n", - stats->which, stats->depth, stats->nodes, stats->score / 100.0, stats->time / 100.0, stats->pv == 0 ? "n/a" : stats->pv ); - - OutputDebugString( buf ); -#endif - EngineOutputUpdate( stats ); }