X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=34c5cc3331ca8f71eac4cd872f6a1663a258332c;hb=53ef7482234709dc44856208bd6b9b14c4503b48;hp=5fda158df19302c1f1f4db892266a5f91c715d63;hpb=2249ff4080c7a199089e97b80539ad794ca6ba7c;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 5fda158..34c5cc3 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -5456,6 +5456,36 @@ LoadGameDialog(HWND hwnd, char* title) } } +void UpdateICSWidth(HWND hText) +{ + HDC hdc; + TEXTMETRIC tm; + RECT rc; + HFONT hfont, hold_font; + LONG old_width, new_width; + + // get the text metrics + hdc = GetDC(hText); + hfont = CreateFontIndirect(&font[boardSize][CONSOLE_FONT]->lf); + hold_font = SelectObject(hdc, hfont); + GetTextMetrics(hdc, &tm); + SelectObject(hdc, hold_font); + DeleteObject(hfont); + ReleaseDC(hText, hdc); + + // get the rectangle + SendMessage(hText, EM_GETRECT, 0, (LPARAM)&rc); + + // update the width + new_width = (rc.right-rc.left) / tm.tmAveCharWidth; + old_width = GetWindowLong(hText, GWL_USERDATA); + if (new_width != old_width) + { + ics_update_width(new_width); + SetWindowLong(hText, GWL_USERDATA, new_width); + } +} + VOID ChangedConsoleFont() { @@ -5495,6 +5525,7 @@ ChangedConsoleFont() paraf.dxOffset = WRAP_INDENT; SendMessage(hText, EM_SETPARAFORMAT, 0, (LPARAM) ¶f); SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)&sel); + UpdateICSWidth(hText); } /*---------------------------------------------------------------------------*\ @@ -8179,6 +8210,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L); SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK); SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L); + SetWindowLong(hText, GWL_USERDATA, 79); // initialize the text window's width return FALSE; @@ -8239,6 +8271,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return OnMoving( &sd, hDlg, wParam, lParam ); case WM_EXITSIZEMOVE: + UpdateICSWidth(hText); return OnExitSizeMove( &sd, hDlg, wParam, lParam ); } @@ -9509,6 +9542,11 @@ DrawPosition(int fullRedraw, Board board) HDCDrawPosition(NULL, (BOOLEAN) fullRedraw, board); } +void NotifyFrontendLogin() +{ + if (hwndConsole) + UpdateICSWidth(GetDlgItem(hwndConsole, OPT_ConsoleText)); +} VOID ResetFrontEnd()