diff options
Diffstat (limited to 'dw/oofawarewidget.hh')
-rw-r--r-- | dw/oofawarewidget.hh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh index 7121f9ea..9421bae0 100644 --- a/dw/oofawarewidget.hh +++ b/dw/oofawarewidget.hh @@ -14,6 +14,26 @@ namespace oof { * * (Perhaps it should be diffenciated between the two roles, container * and generator, but this would make multiple inheritance necessary.) + * + * A sub class should at least take care to call these methods at the + * respective points: + * + * - dw::oof::OOFAwareWidget::correctRequisitionByOOF (from + * dw::core::Widget::getExtremesImpl) + * - dw::oof::OOFAwareWidget::correctExtremesByOOF (from + * dw::core::Widget::sizeRequestImpl) + * - dw::oof::OOFAwareWidget::sizeAllocateStart + * - dw::oof::OOFAwareWidget::sizeAllocateEnd (latter two from + * dw::core::Widget::sizeAllocateImpl) + * - dw::oof::OOFAwareWidget::containerSizeChangedForChildrenOOF + * (from dw::core::Widget::containerSizeChangedForChildren) + * - dw::oof::OOFAwareWidget::drawOOF (from dw::core::Widget::draw) + * - 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. */ class OOFAwareWidget: public core::Widget { @@ -22,6 +42,39 @@ protected: enum { PARENT_REF_OOFM_BITS = 2, PARENT_REF_OOFM_MASK = (1 << PARENT_REF_OOFM_BITS) - 1 }; + inline bool isParentRefOOF (int parentRef) + { return parentRef != -1 && (parentRef & PARENT_REF_OOFM_MASK); } + + inline int makeParentRefInFlow (int inFlowSubRef) + { return (inFlowSubRef << PARENT_REF_OOFM_BITS); } + inline int getParentRefInFlowSubRef (int parentRef) + { assert (!isParentRefOOF (parentRef)); + return parentRef >> PARENT_REF_OOFM_BITS; } + + inline int makeParentRefOOF (int oofmIndex, int oofmSubRef) + { return (oofmSubRef << PARENT_REF_OOFM_BITS) | (oofmIndex + 1); } + inline int getParentRefOOFSubRef (int parentRef) + { assert (isParentRefOOF (parentRef)); + return parentRef >> PARENT_REF_OOFM_BITS; } + inline int getParentRefOOFIndex (int parentRef) + { assert (isParentRefOOF (parentRef)); + return (parentRef & PARENT_REF_OOFM_MASK) - 1; } + inline oof::OutOfFlowMgr *getParentRefOutOfFlowMgr (int parentRef) + { return outOfFlowMgr[getParentRefOOFIndex (parentRef)]; } + + inline bool isWidgetOOF (Widget *widget) + { return isParentRefOOF (widget->parentRef); } + + inline int getWidgetInFlowSubRef (Widget *widget) + { return getParentRefInFlowSubRef (widget->parentRef); } + + inline int getWidgetOOFSubRef (Widget *widget) + { return getParentRefOOFSubRef (widget->parentRef); } + inline int getWidgetOOFIndex (Widget *widget) + { return getParentRefOOFIndex (widget->parentRef); } + inline oof::OutOfFlowMgr *getWidgetOutOfFlowMgr (Widget *widget) + { return getParentRefOutOfFlowMgr (widget->parentRef); } + OOFAwareWidget *oofContainer[NUM_OOFM]; OutOfFlowMgr *outOfFlowMgr[NUM_OOFM]; @@ -43,8 +96,13 @@ protected: { return widget->getStyle()->position == core::style::POSITION_RELATIVE; } void initOutOfFlowMgrs (); + void correctRequisitionByOOF (core::Requisition *requisition); + void correctExtremesByOOF (core::Extremes *extremes); void sizeAllocateStart (core::Allocation *allocation); void sizeAllocateEnd (); + void containerSizeChangedForChildrenOOF (); + void drawOOF (core::View *view, core::Rectangle *area); + core::Widget *getWidgetOOFAtPoint (int x, int y, int level); void notifySetAsTopLevel(); void notifySetParent(); |