From: Eric Mullins Date: Sat, 10 Oct 2009 20:21:12 +0000 (-0600) Subject: Added width updates to ICS client on font and window size changes X-Git-Tag: v4.4.1.20091019~36 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ce931eec108e83cedc54f5f0ce28a19efb70e5bb;p=xboard.git Added width updates to ICS client on font and window size changes What still needs to be done is placing an update call after login to initialize with the correct width. I didn't see where to put that. --- diff --git a/winboard/winboard.c b/winboard/winboard.c index 5fda158..e6fcb8b 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -5456,6 +5456,29 @@ LoadGameDialog(HWND hwnd, char* title) } } +void UpdateICSWidth(HWND hText) +{ + HDC hdc; + TEXTMETRIC tm; + RECT rc; + HFONT hfont, hold_font; + + // 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 + ics_update_width((rc.right-rc.left) / tm.tmAveCharWidth); +} + VOID ChangedConsoleFont() { @@ -5495,6 +5518,7 @@ ChangedConsoleFont() paraf.dxOffset = WRAP_INDENT; SendMessage(hText, EM_SETPARAFORMAT, 0, (LPARAM) ¶f); SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)&sel); + UpdateICSWidth(hText); } /*---------------------------------------------------------------------------*\ @@ -8239,6 +8263,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 ); }