Update wine to 1.2.
[sugaredwine.git] / patches / 0015-explorer-pack-buttons-based-on-text-size.patch
blob6ab1387bb3cbfe658b99594fefc54e68750aeae6
1 From c8f24ebc22ce872e72e665a5f74674f378209530 Mon Sep 17 00:00:00 2001
2 From: Vincent Povirk <vincent@codeweavers.com>
3 Date: Tue, 23 Sep 2008 16:59:33 -0500
4 Subject: [PATCH] explorer: pack buttons based on text size
6 ---
7 programs/explorer/taskbar.c | 42 ++++++++++++++++++++++++++++++++----------
8 1 files changed, 32 insertions(+), 10 deletions(-)
10 diff --git a/programs/explorer/taskbar.c b/programs/explorer/taskbar.c
11 index cae25a0..e5ee6be 100644
12 --- a/programs/explorer/taskbar.c
13 +++ b/programs/explorer/taskbar.c
14 @@ -26,8 +26,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(explorer);
16 #define MSG_APPBAR WM_USER
18 -#define TASKBAR_HEIGHT 25
20 static HWND taskbar_window;
21 static HWND systray_window;
22 static HWND tasklist_window;
23 @@ -36,9 +34,32 @@ static HWND startbutton;
24 static void taskbar_setpos(void)
26 APPBARDATA abd;
27 - RECT rc;
28 + RECT rc, start_rc;
29 + int height, startbutton_width;
30 + LOGFONTA lf;
31 + HFONT font, oldFont;
32 + HDC hdc;
34 + /* calculate size of start button */
35 + ZeroMemory(&lf, sizeof(lf));
36 + ZeroMemory(&start_rc, sizeof(start_rc));
37 + lf.lfHeight = -12;
38 + lf.lfWeight = FW_NORMAL;
39 + lf.lfPitchAndFamily = DEFAULT_PITCH|FF_SWISS;
40 + strcpy(lf.lfFaceName, "Arial");
41 + font = CreateFontIndirectA(&lf);
43 + hdc = GetDC(startbutton);
45 - /* TODO: Try to calculate the needed height */
46 + oldFont = SelectObject(hdc, font);
47 + DrawTextA(hdc, "Start", -1, &start_rc, DT_SINGLELINE|DT_CALCRECT);
48 + SelectObject(hdc, oldFont);
50 + DeleteObject(font);
52 + ReleaseDC(startbutton, hdc);
54 + height = 7 + max(GetSystemMetrics(SM_CYSMICON), start_rc.bottom);
56 /* ask for an acceptable rect */
57 ZeroMemory(&abd, sizeof(abd));
58 @@ -48,23 +69,24 @@ static void taskbar_setpos(void)
59 abd.rc.left = 0;
60 abd.rc.right = GetSystemMetrics(SM_CXSCREEN);
61 abd.rc.bottom = GetSystemMetrics(SM_CYSCREEN);
62 - abd.rc.top = abd.rc.bottom - TASKBAR_HEIGHT;
63 + abd.rc.top = abd.rc.bottom - height;
64 SHAppBarMessage(ABM_QUERYPOS, &abd);
66 /* actually reserve a rect that has the correct height if QUERYPOS moved the bottom */
67 - abd.rc.top = abd.rc.bottom - TASKBAR_HEIGHT;
68 + abd.rc.top = abd.rc.bottom - height;
69 SHAppBarMessage(ABM_SETPOS, &abd);
71 MoveWindow(taskbar_window, abd.rc.left, abd.rc.top, abd.rc.right-abd.rc.left, abd.rc.bottom-abd.rc.top, TRUE);
73 - /* FIXME: reposition start menu */
75 - /* right-align the systray */
76 + /* reposition subwindows */
77 GetWindowRect(systray_window, &rc);
79 SetWindowPos(systray_window, HWND_TOP, abd.rc.right - abd.rc.left - (rc.right - rc.left), 1, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
81 - MoveWindow(tasklist_window, 76, 1, abd.rc.right - abd.rc.left - (rc.right - rc.left) - 80, 24, TRUE);
82 + startbutton_width = 12 + start_rc.right + GetSystemMetrics(SM_CXSMICON);
83 + MoveWindow(startbutton, 0, 1, startbutton_width, height-1, TRUE);
85 + MoveWindow(tasklist_window, startbutton_width+2, 1, abd.rc.right - abd.rc.left - (rc.right - rc.left) - (startbutton_width+2), height-1, TRUE);
88 static LRESULT WINAPI taskbar_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
89 --
90 1.5.6.5