diff options
author | Sebastian Geerken <devnull@localhost> | 2014-09-12 21:56:11 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-09-12 21:56:11 +0200 |
commit | 5e61a16c4ef0c64fd8cdbee2379bcee798dab518 (patch) | |
tree | b3616e8ae7359a1202b247302b366947f7c9c952 /dw | |
parent | ae2d990af432ea56375936e5ec9872fe0503d61f (diff) |
Table gets OOF aware, part 2. (Still crashing.)
Diffstat (limited to 'dw')
-rw-r--r-- | dw/oofawarewidget.cc | 23 | ||||
-rw-r--r-- | dw/oofawarewidget.hh | 21 | ||||
-rw-r--r-- | dw/table.cc | 27 |
3 files changed, 58 insertions, 13 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc index a71b3f0d..edecb12f 100644 --- a/dw/oofawarewidget.cc +++ b/dw/oofawarewidget.cc @@ -255,6 +255,29 @@ Widget *OOFAwareWidget::getWidgetOOFAtPoint (int x, int y, int level) return NULL; } + +int OOFAwareWidget::getAvailWidthOfChild (Widget *child, bool forceValue) +{ + if (isWidgetOOF(child)) { + assert (getWidgetOutOfFlowMgr(child) && + getWidgetOutOfFlowMgr(child)->dealingWithSizeOfChild (child)); + return getWidgetOutOfFlowMgr(child)->getAvailWidthOfChild (child, + forceValue); + } else + return Widget::getAvailWidthOfChild (child, forceValue); +} + +int OOFAwareWidget::getAvailHeightOfChild (Widget *child, bool forceValue) +{ + if (isWidgetOOF(child)) { + assert (getWidgetOutOfFlowMgr(child) && + getWidgetOutOfFlowMgr(child)->dealingWithSizeOfChild (child)); + return getWidgetOutOfFlowMgr(child)->getAvailHeightOfChild (child, + forceValue); + } else + return Widget::getAvailWidthOfChild (child, forceValue); +} + void OOFAwareWidget::borderChanged (int y, Widget *vloat) { assertNotReached (); diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh index 9421bae0..32de4868 100644 --- a/dw/oofawarewidget.hh +++ b/dw/oofawarewidget.hh @@ -31,9 +31,19 @@ namespace oof { * - dw::oof::OOFAwareWidget::getWidgetOOFAtPoint (from * dw::core::Widget::getWidgetAtPoint) * - * See dw::Textblock on how this is done best. For both generators and - * containers of floats (which is only implemented by dw::Textblock) - * it gets a bit more complicated. + * See dw::Textblock on how this is done best. + * + * Furthermore, implementations of dw::core::Widget::getAvailWidthOfChild + * and dw::core::Widget::getAvailHeightOfChild have to distinguish + * between widgets in flow and out of flow; see implementations of + * dw::oof::OOFAwareWidget. (Open issue: What about + * dw::core::Widget::correctRequisitionOfChild and + * dw::core::Widget::correctExtremesOfChild? Currently, all widgets + * are used the default implementation.) + * + * For both generators + * and containers of floats (which is only implemented by + * dw::Textblock) it gets a bit more complicated. */ class OOFAwareWidget: public core::Widget { @@ -104,10 +114,13 @@ protected: void drawOOF (core::View *view, core::Rectangle *area); core::Widget *getWidgetOOFAtPoint (int x, int y, int level); + static bool isOOFContainer (Widget *widget, int oofmIndex); + void notifySetAsTopLevel(); void notifySetParent(); - static bool isOOFContainer (Widget *widget, int oofmIndex); + int getAvailWidthOfChild (Widget *child, bool forceValue); + int getAvailHeightOfChild (Widget *child, bool forceValue); public: static int CLASS_ID; diff --git a/dw/table.cc b/dw/table.cc index a59c0120..899bfe89 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -229,15 +229,22 @@ int Table::getAvailWidthOfChild (Widget *child, bool forceValue) int width; - // Unlike other containers, the table widget sometimes narrows - // columns to a width less than specified by CSS (see - // forceCalcCellSizes). For this reason, the column widths have to - // be calculated in all cases. - if (forceValue) { - calcCellSizes (false); - width = calcAvailWidthForDescendant (child); - } else - width = -1; + if (isWidgetOOF(child)) { + assert (getWidgetOutOfFlowMgr(child) && + getWidgetOutOfFlowMgr(child)->dealingWithSizeOfChild (child)); + width = + getWidgetOutOfFlowMgr(child)->getAvailWidthOfChild (child, forceValue); + } else { + // Unlike other containers, the table widget sometimes narrows + // columns to a width less than specified by CSS (see + // forceCalcCellSizes). For this reason, the column widths have to + // be calculated in all cases. + if (forceValue) { + calcCellSizes (false); + width = calcAvailWidthForDescendant (child); + } else + width = -1; + } DBG_OBJ_MSGF ("resize", 1, "=> %d", width); DBG_OBJ_LEAVE (); @@ -479,6 +486,8 @@ void Table::addCell (Widget *widget, int colspan, int rowspan) curCol += colspanEff; + widget->parentRef = makeParentRefInFlow (0); + widget->setParent (this); if (rowStyle->get (curRow)) widget->setBgColor (rowStyle->get(curRow)->backgroundColor); |