Dillo v3.1.1-46-g8a360e32
Loading...
Searching...
No Matches
widget.cc
Go to the documentation of this file.
1/*
2 * Dillo Widget
3 *
4 * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
5 * Copyright 2023-2024 Rodrigo Arias Mallo <rodarima@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "core.hh"
22
23#include "../lout/msg.h"
24#include "../lout/debug.hh"
25
26using namespace lout;
27using namespace lout::object;
28using namespace lout::misc;
29
30namespace dw {
31namespace core {
32
33// ----------------------------------------------------------------------
34
39
40void Widget::WidgetImgRenderer::getBgArea (int *x, int *y, int *width,
41 int *height)
42{
43 widget->getPaddingArea (x, y, width, height);
44}
45
46void Widget::WidgetImgRenderer::getRefArea (int *xRef, int *yRef, int *widthRef,
47 int *heightRef)
48{
49 widget->getPaddingArea (xRef, yRef, widthRef, heightRef);
50}
51
53{
54 return widget->getStyle ();
55}
56
57void Widget::WidgetImgRenderer::draw (int x, int y, int width, int height)
58{
59 widget->queueDrawArea (x - widget->allocation.x, y - widget->allocation.y,
60 width, height);
61}
62
63// ----------------------------------------------------------------------
64
65bool Widget::adjustMinWidth = true;
66int Widget::CLASS_ID = -1;
67
69{
70 DBG_OBJ_CREATE ("dw::core::Widget");
71 registerName ("dw::core::Widget", &CLASS_ID);
72
75
78 setWidgetReference (NULL);
79 DBG_OBJ_SET_PTR ("container", container);
80
81 layout = NULL;
82
83 allocation.x = -1;
84 allocation.y = -1;
85 allocation.width = 1;
88
90
91 style = NULL;
92 bgColor = NULL;
93 buttonSensitive = true;
94 buttonSensitiveSet = false;
95
96 deleteCallbackData = NULL;
97 deleteCallbackFunc = NULL;
98
99 widgetImgRenderer = NULL;
100
101 stackingContextMgr = NULL;
102}
103
105{
108
109 if (widgetImgRenderer) {
112 delete widgetImgRenderer;
113 }
114
116 delete stackingContextMgr;
117
118 if (style)
119 style->unref ();
120
121 if (parent)
122 parent->removeChild (this);
123 else if (layout)
125
127}
128
129
139bool Widget::intersects (Widget *refWidget, Rectangle *area,
140 Rectangle *intersection)
141{
142 DBG_OBJ_ENTER ("draw", 0, "intersects", "%p, [%d, %d, %d * %d]",
143 refWidget, area->x, area->y, area->width, area->height);
144 bool r;
145
146 if (wasAllocated ()) {
147 *intersection = *area;
148 intersection->x += refWidget->allocation.x;
149 intersection->y += refWidget->allocation.y;
150
151 r = true;
152 // "RefWidget" is excluded; it is assumed that "area" its already within
153 // its allocation.
154 for (Widget *widget = this; r && widget != refWidget;
155 widget = widget->parent) {
156 assert (widget != NULL); // refWidget must be ancestor.
157
158 Rectangle widgetArea, newIntersection;
159 widgetArea.x = widget->allocation.x;
160 widgetArea.y = widget->allocation.y;
161 widgetArea.width = widget->allocation.width;
162 widgetArea.height = widget->getHeight ();
163
164 if (intersection->intersectsWith (&widgetArea, &newIntersection)) {
165 DBG_OBJ_MSGF ("draw", 1, "new intersection: %d, %d, %d * %d",
166 newIntersection.x, newIntersection.y,
167 newIntersection.width, newIntersection.height);
168 *intersection = newIntersection;
169 } else {
170 DBG_OBJ_MSG ("draw", 1, "no new intersection");
171 r = false;
172 }
173 }
174
175 if (r) {
176 intersection->x -= allocation.x;
177 intersection->y -= allocation.y;
178
179 DBG_OBJ_MSGF ("draw", 1, "final intersection: %d, %d, %d * %d",
180 intersection->x, intersection->y,
181 intersection->width, intersection->height);
182 }
183 } else {
184 r = false;
185 DBG_OBJ_MSG ("draw", 1, "not allocated");
186 }
187
188 if (r)
189 DBG_OBJ_LEAVE_VAL ("true: %d, %d, %d * %d",
190 intersection->x, intersection->y,
191 intersection->width, intersection->height);
192 else
193 DBG_OBJ_LEAVE_VAL0 ("false");
194
195 return r;
196}
197
202 DrawingContext *context)
203{
204 Rectangle thisArea;
205 if (intersects (layout->topLevel, context->getToplevelArea (), &thisArea))
206 draw (view, &thisArea, context);
207
208 context->addWidgetProcessedAsInterruption (this);
209}
210
213{
214 // Suitable for simple widgets, without children.
215
216 if (inAllocation (x, y))
217 return this;
218 else
219 return NULL;
220}
221
224 *context)
225{
226 Widget *widgetAtPoint = getWidgetAtPoint (x, y, context);
227 context->addWidgetProcessedAsInterruption (this);
228 return widgetAtPoint;
229}
230
232{
233 DBG_OBJ_ENTER ("construct", 0, "setParent", "%p", parent);
234
235 this->parent = parent;
237
240
242 //printf ("The %s %p becomes a child of the %s %p\n",
243 // getClassName(), this, parent->getClassName(), parent);
244
245 // Determine the container. Currently rather simple; will become
246 // more complicated when absolute and fixed positions are
247 // supported.
248 container = NULL;
249 for (Widget *widget = getParent (); widget != NULL && container == NULL;
250 widget = widget->getParent())
251 if (widget->isPossibleContainer ())
252 container = widget;
253 // If there is no possible container widget, there is
254 // (surprisingly!) also no container (i. e. the viewport is
255 // used). Does not occur in dillo, where the toplevel widget is a
256 // Textblock.
257 DBG_OBJ_SET_PTR ("container", container);
258
259 // If at all, stackingContextMgr should have set *before*, see also
260 // Widget::setStyle() and Layout::addWidget().
261 if (stackingContextMgr) {
263 while (stackingContextWidget &&
266 assert (stackingContextWidget);
268 } else
270
272
273 DBG_OBJ_LEAVE ();
274}
275
277{
278 this->quasiParent = quasiParent;
279
280 // More to do? Compare with setParent().
281
282 DBG_OBJ_SET_PTR ("quasiParent", quasiParent);
283}
284
285void Widget::queueDrawArea (int x, int y, int width, int height)
286{
289 DBG_OBJ_ENTER ("draw", 0, "queueDrawArea", "%d, %d, %d, %d",
290 x, y, width, height);
291
292 _MSG("Widget::queueDrawArea alloc(%d %d %d %d) wid(%d %d %d %d)\n",
295 x, y, width, height);
296 if (layout)
297 layout->queueDraw (x + allocation.x, y + allocation.y, width, height);
298
299 DBG_OBJ_LEAVE ();
300}
301
309void Widget::queueResize (int ref, bool extremesChanged, bool fast)
310{
311 DBG_OBJ_ENTER ("resize", 0, "queueResize", "%d, %s, %s",
312 ref, extremesChanged ? "true" : "false",
313 fast ? "true" : "false");
314
316
317 Widget *widget2, *child;
318
319 Flags resizeFlag, extremesFlag, totalFlags;
320
321 if (layout) {
322 // If RESIZE_QUEUED is set, this widget is already in the list.
323 if (!resizeQueued ())
324 layout->queueResizeList->put (this);
325
326 resizeFlag = RESIZE_QUEUED;
327 extremesFlag = EXTREMES_QUEUED;
328 } else {
329 resizeFlag = NEEDS_RESIZE;
330 extremesFlag = EXTREMES_CHANGED;
331 }
332
333 setFlags (resizeFlag);
335 markSizeChange (ref);
336
337 totalFlags = resizeFlag;
338
339 if (extremesChanged) {
340 totalFlags = (Flags)(totalFlags | extremesFlag);
341
342 setFlags (extremesFlag);
343 markExtremesChange (ref);
344 }
345
346 if (fast) {
347 if (parent) {
348 // In this case, queueResize is called from top (may be a
349 // random entry point) to bottom, so markSizeChange and
350 // markExtremesChange have to be called explicitly for the
351 // parent. The tests (needsResize etc.) are uses to check
352 // whether queueResize has been called for the parent, or
353 // whether this widget is the entry point.
354 if (parent->needsResize () || parent->resizeQueued ())
358 }
359 } else {
360 for (widget2 = parent, child = this; widget2;
361 child = widget2, widget2 = widget2->parent) {
362 if (layout && !widget2->resizeQueued ())
363 layout->queueResizeList->put (widget2);
364
365 DBG_OBJ_MSGF ("resize", 2, "setting %s and ALLOCATE_QUEUED for %p",
366 resizeFlag == RESIZE_QUEUED ?
367 "RESIZE_QUEUED" : "NEEDS_RESIZE",
368 widget2);
369
370 widget2->setFlags (resizeFlag);
371 widget2->markSizeChange (child->parentRef);
372 widget2->setFlags (ALLOCATE_QUEUED);
373
374 if (extremesChanged) {
375 widget2->setFlags (extremesFlag);
376 widget2->markExtremesChange (child->parentRef);
377 }
378
380 if (widget2->parent)
381 DBG_OBJ_MSGF ("resize", 2,
382 "checking parent %p: (%d & %d) [= %d] == %d?",
383 widget2->parent, widget2->parent->flags,
384 totalFlags, widget2->parent->flags & totalFlags,
385 totalFlags);
386 }
387
388 if (widget2->parent &&
389 (widget2->parent->flags & totalFlags) == totalFlags) {
390 widget2->parent->markSizeChange (widget2->parentRef);
391 if (extremesChanged) {
392 widget2->parent->markExtremesChange (widget2->parentRef);
393 }
394
395 break;
396 }
397 }
398
399 if (layout)
401 }
402
404
405 DBG_OBJ_LEAVE ();
406}
407
409{
410 DBG_OBJ_ENTER0 ("resize", 0, "containerSizeChanged");
411
412 // If there is a container widget (not the viewport), which has not
413 // changed its size (which can be determined by the respective
414 // flags: this method is called recursively), this widget will
415 // neither change its size. Also, the recursive iteration can be
416 // stopped, since the children of this widget will
417 if (container == NULL ||
420 // Viewport (container == NULL) or container widget has changed
421 // its size.
423 queueResizeFast (0, true);
424
425 // Even if *this* widget is not affected, children may be, so
426 // iterate over children.
428 }
429
430 DBG_OBJ_LEAVE ();
431}
432
434{
435 DBG_OBJ_ENTER0 ("resize", 0, "affectedByContainerSizeChange");
436
437 bool ret;
438
439 // This standard implementation is suitable for all widgets which
440 // call correctRequisition() and correctExtremes(), even in the way
441 // how Textblock and Image do (see comments there). Has to be kept
442 // in sync.
443
444 if (container == NULL) {
445 if (style::isAbsLength (getStyle()->width) &&
446 style::isAbsLength (getStyle()->height))
447 // Both absolute, i. e. fixed: no dependency.
448 ret = false;
449 else if (style::isPerLength (getStyle()->width) ||
450 style::isPerLength (getStyle()->height)) {
451 // Any percentage: certainly dependenant.
452 ret = true;
453 } else
454 // One or both is "auto": depends ...
455 ret =
457 usesAvailWidth () : false) ||
459 usesAvailHeight () : false);
460 } else
462
463 DBG_OBJ_LEAVE_VAL ("%s", boolToStr(ret));
464 return ret;
465}
466
468{
469 DBG_OBJ_ENTER ("resize", 0, "affectsSizeChangeContainerChild", "%p", child);
470
471 bool ret;
472
473 // From the point of view of the container. This standard
474 // implementation should be suitable for most (if not all)
475 // containers.
476
477 if (style::isAbsLength (child->getStyle()->width) &&
479 // Both absolute, i. e. fixed: no dependency.
480 ret = false;
481 else if (style::isPerLength (child->getStyle()->width) ||
482 style::isPerLength (child->getStyle()->height)) {
483 // Any percentage: certainly dependenant.
484 ret = true;
485 } else
486 // One or both is "auto": depends ...
487 ret =
488 (child->getStyle()->width == style::LENGTH_AUTO ?
489 child->usesAvailWidth () : false) ||
490 (child->getStyle()->height == style::LENGTH_AUTO ?
491 child->usesAvailHeight () : false);
492
493 DBG_OBJ_LEAVE_VAL ("%s", boolToStr(ret));
494 return ret;
495}
496
498{
499 DBG_OBJ_ENTER0 ("resize", 0, "containerSizeChangedForChildren");
500
501 // Working, but inefficient standard implementation.
504 false);
505 while (it->next ())
507 it->unref ();
508
509 DBG_OBJ_LEAVE ();
510}
511
517{
518 return false;
519}
520
526{
527 return false;
528}
529
535 Widget **references, int *x, int *y)
536{
537 assert (!queueResizeEntered ());
538
539 DBG_OBJ_ENTER ("resize", 0, "sizeRequest", "%d, ...", numPos);
540
543 for(int i = 0; i < numPos; i++)
544 DBG_OBJ_MSGF ("resize", 1, "ref #%d: %p, %d, %d",
545 i, references[i], x[i], y[i]);
547 }
548
550
551 if (resizeQueued ()) {
552 // This method is called outside of Layout::resizeIdle.
555 // The widget is not taken out of Layout::queueResizeList, since
556 // other *_QUEUED flags may still be set and processed in
557 // Layout::resizeIdle.
558 }
559
560 SizeParams newRequisitionParams (numPos, references, x, y);
561 DBG_OBJ_ASSOC_CHILD (&newRequisitionParams);
562
563 bool callImpl;
564 if (needsResize ())
565 callImpl = true;
566 else {
567 // Even if RESIZE_QUEUED / NEEDS_RESIZE is not set, calling
568 // sizeRequestImpl is necessary when the relavive positions passed here
569 // have changed.
570 callImpl = !newRequisitionParams.isEquivalent (&requisitionParams);
571 }
572
573 DBG_OBJ_MSGF ("resize", 1, "callImpl = %s", boolToStr (callImpl));
574
575 requisitionParams = newRequisitionParams;
576
577 if (callImpl) {
578 calcExtraSpace (numPos, references, x, y);
580 sizeRequestImpl (requisition, numPos, references, x, y);
581 this->requisition = *requisition;
583
584 DBG_OBJ_SET_NUM ("requisition.width", requisition->width);
585 DBG_OBJ_SET_NUM ("requisition.ascent", requisition->ascent);
586 DBG_OBJ_SET_NUM ("requisition.descent", requisition->descent);
587 } else
588 *requisition = this->requisition;
589
591
592 DBG_OBJ_LEAVE ();
593}
594
604int Widget::getMinWidth (Extremes *extremes, bool forceValue)
605{
607 if (extremes)
608 DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "[%d (%d) / %d (%d)], %s",
611 forceValue ? "true" : "false");
612 else
613 DBG_OBJ_ENTER ("resize", 0, "getMinWidth", "(nil), %s",
614 forceValue ? "true" : "false");
615 }
616
617 int minWidth;
618
619 if (getAdjustMinWidth ()) {
620 Extremes extremes2;
621 if (extremes == NULL) {
622 if (forceValue) {
623 getExtremes (&extremes2);
624 extremes = &extremes2;
625 }
626 }
627
628 // TODO Not completely clear whether this is feasable: Within
629 // the context of getAvailWidth(false) etc., getExtremes may not
630 // be called. We ignore the minimal width then.
631 if (extremes)
632 minWidth = extremes->adjustmentWidth;
633 else
634 minWidth = 0;
635 } else
636 minWidth = 0;
637
638 DBG_OBJ_LEAVE_VAL ("%d", minWidth);
639 return minWidth;
640}
641
649int Widget::getAvailWidth (bool forceValue)
650{
651 DBG_OBJ_ENTER ("resize", 0, "getAvailWidth", "%s",
652 forceValue ? "true" : "false");
653
654 int width;
655
656 if (parent == NULL && quasiParent == NULL) {
657 DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport");
659
660 // TODO Consider nested layouts (e. g. <button>).
661
662 int viewportWidth =
665 width = -1;
666 calcFinalWidth (getStyle (), viewportWidth, NULL, 0, forceValue, &width);
667 if (width == -1)
668 width = viewportWidth;
669
671 } else if (parent) {
672 DBG_OBJ_MSG ("resize", 1, "delegated to parent");
674 width = parent->getAvailWidthOfChild (this, forceValue);
676 } else /* if (quasiParent) */ {
677 DBG_OBJ_MSG ("resize", 1, "delegated to quasiParent");
679 width = quasiParent->getAvailWidthOfChild (this, forceValue);
681 }
682
683 DBG_OBJ_LEAVE_VAL ("%d", width);
684 return width;
685}
686
691int Widget::getAvailHeight (bool forceValue)
692{
693 // TODO Correct by ... not extremes, but ...? (Height extremes?)
694
695 // TODO Consider 'min-height' and 'max-height'. (Minor priority, as long as
696 // "getAvailHeight (true)" is not used.
697
698 DBG_OBJ_ENTER ("resize", 0, "getAvailHeight", "%s",
699 forceValue ? "true" : "false");
700
701 int height;
702
703 if (parent == NULL && quasiParent == NULL) {
704 DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport");
706
707 // TODO Consider nested layouts (e. g. <button>).
708 if (style::isAbsLength (getStyle()->height)) {
709 DBG_OBJ_MSGF ("resize", 1, "absolute height: %dpx",
710 style::absLengthVal (getStyle()->height));
711 height = style::absLengthVal (getStyle()->height) + boxDiffHeight ();
712 } else if (style::isPerLength (getStyle()->height)) {
713 DBG_OBJ_MSGF ("resize", 1, "percentage height: %g%%",
715 (getStyle()->height));
716 // Notice that here -- unlike getAvailWidth() --
717 // layout->hScrollbarThickness is not considered here;
718 // something like canvasWidthGreater (analogue to
719 // canvasHeightGreater) would be complicated and lead to
720 // possibly contradictory self-references.
721 height = applyPerHeight (layout->viewportHeight, getStyle()->height);
722 } else {
723 DBG_OBJ_MSG ("resize", 1, "no specification");
724 height = layout->viewportHeight;
725 }
726
728 } else if (parent) {
729 DBG_OBJ_MSG ("resize", 1, "delegated to parent");
731 height = parent->getAvailHeightOfChild (this, forceValue);
733 } else /* if (quasiParent) */ {
734 DBG_OBJ_MSG ("resize", 1, "delegated to quasiParent");
736 height = quasiParent->getAvailHeightOfChild (this, forceValue);
738 }
739
740 DBG_OBJ_LEAVE_VAL ("%d", height);
741 return height;
742}
743
745 void (*splitHeightFun) (int, int *, int *),
746 bool allowDecreaseWidth,
747 bool allowDecreaseHeight)
748{
749 // TODO Correct height by ... not extremes, but ...? (Height extremes?)
750
751 DBG_OBJ_ENTER ("resize", 0, "correctRequisition",
752 "%d * (%d + %d), ..., %s, %s",
754 requisition->descent, misc::boolToStr (allowDecreaseWidth),
755 misc::boolToStr (allowDecreaseHeight));
756
757 if (parent == NULL && quasiParent == NULL) {
758 DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport");
760
761 int limitMinWidth = getMinWidth (NULL, true);
762 if (!allowDecreaseWidth && limitMinWidth < requisition->width)
763 limitMinWidth = requisition->width;
764
765 int viewportWidth =
768 calcFinalWidth (getStyle (), viewportWidth, NULL, limitMinWidth, false,
770
771 // For layout->viewportHeight, see comment in getAvailHeight().
772 int height = calcHeight (getStyle()->height, false,
773 layout->viewportHeight, NULL, false);
774 adjustHeight (&height, allowDecreaseHeight, requisition->ascent,
776
777 int minHeight = calcHeight (getStyle()->minHeight, false,
778 layout->viewportHeight, NULL, false);
779 adjustHeight (&minHeight, allowDecreaseHeight, requisition->ascent,
781
782 int maxHeight = calcHeight (getStyle()->maxHeight, false,
783 layout->viewportHeight, NULL, false);
784 adjustHeight (&maxHeight, allowDecreaseHeight, requisition->ascent,
786
787 // TODO Perhaps split first, then add box ascent and descent.
788 if (height != -1)
789 splitHeightFun (height, &requisition->ascent, &requisition->descent);
790 if (minHeight != -1 &&
791 requisition->ascent + requisition->descent < minHeight)
792 splitHeightFun (minHeight, &requisition->ascent,
794 if (maxHeight != -1 &&
795 requisition->ascent + requisition->descent > maxHeight)
796 splitHeightFun (maxHeight, &requisition->ascent,
798
800 } else if (parent) {
801 DBG_OBJ_MSG ("resize", 1, "delegated to parent");
803 parent->correctRequisitionOfChild (this, requisition, splitHeightFun,
804 allowDecreaseWidth,
805 allowDecreaseHeight);
807 } else /* if (quasiParent) */ {
808 DBG_OBJ_MSG ("resize", 1, "delegated to quasiParent");
811 splitHeightFun,
812 allowDecreaseWidth,
813 allowDecreaseHeight);
815 }
816
819}
820
821void Widget::correctExtremes (Extremes *extremes, bool useAdjustmentWidth)
822{
823 DBG_OBJ_ENTER ("resize", 0, "correctExtremes", "%d (%d) / %d (%d)",
826
827 if (container == NULL && quasiParent == NULL) {
828 DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport");
830
831 int limitMinWidth =
832 useAdjustmentWidth ? getMinWidth (extremes, false) : 0;
833 int viewportWidth =
836
837 int width = calcWidth (getStyle()->width, viewportWidth, NULL,
838 limitMinWidth, false);
839 int minWidth = calcWidth (getStyle()->minWidth, viewportWidth, NULL,
840 limitMinWidth, false);
841 int maxWidth = calcWidth (getStyle()->maxWidth, viewportWidth, NULL,
842 limitMinWidth, false);
843
844 DBG_OBJ_MSGF ("resize", 1, "width = %d, minWidth = %d, maxWidth = %d",
845 width, minWidth, maxWidth);
846
847 if (width != -1)
849 if (minWidth != -1)
850 extremes->minWidth = minWidth;
851 if (maxWidth != -1)
852 extremes->maxWidth = maxWidth;
853
855 } else if (parent) {
856 DBG_OBJ_MSG ("resize", 1, "delegated to parent");
858 parent->correctExtremesOfChild (this, extremes, useAdjustmentWidth);
860 } else /* if (quasiParent) */ {
861 DBG_OBJ_MSG ("resize", 1, "delegated to quasiParent");
863 quasiParent->correctExtremesOfChild (this, extremes, useAdjustmentWidth);
865 }
866
869
871}
872
883int Widget::calcWidth (style::Length cssValue, int refWidth, Widget *refWidget,
884 int limitMinWidth, bool forceValue)
885{
886 DBG_OBJ_ENTER ("resize", 0, "calcWidth", "0x%x, %d, %p, %d",
887 cssValue, refWidth, refWidget, limitMinWidth);
888
889 assert (refWidth != -1 || refWidget != NULL);
890
891 int width;
892
893 if (style::isAbsLength (cssValue)) {
894 DBG_OBJ_MSGF ("resize", 1, "absolute width: %dpx",
895 style::absLengthVal (cssValue));
896 width = misc::max (style::absLengthVal (cssValue) + boxDiffWidth (),
897 limitMinWidth);
898 } else if (style::isPerLength (cssValue)) {
899 DBG_OBJ_MSGF ("resize", 1, "percentage width: %g%%",
901 (cssValue));
902 if (refWidth != -1)
903 width = misc::max (applyPerWidth (refWidth, cssValue), limitMinWidth);
904 else {
905 int availWidth = refWidget->getAvailWidth (forceValue);
906 if (availWidth != -1) {
907 int containerWidth = availWidth - refWidget->boxDiffWidth ();
908 width = misc::max (applyPerWidth (containerWidth, cssValue),
909 limitMinWidth);
910 } else
911 width = -1;
912 }
913 } else {
914 DBG_OBJ_MSG ("resize", 1, "not specified");
915 width = -1;
916 }
917
918 DBG_OBJ_LEAVE_VAL ("%d", width);
919 return width;
920}
921
922// *finalWidth may be -1.
923/*
924 * If style has minWidth or maxWidth set, the returned value in
925 * *finalWidth is constrained to not exceed any of the set limits.
926 * */
928 Widget *refWidget, int limitMinWidth,
929 bool forceValue, int *finalWidth)
930{
931 DBG_OBJ_ENTER ("resize", 0, "calcFinalWidth", "..., %d, %p, %d, [%d]",
932 refWidth, refWidget, limitMinWidth, *finalWidth);
933
934 int width = calcWidth (style->width, refWidth, refWidget, limitMinWidth,
935 forceValue);
936 int minWidth = calcWidth (style->minWidth, refWidth, refWidget,
937 limitMinWidth, forceValue);
938 int maxWidth = calcWidth (style->maxWidth, refWidth, refWidget,
939 limitMinWidth, forceValue);
940
941 DBG_OBJ_MSGF ("resize", 1, "width = %d, minWidth = %d, maxWidth = %d",
942 width, minWidth, maxWidth);
943
944 if (width != -1)
945 *finalWidth = width;
946
947 /* Set the width if the min or max value is set and finalWidth is
948 * still -1 or exceeds the limit. Start by maxWidth so it defaults to
949 * the maximum available size. */
950 if (maxWidth != -1 && (*finalWidth == -1 || *finalWidth > maxWidth))
951 *finalWidth = maxWidth;
952 if (minWidth != -1 && (*finalWidth == -1 || *finalWidth < minWidth))
953 *finalWidth = minWidth;
954
955 DBG_OBJ_LEAVE_VAL ("%d", *finalWidth);
956}
957
958int Widget::calcHeight (style::Length cssValue, bool usePercentage,
959 int refHeight, Widget *refWidget, bool forceValue)
960{
961 // TODO Search for usage of this method and check the value of
962 // "usePercentage"; this has to be clarified.
963
964 DBG_OBJ_ENTER ("resize", 0, "calcHeight", "0x%x, %s, %d, %p",
965 cssValue, usePercentage ? "true" : "false", refHeight,
966 refWidget);
967
968 assert (refHeight != -1 || refWidget != NULL);
969
970 int height;
971
972 if (style::isAbsLength (cssValue)) {
973 DBG_OBJ_MSGF ("resize", 1, "absolute height: %dpx",
974 style::absLengthVal (cssValue));
975 height =
976 misc::max (style::absLengthVal (cssValue) + boxDiffHeight (), 0);
977 } else if (style::isPerLength (cssValue)) {
978 DBG_OBJ_MSGF ("resize", 1, "percentage height: %g%%",
979 100 *
981 if (usePercentage) {
982 if (refHeight != -1)
983 height = misc::max (applyPerHeight (refHeight, cssValue), 0);
984 else {
985 int availHeight = refWidget->getAvailHeight (forceValue);
986 if (availHeight != -1) {
987 int containerHeight = availHeight - refWidget->boxDiffHeight ();
988 height =
989 misc::max (applyPerHeight (containerHeight, cssValue), 0);
990 } else
991 height = -1;
992 }
993 } else
994 height = -1;
995 } else {
996 DBG_OBJ_MSG ("resize", 1, "not specified");
997 height = -1;
998 }
999
1000 DBG_OBJ_LEAVE_VAL ("%d", height);
1001 return height;
1002}
1003
1004void Widget::adjustHeight (int *height, bool allowDecreaseHeight, int ascent,
1005 int descent)
1006{
1007 if (!allowDecreaseHeight && *height != -1 && *height < ascent + descent)
1008 *height = ascent + descent;
1009}
1010
1014void Widget::getExtremes (Extremes *extremes, int numPos, Widget **references,
1015 int *x, int *y)
1016{
1017 assert (!queueResizeEntered ());
1018
1019 DBG_OBJ_ENTER ("resize", 0, "getExtremes", "%d, ...", numPos);
1020
1022
1023 if (extremesQueued ()) {
1024 // This method is called outside of Layout::resizeIdle.
1027 // The widget is not taken out of Layout::queueResizeList, since
1028 // other *_QUEUED flags may still be set and processed in
1029 // Layout::resizeIdle.
1030 }
1031
1032 bool callImpl;
1033 if (extremesChanged ())
1034 callImpl = true;
1035 else {
1036 // Even if EXTREMES_QUEUED / EXTREMES_CHANGED is not set, calling
1037 // getExtremesImpl is necessary when the relavive positions passed here
1038 // have changed.
1039 SizeParams newParams (numPos, references, x, y);
1040 DBG_OBJ_ASSOC_CHILD (&newParams);
1041 if (newParams.isEquivalent (&extremesParams))
1042 callImpl = false;
1043 else {
1044 callImpl = true;
1045 extremesParams = newParams;
1046 }
1047 }
1048
1049 if (callImpl) {
1050 // For backward compatibility (part 1/2):
1052
1053 getExtremesImpl (extremes, numPos, references, x, y);
1054
1055 // For backward compatibility (part 2/2):
1056 if (extremes->minWidthIntrinsic == -1)
1058 if (extremes->maxWidthIntrinsic == -1)
1060
1061 this->extremes = *extremes;
1063
1064 DBG_OBJ_SET_NUM ("extremes.minWidth", extremes->minWidth);
1065 DBG_OBJ_SET_NUM ("extremes.minWidthIntrinsic",
1067 DBG_OBJ_SET_NUM ("extremes.maxWidth", extremes->maxWidth);
1068 DBG_OBJ_SET_NUM ("extremes.maxWidthIntrinsic",
1070 DBG_OBJ_SET_NUM ("extremes.adjustmentWidth", extremes->adjustmentWidth);
1071 } else
1072 *extremes = this->extremes;
1073
1075
1076 DBG_OBJ_LEAVE ();
1077}
1078
1085void Widget::calcExtraSpace (int numPos, Widget **references, int *x, int *y)
1086{
1087 DBG_OBJ_ENTER0 ("resize", 0, "calcExtraSpace");
1088
1090 calcExtraSpaceImpl (numPos, references, x, y);
1091
1092 DBG_OBJ_SET_NUM ("extraSpace.top", extraSpace.top);
1093 DBG_OBJ_SET_NUM ("extraSpace.bottom", extraSpace.bottom);
1094 DBG_OBJ_SET_NUM ("extraSpace.left", extraSpace.left);
1095 DBG_OBJ_SET_NUM ("extraSpace.right", extraSpace.right);
1096
1097 DBG_OBJ_LEAVE ();
1098}
1099
1101{
1102 return 0;
1103}
1104
1106{
1107 misc::notImplemented ("Widget::sizeRequestReference");
1108 return NULL;
1109}
1110
1112{
1113 return 0;
1114}
1115
1117{
1118 misc::notImplemented ("Widget::getExtremesReference");
1119 return NULL;
1120}
1121
1127{
1128 assert (!queueResizeEntered ());
1129 assert (!sizeRequestEntered ());
1130 assert (!getExtremesEntered ());
1131 assert (resizeIdleEntered ());
1132
1133 DBG_OBJ_ENTER ("resize", 0, "sizeAllocate", "%d, %d; %d * (%d + %d)",
1136
1137 DBG_OBJ_MSGF ("resize", 1,
1138 "old allocation (%d, %d; %d * (%d + %d)); needsAllocate: %s",
1139 this->allocation.x, this->allocation.y, this->allocation.width,
1140 this->allocation.ascent, this->allocation.descent,
1141 needsAllocate () ? "true" : "false");
1142
1144
1145 /*printf ("The %stop-level %s %p is allocated:\n",
1146 parent ? "non-" : "", getClassName(), this);
1147 printf (" old = (%d, %d, %d + (%d + %d))\n",
1148 this->allocation.x, this->allocation.y, this->allocation.width,
1149 this->allocation.ascent, this->allocation.descent);
1150 printf (" new = (%d, %d, %d + (%d + %d))\n",
1151 allocation->x, allocation->y, allocation->width, allocation->ascent,
1152 allocation->descent);
1153 printf (" NEEDS_ALLOCATE = %s\n", needsAllocate () ? "true" : "false");*/
1154
1155 if (needsAllocate () ||
1156 allocation->x != this->allocation.x ||
1157 allocation->y != this->allocation.y ||
1158 allocation->width != this->allocation.width ||
1159 allocation->ascent != this->allocation.ascent ||
1160 allocation->descent != this->allocation.descent) {
1161
1162 if (wasAllocated ()) {
1164 this->allocation.x,
1165 this->allocation.y,
1166 this->allocation.width,
1167 this->allocation.ascent + this->allocation.descent,
1168 allocation->x,
1169 allocation->y,
1172 }
1173
1175
1176 //DEBUG_MSG (DEBUG_ALLOC, "... to %d, %d, %d x %d x %d\n",
1177 // widget->allocation.x, widget->allocation.y,
1178 // widget->allocation.width, widget->allocation.ascent,
1179 // widget->allocation.descent);
1180
1181 this->allocation = *allocation;
1184
1185 resizeDrawImpl ();
1186
1187 DBG_OBJ_SET_NUM ("allocation.x", this->allocation.x);
1188 DBG_OBJ_SET_NUM ("allocation.y", this->allocation.y);
1189 DBG_OBJ_SET_NUM ("allocation.width", this->allocation.width);
1190 DBG_OBJ_SET_NUM ("allocation.ascent", this->allocation.ascent);
1191 DBG_OBJ_SET_NUM ("allocation.descent", this->allocation.descent);
1192 }
1193
1194 /*unsetFlags (NEEDS_RESIZE);*/
1195
1197
1198 DBG_OBJ_LEAVE ();
1199}
1200
1202{
1203 return buttonPressImpl (event);
1204}
1205
1207{
1208 return buttonReleaseImpl (event);
1209}
1210
1212{
1213 return motionNotifyImpl (event);
1214}
1215
1217{
1218 enterNotifyImpl (event);
1219}
1220
1222{
1223 leaveNotifyImpl (event);
1224}
1225
1234{
1235 bool sizeChanged;
1236
1237 if (widgetImgRenderer && this->style && this->style->backgroundImage)
1240
1241 style->ref ();
1242
1243 if (this->style) {
1244 sizeChanged = this->style->sizeDiffs (style);
1245 this->style->unref ();
1246 } else
1247 sizeChanged = true;
1248
1249 this->style = style;
1250
1252
1253 if (style && style->backgroundImage) {
1254 // Create instance of WidgetImgRenderer when needed. Until this
1255 // widget is deleted, "widgetImgRenderer" will be kept, since it
1256 // is not specific to the style, but only to this widget.
1257 if (widgetImgRenderer == NULL)
1260 }
1261
1262 if (layout != NULL) {
1263 layout->updateCursor ();
1264 }
1265
1266 // After Layout::addWidget() (as toplevel widget) or Widget::setParent()
1267 // (which also sets layout), changes of the style cannot be considered
1268 // anymore. (Should print a warning?)
1269 if (layout == NULL &&
1273 stackingContextWidget = this;
1274 }
1275
1276 if (sizeChanged)
1277 queueResize (0, true);
1278 else
1279 queueDraw ();
1280
1281 // These should better be attributed to the style itself, and a
1282 // script processing RTFL messages could transfer it to something
1283 // equivalent:
1284
1285 DBG_OBJ_SET_NUM ("style.margin.top", style->margin.top);
1286 DBG_OBJ_SET_NUM ("style.margin.bottom", style->margin.bottom);
1287 DBG_OBJ_SET_NUM ("style.margin.left", style->margin.left);
1288 DBG_OBJ_SET_NUM ("style.margin.right", style->margin.right);
1289
1290 DBG_OBJ_SET_NUM ("style.border-width.top", style->borderWidth.top);
1291 DBG_OBJ_SET_NUM ("style.border-width.bottom", style->borderWidth.bottom);
1292 DBG_OBJ_SET_NUM ("style.border-width.left", style->borderWidth.left);
1293 DBG_OBJ_SET_NUM ("style.border-width.right", style->borderWidth.right);
1294
1295 DBG_OBJ_SET_NUM ("style.padding.top", style->padding.top);
1296 DBG_OBJ_SET_NUM ("style.padding.bottom", style->padding.bottom);
1297 DBG_OBJ_SET_NUM ("style.padding.left", style->padding.left);
1298 DBG_OBJ_SET_NUM ("style.padding.right", style->padding.right);
1299
1300 DBG_OBJ_SET_NUM ("style.border-spacing (h)", style->hBorderSpacing);
1301 DBG_OBJ_SET_NUM ("style.border-spacing (v)", style->vBorderSpacing);
1302
1303 DBG_OBJ_SET_SYM ("style.display",
1304 style->display == style::DISPLAY_BLOCK ? "block" :
1305 style->display == style::DISPLAY_INLINE ? "inline" :
1307 "inline-block" :
1308 style->display == style::DISPLAY_LIST_ITEM ? "list-item" :
1309 style->display == style::DISPLAY_NONE ? "none" :
1310 style->display == style::DISPLAY_TABLE ? "table" :
1312 "table-row-group" :
1314 "table-header-group" :
1316 "table-footer-group" :
1317 style->display == style::DISPLAY_TABLE_ROW ? "table-row" :
1318 style->display == style::DISPLAY_TABLE_CELL ? "table-cell" :
1319 "???");
1320
1321 DBG_OBJ_SET_NUM ("style.width (raw)", style->width);
1322 DBG_OBJ_SET_NUM ("style.min-width (raw)", style->minWidth);
1323 DBG_OBJ_SET_NUM ("style.max-width (raw)", style->maxWidth);
1324 DBG_OBJ_SET_NUM ("style.height (raw)", style->height);
1325 DBG_OBJ_SET_NUM ("style.min-height (raw)", style->minHeight);
1326 DBG_OBJ_SET_NUM ("style.max-height (raw)", style->maxHeight);
1327
1329 DBG_OBJ_SET_COL ("style.background-color",
1331 else
1332 DBG_OBJ_SET_SYM ("style.background-color", "transparent");
1333}
1334
1341{
1342 this->bgColor = bgColor;
1343}
1344
1349{
1350 Widget *widget = this;
1351
1352 while (widget != NULL) {
1353 if (widget->style->backgroundColor)
1354 return widget->style->backgroundColor;
1355 if (widget->bgColor)
1356 return widget->bgColor;
1357
1358 widget = widget->parent;
1359 }
1360
1361 return layout->getBgColor ();
1362}
1363
1368{
1369 Widget *widget = this;
1370
1371 while (widget != NULL) {
1372 if (widget->style->color)
1373 return widget->style->color;
1374
1375 widget = widget->parent;
1376 }
1377
1378 return NULL;
1379}
1380
1381
1389 int x, int y, int width, int height, bool inverse)
1390{
1391 Rectangle canvasArea;
1392 canvasArea.x = area->x + allocation.x;
1393 canvasArea.y = area->y + allocation.y;
1394 canvasArea.width = area->width;
1395 canvasArea.height = area->height;
1396
1397 style::drawBorder (view, layout, &canvasArea,
1398 allocation.x + x, allocation.y + y,
1399 width, height, style, inverse);
1400
1401 // This method is used for inline elements, where the CSS 2 specification
1402 // does not define what here is called "reference area". To make it look
1403 // smoothly, the widget padding box is used.
1404
1405 // TODO Handle inverse drawing the same way as in drawWidgetBox?
1406 // Maybe this method (drawBox) is anyway obsolete when extraSpace
1407 // is fully supported (as here, in the "dillo_grows" repository).
1408
1409 int xPad, yPad, widthPad, heightPad;
1410 getPaddingArea (&xPad, &yPad, &widthPad, &heightPad);
1412 (view, layout, &canvasArea,
1417 height - style->margin.top - style->borderWidth.top
1419 xPad, yPad, widthPad, heightPad, style, style->backgroundColor,
1420 inverse, false);
1421}
1422
1429void Widget::drawWidgetBox (View *view, Rectangle *area, bool inverse)
1430{
1431 Rectangle canvasArea;
1432 canvasArea.x = area->x + allocation.x;
1433 canvasArea.y = area->y + allocation.y;
1434 canvasArea.width = area->width;
1435 canvasArea.height = area->height;
1436
1437 int xMar, yMar, widthMar, heightMar;
1438 getMarginArea (&xMar, &yMar, &widthMar, &heightMar);
1439 style::drawBorder (view, layout, &canvasArea, xMar, yMar, widthMar,
1440 heightMar, style, inverse);
1441
1442 int xPad, yPad, widthPad, heightPad;
1443 getPaddingArea (&xPad, &yPad, &widthPad, &heightPad);
1444
1446 if (inverse && style->backgroundColor == NULL) {
1447 // See style::drawBackground: for inverse drawing, we need a
1448 // defined background color. Search through ancestors.
1449 Widget *w = this;
1450 while (w != NULL && w->style->backgroundColor == NULL)
1451 w = w->parent;
1452
1453 if (w != NULL && w->style->backgroundColor != NULL)
1455 else
1457 } else
1459
1460 style::drawBackground (view, layout, &canvasArea,
1461 xPad, yPad, widthPad, heightPad,
1462 xPad, yPad, widthPad, heightPad,
1463 style, bgColor, inverse, parent == NULL);
1464}
1465
1466/*
1467 * This function is used by some widgets, when they are selected (as a whole).
1468 *
1469 * \todo This could be accelerated by using clipping bitmaps. Two important
1470 * issues:
1471 *
1472 * (i) There should always been a pixel in the upper-left corner of the
1473 * *widget*, so probably two different clipping bitmaps have to be
1474 * used (10/01 and 01/10).
1475 *
1476 * (ii) Should a new GC always be created?
1477 *
1478 * \bug Not implemented.
1479 */
1481{
1482}
1483
1484
1486{
1487 this->buttonSensitive = buttonSensitive;
1488 buttonSensitiveSet = true;
1489}
1490
1491
1496{
1497 Widget *widget = this;
1498
1499 while (widget->parent)
1500 widget = widget->parent;
1501
1502 return widget;
1503}
1504
1511{
1512 Widget *widget = this;
1513 int level = 0;
1514
1515 while (widget->parent) {
1516 level++;
1517 widget = widget->parent;
1518 }
1519
1520 return level;
1521}
1522
1530{
1531 Widget *widget = this;
1532 int level = 0;
1533
1534 while (widget->getGenerator ()) {
1535 level++;
1536 widget = widget->getGenerator ();
1537 }
1538
1539 return level;
1540}
1541
1547{
1548 Widget *widget1 = this, *widget2 = otherWidget;
1549 int level1 = widget1->getLevel (), level2 = widget2->getLevel();
1550
1551 /* Get both widgets onto the same level.*/
1552 while (level1 > level2) {
1553 widget1 = widget1->parent;
1554 level1--;
1555 }
1556
1557 while (level2 > level1) {
1558 widget2 = widget2->parent;
1559 level2--;
1560 }
1561
1562 /* Search upwards. */
1563 while (widget1 != widget2) {
1564 if (widget1->parent == NULL) {
1565 MSG_WARN("widgets in different trees\n");
1566 return NULL;
1567 }
1568
1569 widget1 = widget1->parent;
1570 widget2 = widget2->parent;
1571 }
1572
1573 return widget1;
1574}
1575
1577 int x, int y, int width, int height)
1578{
1579 layout->scrollTo (hpos, vpos,
1580 x + allocation.x, y + allocation.y, width, height);
1581}
1582
1583void Widget::getMarginArea (int *xMar, int *yMar, int *widthMar, int *heightMar)
1584{
1585 *xMar = allocation.x + extraSpace.left;
1586 *yMar = allocation.y + extraSpace.top;
1587 *widthMar = allocation.width - (extraSpace.left + extraSpace.right);
1588 *heightMar = getHeight () - (extraSpace.top + extraSpace.bottom);
1589}
1590
1591void Widget::getBorderArea (int *xBor, int *yBor, int *widthBor, int *heightBor)
1592{
1593 getMarginArea (xBor, yBor, widthBor, heightBor);
1594
1595 *xBor += style->margin.left;
1596 *yBor += style->margin.top;
1597 *widthBor -= style->margin.left + style->margin.right;
1598 *heightBor -= style->margin.top + style->margin.bottom;
1599}
1600
1607void Widget::getPaddingArea (int *xPad, int *yPad, int *widthPad,
1608 int *heightPad)
1609{
1610 getBorderArea (xPad, yPad, widthPad, heightPad);
1611
1612 *xPad += style->borderWidth.left;
1613 *yPad += style->borderWidth.top;
1614 *widthPad -= style->borderWidth.left + style->borderWidth.right;
1615 *heightPad -= style->borderWidth.top + style->borderWidth.bottom;
1616}
1617
1619 Widget **references, int *x, int *y)
1620{
1621 // Use the simple variant.
1622 DBG_OBJ_ENTER0 ("resize", 0, "Widget::sizeRequestImpl");
1624 DBG_OBJ_LEAVE ();
1625}
1626
1628{
1629 // Either variant should be implemented.
1630 misc::notImplemented ("Widget::sizeRequestSimpl");
1631}
1632
1634 Widget **references, int *x, int *y)
1635{
1636 // Use the simple variant.
1637 DBG_OBJ_ENTER0 ("resize", 0, "Widget::getExtremesImpl");
1639 DBG_OBJ_LEAVE ();
1640}
1641
1643{
1644 // Either variant should be implemented.
1645 misc::notImplemented ("Widget::getExtremesSimpl");
1646}
1647
1651
1661void Widget::calcExtraSpaceImpl (int numPos, Widget **references, int *x,
1662 int *y)
1663{
1664}
1665
1667{
1668}
1669
1671{
1672}
1673
1674int Widget::applyPerWidth (int containerWidth, style::Length perWidth)
1675{
1676 return style::multiplyWithPerLength (containerWidth, perWidth)
1677 + boxDiffWidth ();
1678}
1679
1680int Widget::applyPerHeight (int containerHeight, style::Length perHeight)
1681{
1682 return style::multiplyWithPerLength (containerHeight, perHeight)
1683 + boxDiffHeight ();
1684}
1685
1696int Widget::getAvailWidthOfChild (Widget *child, bool forceValue)
1697{
1698 // This is a halfway suitable implementation for all
1699 // containers. For simplification, this will be used during the
1700 // development; then, a differentiation could be possible.
1701
1702 DBG_OBJ_ENTER ("resize", 0, "getAvailWidthOfChild", "%p, %s",
1703 child, forceValue ? "true" : "false");
1704
1705 int width;
1706
1707 if (child->getStyle()->width == style::LENGTH_AUTO) {
1708 DBG_OBJ_MSG ("resize", 1, "no specification");
1709
1710 /* We only compute when forceValue is true */
1711 if (forceValue) {
1712 width = misc::max (getAvailWidth (true) - boxDiffWidth (), 0);
1713
1714 if (width != -1) {
1715 /* Clamp to min-width and max-width if given */
1716 int maxWidth = child->calcWidth (child->getStyle()->maxWidth,
1717 -1, this, -1, false);
1718 if (maxWidth != -1 && width > maxWidth)
1719 width = maxWidth;
1720
1721 int minWidth = child->calcWidth (child->getStyle()->minWidth,
1722 -1, this, -1, false);
1723 if (minWidth != -1 && width < minWidth)
1724 width = minWidth;
1725 }
1726
1727 } else {
1728 width = -1;
1729 }
1730 } else {
1731 // In most cases, the toplevel widget should be a container, so
1732 // the container is non-NULL when the parent is non-NULL. Just
1733 // in case, regard also parent. And quasiParent.
1734 Widget *effContainer = child->quasiParent ? child->quasiParent :
1735 (child->container ? child->container : child->parent);
1736
1737 if (effContainer == this) {
1738 width = -1;
1739 child->calcFinalWidth (child->getStyle(), -1, this, 0, forceValue,
1740 &width);
1741 } else {
1742 DBG_OBJ_MSG ("resize", 1, "delegated to (effective) container");
1744 width = effContainer->getAvailWidthOfChild (child, forceValue);
1745 DBG_OBJ_MSG_END ();
1746 }
1747 }
1748
1749 DBG_OBJ_LEAVE_VAL ("%d", width);
1750 return width;
1751}
1752
1753int Widget::getAvailHeightOfChild (Widget *child, bool forceValue)
1754{
1755 // Again, a suitable implementation for all widgets (perhaps).
1756
1757 // TODO Consider 'min-height' and 'max-height'. (Minor priority, as long as
1758 // "getAvailHeight (true)" is not used.
1759
1760 DBG_OBJ_ENTER ("resize", 0, "getAvailHeightOfChild", "%p, %s",
1761 child, forceValue ? "true" : "false");
1762
1763 int height;
1764
1765 if (child->getStyle()->height == style::LENGTH_AUTO) {
1766 DBG_OBJ_MSG ("resize", 1, "no specification");
1767 if (forceValue)
1768 height = misc::max (getAvailHeight (true) - boxDiffHeight (), 0);
1769 else
1770 height = -1;
1771 } else {
1772 // See comment in Widget::getAvailWidthOfChild.
1773 Widget *effContainer = child->quasiParent ? child->quasiParent :
1774 (child->container ? child->container : child->parent);
1775
1776 if (effContainer == this) {
1777 if (style::isAbsLength (child->getStyle()->height)) {
1778 DBG_OBJ_MSGF ("resize", 1, "absolute height: %dpx",
1779 style::absLengthVal (child->getStyle()->height));
1780 height = misc::max (style::absLengthVal (child->getStyle()->height)
1781 + child->boxDiffHeight (), 0);
1782 } else {
1783 assert (style::isPerLength (child->getStyle()->height));
1784 DBG_OBJ_MSGF ("resize", 1, "percentage height: %g%%",
1786 (child->getStyle()->height));
1787
1788 int availHeight = getAvailHeight (forceValue);
1789 if (availHeight == -1)
1790 height = -1;
1791 else
1792 height =
1793 misc::max (child->applyPerHeight (availHeight -
1794 boxDiffHeight (),
1795 child->getStyle()->height),
1796 0);
1797 }
1798 } else {
1799 DBG_OBJ_MSG ("resize", 1, "delegated to (effective) container");
1801 height = effContainer->getAvailHeightOfChild (child, forceValue);
1802 DBG_OBJ_MSG_END ();
1803 }
1804 }
1805
1806 DBG_OBJ_LEAVE_VAL ("%d", height);
1807 return height;
1808}
1809
1811 void (*splitHeightFun) (int, int*,
1812 int*),
1813 bool allowDecreaseWidth,
1814 bool allowDecreaseHeight)
1815{
1816 // Again, a suitable implementation for all widgets (perhaps).
1817
1818 DBG_OBJ_ENTER ("resize", 0, "correctRequisitionOfChild",
1819 "%p, %d * (%d + %d), ..., %s, %s", child, requisition->width,
1821 misc::boolToStr (allowDecreaseWidth),
1822 misc::boolToStr (allowDecreaseHeight));
1823
1824 // See comment in Widget::getAvailWidthOfChild.
1825 Widget *effContainer = child->quasiParent ? child->quasiParent :
1826 (child->container ? child->container : child->parent);
1827
1828 if (effContainer == this) {
1829 correctReqWidthOfChild (child, requisition, allowDecreaseWidth);
1830 correctReqHeightOfChild (child, requisition, splitHeightFun,
1831 allowDecreaseHeight);
1832 } else {
1833 DBG_OBJ_MSG ("resize", 1, "delegated to (effective) container");
1835 effContainer->correctRequisitionOfChild (child, requisition,
1836 splitHeightFun,
1837 allowDecreaseWidth,
1838 allowDecreaseHeight);
1839 DBG_OBJ_MSG_END ();
1840 }
1841
1844}
1845
1847 bool allowDecreaseWidth)
1848{
1849 DBG_OBJ_ENTER ("resize", 0, "correctReqWidthOfChild",
1850 "%p, %d * (%d + %d), %s",
1852 requisition->descent, misc::boolToStr (allowDecreaseWidth));
1853
1854 assert (this == child->quasiParent || this == child->container);
1855
1856 int limitMinWidth = child->getMinWidth (NULL, true);
1857 if (!allowDecreaseWidth && limitMinWidth < requisition->width)
1858 limitMinWidth = requisition->width;
1859
1860 child->calcFinalWidth (child->getStyle(), -1, this, limitMinWidth, true,
1861 &requisition->width);
1862
1865}
1866
1868 void (*splitHeightFun) (int, int*, int*),
1869 bool allowDecreaseHeight)
1870{
1871 // TODO Correct height by extremes? (Height extemes?)
1872
1873 assert (this == child->quasiParent || this == child->container);
1874
1875 DBG_OBJ_ENTER ("resize", 0, "correctReqHeightOfChild",
1876 "%p, %d * (%d + %d), ..., %s", child, requisition->width,
1878 misc::boolToStr (allowDecreaseHeight));
1879
1880 int height = child->calcHeight (child->getStyle()->height, false, -1, this,
1881 false);
1882 adjustHeight (&height, allowDecreaseHeight, requisition->ascent,
1884
1885 int minHeight = child->calcHeight (child->getStyle()->minHeight, false, -1,
1886 this, false);
1887 adjustHeight (&minHeight, allowDecreaseHeight, requisition->ascent,
1889
1890 int maxHeight = child->calcHeight (child->getStyle()->maxHeight, false, -1,
1891 this, false);
1892 adjustHeight (&maxHeight, allowDecreaseHeight, requisition->ascent,
1894
1895 // TODO Perhaps split first, then add box ascent and descent.
1896 if (height != -1)
1897 splitHeightFun (height, &requisition->ascent, &requisition->descent);
1898 if (minHeight != -1 &&
1899 requisition->ascent + requisition->descent < minHeight)
1900 splitHeightFun (minHeight, &requisition->ascent,
1902 if (maxHeight != -1 &&
1903 requisition->ascent + requisition->descent > maxHeight)
1904 splitHeightFun (maxHeight, &requisition->ascent,
1906
1909}
1910
1912 bool useAdjustmentWidth)
1913{
1914 // See comment in correctRequisitionOfChild.
1915
1916 DBG_OBJ_ENTER ("resize", 0, "correctExtremesOfChild",
1917 "%p, %d (%d) / %d (%d)",
1920
1921 // See comment in Widget::getAvailWidthOfChild.
1922 Widget *effContainer = child->quasiParent ? child->quasiParent :
1923 (child->container ? child->container : child->parent);
1924
1925 if (effContainer == this) {
1926 int limitMinWidth =
1927 useAdjustmentWidth ? child->getMinWidth (extremes, false) : 0;
1928 int width = child->calcWidth (child->getStyle()->width, -1, this,
1929 limitMinWidth, false);
1930 int minWidth = child->calcWidth (child->getStyle()->minWidth, -1, this,
1931 limitMinWidth, false);
1932 int maxWidth = child->calcWidth (child->getStyle()->maxWidth, -1, this,
1933 limitMinWidth, false);
1934
1935 DBG_OBJ_MSGF ("resize", 1, "width = %d, minWidth = %d, maxWidth = %d",
1936 width, minWidth, maxWidth);
1937
1938 if (width != -1)
1939 extremes->minWidth = extremes->maxWidth = width;
1940 if (minWidth != -1)
1941 extremes->minWidth = minWidth;
1942 if (maxWidth != -1)
1943 extremes->maxWidth = maxWidth;
1944 } else {
1945 DBG_OBJ_MSG ("resize", 1, "delegated to (effective) container");
1947 effContainer->correctExtremesOfChild (child, extremes,
1948 useAdjustmentWidth);
1949 DBG_OBJ_MSG_END ();
1950 }
1951
1952
1954}
1955
1965
1972{
1973}
1974
1976{
1977 // Most widgets are not block-level.
1978 return false;
1979}
1980
1982{
1983 // In most (all?) cases identical to:
1984 return isBlockLevel ();
1985}
1986
1988{
1989 return false;
1990}
1991
1993{
1994 return false;
1995}
1996
1998{
1999 return false;
2000}
2001
2003{
2004 style::Tooltip *tooltip = getStyle()->x_tooltip;
2005
2006 if (tooltip)
2007 tooltip->onEnter();
2008}
2009
2011{
2012 style::Tooltip *tooltip = getStyle()->x_tooltip;
2013
2014 if (tooltip)
2015 tooltip->onLeave();
2016}
2017
2018
2020{
2021 // Should be implemented.
2022 misc::notImplemented ("Widget::removeChild");
2023}
2024
2025// ----------------------------------------------------------------------
2026
2027void splitHeightPreserveAscent (int height, int *ascent, int *descent)
2028{
2029 DBG_OBJ_ENTER_S ("resize", 1, "splitHeightPreserveAscent", "%d, %d, %d",
2030 height, *ascent, *descent);
2031
2032 *descent = height - *ascent;
2033 if (*descent < 0) {
2034 *descent = 0;
2035 *ascent = height;
2036 }
2037
2038 DBG_OBJ_LEAVE_VAL_S ("%d, %d", *ascent, *descent);
2039}
2040
2041void splitHeightPreserveDescent (int height, int *ascent, int *descent)
2042{
2043 DBG_OBJ_ENTER_S ("resize", 1, "splitHeightPreserveDescent", "%d, %d, %d",
2044 height, *ascent, *descent);
2045
2046 *ascent = height - *descent;
2047 if (*ascent < 0) {
2048 *ascent = 0;
2049 *descent = height;
2050 }
2051
2052 DBG_OBJ_LEAVE_VAL_S ("%d, %d", *ascent, *descent);
2053}
2054
2055} // namespace core
2056} // namespace dw
#define _MSG(...)
Definition bookmarks.c:45
Set at the top when drawing.
Definition types.hh:295
Rectangle * getToplevelArea()
Definition types.hh:304
Represents a button press or release event.
Definition events.hh:58
Represents a enter or leave notify event.
Definition events.hh:75
Represents a mouse motion event.
Definition events.hh:68
Set at the top when getting the widget at the point.
Definition types.hh:313
Iterators are used to iterate through the contents of a widget.
Definition iterator.hh:20
virtual void unref()
Delete the iterator.
Definition iterator.cc:82
virtual bool next()=0
Move iterator forward and store content it.
Content * getContent()
Definition iterator.hh:37
void queueDraw(int x, int y, int width, int height)
Definition layout.cc:988
style::Color * getBgColor()
Definition layout.hh:442
void queueDrawExcept(int x, int y, int width, int height, int ex, int ey, int ewidth, int eheight)
Definition layout.cc:1001
lout::container::typed::Vector< Widget > * queueResizeList
Definition layout.hh:158
int vScrollbarThickness
Definition layout.hh:173
void updateCursor()
Definition layout.cc:817
void removeWidget()
Definition layout.cc:405
Widget * topLevel
Definition layout.hh:157
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.
Definition layout.cc:538
bool canvasHeightGreater
Definition layout.hh:172
void queueResize(bool extremesChanged)
Definition layout.cc:1024
dw::core::Shape implemtation for simple rectangles.
Definition types.hh:70
bool intersectsWith(Rectangle *otherRect, Rectangle *dest)
Return whether this rectangle and otherRect intersect.
Definition types.cc:53
Hold arguments passed to dw::core::Widget::sizeRequest and dw::core::Widget::getExtremes,...
Definition tools.hh:19
bool isEquivalent(SizeParams *other)
Compares two instances, but considers a change in the order of the reference widgets as equivalent.
Definition tools.cc:164
See Handling stacking contexts.
static bool isEstablishingStackingContext(Widget *widget)
void addChildSCWidget(Widget *widget)
void addWidgetProcessedAsInterruption(Widget *widget)
Definition types.hh:282
An interface to encapsulate platform dependent drawing.
Definition view.hh:17
Implementation which represents the whole widget.
Definition widget.hh:105
bool readyToDraw()
If this method returns false, nothing is done at all.
Definition widget.cc:35
style::Style * getStyle()
Return the style this background image is part of.
Definition widget.cc:52
void getBgArea(int *x, int *y, int *width, int *height)
Return the area covered by the background image.
Definition widget.cc:40
void getRefArea(int *xRef, int *yRef, int *widthRef, int *heightRef)
Return the "reference area".
Definition widget.cc:46
void draw(int x, int y, int width, int height)
Draw (or queue for drawing) an area, which is given in canvas coordinates.
Definition widget.cc:57
The base class of all dillo widgets.
Definition widget.hh:44
virtual void notifySetParent()
This method is called after a widget has been added to a parent.
Definition widget.cc:1971
virtual void setStyle(style::Style *style)
Change the style of a widget.
Definition widget.cc:1233
void leaveSizeRequest()
Definition widget.hh:438
WidgetImgRenderer * widgetImgRenderer
Definition widget.hh:119
virtual void leaveNotifyImpl(EventCrossing *event)
Definition widget.cc:2010
void sizeAllocate(Allocation *allocation)
Wrapper for Widget::sizeAllocateImpl, calls the latter only when needed.
Definition widget.cc:1126
bool queueResizeEntered()
Definition widget.hh:431
bool motionNotify(EventMotion *event)
Definition widget.cc:1211
void setWidgetReference(WidgetReference *widgetReference)
Definition widget.hh:581
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition widget.hh:166
Layout * layout
Definition widget.hh:209
Widget * container
The containing widget, equivalent to the "containing block" defined by CSS.
Definition widget.hh:146
void enterQueueResize()
Definition widget.hh:429
SizeParams requisitionParams
Definition widget.hh:161
virtual bool usesAvailWidth()
Must be implemengted by a method returning true, when getAvailWidth() is called.
Definition widget.cc:516
bool intersects(Widget *refWidget, Rectangle *area, Rectangle *intersection)
Calculates the intersection of the visible allocation (i.
Definition widget.cc:139
void setQuasiParent(Widget *quasiParent)
Definition widget.cc:276
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition widget.hh:203
static void adjustHeight(int *height, bool allowDecreaseHeight, int ascent, int descent)
Definition widget.cc:1004
virtual bool affectedByContainerSizeChange()
Definition widget.cc:433
virtual Iterator * iterator(Content::Type mask, bool atEnd)=0
Return an iterator for this widget.
style::Color * getFgColor()
Get the actual foreground color of a widget.
Definition widget.cc:1367
void leaveGetExtremes()
Definition widget.hh:442
virtual void draw(View *view, Rectangle *area, DrawingContext *context)=0
Area is given in widget coordinates.
void setButtonSensitive(bool buttonSensitive)
Definition widget.cc:1485
virtual void markExtremesChange(int ref)
See Sizes of Dillo Widgets.
Definition widget.cc:1670
@ NEEDS_ALLOCATE
Only used internally, set to enforce size allocation.
Definition widget.hh:76
@ WAS_ALLOCATED
Set, when a widget was already once allocated,.
Definition widget.hh:96
@ EXTREMES_CHANGED
Set, when dw::core::Widget::extremes is not up to date anymore.
Definition widget.hh:89
@ NEEDS_RESIZE
Set, when dw::core::Widget::requisition is not up to date anymore.
Definition widget.hh:65
virtual int getAvailWidthOfChild(Widget *child, bool forceValue)
Computes the content width available of a child widget.
Definition widget.cc:1696
virtual bool affectsSizeChangeContainerChild(Widget *child)
Definition widget.cc:467
void sizeRequest(Requisition *requisition, int numPos=0, Widget **references=NULL, int *x=NULL, int *y=NULL)
This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed.
Definition widget.cc:534
Widget * getParent()
Definition widget.hh:573
int boxDiffWidth()
Definition widget.hh:481
int parentRef
This value is defined by the parent widget, and used for incremential resizing.
Definition widget.hh:195
int getAvailWidth(bool forceValue)
Return available width including margin/border/padding (extraSpace?), not only the content width.
Definition widget.cc:649
bool sizeRequestEntered()
Definition widget.hh:439
void enterNotify(EventCrossing *event)
Definition widget.cc:1216
void calcFinalWidth(style::Style *style, int refWidth, Widget *refWidget, int limitMinWidth, bool forceValue, int *finalWidth)
Definition widget.cc:927
void drawWidgetBox(View *view, Rectangle *area, bool inverse)
Draw borders and background of a widget.
Definition widget.cc:1429
bool needsAllocate()
Definition widget.hh:458
void correctRequisition(Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition widget.cc:744
void drawSelected(View *view, Rectangle *area)
Definition widget.cc:1480
void calcExtraSpace(int numPos, Widget **references, int *x, int *y)
Calculates dw::core::Widget::extraSpace.
Definition widget.cc:1085
virtual bool getAdjustMinWidth()
Definition widget.hh:518
style::Style * getStyle()
Definition widget.hh:468
int getLevel()
Get the level of the widget within the tree.
Definition widget.cc:1510
bool resizeQueued()
Definition widget.hh:455
virtual void removeChild(Widget *child)
Definition widget.cc:2019
virtual bool motionNotifyImpl(EventMotion *event)
Definition widget.cc:1997
bool buttonRelease(EventButton *event)
Definition widget.cc:1206
Widget * stackingContextWidget
The bottom-most ancestor (or this) for which stackingContextMgr is set.
Definition widget.hh:231
virtual void notifySetAsTopLevel()
This method is called after a widget has been set as the top of a widget tree.
Definition widget.cc:1962
style::Color * bgColor
See dw::core::Widget::setBgColor().
Definition widget.hh:172
StackingContextMgr * stackingContextMgr
Set iff this widget constitutes a stacking context, as defined by CSS.
Definition widget.hh:225
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition widget.hh:160
Widget * getGenerator()
Definition widget.hh:586
Widget * getWidgetAtPointInterrupted(int x, int y, GettingWidgetAtPointContext *context)
Definition widget.cc:222
virtual void enterNotifyImpl(EventCrossing *event)
Definition widget.cc:2002
style::Box extraSpace
Space around the margin box.
Definition widget.hh:219
int calcWidth(style::Length cssValue, int refWidth, Widget *refWidget, int limitMinWidth, bool forceValue)
Computes a width value in pixels from cssValue.
Definition widget.cc:883
virtual void getExtremesSimpl(Extremes *extremes)
Simple variant, to be implemented by widgets with extremes not depending on positions.
Definition widget.cc:1642
void queueDrawArea(int x, int y, int width, int height)
Definition widget.cc:285
virtual int getAvailHeightOfChild(Widget *child, bool forceValue)
Definition widget.cc:1753
bool resizeIdleEntered()
Definition widget.hh:427
bool inAllocation(int x, int y)
Definition widget.hh:471
virtual void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition widget.cc:1810
Widget * getNearestCommonAncestor(Widget *otherWidget)
Get the widget with the highest level, which is a direct ancestor of widget1 and widget2.
Definition widget.cc:1546
virtual void sizeAllocateImpl(Allocation *allocation)
See Sizes of Dillo Widgets.
Definition widget.cc:1648
bool extremesQueued()
Definition widget.hh:456
bool extremesChanged()
Definition widget.hh:460
virtual void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition widget.cc:1911
bool getExtremesEntered()
Definition widget.hh:443
Widget * generator
The generating widget, NULL for top-level widgets, or if not set; in the latter case,...
Definition widget.hh:139
virtual void sizeRequestSimpl(Requisition *requisition)
Simple variant, to be implemented by widgets with sizes not depending on positions.
Definition widget.cc:1627
void * deleteCallbackData
Definition widget.hh:419
int getMinWidth(Extremes *extremes, bool forceValue)
Used to evaluate Widget::adjustMinWidth.
Definition widget.cc:604
virtual void calcExtraSpaceImpl(int numPos, Widget **references, int *x, int *y)
The actual implementation for calculating dw::core::Widget::extraSpace.
Definition widget.cc:1661
virtual void resizeDrawImpl()
Called after sizeAllocateImpl() to redraw necessary areas.
Definition widget.hh:339
virtual bool buttonPressImpl(EventButton *event)
Definition widget.cc:1987
void setParent(Widget *parent)
Definition widget.cc:231
virtual bool isPossibleContainer()
Definition widget.cc:1981
DW_Callback_t deleteCallbackFunc
Definition widget.hh:420
virtual void getExtremesImpl(Extremes *extremes, int numPos, Widget **references, int *x, int *y)
See Sizes of Dillo Widgets.
Definition widget.cc:1633
void queueResizeFast(int ref, bool extremesChanged)
Definition widget.hh:185
bool needsResize()
Definition widget.hh:457
virtual void containerSizeChangedForChildren()
Definition widget.cc:497
void scrollTo(HPosition hpos, VPosition vpos, int x, int y, int width, int height)
Definition widget.cc:1576
void enterSizeAllocate()
Definition widget.hh:433
int calcHeight(style::Length cssValue, bool usePercentage, int refHeight, Widget *refWidget, bool forceValue)
Definition widget.cc:958
virtual Widget * getWidgetAtPoint(int x, int y, GettingWidgetAtPointContext *context)
Definition widget.cc:211
virtual int applyPerHeight(int containerHeight, style::Length perHeight)
Definition widget.cc:1680
void leaveNotify(EventCrossing *event)
Definition widget.cc:1221
void drawInterruption(View *view, Rectangle *area, DrawingContext *context)
See Interrupted drawing for details.
Definition widget.cc:201
virtual int numGetExtremesReferences()
See Sizes of Dillo Widgets (or Size requisitions depending on positions).
Definition widget.cc:1111
virtual Widget * sizeRequestReference(int index)
See Sizes of Dillo Widgets (or Size requisitions depending on positions).
Definition widget.cc:1105
Widget * parent
The parent widget, NULL for top-level widgets.
Definition widget.hh:127
int getAvailHeight(bool forceValue)
Return available height including margin/border/padding (extraSpace?), not only the content height.
Definition widget.cc:691
void leaveQueueResize()
Definition widget.hh:430
style::Style * style
Definition widget.hh:150
static bool adjustMinWidth
Definition widget.hh:122
void containerSizeChanged()
Definition widget.cc:408
int getGeneratorLevel()
Get the level of the widget within the tree, regarting the generators, not the parents.
Definition widget.cc:1529
void leaveSizeAllocate()
Definition widget.hh:434
void unsetFlags(Flags f)
Definition widget.hh:294
void queueResize(int ref, bool extremesChanged, bool fast)
This method should be called, when a widget changes its size.
Definition widget.cc:309
virtual void sizeRequestImpl(Requisition *requisition, int numPos, Widget **references, int *x, int *y)
See Sizes of Dillo Widgets.
Definition widget.cc:1618
bool buttonPress(EventButton *event)
Definition widget.cc:1201
void correctReqHeightOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseHeight)
Definition widget.cc:1867
virtual bool usesAvailHeight()
Must be implemengted by a method returning true, when getAvailHeight() is called.
Definition widget.cc:525
virtual void markSizeChange(int ref)
See Sizes of Dillo Widgets.
Definition widget.cc:1666
Widget * getTopLevel()
Get the widget at the root of the tree, this widget is part from.
Definition widget.cc:1495
style::Color * getBgColor()
Get the actual background of a widget.
Definition widget.cc:1348
bool wasAllocated()
Definition widget.hh:461
virtual int numSizeRequestReferences()
See Sizes of Dillo Widgets (or Size requisitions depending on positions).
Definition widget.cc:1100
virtual Widget * getExtremesReference(int index)
See Sizes of Dillo Widgets (or Size requisitions depending on positions).
Definition widget.cc:1116
void getBorderArea(int *xBor, int *yBor, int *widthBor, int *heightBor)
Definition widget.cc:1591
int boxDiffHeight()
Definition widget.hh:486
void setBgColor(style::Color *bgColor)
Set the background "behind" the widget, if it is not the background of the parent widget,...
Definition widget.cc:1340
void queueDraw()
Definition widget.hh:297
virtual int applyPerWidth(int containerWidth, style::Length perWidth)
Definition widget.cc:1674
void correctExtremes(Extremes *extremes, bool useAdjustmentWidth)
Definition widget.cc:821
void getMarginArea(int *xMar, int *yMar, int *widthMar, int *heightMar)
Definition widget.cc:1583
void getPaddingArea(int *xPad, int *yPad, int *widthPad, int *heightPad)
Return the padding area (content plus padding).
Definition widget.cc:1607
virtual bool buttonReleaseImpl(EventButton *event)
Definition widget.cc:1992
SizeParams extremesParams
Definition widget.hh:167
void setFlags(Flags f)
Definition widget.hh:292
void correctReqWidthOfChild(Widget *child, Requisition *requisition, bool allowDecreaseWidth)
Definition widget.cc:1846
bool buttonSensitiveSet
See dw::core::Widget::setButtonSensitive().
Definition widget.hh:182
void getExtremes(Extremes *extremes, int numPos=0, Widget **references=NULL, int *x=NULL, int *y=NULL)
Wrapper for Widget::getExtremesImpl().
Definition widget.cc:1014
void enterGetExtremes()
Definition widget.hh:441
void drawBox(View *view, style::Style *style, Rectangle *area, int x, int y, int width, int height, bool inverse)
Draw borders and background of a widget part, which allocation is given by (x, y, width,...
Definition widget.cc:1388
Widget * quasiParent
...
Definition widget.hh:132
static int CLASS_ID
Definition widget.hh:447
bool buttonSensitive
See dw::core::Widget::setButtonSensitive().
Definition widget.hh:177
void enterSizeRequest()
Definition widget.hh:437
virtual bool isBlockLevel()
Definition widget.cc:1975
StyleImage * backgroundImage
Definition style.hh:536
bool sizeDiffs(StyleAttrs *otherStyleAttrs)
This method returns whether something may change its size, when its style changes from this style to ...
Definition style.cc:150
void putExternalImgRenderer(ImgRenderer *ir)
Add an additional ImgRenderer, especially used for drawing.
Definition style.hh:890
void removeExternalImgRenderer(ImgRenderer *ir)
Remove a previously added additional ImgRenderer.
Definition style.hh:896
virtual void onLeave()
Definition style.hh:672
virtual void onEnter()
Definition style.hh:671
void registerName(const char *className, int *classId)
This method must be called in the constructor for the sub class.
Definition identity.cc:83
#define DBG_IF_RTFL
Definition debug.hh:73
#define DBG_OBJ_LEAVE_VAL_S(fmt,...)
Definition debug.hh:80
#define DBG_OBJ_ENTER_S(aspect, prio, funname, fmt,...)
Definition debug.hh:78
#define DBG_OBJ_ENTER0(aspect, prio, funname)
#define DBG_OBJ_DELETE()
#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_LEAVE()
#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,...)
#define MSG_WARN(...)
Definition msg.h:26
int multiplyWithPerLength(int x, Length l)
Multiply an int with a percentage length, returning int.
Definition style.hh:473
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.
Definition style.cc:1233
@ DISPLAY_TABLE_HEADER_GROUP
Definition style.hh:285
@ DISPLAY_TABLE_ROW_GROUP
Definition style.hh:284
@ DISPLAY_INLINE_BLOCK
Definition style.hh:280
@ DISPLAY_TABLE_FOOTER_GROUP
Definition style.hh:286
int Length
Type for representing all lengths within dw::core::style.
Definition style.hh:428
double perLengthVal_useThisOnlyForDebugging(Length l)
Returns the value of a percentage, relative to 1, as a double.
Definition style.hh:458
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.
Definition style.cc:1168
bool isPerLength(Length l)
Returns true if l is a percentage.
Definition style.hh:445
bool isAbsLength(Length l)
Returns true if l is an absolute length.
Definition style.hh:442
int absLengthVal(Length l)
Returns the value of a length in pixels, as an integer.
Definition style.hh:451
@ LENGTH_AUTO
Represents "auto" lengths.
Definition style.hh:494
void splitHeightPreserveDescent(int height, int *ascent, int *descent)
Definition widget.cc:2041
VPosition
Definition types.hh:26
void splitHeightPreserveAscent(int height, int *ascent, int *descent)
Definition widget.cc:2027
HPosition
Definition types.hh:16
Dw is in this namespace, or sub namespaces of this one.
Miscellaneous stuff, which does not fit anywhere else.
Definition misc.cc:31
void notImplemented(const char *name)
Definition misc.hh:56
T max(T a, T b)
Definition misc.hh:21
const char * boolToStr(bool b)
Definition misc.hh:88
Here, some common classes (or interfaces) are defined, to standardize the access to other classes.
Definition object.cc:30
Represents the allocation, i.e.
Definition types.hh:164
@ WIDGET_IN_FLOW
widget in normal flow, so that this widget (containing this content) is both container (parent) and g...
Definition types.hh:207
@ WIDGET_OOF_CONT
widget out of flow (OOF); this widget (containing this content) is only the container (parent),...
Definition types.hh:212
Widget * widget
Definition types.hh:237