libyui  3.3.2
YLayoutBox.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YLayoutBox.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include <iomanip> // std::setw()
27 #include <algorithm> // std::max()
28 
29 #define YUILogComponent "ui-layout"
30 #include "YUILog.h"
31 
32 #include "YLayoutBox.h"
33 #include "YAlignment.h"
34 #include "YSpacing.h"
35 #include "YUI.h"
36 #include "YApplication.h"
37 
38 using std::endl;
39 using std::setw;
40 using std::max;
41 using std::boolalpha;
42 
44 {
45  /**
46  * Constructor
47  **/
48  YLayoutBoxPrivate( YUIDimension prim )
49  : primary( prim )
50  , secondary( prim == YD_HORIZ ? YD_VERT : YD_HORIZ )
51  , debugLayout( false )
52  {}
53 
54  //
55  // Data members
56  //
57 
58  YUIDimension primary;
59  YUIDimension secondary;
60  bool debugLayout;
61 };
62 
63 
64 
65 
66 YLayoutBox::YLayoutBox( YWidget * parent, YUIDimension primaryDimension )
67  : YWidget( parent )
68  , priv( new YLayoutBoxPrivate( primaryDimension ) )
69 {
70  YUI_CHECK_NEW( priv );
72 }
73 
74 
76 {
77  // NOP
78 }
79 
80 
81 YUIDimension
83 {
84  return priv->primary;
85 }
86 
87 
88 YUIDimension
90 {
91  return priv->secondary;
92 }
93 
94 
95 bool
97 {
98  return priv->debugLayout;
99 }
100 
101 void
103 {
104  priv->debugLayout = deb;
105 
106  yuiDebug() << "YLayoutBox: Layout debugging: " << boolalpha << deb << endl;
107 }
108 
109 
110 int
111 YLayoutBox::preferredSize( YUIDimension dimension )
112 {
113  if ( dimension == secondary() ) // the easy case first: secondary dimension
114  {
115  return childrenMaxPreferredSize( dimension );
116  }
117  else
118  {
119  /*
120  * In the primary dimension things are much more complicated: We want to
121  * honor any weights specified under all circumstances. So we first
122  * need to determine the "dominating child" - the widget that determines the
123  * overall size with respect to its weight in that dimension. Once we
124  * know that, we need to stretch all other weighted children accordingly
125  * so the weight ratios are respected.
126  *
127  * As a final step, the preferred sizes of all children that don't have
128  * a weight attached are summed up.
129  */
130 
131  int size = 0L;
132 
133  // Search for the dominating child
134  YWidget * dominatingChild = findDominatingChild();
135 
136  if ( dominatingChild )
137  {
138  // Calculate size of all weighted widgets.
139 
140  size = dominatingChild->preferredSize( primary() )
142  / dominatingChild->weight( primary() );
143 
144  // Maintain this order of calculation in order to minimize integer
145  // rounding errors!
146  }
147 
148 
149  // Add up the size of all non-weighted children;
150  // they will get their respective preferred size.
151 
153 
154  return size;
155  }
156 }
157 
158 
160 {
161  return preferredSize( YD_HORIZ );
162 }
163 
164 
166 {
167  return preferredSize( YD_VERT );
168 }
169 
170 
171 /*
172  * Search for the "dominating child" widget.
173  *
174  * This is the widget that determines the overall size of the
175  * container with respect to all children's weights: It is the child
176  * with the maximum ratio of preferred size and weight. All other
177  * weighted children need to be stretched accordingly so the weight
178  * ratios can be maintained.
179  *
180  * Returns 0 if there is no dominating child, i.e. if there are only
181  * non-weighted children.
182  */
183 
184 YWidget *
186 {
187  YWidget * dominatingChild = 0;
188  double dominatingRatio = 0.0;
189  double ratio;
190 
191  for ( YWidgetListConstIterator it = childrenBegin();
192  it != childrenEnd();
193  ++it )
194  {
195  YWidget * child = *it;
196 
197  if ( child->weight( primary() ) != 0 ) // avoid division by zero
198  {
199  ratio = ( ( double ) child->preferredSize( primary() ) )
200  / child->weight( primary() );
201 
202  if ( ratio > dominatingRatio ) // we have a new dominating child
203  {
204  dominatingChild = child;
205  dominatingRatio = ratio;
206  }
207  }
208  }
209 
210 
211  if ( debugLayout() )
212  {
213  if ( dominatingChild )
214  {
215  yuiDebug() << "Found dominating child: " << dominatingChild
216  << " - preferred size: " << dominatingChild->preferredSize( primary() )
217  << ", weight: " << dominatingChild->weight( primary() )
218  << endl;
219  }
220  else
221  {
222  yuiDebug() << "This layout doesn't have a dominating child." << endl;
223  }
224  }
225 
226  return dominatingChild;
227 }
228 
229 
230 int
231 YLayoutBox::childrenMaxPreferredSize( YUIDimension dimension )
232 {
233  int maxPreferredSize = 0L;
234 
235  for ( YWidgetListConstIterator it = childrenBegin();
236  it != childrenEnd();
237  ++it )
238  {
239  maxPreferredSize = std::max( (*it)->preferredSize( dimension ), maxPreferredSize );
240  }
241 
242  return maxPreferredSize;
243 }
244 
245 
246 int
247 YLayoutBox::childrenTotalWeight( YUIDimension dimension )
248 {
249  int totalWeight = 0L;
250 
251  for ( YWidgetListConstIterator it = childrenBegin();
252  it != childrenEnd();
253  ++it )
254  {
255  totalWeight += (*it)->weight( dimension );
256  }
257 
258  return totalWeight;
259 }
260 
261 
262 int
264 {
265  int size = 0L;
266 
267  for ( YWidgetListConstIterator it = childrenBegin();
268  it != childrenEnd();
269  ++it )
270  {
271  if ( ! (*it)->hasWeight( dimension ) ) // non-weighted children only
272  size += (*it)->preferredSize( dimension );
273  }
274 
275  return size;
276 }
277 
278 
279 int
280 YLayoutBox::countNonWeightedChildren( YUIDimension dimension )
281 {
282  int count = 0;
283 
284  for ( YWidgetListConstIterator it = childrenBegin();
285  it != childrenEnd();
286  ++it )
287  {
288  if ( ! (*it)->hasWeight( dimension ) )
289  count++;
290  }
291 
292  return count;
293 }
294 
295 
296 int
297 YLayoutBox::countStretchableChildren( YUIDimension dimension )
298 {
299  int count = 0;
300 
301  for ( YWidgetListConstIterator it = childrenBegin();
302  it != childrenEnd();
303  ++it )
304  {
305  if ( ! (*it)->hasWeight( dimension ) &&
306  (*it)->stretchable( dimension ) )
307  count++;
308  }
309 
310  return count;
311 }
312 
313 
314 int
315 YLayoutBox::countLayoutStretchChildren( YUIDimension dimension )
316 {
317  int count = 0;
318 
319  for ( YWidgetListConstIterator it = childrenBegin();
320  it != childrenEnd();
321  ++it )
322  {
323  if ( ! (*it)->hasWeight( dimension ) &&
324  isLayoutStretch( *it, dimension ) )
325  count++;
326  }
327 
328  return count;
329 }
330 
331 
332 bool
333 YLayoutBox::isLayoutStretch( YWidget * child, YUIDimension dimension )
334 {
335  if ( ! child )
336  return false;
337 
338  YSpacing * spacing = dynamic_cast<YSpacing *> (child);
339 
340  if ( spacing && spacing->stretchable( dimension ) )
341  return true;
342  else
343  return false;
344 }
345 
346 
347 
348 bool
349 YLayoutBox::stretchable( YUIDimension dimension ) const
350 {
351  for ( YWidgetListConstIterator it = childrenBegin();
352  it != childrenEnd();
353  ++it )
354  {
355  if ( (*it)->stretchable( dimension ) ||
356  (*it)->hasWeight( dimension ) )
357  return true;
358  }
359 
360  return false;
361 }
362 
363 
364 void
365 YLayoutBox::setSize( int newWidth, int newHeight )
366 {
367  int count = childrenCount();
368  sizeVector widths ( count );
369  sizeVector heights ( count );
370  posVector x_pos ( count );
371  posVector y_pos ( count );
372 
373  if ( primary() == YD_HORIZ )
374  {
375  calcPrimaryGeometry ( newWidth, widths, x_pos );
376  calcSecondaryGeometry( newHeight, heights, y_pos );
377  }
378  else
379  {
380  calcPrimaryGeometry ( newHeight, heights, y_pos );
381  calcSecondaryGeometry( newWidth, widths, x_pos );
382  }
383 
384  if ( YUI::app()->reverseLayout() )
385  {
386  // Mirror the widget X geometry for languages with left-to-right
387  // writing direction (Arabic, Hebrew).
388 
389  for ( int i = 0; i < childrenCount(); i++ )
390  x_pos[i] = newWidth - x_pos[i] - widths[i];
391  }
392 
393  doResize( widths, heights, x_pos, y_pos );
394 }
395 
396 
397 void
399  sizeVector & childSize,
400  posVector & childPos )
401 {
402  int pos = 0L;
403  int distributableSize = newSize - totalNonWeightedChildrenPreferredSize( primary() );
404 
405  if ( distributableSize >= 0L )
406  {
407  // The (hopefully) normal case: There is enough space.
408  // The non-weighted children will get their preferred sizes,
409  // the rest will be distributed among the weighted children
410  // according to their respective weight ratios.
411 
412  int nonWeightedExtra = 0L;
413  int totalWeight = childrenTotalWeight( primary() );
414  int rubberBands = 0;
415  int rubberBandExtra = 0L;
416 
417  if ( totalWeight <= 0 )
418  {
419  // If there are no weighted children, equally divide the
420  // extra space among the stretchable children (if any).
421  // This includes any layout stretch spaces.
422 
423  int stretchableChildren = countStretchableChildren( primary() );
424 
425  if ( stretchableChildren > 0 ) // avoid division by zero
426  nonWeightedExtra = distributableSize / stretchableChildren;
427  }
428  else
429  {
430  // If there are weighted children and there are rubber band
431  // widgets, equally divide any surplus space (i.e. space that
432  // exceeds the weighted children's preferred sizes with respect to
433  // their weights) between the rubber bands.
434  //
435  // This offers an easy way to make nicely even spaced buttons
436  // of equal size: Give all buttons a weight of 1 and insert a
437  // stretch (without weight!) between each.
438 
439  int surplusSize = newSize - preferredSize( primary() );
440 
441  if ( surplusSize > 0L )
442  {
443  rubberBands = countLayoutStretchChildren( primary() );
444 
445  if ( rubberBands > 0 )
446  {
447  rubberBandExtra = surplusSize / rubberBands;
448  distributableSize -= rubberBandExtra * rubberBands;
449  }
450  }
451  }
452 
453  if ( debugLayout() )
454  {
455  yuiDebug() << "Distributing extra space" << endl;
456  yuiDebug() << "\tnew size: " << newSize << endl;
457  yuiDebug() << "\tdistributable size: " << distributableSize << endl;
458  yuiDebug() << "\trubber band extra: " << rubberBandExtra << endl;
459  yuiDebug() << "\trubber bands: " << rubberBands << endl;
460  yuiDebug() << "\ttotal weight: " << totalWeight << endl;
461  yuiDebug() << "\tnon weighted extra: " << nonWeightedExtra << endl;
462  }
463 
464  int i=0;
465  for ( YWidgetListConstIterator it = childrenBegin();
466  it != childrenEnd();
467  ++it, i++ )
468  {
469  YWidget * child = *it;
470 
471  if ( child->hasWeight( primary() ) )
472  {
473  // Weighted children will get their share.
474 
475  childSize[i] = distributableSize * child->weight( primary() ) / totalWeight;
476 
477  if ( childSize[i] < child->preferredSize( primary() ) )
478  {
479  yuiDebug() << "Layout running out of space: "
480  << "Resizing child widget #" << i << " ("<< child
481  << ") below its preferred size of " << child->preferredSize( primary() )
482  << " to " << childSize[i]
483  << endl;
484  }
485  }
486  else
487  {
488  // Non-weighted children will get their preferred size.
489 
490  childSize[i] = child->preferredSize( primary() );
491 
492 
493  if ( child->stretchable( primary() ) )
494  {
495  // If there are only non-weighted children (and only then),
496  // the stretchable children will get their fair share of the
497  // extra space.
498 
499  childSize[i] += nonWeightedExtra;
500  }
501 
502  if ( isLayoutStretch( child, primary() ) )
503  {
504  // If there is more than the total preferred size and there
505  // are rubber bands, distribute surplus space among the
506  // rubber bands.
507 
508  childSize[i] += rubberBandExtra;
509  }
510  }
511 
512  childPos[i] = pos;
513  pos += childSize[i];
514  }
515  }
516  else // The pathological case: Not enough space.
517  {
518  /*
519  * We're in deep shit.
520  *
521  * Not only is there nothing to distribute among the weighted children,
522  * we also need to resize the non-weighted children below their preferred
523  * sizes. Let's at least treat them equally bad - divide the lost space
524  * among them as fair as possible.
525  */
526 
527  int tooSmall = -distributableSize;
528  int loserCount = 0;
529  int totalMargins = 0L;
530  int remainingMargins = 0L;
531  double marginScale = 0.0;
532 
533  yuiDebug() << "Not enough space: " << tooSmall << " too small - check the layout!" << endl;
534 
535 
536  // Maybe some of the children are YAlignments with margins that can be reduced
537 
538  for ( YWidgetListConstIterator it = childrenBegin();
539  it != childrenEnd();
540  ++it )
541  {
542  if ( ! (*it)->hasWeight( primary() ) ) // children with weights will get nothing anyway
543  {
544  YAlignment * alignment = dynamic_cast<YAlignment *> (*it);
545 
546  if ( alignment )
547  {
548  totalMargins += alignment->totalMargins( primary() );
549  yuiDebug() << "Found alignment with margins" << endl;
550  }
551  }
552  }
553 
554 
555  if ( totalMargins > tooSmall ) // We can make up for insufficient space just by reducing margins
556  {
557  remainingMargins = totalMargins - tooSmall;
558  tooSmall = 0L;
559  marginScale = ( (double) remainingMargins ) / totalMargins;
560 
561  yuiDebug() << "Making up for insufficient space by reducing margins to "
562  << 100.0 * marginScale << "% - "
563  << remainingMargins << " left for margins"
564  << endl;
565  }
566  else // Reducing all margins to zero still doesn't solve the problem
567  {
568  tooSmall -= totalMargins;
569 
570  yuiDebug() << "Reducing all margins to 0, but still " << tooSmall << " too small" << endl;
571  }
572 
573 
574  // Calculate initial sizes
575 
576  int i=0;
577  for ( YWidgetListConstIterator it = childrenBegin();
578  it != childrenEnd();
579  ++it, i++ )
580  {
581  if ( ! (*it)->hasWeight( primary() ) )
582  {
583  loserCount++;
584  childSize[i] = (*it)->preferredSize( primary() );
585 
586  YAlignment * alignment = dynamic_cast<YAlignment *> (*it);
587 
588  if ( alignment ) // Alignment widgets may have margins we can reduce
589  {
590  int margins = alignment->totalMargins( primary() );
591  childSize[i] -= margins; // Strip off original margin
592 
593  if ( remainingMargins > 0 ) // Anything left to redistribute?
594  {
595  margins = (int) marginScale * margins; // Scale down margin
596  childSize[i] += margins; // Add the scaled-down margin
597  remainingMargins -= margins; // Deduct from redistributable margin
598  }
599  }
600  }
601  else
602  {
603  // Weighted children will get nothing anyway if there is nothing
604  // to distribute.
605 
606  childSize[i] = 0L;
607  }
608  }
609 
610 
611  // Distribute loss
612 
613  int oldTooSmall = tooSmall;
614  int oldLoserCount = loserCount;
615  while ( tooSmall > 0 && loserCount > 0 )
616  {
617  if ( debugLayout() )
618  {
619  yuiWarning() << "Distributing insufficient space of " << tooSmall
620  << " among " << loserCount << " losers"
621  << endl;
622  }
623 
624  int dividedLoss = std::max( tooSmall / loserCount, 1 );
625 
626  int i=0;
627  for ( YWidgetListConstIterator it = childrenBegin();
628  it != childrenEnd() && tooSmall > 0;
629  ++it, i++ )
630  {
631  if ( childSize[i] < dividedLoss )
632  {
633  // This widget is too small to take its share of the
634  // loss. We'll have to re-distribute the rest of the
635  // loss among the others. Arrgh.
636 
637  if ( childSize[i] > 0L )
638  {
639  tooSmall -= childSize[i];
640  childSize[i] = 0L;
641  loserCount--;
642 
643  if ( loserCount > 0 )
644  dividedLoss = std::max( tooSmall / loserCount, 1 );
645  }
646  }
647  else
648  {
649  childSize[i] -= dividedLoss;
650  tooSmall -= dividedLoss;
651  }
652 
653  if ( debugLayout() )
654  {
655  YWidget * child = *it;
656 
657  yuiWarning() << "child #" << i <<" ( " << child
658  << " ) will get " << childSize[i]
659  << " - " << child->preferredSize( primary() ) - childSize[i] << " too small"
660  << " (preferred size: "<< child->preferredSize( primary() )
661  << ", weight: " << child->weight( primary() )
662  << ", stretchable: " << boolalpha << child->stretchable( primary() )
663  << "), pos: " << childPos[i]
664  << endl;
665  }
666  }
667 
668  if ( oldTooSmall == tooSmall &&
669  oldLoserCount == loserCount )
670  {
671  yuiWarning() << "Preventing endless loop while layout space distribution. Break." << endl;
672  break;
673  }
674 
675  oldTooSmall = tooSmall;
676  oldLoserCount = loserCount;
677  }
678 
679 
680  // Calculate postitions
681 
682  for ( int i = 0, pos=0; i < childrenCount(); i++ )
683  {
684  childPos[i] = pos;
685  pos += childSize[i];
686 
687  }
688 
689  }
690 }
691 
692 
693 void
695  sizeVector & childSize,
696  posVector & childPos )
697 {
698  int i=0;
699  for ( YWidgetListConstIterator it = childrenBegin();
700  it != childrenEnd();
701  ++it, i++ )
702  {
703  YWidget * child = *it;
704  int preferred = child->preferredSize( secondary() );
705 
706  if ( child->stretchable( secondary() ) || newSize < preferred || preferred == 0 )
707  // Also checking for preferred == 0 to make HSpacing / VSpacing visible in YDialogSpy:
708  // Otherwise they would be 0 pixels wide or high, i.e. invisible
709  {
710  childSize[i] = newSize;
711  childPos [i] = 0L;
712  }
713  else // child is not stretchable and there is more space than it wants
714  {
715  childSize[i] = preferred;
716  childPos [i] = ( newSize - preferred ) / 2; // center
717  }
718 
719  if ( childSize[i] < preferred )
720  {
721  yuiDebug() << "Layout running out of space: "
722  << "Resizing child widget #" << i
723  << " (" << child
724  << ") below its preferred size of " << preferred
725  << " to " << childSize[i]
726  << endl;
727  }
728 
729  if ( debugLayout() )
730  {
731  ( childSize[i] < preferred ? yuiWarning() : yuiDebug() )
732  << "child #" << i
733  << " (" << child
734  << ") will get " << childSize[i]
735  << " (preferred size: " << preferred
736  << ", weight: " << child->weight( secondary() )
737  << ", stretchable: " << boolalpha << child->stretchable( secondary() )
738  << "), pos: " << childPos[i]
739  << endl;
740  }
741  }
742 }
743 
744 
745 void
746 YLayoutBox::doResize( sizeVector & width,
747  sizeVector & height,
748  posVector & x_pos,
749  posVector & y_pos )
750 {
751  int i=0;
752  for ( YWidgetListConstIterator it = childrenBegin();
753  it != childrenEnd();
754  ++it, i++ )
755  {
756  YWidget * child = *it;
757 
758  child->setSize( width[i], height[i] );
759  moveChild( child, x_pos[i], y_pos[i] );
760 
761  if ( debugLayout() )
762  {
763  yuiMilestone() << " x: " << setw( 3 ) << x_pos[i]
764  << " y: " << setw( 3 ) << y_pos[i]
765  << " w: " << setw( 3 ) << width[i]
766  << " h: " << setw( 3 ) << height[i]
767  << " " << child
768  << endl;
769  }
770  }
771 }
772 
773 
774 const char *
776 {
777  return primary() == YD_VERT ? "YVBox" : "YHBox";
778 }
int childrenCount() const
Returns the current number of children.
Definition: YWidget.h:251
int childrenTotalWeight(YUIDimension dimension)
Add up all the children&#39;s weights.
Definition: YLayoutBox.cc:247
virtual void moveChild(YWidget *child, int newX, int newY)=0
Move a child to a new position.
bool hasWeight(YUIDimension dim)
Return whether or not the widget has a weight in the specified dimension.
Definition: YWidget.cc:585
virtual bool stretchable(YUIDimension dimension) const
Returns the stretchability of the layout box: The layout box is stretchable if one of the children is...
Definition: YLayoutBox.cc:349
static bool isLayoutStretch(YWidget *child, YUIDimension dimension)
Check if this is a layout stretch widget in the specfied dimension, i.e.
Definition: YLayoutBox.cc:333
void setChildrenManager(YWidgetChildrenManager *manager)
Sets a new children manager for this widget.
Definition: YWidget.cc:164
bool debugLayout() const
Returns &#39;true&#39; if layout debugging (verbose logging during layout) is on.
Definition: YLayoutBox.cc:96
virtual int preferredWidth()
Preferred width of the widget.
Definition: YLayoutBox.cc:159
YUIDimension secondary() const
Return the secondary dimension.
Definition: YLayoutBox.cc:89
void calcPrimaryGeometry(int newSize, sizeVector &childSize, posVector &childPos)
Calculate the sizes and positions of all children in the primary dimension and store them in "childSi...
Definition: YLayoutBox.cc:398
void calcSecondaryGeometry(int newSize, sizeVector &childSize, posVector &childPos)
Calculate the sizes and positions of all children in the secondary dimension and store them in "child...
Definition: YLayoutBox.cc:694
void setDebugLayout(bool deb=true)
Enable or disable layout debugging.
Definition: YLayoutBox.cc:102
virtual bool stretchable(YUIDimension dim) const
This is a boolean value that determines whether the widget is resizable beyond its preferred size in ...
Definition: YWidget.cc:567
virtual void setSize(int newWidth, int newHeight)
Sets the size of the layout box.
Definition: YLayoutBox.cc:365
void doResize(sizeVector &width, sizeVector &height, posVector &x_pos, posVector &y_pos)
Actually perform resizing and moving the child widgets to the appropriate position.
Definition: YLayoutBox.cc:746
virtual int preferredSize(YUIDimension dim)
Preferred size of the widget in the specified dimension.
Definition: YWidget.cc:541
int countNonWeightedChildren(YUIDimension dimension)
Count the number of non-weighted children.
Definition: YLayoutBox.cc:280
int totalNonWeightedChildrenPreferredSize(YUIDimension dimension)
Add up all the non-weighted children&#39;s preferred sizes in the specified dimension.
Definition: YLayoutBox.cc:263
virtual int preferredSize(YUIDimension dim)
Preferred size of the widget in the specified dimension.
Definition: YLayoutBox.cc:111
Abstract base template class for children management, such as child widgets.
virtual void setSize(int newWidth, int newHeight)=0
Set the new size of the widget.
Implementation of all the alignment widgets:
Definition: YAlignment.h:41
virtual int preferredHeight()
Preferred height of the widget.
Definition: YLayoutBox.cc:165
YLayoutBox(YWidget *parent, YUIDimension dim)
Constructor.
Definition: YLayoutBox.cc:66
HSpacing, VSpacing, HStretch, VStretch.
Definition: YSpacing.h:37
int totalMargins(YUIDimension dim) const
Return the sum of all margins in the specified dimension.
Definition: YAlignment.cc:326
int countStretchableChildren(YUIDimension dimension)
Count the number of stretchable ( non-weighted ) children.
Definition: YLayoutBox.cc:297
YWidgetListIterator childrenBegin() const
Return an iterator that points to the first child or to childrenEnd() if there are no children...
Definition: YWidget.h:212
static YApplication * app()
Return the global YApplication object.
Definition: YUI.cc:156
YWidget * findDominatingChild()
Determine the number of the "dominating child" - the child widget that determines the overall size wi...
Definition: YLayoutBox.cc:185
YLayoutBoxPrivate(YUIDimension prim)
Constructor.
Definition: YLayoutBox.cc:48
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YLayoutBox.cc:775
virtual int weight(YUIDimension dim)
The weight is used in situations where all widgets can get their preferred size and yet space is avai...
Definition: YWidget.cc:573
Abstract base class of all UI widgets.
Definition: YWidget.h:54
int childrenMaxPreferredSize(YUIDimension dimension)
Return the maximum preferred size of all children in the specified dimension.
Definition: YLayoutBox.cc:231
int countLayoutStretchChildren(YUIDimension dimension)
Count the number of "rubber bands", i.e.
Definition: YLayoutBox.cc:315
YUIDimension primary() const
Return the primary dimension, i.e., the dimension this LayoutBox lays out its children in: YD_VERT fo...
Definition: YLayoutBox.cc:82
virtual ~YLayoutBox()
Destructor.
Definition: YLayoutBox.cc:75
YWidgetListIterator childrenEnd() const
Return an interator that points after the last child.
Definition: YWidget.h:218