diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2019-01-06 21:32:15 +0100 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2019-01-06 21:32:15 +0100 |
| commit | 8543cc8ce9e25b807a950accbd34995572a8a2cc (patch) | |
| tree | 8b5be4915aaf10f1d58e07294a1bd45ab520dbed | |
| parent | 73ac4e4160eed3a564a9cc4128b16c49e94c06a7 (diff) | |
move some message handling code into layout
| -rw-r--r-- | alf/alf.cpp | 36 | ||||
| -rw-r--r-- | alf/alflayout.cpp | 41 | ||||
| -rw-r--r-- | alf/alflayout.h | 2 |
3 files changed, 47 insertions, 32 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp index f36dda3..0d50f4a 100644 --- a/alf/alf.cpp +++ b/alf/alf.cpp @@ -122,19 +122,6 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { ALFWindowPriv *priv = (ALFWindowPriv*)GetWindowLongPtr(hwnd, 0); - if (msg == ALF_WM_QUERYSIZE) { - ALF_Layout_CalcSizes(&priv->layout, hwnd); - SIZE *ps = (SIZE*)lparam; - ps->cx = priv->layout.totalMinWidth; - ps->cy = priv->layout.totalMinHeight; - return 0; - } - - if (msg == ALF_WM_APPLYLAYOUT) { - ALF_Layout_Apply(&priv->layout, hwnd); - return 0; - } - if (msg == ALF_WM_GETMODALRESULT) { return (LRESULT)priv->modalResult; } @@ -147,23 +134,6 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) return (LRESULT)ALF_CentipointsToPxPriv(priv, (int)wparam); } - if (msg == ALF_WM_ADDWIDGET) { - ALF_Layout_AddWidget(&priv->layout, hwnd, (ALFWidgetLayoutParams *)lparam); - return 0; - } - - if (msg == ALF_WM_GETLAYOUTPARAMS) { - return (LRESULT)ALF_Layout_GetWidgetParams(&priv->layout, (ALFWidgetLayoutParams *)lparam, (HWND)wparam); - } - - if (msg == ALF_WM_SETLAYOUTPARAMS) { - return (LRESULT)ALF_Layout_SetWidgetParams(&priv->layout, (const ALFWidgetLayoutParams *)lparam, (HWND)wparam); - } - - if (msg == ALF_WM_GETWIDGETATPOS) { - return (LRESULT)ALF_Layout_WidgetAtPos(&priv->layout, ((UINT*)lparam)[0], ((UINT*)lparam)[1]); - } - if (msg == ALF_WM_SETFOCUS) { priv->hwndFocus = (HWND)lparam; ALF_ApplyFocus(hwnd, priv, FALSE); @@ -224,7 +194,6 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) if (msg == WM_SIZE) { ALF_Layout_Apply(&priv->layout, hwnd); - return 0; } if (msg == WM_GETMINMAXINFO) { @@ -313,6 +282,11 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) return TRUE; } + LRESULT ret = 0; + if (ALF_Layout_HandleMessage(&priv->layout, hwnd, msg, wparam, lparam, &ret)) { + return ret; + } + return DefWindowProc(hwnd, msg, wparam, lparam); } diff --git a/alf/alflayout.cpp b/alf/alflayout.cpp index 7251ca6..5e207d8 100644 --- a/alf/alflayout.cpp +++ b/alf/alflayout.cpp @@ -315,3 +315,44 @@ ALF_Layout_WidgetAtPos(ALFLayout* layout, UINT x, UINT y) return NULL; } + +BOOL +ALF_Layout_HandleMessage(ALFLayout *layout, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *pRet) +{ + *pRet = 0; + + if (msg == ALF_WM_QUERYSIZE) { + ALF_Layout_CalcSizes(layout, hwnd); + SIZE *ps = (SIZE*)lparam; + ps->cx = layout->totalMinWidth; + ps->cy = layout->totalMinHeight; + return TRUE; + } + + if (msg == ALF_WM_APPLYLAYOUT) { + ALF_Layout_Apply(layout, hwnd); + return TRUE; + } + + if (msg == ALF_WM_ADDWIDGET) { + ALF_Layout_AddWidget(layout, hwnd, (ALFWidgetLayoutParams *)lparam); + return TRUE; + } + + if (msg == ALF_WM_GETLAYOUTPARAMS) { + *pRet = (LRESULT)ALF_Layout_GetWidgetParams(layout, (ALFWidgetLayoutParams *)lparam, (HWND)wparam); + return TRUE; + } + + if (msg == ALF_WM_SETLAYOUTPARAMS) { + *pRet = (LRESULT)ALF_Layout_SetWidgetParams(layout, (const ALFWidgetLayoutParams *)lparam, (HWND)wparam); + return TRUE; + } + + if (msg == ALF_WM_GETWIDGETATPOS) { + *pRet = (LRESULT)ALF_Layout_WidgetAtPos(layout, ((UINT*)lparam)[0], ((UINT*)lparam)[1]); + return TRUE; + } + + return FALSE; +} diff --git a/alf/alflayout.h b/alf/alflayout.h index 8772908..a9a766c 100644 --- a/alf/alflayout.h +++ b/alf/alflayout.h @@ -61,7 +61,7 @@ BOOL ALF_Layout_GetWidgetParams(ALFLayout *layout, ALFWidgetLayoutParams *params, HWND widget); BOOL -ALF_Layout_HandleMessage(ALFLayout *layout, HWND window, WPARAM wparam, LPARAM lparam); +ALF_Layout_HandleMessage(ALFLayout *layout, HWND window, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *ret); HWND ALF_Layout_WidgetAtPos(ALFLayout *layout, UINT x, UINT y); |
