diff options
Diffstat (limited to 'alf/alflayout.cpp')
| -rw-r--r-- | alf/alflayout.cpp | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/alf/alflayout.cpp b/alf/alflayout.cpp index 9c35b65..8035e74 100644 --- a/alf/alflayout.cpp +++ b/alf/alflayout.cpp @@ -278,9 +278,8 @@ ALF_Layout_CalcMinWidgetSize(ALFLayout *layout, ALFWidgetPriv *c, HWND window, S void ALF_Layout_CalcSizes(ALFLayout* layout, HWND window) { - SIZE containerMinSize = { 0, 0 }; - if (layout->calculateContainerMetrics) { - layout->calculateContainerMetrics(layout, window, &layout->containerMargins, &containerMinSize); + if (layout->beginCalcSizes) { + layout->beginCalcSizes(layout, window); } layout->biggestColumnNo = 0; @@ -317,16 +316,21 @@ ALF_Layout_CalcSizes(ALFLayout* layout, HWND window) int col = c->x; // TODO: skip spanning cells int row = c->y; - ALF_Layout_EnsureColumnExists(layout, col); - ALF_Layout_EnsureRowExists(layout, row); - SIZE qs = { 0, 0 }; ALF_Layout_CalcMinWidgetSize(layout, c, window, &qs); - if (qs.cx > layout->columns[col].calculatedMinWidth) - layout->columns[col].calculatedMinWidth = qs.cx; - if (qs.cy > layout->rows[row].calculatedMinWidth) - layout->rows[row].calculatedMinWidth = qs.cy; + if (col < 0 || row < 0) { + if (layout->handleContainerWidgetSize) + layout->handleContainerWidgetSize(layout, window, c->hwnd, &qs); + } else { + ALF_Layout_EnsureColumnExists(layout, col); + ALF_Layout_EnsureRowExists(layout, row); + + if (qs.cx > layout->columns[col].calculatedMinWidth) + layout->columns[col].calculatedMinWidth = qs.cx; + if (qs.cy > layout->rows[row].calculatedMinWidth) + layout->rows[row].calculatedMinWidth = qs.cy; + } } // TODO: second pass for spanning cells @@ -376,6 +380,10 @@ ALF_Layout_CalcSizes(ALFLayout* layout, HWND window) } } + SIZE containerMinSize = { 0,0 }; + if (layout->endCalcSizes) + layout->endCalcSizes(layout, window, &containerMinSize); + if (layout->totalMinWidth < containerMinSize.cx - layout->containerMargins.left - layout->containerMargins.right) layout->totalMinWidth = containerMinSize.cx - layout->containerMargins.left - layout->containerMargins.right; @@ -461,13 +469,18 @@ ALF_Layout_Apply(ALFLayout* layout, HWND window) int col = c->x; int row = c->y; if (col >= layout->nColumns || row >= layout->nRows) - continue; // FIXME! can that actually happen? + continue; // FIXME: wat? RECT r = { 0,0,0,0 }; - r.left = layout->columns[col].allocatedPosition; - r.right = r.left + layout->columns[col].allocatedWidth; - r.top = layout->rows[row].allocatedPosition; - r.bottom = r.top + layout->rows[row].allocatedWidth; + if (row < 0 || col < 0) { + if (layout->preApplyLayoutToContainerWidget) + layout->preApplyLayoutToContainerWidget(layout, window, c->hwnd, &r); + } else { + r.left = layout->columns[col].allocatedPosition; + r.right = r.left + layout->columns[col].allocatedWidth; + r.top = layout->rows[row].allocatedPosition; + r.bottom = r.top + layout->rows[row].allocatedWidth; + } if (c->flags & ALF_LAYOUT_CUSTOMPOS) { hdwp = (HDWP)SendMessage(c->hwnd, ALF_WM_APPLYSIZE, (WPARAM)hdwp, (LPARAM)&r); @@ -495,9 +508,9 @@ ALF_Layout_Apply(ALFLayout* layout, HWND window) } hdwp = DeferWindowPos(hdwp, - c->hwnd, 0, - r.left, r.top, r.right - r.left, r.bottom - r.top, - flags); + c->hwnd, 0, + r.left, r.top, r.right - r.left, r.bottom - r.top, + flags); } } |
