diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-29 11:31:02 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-29 11:31:02 +0200 |
| commit | e40fa1cd91cff58be6e7c91273789eb838ebe611 (patch) | |
| tree | 478e8076407e66b50a4a323afd1cbe7ffd7d5978 /alf/alfpanel.cpp | |
| parent | ff2992cd89491957543667e91fa1fd4373c004d9 (diff) | |
widget factory: move to tabbed interface
Diffstat (limited to 'alf/alfpanel.cpp')
| -rw-r--r-- | alf/alfpanel.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/alf/alfpanel.cpp b/alf/alfpanel.cpp index 965264e..2f2ee68 100644 --- a/alf/alfpanel.cpp +++ b/alf/alfpanel.cpp @@ -21,21 +21,38 @@ ALF_Panel_ClearPriv(ALFPanelPriv *priv) } static void +ALF_Panel_InternalDefPaint(ALFPanelPriv *priv, HWND hwnd, HDC dc, RECT *r) +{ + if (priv->layout.bgcolor == ALF_COLOR_TRANSPARENT) { + ALF_Compat_DrawThemeParentBackground(hwnd, dc, r); + } else { + ALF_FillRect(dc, r, priv->layout.bgcolor); + } +} + + +void +ALF_Panel_DefPaint(HWND panel, HDC hDC, RECT *rcPaint) +{ + ALFPanelPriv *priv = (ALFPanelPriv*)GetWindowLongPtr(panel, 0); + ALF_Panel_InternalDefPaint(priv, panel, hDC, rcPaint); +} + +static void ALF_Panel_Paint(ALFPanelPriv *priv, HWND hwnd, HDC dc, RECT *r) { if (priv->vtbl && priv->vtbl->paint) { priv->vtbl->paint(priv->closure, hwnd, dc, r); - } else if (priv->layout.bgcolor == ALF_COLOR_TRANSPARENT) { - ALF_Compat_DrawThemeParentBackground(hwnd, dc, r); } else { - ALF_FillRect(dc, r, priv->layout.bgcolor); + ALF_Panel_InternalDefPaint(priv, hwnd, dc, r); } } void ALF_Panel_SetVTable(HWND panel, const ALFPanelVTable *vtbl, void *closure) { - SendMessage(panel, ALF_WM_PANEL_SETVTABLE, (WPARAM)vtbl, (LPARAM)closure); + ALFPanelSetVtblParams p = { vtbl, closure }; + SendMessage(panel, ALF_WM_PANEL_SETVTABLE, 0, (LPARAM)&p); } LRESULT @@ -43,11 +60,6 @@ ALF_Panel_DefWindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) { ALFPanelPriv *priv = (ALFPanelPriv *)GetWindowLongPtr(window, 0); - if (msg == WM_CREATE) { - if (priv->vtbl && priv->vtbl->create) - priv->vtbl->create(priv->closure, window); - } - if (msg == WM_DESTROY) { if (priv->vtbl && priv->vtbl->destroy) priv->vtbl->destroy(priv->closure, window); @@ -57,10 +69,6 @@ ALF_Panel_DefWindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) return TRUE; } - if (msg == WM_SETTEXT) { - InvalidateRect(window, NULL, TRUE); - } - if (msg == WM_PRINTCLIENT) { RECT r = { 0, 0, 0, 0 }; GetClientRect(window, &r); @@ -82,8 +90,15 @@ ALF_Panel_DefWindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) } if (msg == ALF_WM_PANEL_SETVTABLE) { - priv->vtbl = (const ALFPanelVTable *)wparam; - priv->closure = (void *)lparam; + const ALFPanelSetVtblParams *params = (const ALFPanelSetVtblParams *)lparam; + if (!params) + return FALSE; + + priv->vtbl = params->vtbl; + priv->closure = params->closure; + if (priv->vtbl->attachvtbl) { + priv->vtbl->attachvtbl(priv->closure, window); + } return TRUE; } |
