summaryrefslogtreecommitdiff
path: root/widgetfactory.cpp
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2020-10-01 15:26:49 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2020-10-01 18:17:40 +0200
commitfdb780a69d47d6438c0116a208afad2e94476e95 (patch)
treed0c77bd94ea06be4daca07fc2298a7149e1c50e1 /widgetfactory.cpp
parentc8a5d9cc2dedf3a8573659fa70b14f86e899bac4 (diff)
custom button rework
Diffstat (limited to 'widgetfactory.cpp')
-rw-r--r--widgetfactory.cpp54
1 files changed, 33 insertions, 21 deletions
diff --git a/widgetfactory.cpp b/widgetfactory.cpp
index 12c08d9..f26f64b 100644
--- a/widgetfactory.cpp
+++ b/widgetfactory.cpp
@@ -238,9 +238,9 @@ buttonPanelAttach(void *closure, HWND outerPanel)
ALF_AddLabel(panel, (WORD)-1, 4, 0, TEXT("native"));
ALF_AddLabel(panel, (WORD)-1, 0, 6, TEXT("layout dummy"));
- b = ALF_AddButton(panel, (WORD)-1, 2, 2, TEXT("Hello, World!"));
+ b = ALF_AddCustomButton(panel, (WORD)-1, 2, 2, TEXT("Hello, World!"), ALF_CustomButtonMeasureText, ALF_CustomButtonPaintText, NULL);
ALF_Layout_SetControlMinSize(panel, b, 0, 0);
- b = ALF_AddButton(panel, (WORD)-1, 2, 4, TEXT("Hello, World!"));
+ b = ALF_AddCustomButton(panel, (WORD)-1, 2, 4, TEXT("Hello, World!"), ALF_CustomButtonMeasureText, ALF_CustomButtonPaintText, NULL);
EnableWindow(b, FALSE);
ALF_Layout_SetControlMinSize(panel, b, 0, 0);
@@ -268,10 +268,10 @@ buttonPanelAttach(void *closure, HWND outerPanel)
ALF_AddControl(panel, 4, 2, hwndNb1, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG);
ALF_AddControl(panel, 4, 4, hwndNb2, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG);
- b = ALF_AddButton(panel, (WORD)-1, 4, 6, TEXT("Hello, World!"));
+ b = ALF_AddCustomButton(panel, (WORD)-1, 4, 6, TEXT("Hello, World!"), ALF_CustomButtonMeasureText, ALF_CustomButtonPaintText, NULL);
ALF_Layout_SetControlMinSize(panel, b, 0, 0);
- b = ALF_AddButton(panel, (WORD)-1, 2, 8, TEXT("Multiline\r\nButton"));
+ b = ALF_AddCustomButton(panel, (WORD)-1, 2, 8, TEXT("Multiline\r\nButton"), ALF_CustomButtonMeasureText, ALF_CustomButtonPaintText, NULL);
ALF_Layout_SetControlMinSize(panel, b, 0, 0);
HWND hwndNb3 = CreateWindowEx(0,
@@ -300,7 +300,7 @@ buttonPanelAttach(void *closure, HWND outerPanel)
panel = ALF_AddPanel(outerPanel, (WORD)-1, 0, 1);
- ALF_AddButton(panel, (WORD)-1, 2, 2, TEXT("Standard"));
+ ALF_AddCustomButton(panel, (WORD)-1, 2, 2, TEXT("Standard"), ALF_CustomButtonMeasureText, ALF_CustomButtonPaintText, NULL);
HWND hwndNb4 = CreateWindowEx(0,
TEXT("BUTTON"),
@@ -313,7 +313,7 @@ buttonPanelAttach(void *closure, HWND outerPanel)
NULL);
ALF_AddControl(panel, 4, 2, hwndNb4, 5625, 1725, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG);
- ALF_AddButton(panel, (WORD)-1, 2, 4, TEXT("Expanding"));
+ ALF_AddCustomButton(panel, (WORD)-1, 2, 4, TEXT("Expanding"), ALF_CustomButtonMeasureText, ALF_CustomButtonPaintText, NULL);
HWND hwndNb5 = CreateWindowEx(0,
TEXT("BUTTON"),
@@ -326,7 +326,7 @@ buttonPanelAttach(void *closure, HWND outerPanel)
NULL);
ALF_AddControl(panel, 4, 4, hwndNb5, 0, 0, ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_TRANSPARENTBG);
- ALF_AddButton(panel, (WORD)-1, 2, 6, TEXT("Expanding\r\nMultiline"));
+ ALF_AddCustomButton(panel, (WORD)-1, 2, 6, TEXT("Expanding\r\nMultiline"), ALF_CustomButtonMeasureText, ALF_CustomButtonPaintText, NULL);
HWND hwndNb6 = CreateWindowEx(0,
TEXT("BUTTON"),
@@ -352,6 +352,18 @@ buttonPanelAttach(void *closure, HWND outerPanel)
ALF_Panel_SetEdge(panel, BDR_RAISEDINNER);
+ panel = ALF_AddPanel(outerPanel, (WORD)-1, 0, 2);
+ ALF_Panel_SetEdge(panel, BDR_RAISEDINNER);
+
+ HICON winlogo = ALF_LoadIcon(NULL, IDI_WINLOGO, 64, 64);
+ // FIXME! memory leak here
+
+ b = ALF_AddCustomButton(panel, (WORD)-1, 0, 0, TEXT("WINLOGO"), ALF_CustomButtonMeasureIcon, ALF_CustomButtonPaintIcon, (void*)winlogo);
+ ALF_Layout_SetControlMinSize(panel, b, 0, 0);
+
+ ALF_Layout_SetColumnExpandNumerator(panel, 9, 1);
+ ALF_Layout_SetRowExpandNumerator(panel, 9, 1);
+
ALF_Layout_SetRowExpandNumerator(outerPanel, 1, 1);
@@ -627,7 +639,7 @@ checkboxPanelAttach(void *closure, HWND outerPanel)
{
(void)closure;
- HWND panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 1, 1, TEXT("ALF Checkbox"));
+ HWND panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 1, 1, TEXT("Checkbox 1"));
ALF_AddCheckbox(panel, (WORD)-1, 1, 2, TEXT("Some Checkbo&x with a very very really very very long text"));
@@ -646,10 +658,10 @@ checkboxPanelAttach(void *closure, HWND outerPanel)
ALF_Layout_SetColumnExpandNumerator(panel, 9, 1);
ALF_Layout_SetRowExpandNumerator(panel, 9, 1);
- panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 3, 1, TEXT("Nat&ive Checkbox"));
+ panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 3, 1, TEXT("Ch&eckbox 2"));
- ALF_AddNativeCheckbox(panel, (WORD)-1, 1, 1, TEXT("Native Checkbox &with long text"));
- HWND hwnd = ALF_AddNativeCheckbox(panel, (WORD)-1, 1, 3, TEXT("Native disabled Chec&kbox"));
+ ALF_AddCheckbox(panel, (WORD)-1, 1, 1, TEXT("Native Checkbox &with long text"));
+ HWND hwnd = ALF_AddCheckbox(panel, (WORD)-1, 1, 3, TEXT("Native disabled Chec&kbox"));
EnableWindow(hwnd, FALSE);
ALF_Layout_SetRowMinSize(panel, 2, 525);
@@ -657,7 +669,7 @@ checkboxPanelAttach(void *closure, HWND outerPanel)
ALF_Layout_SetColumnExpandNumerator(panel, 9, 1);
ALF_Layout_SetRowExpandNumerator(panel, 9, 1);
- panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 1, 3, TEXT("ALF Radio Button"));
+ panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 1, 3, TEXT("Radio 1"));
hwnd = ALF_AddRadioButton(panel, (WORD)-1, 1, 2, TEXT("Some R&adio button"));
ALF_AddRadioButton(panel, (WORD)-1, 1, 4, TEXT("Anot&her long One"));
@@ -672,12 +684,12 @@ checkboxPanelAttach(void *closure, HWND outerPanel)
ALF_Layout_SetColumnExpandNumerator(panel, 9, 1);
ALF_Layout_SetRowExpandNumerator(panel, 9, 1);
- panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 3, 3, TEXT("Native Radio"));
+ panel = ALF_AddGroupBox(outerPanel, (WORD)-1, 3, 3, TEXT("Radio 2"));
- hwnd = ALF_AddNativeRadioButton(panel, (WORD)-1, 1, 1, TEXT("Native Radio Butto&n with long text"));
+ hwnd = ALF_AddRadioButton(panel, (WORD)-1, 1, 1, TEXT("Native Radio Butto&n with long text"));
SendMessage(hwnd, BM_SETCHECK, BST_CHECKED, 0);
- ALF_AddNativeRadioButton(panel, (WORD)-1, 1, 3, TEXT("Native Radio B&utton #2"));
+ ALF_AddRadioButton(panel, (WORD)-1, 1, 3, TEXT("Native Radio B&utton #2"));
ALF_Layout_SetRowMinSize(panel, 2, 525);
ALF_Layout_SetRowMinSize(panel, 4, 525);
@@ -938,10 +950,10 @@ progressPanelAttach(void *closure, HWND panel)
ALF_Progress_SetRange(gauge, -50, 50);
ALF_AddNumericSpinBox(panel, ID_PROGRESS_SPINBOX, 1, 7, 12, -50, 50);
- ALF_AddNativeButton(panel, ID_PROGRESS_NORMAL, 1, 9, TEXT("Normal"));
- ALF_AddNativeButton(panel, ID_PROGRESS_PAUSED, 1, 11, TEXT("Paused"));
- ALF_AddNativeButton(panel, ID_PROGRESS_ERROR, 1, 13, TEXT("Error"));
- ALF_AddNativeButton(panel, ID_PROGRESS_INDETERMINATE, 1, 15, TEXT("Indeterminate"));
+ ALF_AddButton(panel, ID_PROGRESS_NORMAL, 1, 9, TEXT("Normal"));
+ ALF_AddButton(panel, ID_PROGRESS_PAUSED, 1, 11, TEXT("Paused"));
+ ALF_AddButton(panel, ID_PROGRESS_ERROR, 1, 13, TEXT("Error"));
+ ALF_AddButton(panel, ID_PROGRESS_INDETERMINATE, 1, 15, TEXT("Indeterminate"));
ALF_Layout_SetRowMinSize(panel, 0, 825);
ALF_Layout_SetRowMinSize(panel, 2, 825);
@@ -1268,8 +1280,8 @@ WinMain
addPaneToNotebook(hwndNtbk, PANE_SPINBOX);
addPaneToNotebook(hwndNtbk, PANE_PROGRESS);
- ALF_AddNativeButton(win, ID_HELLO, 1, 3, TEXT("&Hello World!"));
- ALF_AddNativeButton(win, (WORD)-1, 3, 3, TEXT("Goodbye, World"));
+ ALF_AddButton(win, ID_HELLO, 1, 3, TEXT("&Hello World!"));
+ ALF_AddButton(win, (WORD)-1, 3, 3, TEXT("Goodbye, World"));
ALF_Layout_SetRowMinSize(win, 2, 525);
ALF_Layout_SetRowMinSize(win, 0, 525);