24#include "../lout/msg.h"
25#include "../lout/debug.hh"
53 widget->getPaddingArea (x, y, width, height);
59 widget->getPaddingArea (xRef, yRef, widthRef, heightRef);
64 return widget->getStyle ();
69 widget->queueDrawArea (x - widget->allocation.x, y - widget->allocation.y,
154 DBG_OBJ_ENTER (
"draw", 0,
"intersects",
"%p, [%d, %d, %d * %d]",
159 *intersection = *area;
166 for (
Widget *widget =
this; r && widget != refWidget;
167 widget = widget->
parent) {
168 assert (widget != NULL);
171 widgetArea.
x = widget->allocation.x;
172 widgetArea.
y = widget->allocation.y;
173 widgetArea.
width = widget->allocation.width;
174 widgetArea.
height = widget->getHeight ();
176 if (intersection->
intersectsWith (&widgetArea, &newIntersection)) {
177 DBG_OBJ_MSGF (
"draw", 1,
"new intersection: %d, %d, %d * %d",
178 newIntersection.
x, newIntersection.
y,
180 *intersection = newIntersection;
191 DBG_OBJ_MSGF (
"draw", 1,
"final intersection: %d, %d, %d * %d",
192 intersection->
x, intersection->
y,
202 intersection->
x, intersection->
y,
218 draw (view, &thisArea, context);
240 return widgetAtPoint;
263 if (widget->isPossibleContainer ())
302 x, y, width, height);
304 _MSG(
"Widget::queueDrawArea alloc(%d %d %d %d) wid(%d %d %d %d)\n",
307 x, y, width, height);
325 fast ?
"true" :
"false");
331 Flags resizeFlag, extremesFlag, totalFlags;
349 totalFlags = resizeFlag;
352 totalFlags = (
Flags)(totalFlags | extremesFlag);
372 for (widget2 =
parent, child =
this; widget2;
373 child = widget2, widget2 = widget2->
parent) {
374 if (
layout && !widget2->resizeQueued ())
377 DBG_OBJ_MSGF (
"resize", 2,
"setting %s and ALLOCATE_QUEUED for %p",
379 "RESIZE_QUEUED" :
"NEEDS_RESIZE",
382 widget2->setFlags (resizeFlag);
383 widget2->markSizeChange (child->
parentRef);
387 widget2->setFlags (extremesFlag);
388 widget2->markExtremesChange (child->
parentRef);
394 "checking parent %p: (%d & %d) [= %d] == %d?",
395 widget2->parent, widget2->parent->flags,
396 totalFlags, widget2->parent->flags & totalFlags,
400 if (widget2->parent &&
401 (widget2->parent->flags & totalFlags) == totalFlags) {
402 widget2->parent->markSizeChange (widget2->parentRef);
404 widget2->parent->markExtremesChange (widget2->parentRef);
481 DBG_OBJ_ENTER (
"resize", 0,
"affectsSizeChangeContainerChild",
"%p", child);
551 Widget **references,
int *x,
int *y)
555 DBG_OBJ_ENTER (
"resize", 0,
"sizeRequest",
"%d, ...", numPos);
559 for(
int i = 0; i < numPos; i++)
561 i, references[i], x[i], y[i]);
576 SizeParams newRequisitionParams (numPos, references, x, y);
624 DBG_OBJ_ENTER (
"resize", 0,
"getMinWidth",
"[%d (%d) / %d (%d)], %s",
627 forceValue ?
"true" :
"false");
630 forceValue ?
"true" :
"false");
668 forceValue ?
"true" :
"false");
673 DBG_OBJ_MSG (
"resize", 1,
"no parent, regarding viewport");
681 width = viewportWidth;
691 DBG_OBJ_MSG (
"resize", 1,
"delegated to quasiParent");
713 forceValue ?
"true" :
"false");
718 DBG_OBJ_MSG (
"resize", 1,
"no parent, regarding viewport");
751 DBG_OBJ_MSG (
"resize", 1,
"delegated to quasiParent");
769 void (*splitHeightFun) (
int,
int *,
int *),
770 bool allowDecreaseWidth,
771 bool allowDecreaseHeight)
774 if (!allowDecreaseWidth && limitMinWidth < requisition->width)
795 if (minHeight != -1 && maxHeight != -1) {
797 if (maxHeight < minHeight)
798 maxHeight = minHeight;
810 if (minHeight != -1 &&
814 if (maxHeight != -1 &&
821 void (*splitHeightFun) (
int,
int *,
int *),
822 bool allowDecreaseWidth,
823 bool allowDecreaseHeight)
828 "%d * (%d + %d), ..., %s, %s",
834 DBG_OBJ_MSG (
"resize", 1,
"no parent, regarding viewport");
837 for (
int pass = 0; pass < 3; pass++) {
839 allowDecreaseWidth, allowDecreaseHeight);
841 allowDecreaseWidth, allowDecreaseHeight, splitHeightFun);
854 allowDecreaseHeight);
857 DBG_OBJ_MSG (
"resize", 1,
"delegated to quasiParent");
862 allowDecreaseHeight);
872 DBG_OBJ_ENTER (
"resize", 0,
"correctExtremes",
"%d (%d) / %d (%d)",
877 DBG_OBJ_MSG (
"resize", 1,
"no parent, regarding viewport");
887 limitMinWidth,
false);
889 limitMinWidth,
false);
891 limitMinWidth,
false);
893 DBG_OBJ_MSGF (
"resize", 1,
"width = %d, minWidth = %d, maxWidth = %d",
894 width, minWidth, maxWidth);
910 DBG_OBJ_MSG (
"resize", 1,
"delegated to quasiParent");
933 int limitMinWidth,
bool forceValue)
936 cssValue, refWidth, refWidget, limitMinWidth);
938 assert (refWidth != -1 || refWidget != NULL);
955 if (availWidth != -1) {
956 int containerWidth = availWidth - refWidget->
boxDiffWidth ();
992 Widget *refWidget,
int limitMinWidth,
993 bool forceValue,
int *finalWidth)
995 DBG_OBJ_ENTER (
"resize", 0,
"calcFinalWidth",
"..., %d, %p, %d, [%d]",
996 refWidth, refWidget, limitMinWidth, *finalWidth);
1001 DBG_OBJ_MSGF (
"resize", 1,
"w = %d, width = %d", w, width);
1009 limitMinWidth, forceValue);
1011 limitMinWidth, forceValue);
1013 DBG_OBJ_MSGF (
"resize", 1,
"minWidth = %d, maxWidth = %d",
1014 minWidth, maxWidth);
1016 if (minWidth != -1 && maxWidth != -1) {
1018 if (maxWidth < minWidth)
1019 maxWidth = minWidth;
1022 if (minWidth != -1 && w < minWidth)
1025 if (maxWidth != -1 && w > maxWidth)
1030 assert(!(*finalWidth != -1 && w == -1));
1038 int refHeight,
Widget *refWidget,
bool forceValue)
1043 DBG_OBJ_ENTER (
"resize", 0,
"calcHeight",
"0x%x, %s, %d, %p",
1044 cssValue, usePercentage ?
"true" :
"false", refHeight,
1047 assert (refHeight != -1 || refWidget != NULL);
1060 if (usePercentage) {
1061 if (refHeight != -1)
1065 if (availHeight != -1) {
1066 int containerHeight = availHeight - refWidget->
boxDiffHeight ();
1086 if (!allowDecreaseHeight && *height != -1 && *height < ascent + descent)
1087 *height = ascent + descent;
1098 DBG_OBJ_ENTER (
"resize", 0,
"getExtremes",
"%d, ...", numPos);
1118 SizeParams newParams (numPos, references, x, y);
1216 DBG_OBJ_ENTER (
"resize", 0,
"sizeAllocate",
"%d, %d; %d * (%d + %d)",
1221 "old allocation (%d, %d; %d * (%d + %d)); needsAllocate: %s",
1222 this->allocation.
x, this->allocation.y, this->allocation.width,
1223 this->allocation.ascent, this->allocation.descent,
1249 this->allocation.width,
1250 this->allocation.ascent + this->allocation.descent,
1328 this->style->
unref ();
1332 this->style =
style;
1397 "table-header-group" :
1399 "table-footer-group" :
1435 while (widget != NULL) {
1454 while (widget != NULL) {
1472 int x,
int y,
int width,
int height,
bool inverse)
1482 width, height,
style, inverse);
1492 int xPad, yPad, widthPad, heightPad;
1495 (view,
layout, &canvasArea,
1520 int xMar, yMar, widthMar, heightMar;
1523 heightMar,
style, inverse);
1525 int xPad, yPad, widthPad, heightPad;
1544 xPad, yPad, widthPad, heightPad,
1545 xPad, yPad, widthPad, heightPad,
1631 Widget *widget1 =
this, *widget2 = otherWidget;
1632 int level1 = widget1->
getLevel (), level2 = widget2->getLevel();
1635 while (level1 > level2) {
1636 widget1 = widget1->
parent;
1640 while (level2 > level1) {
1641 widget2 = widget2->
parent;
1646 while (widget1 != widget2) {
1647 if (widget1->
parent == NULL) {
1648 MSG_WARN(
"widgets in different trees\n");
1652 widget1 = widget1->
parent;
1653 widget2 = widget2->
parent;
1660 int x,
int y,
int width,
int height)
1702 Widget **references,
int *x,
int *y)
1717 Widget **references,
int *x,
int *y)
1785 DBG_OBJ_ENTER (
"resize", 0,
"getAvailWidthOfChild",
"%p, %s",
1786 child, forceValue ?
"true" :
"false");
1800 -1,
this, -1,
false);
1801 if (maxWidth != -1 && width > maxWidth)
1805 -1,
this, -1,
false);
1806 if (minWidth != -1 && width < minWidth)
1820 if (effContainer ==
this) {
1825 DBG_OBJ_MSG (
"resize", 1,
"delegated to (effective) container");
1843 DBG_OBJ_ENTER (
"resize", 0,
"getAvailHeightOfChild",
"%p, %s",
1844 child, forceValue ?
"true" :
"false");
1859 if (effContainer ==
this) {
1872 if (availHeight == -1)
1882 DBG_OBJ_MSG (
"resize", 1,
"delegated to (effective) container");
1894 void (*splitHeightFun) (
int,
int*,
1896 bool allowDecreaseWidth,
1897 bool allowDecreaseHeight)
1911 if (effContainer ==
this) {
1913 for (
int pass = 0; pass < 3; pass++) {
1916 allowDecreaseHeight);
1918 allowDecreaseWidth, allowDecreaseHeight, splitHeightFun);
1925 DBG_OBJ_MSG (
"resize", 1,
"delegated to (effective) container");
1930 allowDecreaseHeight);
1959 bool allowDecreaseWidth,
bool allowDecreaseHeight,
1960 void (*splitHeightFun) (
int,
int*,
int*))
1968 bool sizeSet = wReq > 0 && hReq > 0;
1971 bool changed =
false;
1973 DEBUG_MSG(1,
"Widget::correctReqAspectRatio() -- wReq=%d, hReq=%d, pass=%d\n",
1976 DEBUG_MSG(1,
"Widget::correctReqAspectRatio() -- border: w=%d, h=%d\n",
1981 DEBUG_MSG(1,
"Widget::correctReqAspectRatio() -- with border: wReq=%d, hReq=%d\n",
1987 float curRatio = (float) wReq / (
float) hReq;
1988 DEBUG_MSG(1,
"curRatio=%f, preferred ratio=%f\n", curRatio,
ratio);
1990 if (curRatio <
ratio) {
1994 int w = (float) hReq *
ratio;
1995 DEBUG_MSG(1,
"increase w: %d -> %d\n", wReq, w);
1997 DEBUG_MSG(1,
"increase w (with border): %d -> %d\n", wReq, w);
2002 if (allowDecreaseHeight) {
2007 int h = (float) wReq /
ratio;
2008 DEBUG_MSG(1,
"decrease h: %d -> %d\n", hReq, h);
2010 DEBUG_MSG(1,
"decrease h (with border): %d -> %d\n", hReq, h);
2015 }
else if (curRatio >
ratio) {
2019 int h = (float) wReq /
ratio;
2020 DEBUG_MSG(1,
"increase h: %d -> %d\n", hReq, h);
2022 DEBUG_MSG(1,
"increase h (width border): %d -> %d\n", hReq, h);
2027 if (allowDecreaseWidth) {
2032 int w = (float) hReq *
ratio;
2033 DEBUG_MSG(1,
"decrease w: %d -> %d\n", wReq, w);
2035 DEBUG_MSG(1,
"decrease w (width border): %d -> %d\n", wReq, w);
2045 DEBUG_MSG(1,
"Widget::correctReqAspectRatio() -- output: wReq=%d, hReq=%d, changed=%d\n",
2057 bool allowDecreaseWidth)
2060 "%p, %d * (%d + %d), %s",
2066 int limitMinWidth = child->
getMinWidth (NULL,
true);
2067 if (!allowDecreaseWidth && limitMinWidth < requisition->width)
2078 void (*splitHeightFun) (
int,
int*,
int*),
2079 bool allowDecreaseHeight)
2100 if (minHeight != -1 && maxHeight != -1) {
2102 if (maxHeight < minHeight)
2103 maxHeight = minHeight;
2115 if (minHeight != -1 &&
2119 if (maxHeight != -1 &&
2129 bool useAdjustmentWidth)
2134 "%p, %d (%d) / %d (%d)",
2142 if (effContainer ==
this) {
2146 limitMinWidth,
false);
2148 limitMinWidth,
false);
2150 limitMinWidth,
false);
2152 DBG_OBJ_MSGF (
"resize", 1,
"width = %d, minWidth = %d, maxWidth = %d",
2153 width, minWidth, maxWidth);
2162 DBG_OBJ_MSG (
"resize", 1,
"delegated to (effective) container");
2165 useAdjustmentWidth);
2246 DBG_OBJ_ENTER_S (
"resize", 1,
"splitHeightPreserveAscent",
"%d, %d, %d",
2247 height, *ascent, *descent);
2249 *descent = height - *ascent;
2260 DBG_OBJ_ENTER_S (
"resize", 1,
"splitHeightPreserveDescent",
"%d, %d, %d",
2261 height, *ascent, *descent);
2263 *ascent = height - *descent;
Set at the top when drawing.
Rectangle * getToplevelArea()
Represents a enter or leave notify event.
Represents a mouse motion event.
Set at the top when getting the widget at the point.
Iterators are used to iterate through the contents of a widget.
virtual void unref()
Delete the iterator.
virtual bool next()=0
Move iterator forward and store content it.
void queueDraw(int x, int y, int width, int height)
style::Color * getBgColor()
void queueDrawExcept(int x, int y, int width, int height, int ex, int ey, int ewidth, int eheight)
lout::container::typed::Vector< Widget > * queueResizeList
void scrollTo(HPosition hpos, VPosition vpos, int x, int y, int width, int height)
Scrolls all viewports, so that the region [x, y, width, height] is seen, according to hpos and vpos.
void queueResize(bool extremesChanged)
dw::core::Shape implemtation for simple rectangles.
bool intersectsWith(Rectangle *otherRect, Rectangle *dest)
Return whether this rectangle and otherRect intersect.
Hold arguments passed to dw::core::Widget::sizeRequest and dw::core::Widget::getExtremes,...
bool isEquivalent(SizeParams *other)
Compares two instances, but considers a change in the order of the reference widgets as equivalent.
See Handling stacking contexts.
static bool isEstablishingStackingContext(Widget *widget)
void addChildSCWidget(Widget *widget)
void addWidgetProcessedAsInterruption(Widget *widget)
An interface to encapsulate platform dependent drawing.
StyleImage * backgroundImage
bool sizeDiffs(StyleAttrs *otherStyleAttrs)
This method returns whether something may change its size, when its style changes from this style to ...
void putExternalImgRenderer(ImgRenderer *ir)
Add an additional ImgRenderer, especially used for drawing.
void removeExternalImgRenderer(ImgRenderer *ir)
Remove a previously added additional ImgRenderer.
const char * getClassName()
Return the name, under which the class of this object was registered.
void registerName(const char *className, int *classId)
This method must be called in the constructor for the sub class.
#define DEBUG_MSG(level,...)
#define DBG_OBJ_LEAVE_VAL_S(fmt,...)
#define DBG_OBJ_ENTER_S(aspect, prio, funname, fmt,...)
#define DBG_OBJ_ENTER0(aspect, prio, funname)
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_SET_COL(var, val)
#define DBG_OBJ_SET_SYM(var, val)
#define DBG_OBJ_MSG_END()
#define DBG_OBJ_MSGF(aspect, prio, fmt,...)
#define DBG_OBJ_SET_NUM(var, val)
#define DBG_OBJ_MSG(aspect, prio, msg)
#define DBG_OBJ_ENTER(aspect, prio, funname, fmt,...)
#define DBG_OBJ_MSG_START()
#define DBG_OBJ_ASSOC_PARENT(parent)
#define DBG_OBJ_ASSOC_CHILD(child)
#define DBG_OBJ_SET_PTR(var, val)
#define DBG_OBJ_LEAVE_VAL0(val)
#define DBG_OBJ_LEAVE_VAL(fmt,...)
int multiplyWithPerLength(int x, Length l)
Multiply an int with a percentage length, returning int.
void drawBackground(View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, int xRef, int yRef, int widthRef, int heightRef, Style *style, Color *bgColor, bool inverse, bool atTop)
Draw the background (content plus padding) of a region in window, according to style.
@ DISPLAY_TABLE_HEADER_GROUP
@ DISPLAY_TABLE_ROW_GROUP
@ DISPLAY_TABLE_FOOTER_GROUP
int Length
Type for representing all lengths within dw::core::style.
double perLengthVal_useThisOnlyForDebugging(Length l)
Returns the value of a percentage, relative to 1, as a double.
void drawBorder(View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, Style *style, bool inverse)
Draw the border of a region in window, according to style.
bool isPerLength(Length l)
Returns true if l is a percentage.
bool isAbsLength(Length l)
Returns true if l is an absolute length.
int absLengthVal(Length l)
Returns the value of a length in pixels, as an integer.
@ LENGTH_AUTO
Represents "auto" lengths.
void splitHeightPreserveDescent(int height, int *ascent, int *descent)
void splitHeightPreserveAscent(int height, int *ascent, int *descent)
Dw is in this namespace, or sub namespaces of this one.
Miscellaneous stuff, which does not fit anywhere else.
void notImplemented(const char *name)
const char * boolToStr(bool b)
Here, some common classes (or interfaces) are defined, to standardize the access to other classes.
Represents the allocation, i.e.
@ WIDGET_IN_FLOW
widget in normal flow, so that this widget (containing this content) is both container (parent) and g...
@ WIDGET_OOF_CONT
widget out of flow (OOF); this widget (containing this content) is only the container (parent),...