[PATCH] comctl32: statusbar: change the height expression to one that seems to be the same as in Windows
Mikołaj Zalewski
mikolaj at zalewski.pl
Thu Jul 17 10:33:08 CDT 2008
---
dlls/comctl32/status.c | 5 +++-
dlls/comctl32/tests/status.c | 50 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index 1b97b41..45615eb 100644
--- a/dlls/comctl32/status.c
+++ b/dlls/comctl32/status.c
@@ -94,6 +94,7 @@ typedef struct
#define HORZ_BORDER 0
#define VERT_BORDER 2
#define HORZ_GAP 2
+#define MIN_PANE_HEIGHT 18
static const WCHAR themeClass[] = { 'S','t','a','t','u','s',0 };
@@ -114,9 +115,11 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
HTHEME theme;
UINT height;
TEXTMETRICW tm;
+ int margin;
COMCTL32_GetFontMetrics(infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont, &tm);
- height = tm.tmHeight + 4 + infoPtr->verticalBorder;
+ margin = (tm.tmInternalLeading ? tm.tmInternalLeading : 2);
+ height = max(tm.tmHeight + margin + 2*GetSystemMetrics(SM_CYBORDER), MIN_PANE_HEIGHT) + infoPtr->verticalBorder;
if ((theme = GetWindowTheme(infoPtr->Self)))
{
diff --git a/dlls/comctl32/tests/status.c b/dlls/comctl32/tests/status.c
index b6c5b7b..d7a290a 100644
--- a/dlls/comctl32/tests/status.c
+++ b/dlls/comctl32/tests/status.c
@@ -106,12 +106,49 @@ static void test_create()
DestroyWindow(hwnd);
}
-static void test_setfont()
+static int CALLBACK check_height_font_enumproc(ENUMLOGFONTEX *enumlf, NEWTEXTMETRICEX *ntm, DWORD type, LPARAM lParam)
{
+ HDC hdc = GetDC(NULL);
+ HFONT hFont;
+ HWND hwndStatus = (HWND)lParam;
+ TEXTMETRIC tm;
+ HFONT hCtrlFont;
+ HFONT hOldFont;
+ RECT rcCtrl;
+
+ trace("Font %s, height: %d\n", enumlf->elfFullName, ntm->ntmTm.tmHeight);
+ hFont = CreateFontIndirect(&enumlf->elfLogFont);
+ hCtrlFont = (HFONT)SendMessage(hwndStatus, WM_SETFONT, (WPARAM)hFont, TRUE);
+ hOldFont = SelectObject(hdc, hFont);
+
+ GetClientRect(hwndStatus, &rcCtrl);
+ GetTextMetrics(hdc, &tm);
+ expect(max(tm.tmHeight + (tm.tmInternalLeading ? tm.tmInternalLeading : 2) + 4, 20), rcCtrl.bottom);
+
+ SelectObject(hdc, hOldFont);
+ SendMessage(hwndStatus, WM_SETFONT, (WPARAM)hCtrlFont, TRUE);
+ DeleteObject(hFont);
+ ReleaseDC(NULL, hdc);
+ return 1;
+}
+
+static int CALLBACK check_height_family_enumproc(ENUMLOGFONTEX *enumlf, NEWTEXTMETRICEX *ntm, DWORD type, LPARAM lParam)
+{
+ HDC hdc = GetDC(NULL);
+ enumlf->elfLogFont.lfHeight = 0;
+ EnumFontFamiliesEx(hdc, &enumlf->elfLogFont, (FONTENUMPROC)check_height_font_enumproc, lParam, 0);
+ ReleaseDC(NULL, hdc);
+ return 1;
+}
+
+static void test_height()
+{
+ LOGFONT lf;
HFONT hFont;
RECT rc1, rc2;
HWND hwndStatus = CreateWindow(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE,
0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL);
+ HDC hdc;
GetClientRect(hwndStatus, &rc1);
hFont = CreateFont(32, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
@@ -122,7 +159,7 @@ static void test_setfont()
ok(g_wmsize_count > 0, "WM_SETFONT should issue WM_SIZE\n");
GetClientRect(hwndStatus, &rc2);
- todo_wine expect_rect(0, 0, 672, 42, rc2);
+ todo_wine expect_rect(0, 0, 672, 42, rc2); /* GetTextMetrics returns invalid tmInternalLeading for this font */
g_wmsize_count = 0;
SendMessage(hwndStatus, WM_SETFONT, (WPARAM)hFont, TRUE);
@@ -131,6 +168,13 @@ static void test_setfont()
GetClientRect(hwndStatus, &rc2);
todo_wine expect_rect(0, 0, 672, 42, rc2);
+ /* test the height formula */
+ ZeroMemory(&lf, sizeof(lf));
+ SendMessage(hwndStatus, SB_SETMINHEIGHT, 0, 0);
+ hdc = GetDC(NULL);
+ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)check_height_family_enumproc, (LPARAM)hwndStatus, 0);
+ ReleaseDC(NULL, hdc);
+
DestroyWindow(hwndStatus);
DeleteObject(hFont);
}
@@ -294,5 +338,5 @@ START_TEST(status)
test_status_control();
test_create();
- test_setfont();
+ test_height();
}
--
1.5.4
--------------000700020807070208010306--
More information about the wine-patches
mailing list