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