diff options
author | Sebastian Geerken <devnull@localhost> | 2015-05-20 22:47:25 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-05-20 22:47:25 +0200 |
commit | bb6b9a5275d148782cb81811461d5063de38cb92 (patch) | |
tree | 04fdfdae48bb291c7c26a87d6044fd3c1ff122a7 | |
parent | 150606242d7da8d9c616e05bdf8a3e92de428c8a (diff) |
Size requisitions depending on positions (SRDOP): added method signatures.
-rw-r--r-- | doc/dw-size-request-pos.doc | 2 | ||||
-rw-r--r-- | dw/bullet.cc | 3 | ||||
-rw-r--r-- | dw/bullet.hh | 3 | ||||
-rw-r--r-- | dw/image.cc | 3 | ||||
-rw-r--r-- | dw/image.hh | 3 | ||||
-rw-r--r-- | dw/ruler.cc | 3 | ||||
-rw-r--r-- | dw/ruler.hh | 3 | ||||
-rw-r--r-- | dw/table.cc | 3 | ||||
-rw-r--r-- | dw/table.hh | 3 | ||||
-rw-r--r-- | dw/textblock.cc | 15 | ||||
-rw-r--r-- | dw/textblock.hh | 7 | ||||
-rw-r--r-- | dw/ui.cc | 3 | ||||
-rw-r--r-- | dw/ui.hh | 3 | ||||
-rw-r--r-- | dw/widget.cc | 11 | ||||
-rw-r--r-- | dw/widget.hh | 11 | ||||
-rw-r--r-- | test/dw_simple_container.cc | 3 | ||||
-rw-r--r-- | test/dw_simple_container.hh | 3 |
17 files changed, 61 insertions, 21 deletions
diff --git a/doc/dw-size-request-pos.doc b/doc/dw-size-request-pos.doc index c86c3d93..08af0eec 100644 --- a/doc/dw-size-request-pos.doc +++ b/doc/dw-size-request-pos.doc @@ -23,7 +23,7 @@ General Idea A widget size may depend on the position relative to an anchestor widget. If a widget wants to get the size of a child widget, it should -1. call the new method **dw::core::Widget::sizeRequestReference**, +1. call the new method dw::core::Widget::sizeRequestReference, which returns NULL, when the child's size does not depend on the position, or a widget relative to which the child's position must be calculated; diff --git a/dw/bullet.cc b/dw/bullet.cc index 98d90672..7fea82a1 100644 --- a/dw/bullet.cc +++ b/dw/bullet.cc @@ -35,7 +35,8 @@ Bullet::~Bullet () DBG_OBJ_DELETE (); } -void Bullet::sizeRequestImpl (core::Requisition *requisition) +void Bullet::sizeRequestImpl (core::Requisition *requisition, bool posDefined, + int x, int y) { requisition->width = lout::misc::max (getStyle()->font->xHeight * 4 / 5, 1); requisition->ascent = lout::misc::max (getStyle()->font->xHeight, 1); diff --git a/dw/bullet.hh b/dw/bullet.hh index e50fa0eb..66ca45f6 100644 --- a/dw/bullet.hh +++ b/dw/bullet.hh @@ -14,7 +14,8 @@ namespace dw { class Bullet: public core::Widget { protected: - void sizeRequestImpl (core::Requisition *requisition); + void sizeRequestImpl (core::Requisition *requisition, bool posDefined, int x, + int y); void getExtremesImpl (core::Extremes *extremes); void containerSizeChangedForChildren (); void draw (core::View *view, core::Rectangle *area, diff --git a/dw/image.cc b/dw/image.cc index 030d4882..2a164c7d 100644 --- a/dw/image.cc +++ b/dw/image.cc @@ -172,7 +172,8 @@ Image::~Image() DBG_OBJ_DELETE (); } -void Image::sizeRequestImpl (core::Requisition *requisition) +void Image::sizeRequestImpl (core::Requisition *requisition, bool posDefined, + int x, int y) { DBG_OBJ_ENTER0 ("resize", 0, "sizeRequestImpl"); diff --git a/dw/image.hh b/dw/image.hh index a46dd20a..c8752b22 100644 --- a/dw/image.hh +++ b/dw/image.hh @@ -130,7 +130,8 @@ private: bool isMap; protected: - void sizeRequestImpl (core::Requisition *requisition); + void sizeRequestImpl (core::Requisition *requisition, bool posDefined, int x, + int y); void getExtremesImpl (core::Extremes *extremes); void sizeAllocateImpl (core::Allocation *allocation); void containerSizeChangedForChildren (); diff --git a/dw/ruler.cc b/dw/ruler.cc index c34d8ecf..ac5644bb 100644 --- a/dw/ruler.cc +++ b/dw/ruler.cc @@ -39,7 +39,8 @@ Ruler::~Ruler () DBG_OBJ_DELETE (); } -void Ruler::sizeRequestImpl (core::Requisition *requisition) +void Ruler::sizeRequestImpl (core::Requisition *requisition, bool posDefined, + int x, int y) { requisition->width = lout::misc::max (getAvailWidth (true), boxDiffWidth ()); requisition->ascent = boxOffsetY (); diff --git a/dw/ruler.hh b/dw/ruler.hh index c90afccf..6b28ce8e 100644 --- a/dw/ruler.hh +++ b/dw/ruler.hh @@ -20,7 +20,8 @@ namespace dw { class Ruler: public RegardingBorder { protected: - void sizeRequestImpl (core::Requisition *requisition); + void sizeRequestImpl (core::Requisition *requisition, bool posDefined, int x, + int y); void getExtremesImpl (core::Extremes *extremes); void containerSizeChangedForChildren (); bool usesAvailWidth (); diff --git a/dw/table.cc b/dw/table.cc index 3e7d30df..460e9a29 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -103,7 +103,8 @@ Table::~Table() DBG_OBJ_DELETE (); } -void Table::sizeRequestImpl (core::Requisition *requisition) +void Table::sizeRequestImpl (core::Requisition *requisition, bool posDefined, + int x, int y) { DBG_OBJ_ENTER0 ("resize", 0, "sizeRequestImpl"); diff --git a/dw/table.hh b/dw/table.hh index c5806535..c94514c0 100644 --- a/dw/table.hh +++ b/dw/table.hh @@ -459,7 +459,8 @@ private: } protected: - void sizeRequestImpl (core::Requisition *requisition); + void sizeRequestImpl (core::Requisition *requisition, bool posDefined, int x, + int y); void getExtremesImpl (core::Extremes *extremes); void sizeAllocateImpl (core::Allocation *allocation); void resizeDrawImpl (); diff --git a/dw/textblock.cc b/dw/textblock.cc index d1d2fb26..3dba2dc2 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -314,10 +314,13 @@ Textblock::~Textblock () * padding/border/margin. This can be used to align the first lines * of several textblocks in a horizontal line. */ -void Textblock::sizeRequestImpl (core::Requisition *requisition) +void Textblock::sizeRequestImpl (core::Requisition *requisition, + bool posDefined, int x, int y) { DBG_OBJ_ENTER0 ("resize", 0, "sizeRequestImpl"); + assert (posDefined || !needsPositionForSize ()); + int newLineBreakWidth = getAvailWidth (true); if (newLineBreakWidth != lineBreakWidth) { lineBreakWidth = newLineBreakWidth; @@ -401,6 +404,16 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) DBG_OBJ_LEAVE (); } +core::Widget *Textblock::sizeRequestReference () +{ + return needsPositionForSize() ? oofContainer[OOFM_FLOATS] : NULL; +} + +bool Textblock::needsPositionForSize () +{ + return false; +} + int Textblock::calcVerticalBorder (int widgetPadding, int widgetBorder, int widgetMargin, int lineBorderTotal, int lineMarginTotal) diff --git a/dw/textblock.hh b/dw/textblock.hh index db5d845f..28a9c4f4 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -620,9 +620,10 @@ protected: int hoverLink; /* The link under the mouse pointer */ void queueDrawRange (int index1, int index2); + bool needsPositionForSize (); int calcVerticalBorder (int widgetPadding, int widgetBorder, int widgetMargin, int lineBorderTotal, - int lineMarginTotal); + int lineMarginTotal); void getWordExtremes (Word *word, core::Extremes *extremes); void justifyLine (Line *line, int diff); Line *addLine (int firstWord, int lastWord, int newLastOofPos, @@ -814,7 +815,9 @@ protected: Widget *getWidgetAtPointLevel (int x, int y, int level, core::GettingWidgetAtPointContext *context); - void sizeRequestImpl (core::Requisition *requisition); + void sizeRequestImpl (core::Requisition *requisition, bool posDefined, int x, + int y); + Widget *sizeRequestReference (); void getExtremesImpl (core::Extremes *extremes); void sizeAllocateImpl (core::Allocation *allocation); @@ -48,7 +48,8 @@ Embed::~Embed() DBG_OBJ_DELETE (); } -void Embed::sizeRequestImpl (Requisition *requisition) +void Embed::sizeRequestImpl (Requisition *requisition, bool posDefined, int x, + int y) { resource->sizeRequest (requisition); } @@ -228,7 +228,8 @@ private: Resource *resource; protected: - void sizeRequestImpl (Requisition *requisition); + void sizeRequestImpl (Requisition *requisition, bool posDefined, int x, + int y); void getExtremesImpl (Extremes *extremes); void sizeAllocateImpl (Allocation *allocation); diff --git a/dw/widget.cc b/dw/widget.cc index 191feda9..252ff8c8 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -567,7 +567,8 @@ bool Widget::usesAvailHeight () * \brief This method is a wrapper for Widget::sizeRequestImpl(); it calls * the latter only when needed. */ -void Widget::sizeRequest (Requisition *requisition) +void Widget::sizeRequest (Requisition *requisition, bool posDefined, int x, + int y) { assert (!queueResizeEntered ()); @@ -587,7 +588,7 @@ void Widget::sizeRequest (Requisition *requisition) if (needsResize ()) { calcExtraSpace (); /** \todo Check requisition == &(this->requisition) and do what? */ - sizeRequestImpl (requisition); + sizeRequestImpl (requisition, posDefined, x, y); this->requisition = *requisition; unsetFlags (NEEDS_RESIZE); @@ -1051,7 +1052,11 @@ void Widget::calcExtraSpace () DBG_OBJ_SET_NUM ("extraSpace.bottom", extraSpace.bottom); DBG_OBJ_SET_NUM ("extraSpace.left", extraSpace.left); DBG_OBJ_SET_NUM ("extraSpace.right", extraSpace.right); - +} + +Widget *Widget::sizeRequestReference () +{ + return NULL; } /** diff --git a/dw/widget.hh b/dw/widget.hh index 176fed08..ea743465 100644 --- a/dw/widget.hh +++ b/dw/widget.hh @@ -280,9 +280,15 @@ protected: /** * \brief See \ref dw-widget-sizes. */ - virtual void sizeRequestImpl (Requisition *requisition) = 0; + virtual void sizeRequestImpl (Requisition *requisition, bool posDefined, + int x, int y) = 0; /** + * \brief See \ref dw-widget-sizes (or \ref dw-size-request-pos). + */ + virtual Widget *sizeRequestReference (); + + /** * \brief See \ref dw-widget-sizes. */ virtual void getExtremesImpl (Extremes *extremes) = 0; @@ -443,7 +449,8 @@ public: { return extraSpace.bottom + getStyle()->boxRestHeight (); } inline int boxDiffHeight () { return boxOffsetY () + boxRestHeight (); } - void sizeRequest (Requisition *requisition); + void sizeRequest (Requisition *requisition, bool posDefined = false, + int x = 0, int y = 0); void getExtremes (Extremes *extremes); void sizeAllocate (Allocation *allocation); diff --git a/test/dw_simple_container.cc b/test/dw_simple_container.cc index 2e9ed6ae..bd1ce47d 100644 --- a/test/dw_simple_container.cc +++ b/test/dw_simple_container.cc @@ -160,7 +160,8 @@ SimpleContainer::~SimpleContainer () delete child; } -void SimpleContainer::sizeRequestImpl (Requisition *requisition) +void SimpleContainer::sizeRequestImpl (Requisition *requisition, + bool posDefined, int x, int y) { Requisition childReq; if (child) diff --git a/test/dw_simple_container.hh b/test/dw_simple_container.hh index 021f5277..98d1ed86 100644 --- a/test/dw_simple_container.hh +++ b/test/dw_simple_container.hh @@ -34,7 +34,8 @@ private: Widget *child; protected: - void sizeRequestImpl (core::Requisition *requisition); + void sizeRequestImpl (core::Requisition *requisition, bool posDefined, int x, + int y); void getExtremesImpl (core::Extremes *extremes); void sizeAllocateImpl (core::Allocation *allocation); |