diff options
| -rw-r--r-- | alf/alfbutton.cpp | 22 | ||||
| -rw-r--r-- | widgetfactory.cpp | 92 |
2 files changed, 97 insertions, 17 deletions
diff --git a/alf/alfbutton.cpp b/alf/alfbutton.cpp index dcf0898..6721dc7 100644 --- a/alf/alfbutton.cpp +++ b/alf/alfbutton.cpp @@ -306,12 +306,13 @@ ALF_NtButton_RenderClassic(HWND hwnd, ALFNtButtonPriv *priv, HDC dc, RECT *rcPai DrawFrameControl(dc, &r, DFC_BUTTON, dfcs); - RECT textbounds = rcClient; + RECT textbounds = r; DrawTextW(dc, priv->text, -1, &textbounds, DT_LEFT | DT_CALCRECT); + textbounds.bottom++; // this appears to be the secret for correct vertical centering - RECT texttarget = rcClient; - texttarget.top += ((rcClient.bottom - rcClient.top) - (textbounds.bottom - textbounds.top)) / 2 - 1; - texttarget.left += ((rcClient.right - rcClient.left) - (textbounds.right - textbounds.left)) / 2; + RECT texttarget = r; + texttarget.top += (texttarget.bottom - texttarget.top - textbounds.bottom + textbounds.top) / 2; + texttarget.left += (texttarget.right - texttarget.left - textbounds.right + textbounds.left) / 2; texttarget.right = texttarget.left + (textbounds.right - textbounds.left); texttarget.bottom = texttarget.top + (textbounds.bottom - textbounds.top); @@ -694,7 +695,7 @@ ALF_NtButton_Create(HWND win, WORD id, int x, int y, const TCHAR *text) ALF_HINSTANCE, NULL); - ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_SENDDPICHANGE | ALF_LAYOUT_TRANSPARENTBG); + ALF_AddWidget(win, x, y, hwndButton, 5625, 1725, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_SENDDPICHANGE | ALF_LAYOUT_TRANSPARENTBG); return hwndButton; } @@ -777,12 +778,13 @@ ALF_ClassicButton_Paint(HWND hwnd, ALFClassicButtonPriv *priv, DRAWITEMSTRUCT *d DrawFrameControl(dis->hDC, &r, DFC_BUTTON, dfcs); - RECT textbounds = dis->rcItem; + RECT textbounds = r; DrawText(dis->hDC, textbuf, -1, &textbounds, DT_LEFT | DT_CALCRECT); + textbounds.bottom++; // this appears to be the secret for correct vertical centering - RECT texttarget = dis->rcItem; - texttarget.top += ((dis->rcItem.bottom - dis->rcItem.top) - (textbounds.bottom - textbounds.top)) / 2 - 1; - texttarget.left += ((dis->rcItem.right - dis->rcItem.left) - (textbounds.right - textbounds.left)) / 2; + RECT texttarget = r; + texttarget.top += (texttarget.bottom - texttarget.top - textbounds.bottom + textbounds.top) / 2; + texttarget.left += (texttarget.right - texttarget.left - textbounds.right + textbounds.left) / 2; texttarget.right = texttarget.left + (textbounds.right - textbounds.left); texttarget.bottom = texttarget.top + (textbounds.bottom - textbounds.top); @@ -874,7 +876,7 @@ ALF_ClassicButton_Create(HWND win, WORD id, int x, int y, const TCHAR *text) SetWindowLongPtr(hwndButton, GWLP_USERDATA, (LONG_PTR)priv); priv->origWndProc = (WNDPROC)SetWindowLongPtr(hwndButton, GWLP_WNDPROC, (LONG_PTR)ALF_ClassicButton_WndProc); - ALF_AddWidget(win, x, y, hwndButton, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT); + ALF_AddWidget(win, x, y, hwndButton, 5625, 1725, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT); return hwndButton; } diff --git a/widgetfactory.cpp b/widgetfactory.cpp index 2273806..3e8dceb 100644 --- a/widgetfactory.cpp +++ b/widgetfactory.cpp @@ -230,19 +230,27 @@ commonPanelDestroy(void *closure, HWND window) /* button panel */ static void -buttonPanelAttach(void *closure, HWND panel) +buttonPanelAttach(void *closure, HWND outerPanel) { (void)closure; + HWND b; + HWND panel; + + panel = ALF_AddPanel(outerPanel, (WORD)-1, 0, 0); + ALF_AddLabel(panel, (WORD)-1, 0, 2, TEXT("normal")); ALF_AddLabel(panel, (WORD)-1, 0, 4, TEXT("disabled")); ALF_AddLabel(panel, (WORD)-1, 2, 0, TEXT("ALF")); ALF_AddLabel(panel, (WORD)-1, 4, 0, TEXT("native")); ALF_AddLabel(panel, (WORD)-1, 0, 6, TEXT("layout dummy")); - ALF_AddButton(panel, ID_HELLO, 2, 2, TEXT("&Hello, World!")); - HWND bDisabled = ALF_AddButton(panel, (WORD)-1, 2, 4, TEXT("Hello, World!")); - EnableWindow(bDisabled, FALSE); + b = ALF_AddButton(panel, ID_HELLO, 2, 2, TEXT("&Hello, World!")); + ALF_SetWidgetLayoutMinSize(panel, b, 0, 0); + b = ALF_AddButton(panel, (WORD)-1, 2, 4, TEXT("Hello, World!")); + EnableWindow(b, FALSE); + ALF_SetWidgetLayoutMinSize(panel, b, 0, 0); + HWND hwndNb1 = CreateWindowEx(0, TEXT("BUTTON"), @@ -267,18 +275,88 @@ buttonPanelAttach(void *closure, HWND panel) ALF_AddWidget(panel, 4, 2, hwndNb1, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG); ALF_AddWidget(panel, 4, 4, hwndNb2, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG); - ALF_AddButton(panel, (WORD)-1, 4, 6, TEXT("Hello, World!")); + b = ALF_AddButton(panel, (WORD)-1, 4, 6, TEXT("Hello, World!")); + ALF_SetWidgetLayoutMinSize(panel, b, 0, 0); - ALF_AddButton(panel, (WORD)-1, 4, 8, TEXT("Multiline\r\nButton")); + b = ALF_AddButton(panel, (WORD)-1, 2, 8, TEXT("Multiline\r\nButton")); + ALF_SetWidgetLayoutMinSize(panel, b, 0, 0); + + HWND hwndNb3 = CreateWindowEx(0, + TEXT("BUTTON"), + TEXT("Multiline\r\nButton"), + WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, + 0, 0, 100, 100, + panel, + (HMENU)(WORD)-1, + (HINSTANCE)GetModuleHandle(NULL), + NULL); + + ALF_AddWidget(panel, 4, 8, hwndNb3, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG); ALF_LayoutSetRowMinSize(panel, 1, 825); ALF_LayoutSetRowMinSize(panel, 3, 825); ALF_LayoutSetRowMinSize(panel, 5, 825); ALF_LayoutSetRowMinSize(panel, 7, 825); + ALF_LayoutSetRowMinSize(panel, 9, 825); ALF_LayoutSetColumnMinSize(panel, 1, 825); ALF_LayoutSetColumnMinSize(panel, 3, 825); + ALF_LayoutSetColumnExpandNumerator(panel, 9, 1); - ALF_LayoutSetRowExpandNumerator(panel, 9, 1); + + panel = ALF_AddPanel(outerPanel, (WORD)-1, 0, 1); + + ALF_AddButton(panel, (WORD)-1, 2, 2, TEXT("Standard")); + + HWND hwndNb4 = CreateWindowEx(0, + TEXT("BUTTON"), + TEXT("Standard"), + WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON, + 0, 0, 100, 100, + panel, + (HMENU)(WORD)-1, + (HINSTANCE)GetModuleHandle(NULL), + NULL); + ALF_AddWidget(panel, 4, 2, hwndNb4, 5625, 1725, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG); + + ALF_AddButton(panel, (WORD)-1, 2, 4, TEXT("Expanding")); + + HWND hwndNb5 = CreateWindowEx(0, + TEXT("BUTTON"), + TEXT("Expanding"), + WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON, + 0, 0, 100, 100, + panel, + (HMENU)(WORD)-1, + (HINSTANCE)GetModuleHandle(NULL), + NULL); + ALF_AddWidget(panel, 4, 4, hwndNb5, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG); + + ALF_AddButton(panel, (WORD)-1, 2, 6, TEXT("Expanding\r\nMultiline")); + + HWND hwndNb6 = CreateWindowEx(0, + TEXT("BUTTON"), + TEXT("Expanding\r\nMultiline"), + WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON | BS_MULTILINE, + 0, 0, 100, 100, + panel, + (HMENU)(WORD)-1, + (HINSTANCE)GetModuleHandle(NULL), + NULL); + ALF_AddWidget(panel, 4, 6, hwndNb6, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG); + + ALF_LayoutSetRowMinSize(panel, 1, 825); + ALF_LayoutSetRowMinSize(panel, 3, 825); + ALF_LayoutSetRowMinSize(panel, 5, 825); + ALF_LayoutSetRowMinSize(panel, 7, 825); + ALF_LayoutSetColumnMinSize(panel, 1, 825); + ALF_LayoutSetColumnMinSize(panel, 3, 825); + + ALF_LayoutSetColumnExpandNumerator(panel, 9, 1); + ALF_LayoutSetRowExpandNumerator(panel, 4, 1); + ALF_LayoutSetRowExpandNumerator(panel, 6, 1); + + ALF_LayoutSetRowExpandNumerator(outerPanel, 1, 1); + // TODO: recreate old button box /*HWND panel = ALF_AddPanel(win, (WORD)-1, 1, 2); |
