From: <kr_...@us...> - 2003-08-24 18:45:46
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv11621/src/cbits/Win32 Modified Files: CheckBox.c RadioBox.c Log Message: Better implementation for *ReqSize* functions Index: CheckBox.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/CheckBox.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CheckBox.c 21 Aug 2003 17:34:01 -0000 1.4 --- CheckBox.c 24 Aug 2003 10:50:18 -0000 1.5 *************** *** 24,27 **** --- 24,28 ---- SIZE sz; TEXTMETRIC tm; + HFONT hOldFont; HDC hDC = GetDC(checkbox); int nLen = GetWindowTextLength(checkbox); *************** *** 29,39 **** nLen = GetWindowText(checkbox, buffer, nLen+1); GetTextExtentPoint32(hDC, buffer, nLen, &sz); GetTextMetrics(hDC, &tm); rfree(buffer); ReleaseDC(checkbox, hDC); ! res[0] = sz.cx + ((tm.tmHeight+tm.tmDescent)*3)/2; res[1] = tm.tmHeight+tm.tmDescent; }; --- 30,44 ---- nLen = GetWindowText(checkbox, buffer, nLen+1); + hOldFont = SelectObject(hDC, (HFONT) SendMessage(checkbox, WM_GETFONT, 0, 0)); + GetTextExtentPoint32(hDC, buffer, nLen, &sz); GetTextMetrics(hDC, &tm); + + SelectObject(hDC, hOldFont); rfree(buffer); ReleaseDC(checkbox, hDC); ! res[0] = sz.cx + 32; res[1] = tm.tmHeight+tm.tmDescent; }; Index: RadioBox.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/RadioBox.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RadioBox.c 21 Aug 2003 17:34:01 -0000 1.4 --- RadioBox.c 24 Aug 2003 10:50:18 -0000 1.5 *************** *** 5,11 **** WindowHandle osCreateRadioBox(WindowHandle window) { ! HWND hCheckBox; ! hCheckBox = CreateWindow( "BUTTON", NULL, --- 5,11 ---- WindowHandle osCreateRadioBox(WindowHandle window) { ! HWND hRadioBox; ! hRadioBox = CreateWindow( "BUTTON", NULL, *************** *** 17,22 **** NULL ); ! SetWindowLong(hCheckBox, GWL_USERDATA, (LONG) hCheckBox); ! return checkWindow(hCheckBox, "RADIOBOX"); }; --- 17,22 ---- NULL ); ! SetWindowLong(hRadioBox, GWL_USERDATA, (LONG) hRadioBox); ! return checkWindow(hRadioBox, "RADIOBOX"); }; *************** *** 25,28 **** --- 25,29 ---- SIZE sz; TEXTMETRIC tm; + HFONT hOldFont; HDC hDC = GetDC(radiobox); int nLen = GetWindowTextLength(radiobox); *************** *** 30,40 **** nLen = GetWindowText(radiobox, buffer, nLen+1); GetTextExtentPoint32(hDC, buffer, nLen, &sz); GetTextMetrics(hDC, &tm); rfree(buffer); ReleaseDC(radiobox, hDC); ! res[0] = sz.cx + ((tm.tmHeight+tm.tmDescent)*3)/2; res[1] = tm.tmHeight+tm.tmDescent; }; --- 31,45 ---- nLen = GetWindowText(radiobox, buffer, nLen+1); + hOldFont = SelectObject(hDC, (HFONT) SendMessage(radiobox, WM_GETFONT, 0, 0)); + GetTextExtentPoint32(hDC, buffer, nLen, &sz); GetTextMetrics(hDC, &tm); + + SelectObject(hDC, hOldFont); rfree(buffer); ReleaseDC(radiobox, hDC); ! res[0] = sz.cx + 32; res[1] = tm.tmHeight+tm.tmDescent; }; |