1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
|
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
License:
LGPL: http://www.gnu.org/licenses/lgpl.html
EPL: http://www.eclipse.org/org/documents/epl-v10.php
See the LICENSE file in the project's top-level directory for details.
Authors:
* Sebastian Werner (wpbasti)
* Andreas Ecker (ecker)
************************************************************************ */
/* ************************************************************************
#module(ui_basic)
#module(ui_layout)
************************************************************************ */
qx.OO.defineClass("qx.renderer.layout.HorizontalBoxLayoutImpl", qx.renderer.layout.LayoutImpl,
function(vWidget) {
qx.renderer.layout.LayoutImpl.call(this, vWidget);
});
qx.OO.addProperty({ name : "enableFlexSupport", type : "boolean", defaultValue : true });
/*!
Global Structure:
[01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD
[02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD
[03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN
[04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS
[05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT
[06] UPDATE LAYOUT ON JOB QUEUE FLUSH
[07] UPDATE CHILDREN ON JOB QUEUE FLUSH
[08] CHILDREN ADD/REMOVE/MOVE HANDLING
[09] FLUSH LAYOUT QUEUES OF CHILDREN
[10] LAYOUT CHILD
[11] DISPOSER
Inherits from qx.renderer.layout.LayoutImpl:
[02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD
[11] DISPOSER
*/
/*
---------------------------------------------------------------------------
[01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD
---------------------------------------------------------------------------
*/
/*!
Compute and return the box width of the given child.
*/
qx.Proto.computeChildBoxWidth = function(vChild) {
return vChild.getWidthValue() || vChild._computeBoxWidthFallback();
}
/*!
Compute and return the box height of the given child.
*/
qx.Proto.computeChildBoxHeight = function(vChild)
{
if (this.getWidget().getStretchChildrenOrthogonalAxis() && vChild._computedHeightTypeNull && vChild.getAllowStretchY()) {
return this.getWidget().getInnerHeight();
}
return vChild.getHeightValue() || vChild._computeBoxHeightFallback();
}
/*!
Computes the width of all flexible children.
*/
qx.Proto.computeChildrenFlexWidth = function()
{
if (this._childrenFlexWidthComputed || !this.getEnableFlexSupport()) {
return;
}
this._childrenFlexWidthComputed = true;
// this.debug("computeChildrenFlexWidth");
var vWidget = this.getWidget();
var vChildren = vWidget.getVisibleChildren();
var vChildrenLength = vChildren.length;
var vCurrentChild;
var vFlexibleChildren = [];
var vAvailWidth = vWidget.getInnerWidth();
var vUsedWidth = vWidget.getSpacing() * (vChildrenLength-1);
var vIterator;
// *************************************************************
// 1. Compute the sum of all static sized children and finding
// all flexible children.
// *************************************************************
for (vIterator=0; vIterator<vChildrenLength; vIterator++)
{
vCurrentChild = vChildren[vIterator];
if (vCurrentChild._computedWidthTypeFlex)
{
vFlexibleChildren.push(vCurrentChild);
if (vWidget._computedWidthTypeAuto) {
vUsedWidth += vCurrentChild.getPreferredBoxWidth();
}
}
else
{
vUsedWidth += vCurrentChild.getOuterWidth();
}
}
// this.debug("Width: " + vUsedWidth + "/" + vAvailWidth);
// this.debug("Flexible Count: " + vFlexibleChildren.length);
// *************************************************************
// 2. Compute the sum of all flexible children widths
// *************************************************************
var vRemainingWidth = vAvailWidth - vUsedWidth;
var vFlexibleChildrenLength = vFlexibleChildren.length;
var vPrioritySum = 0;
for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) {
vPrioritySum += vFlexibleChildren[vIterator]._computedWidthParsed;
}
// *************************************************************
// 3. Calculating the size of each 'part'.
// *************************************************************
var vPartWidth = vRemainingWidth / vPrioritySum;
if (!vWidget.getUseAdvancedFlexAllocation())
{
// *************************************************************
// 4a. Computing the flex width value of each flexible child
// and add the width to the usedWidth, so that we can
// fix rounding problems later.
// *************************************************************
for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++)
{
vCurrentChild = vFlexibleChildren[vIterator];
vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthParsed * vPartWidth);
vUsedWidth += vCurrentChild._computedWidthFlexValue;
}
}
else
{
// *************************************************************
// 4b. Calculating the diff. Which means respect the min/max
// width configuration in flex and store the higher/lower
// data in a diff.
// *************************************************************
var vAllocationDiff = 0;
var vMinAllocationLoops, vFlexibleChildrenLength, vAdjust, vCurrentAllocationSum, vFactorSum, vComputedFlexibleWidth;
for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++)
{
vCurrentChild = vFlexibleChildren[vIterator];
vComputedFlexibleWidth = vCurrentChild._computedWidthFlexValue = vCurrentChild._computedWidthParsed * vPartWidth;
vAllocationDiff += vComputedFlexibleWidth - qx.lang.Number.limit(vComputedFlexibleWidth, vCurrentChild.getMinWidthValue(), vCurrentChild.getMaxWidthValue());
}
// Rounding diff
vAllocationDiff = Math.round(vAllocationDiff);
if (vAllocationDiff == 0)
{
// *************************************************************
// 5a. If the diff is equal zero we must not do anything more
// and do nearly identical the same like in 4a. which means
// to round the calculated flex value and add it to the
// used width so we can fix rounding problems later.
// *************************************************************
// Rounding values and fixing rounding errors
for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++)
{
vCurrentChild = vFlexibleChildren[vIterator];
vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue);
vUsedWidth += vCurrentChild._computedWidthFlexValue;
}
}
else
{
// *************************************************************
// 5b. Find maximum loops of each adjustable child to adjust
// the width until the min/max width limits are reached.
// *************************************************************
var vUp = vAllocationDiff > 0;
for (vIterator=vFlexibleChildrenLength-1; vIterator>=0; vIterator--)
{
vCurrentChild = vFlexibleChildren[vIterator];
if (vUp)
{
vAdjust = (vCurrentChild.getMaxWidthValue() || Infinity) - vCurrentChild._computedWidthFlexValue;
if (vAdjust > 0)
{
vCurrentChild._allocationLoops = Math.floor(vAdjust / vCurrentChild._computedWidthParsed);
}
else
{
qx.lang.Array.removeAt(vFlexibleChildren, vIterator);
vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue);
vUsedWidth += Math.round(vCurrentChild._computedWidthFlexValue + vAdjust);
}
}
else
{
vAdjust = qx.util.Validation.isValidNumber(vCurrentChild.getMinWidthValue()) ? vCurrentChild._computedWidthFlexValue - vCurrentChild.getMinWidthValue() : vCurrentChild._computedWidthFlexValue;
if (vAdjust > 0)
{
vCurrentChild._allocationLoops = Math.floor(vAdjust / vCurrentChild._computedWidthParsed);
}
else
{
qx.lang.Array.removeAt(vFlexibleChildren, vIterator);
vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue);
vUsedWidth += Math.round(vCurrentChild._computedWidthFlexValue - vAdjust);
}
}
}
// *************************************************************
// 6. Try to reallocate the width between flexible children
// so that the requirements through min/max limits
// are satisfied.
// *************************************************************
while (vAllocationDiff != 0 && vFlexibleChildrenLength > 0)
{
vFlexibleChildrenLength = vFlexibleChildren.length;
vMinAllocationLoops = Infinity;
vFactorSum = 0;
// Find minimal loop amount
for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++)
{
vMinAllocationLoops = Math.min(vMinAllocationLoops, vFlexibleChildren[vIterator]._allocationLoops);
vFactorSum += vFlexibleChildren[vIterator]._computedWidthParsed;
}
// Be sure that the adjustment is not bigger/smaller than diff
vCurrentAllocationSum = Math.min(vFactorSum * vMinAllocationLoops, vAllocationDiff);
// this.debug("Diff: " + vAllocationDiff);
// this.debug("Min Loops: " + vMinAllocationLoops);
// this.debug("Sum: " + vCurrentAllocationSum);
// this.debug("Factor: " + vFactorSum);
// Reducing diff by current sum
vAllocationDiff -= vCurrentAllocationSum;
// Adding sizes to children to adjust
for (vIterator=vFlexibleChildrenLength-1; vIterator>=0; vIterator--)
{
vCurrentChild = vFlexibleChildren[vIterator];
vCurrentChild._computedWidthFlexValue += vCurrentAllocationSum / vFactorSum * vCurrentChild._computedWidthParsed;
if (vCurrentChild._allocationLoops == vMinAllocationLoops)
{
vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue);
vUsedWidth += vCurrentChild._computedWidthFlexValue;
delete vCurrentChild._allocationLoops;
qx.lang.Array.removeAt(vFlexibleChildren, vIterator);
}
else
{
if (vAllocationDiff == 0)
{
vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue);
vUsedWidth += vCurrentChild._computedWidthFlexValue;
delete vCurrentChild._allocationLoops;
}
else
{
vCurrentChild._allocationLoops -= vMinAllocationLoops;
}
}
}
}
}
}
// *************************************************************
// 7. Fix rounding errors
// *************************************************************
vCurrentChild._computedWidthFlexValue += vAvailWidth - vUsedWidth;
}
qx.Proto.invalidateChildrenFlexWidth = function() {
delete this._childrenFlexWidthComputed;
}
/*
---------------------------------------------------------------------------
[03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN
---------------------------------------------------------------------------
*/
/*!
Compute and return the width needed by all children of this widget
*/
qx.Proto.computeChildrenNeededWidth = function()
{
var w = this.getWidget();
return qx.renderer.layout.LayoutImpl.prototype.computeChildrenNeededWidth_sum.call(this) + ((w.getVisibleChildrenLength()-1) * w.getSpacing());
}
/*
---------------------------------------------------------------------------
[04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS
---------------------------------------------------------------------------
*/
/*!
Things to do and layout when any of the childs changes its outer width.
Needed by layouts where the children depends on each-other, like flow- or box-layouts.
*/
qx.Proto.updateSelfOnChildOuterWidthChange = function(vChild)
{
// if a childrens outer width changes we need to update our accumulated
// width of all childrens (used for center or right alignments)
this.getWidget()._invalidateAccumulatedChildrenOuterWidth();
}
/*
---------------------------------------------------------------------------
[05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT
---------------------------------------------------------------------------
*/
/*!
Actions that should be done if the inner width of the widget was changed.
Normally this includes update to percent values and ranges.
*/
qx.Proto.updateChildOnInnerWidthChange = function(vChild)
{
if (this.getWidget().getHorizontalChildrenAlign() == "center") {
vChild.addToLayoutChanges("locationX");
}
// use variables here to be sure to call both methods.
var vUpdatePercent = vChild._recomputePercentX();
var vUpdateFlex = vChild._recomputeFlexX();
// inform the caller if there were any notable changes occured
return vUpdatePercent || vUpdateFlex;
}
/*!
Actions that should be done if the inner height of the widget was changed.
Normally this includes update to percent values and ranges.
*/
qx.Proto.updateChildOnInnerHeightChange = function(vChild)
{
// use variables here to be sure to call both methods.
var vUpdatePercent = vChild._recomputePercentY();
var vUpdateStretch = vChild._recomputeStretchingY();
// priority to childs internal alignment
if ((vChild.getVerticalAlign() || this.getWidget().getVerticalChildrenAlign()) == "middle") {
vChild.addToLayoutChanges("locationY");
}
// inform the caller if there were any notable changes occured
return vUpdatePercent || vUpdateStretch;
}
/*
---------------------------------------------------------------------------
[06] UPDATE LAYOUT ON JOB QUEUE FLUSH
---------------------------------------------------------------------------
*/
/*!
Invalidate and recompute things because of job in queue (before the rest of job handling will be executed).
*/
qx.Proto.updateSelfOnJobQueueFlush = function(vJobQueue)
{
if (vJobQueue.addChild || vJobQueue.removeChild) {
this.getWidget()._invalidateAccumulatedChildrenOuterWidth();
}
}
/*
---------------------------------------------------------------------------
[07] UPDATE CHILDREN ON JOB QUEUE FLUSH
---------------------------------------------------------------------------
*/
/*!
Updates children on special jobs
*/
qx.Proto.updateChildrenOnJobQueueFlush = function(vQueue)
{
var vStretchX=false, vStretchY=false;
var vWidget = this.getWidget();
// switching the orientation need updates for stretching on both axis
if (vQueue.orientation) {
vStretchX = vStretchY = true;
}
// different updates depending from the current orientation (or the new one)
if (vQueue.spacing || vQueue.orientation || vQueue.reverseChildrenOrder || vQueue.horizontalChildrenAlign) {
vWidget._addChildrenToLayoutQueue("locationX");
}
if (vQueue.verticalChildrenAlign) {
vWidget._addChildrenToLayoutQueue("locationY");
}
if (vQueue.stretchChildrenOrthogonalAxis) {
vStretchY = true;
}
// if stretching should be reworked reset the previous one and add
// a layout job to update the width respectively height.
if (vStretchX)
{
vWidget._recomputeChildrenStretchingX();
vWidget._addChildrenToLayoutQueue("width");
}
if (vStretchY)
{
vWidget._recomputeChildrenStretchingY();
vWidget._addChildrenToLayoutQueue("height");
}
return true;
}
/*
---------------------------------------------------------------------------
[08] CHILDREN ADD/REMOVE/MOVE HANDLING
---------------------------------------------------------------------------
*/
/*!
This method combines calls of methods which should be done if a widget should be removed from the current layout.
Needed by layouts where the children depends on each-other, like flow- or box-layouts.
*/
qx.Proto.updateChildrenOnRemoveChild = function(vChild, vIndex)
{
var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, i=-1;
// Fix index to be at the first flex child
if (this.getEnableFlexSupport())
{
for (i=0; i<chl; i++)
{
chc = ch[i];
if (chc.getHasFlexX())
{
vIndex = Math.min(vIndex, i);
break;
}
}
i=-1;
}
// Handle differently depending on layout mode
switch(w.getLayoutMode())
{
case "right":
case "left-reversed":
while((chc=ch[++i]) && i<vIndex) {
chc.addToLayoutChanges("locationX");
}
break;
case "center":
case "center-reversed":
while(chc=ch[++i]) {
chc.addToLayoutChanges("locationX");
}
break;
default:
i+=vIndex;
while(chc=ch[++i]) {
chc.addToLayoutChanges("locationX");
}
}
}
/*!
This method combines calls of methods which should be done if a child should be moved
inside the same parent to a new positions.
Needed by layouts where the children depends on each-other, like flow- or box-layouts.
*/
qx.Proto.updateChildrenOnMoveChild = function(vChild, vIndex, vOldIndex)
{
var vChildren = this.getWidget().getVisibleChildren();
var vStart = Math.min(vIndex, vOldIndex);
var vStop = Math.max(vIndex, vOldIndex)+1;
for (var i=vStart; i<vStop; i++) {
vChildren[i].addToLayoutChanges("locationX");
}
}
/*
---------------------------------------------------------------------------
[09] FLUSH LAYOUT QUEUES OF CHILDREN
---------------------------------------------------------------------------
*/
/*!
This method have full control of the order in which the
registered (or also non-registered) children should be
layouted on the horizontal axis.
*/
qx.Proto.flushChildrenQueue = function(vChildrenQueue)
{
var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, i;
// This block is needed for flex handling and
// will inform flex children if there was any
// change to the other content
if (this.getEnableFlexSupport())
{
this.invalidateChildrenFlexWidth();
for (i=0; i<chl; i++)
{
chc = ch[i];
if (chc.getHasFlexX())
{
chc._computedWidthValue = null;
if (chc._recomputeBoxWidth())
{
chc._recomputeOuterWidth();
chc._recomputeInnerWidth();
}
vChildrenQueue[chc.toHashCode()] = chc;
chc._layoutChanges.width = true;
}
}
}
switch(w.getLayoutMode())
{
case "right":
case "left-reversed":
// find the last child which has a layout request
for (var i=chl-1; i>=0 && !vChildrenQueue[ch[i].toHashCode()]; i--) {}
// layout all children before this last child
for (var j=0; j<=i; j++) {
w._layoutChild(chc=ch[j]);
}
break;
case "center":
case "center-reversed":
// re-layout all children
i = -1;
while(chc=ch[++i]) {
w._layoutChild(chc);
}
break;
default:
// layout all childs from the first child
// with an own layout request to the end
i = -1;
var changed=false;
while(chc=ch[++i])
{
if (changed || vChildrenQueue[chc.toHashCode()])
{
w._layoutChild(chc);
changed = true;
}
}
}
}
/*
---------------------------------------------------------------------------
[10] LAYOUT CHILD
---------------------------------------------------------------------------
*/
/*!
This is called from qx.ui.core.Widget and it's task is to apply the layout
(excluding border and padding) to the child.
*/
qx.Proto.layoutChild = function(vChild, vJobs)
{
this.layoutChild_sizeX(vChild, vJobs);
this.layoutChild_sizeY(vChild, vJobs);
this.layoutChild_sizeLimitX(vChild, vJobs);
this.layoutChild_sizeLimitY(vChild, vJobs);
this.layoutChild_locationX(vChild, vJobs);
this.layoutChild_locationY(vChild, vJobs);
this.layoutChild_marginX(vChild, vJobs);
this.layoutChild_marginY(vChild, vJobs);
}
if (qx.core.Client.getInstance().isMshtml() || qx.core.Client.getInstance().isOpera() || qx.core.Client.getInstance().isWebkit() )
{
qx.Proto.layoutChild_sizeX = function(vChild, vJobs)
{
if (vJobs.initial || vJobs.width || vJobs.minWidth || vJobs.maxWidth)
{
if (vChild._isWidthEssential() && (!vChild._computedWidthTypeNull || !vChild._computedMinWidthTypeNull || !vChild._computedMaxWidthTypeNull))
{
vChild._applyRuntimeWidth(vChild.getBoxWidth());
}
else
{
vChild._resetRuntimeWidth();
}
}
}
qx.Proto.layoutChild_sizeY = function(vChild, vJobs)
{
if (vJobs.initial || vJobs.height || vJobs.minHeight || vJobs.maxHeight)
{
if ((vChild._isHeightEssential() && (!vChild._computedHeightTypeNull || !vChild._computedMinHeightTypeNull || !vChild._computedMaxHeightTypeNull)) || (vChild.getAllowStretchY() && this.getWidget().getStretchChildrenOrthogonalAxis()))
{
vChild._applyRuntimeHeight(vChild.getBoxHeight());
}
else
{
vChild._resetRuntimeHeight();
}
}
}
}
else
{
qx.Proto.layoutChild_sizeX = function(vChild, vJobs)
{
if (vJobs.initial || vJobs.width)
{
if (vChild._isWidthEssential() && !vChild._computedWidthTypeNull)
{
vChild._applyRuntimeWidth(vChild.getWidthValue());
}
else
{
vChild._resetRuntimeWidth();
}
}
}
qx.Proto.layoutChild_sizeY = function(vChild, vJobs)
{
if (vJobs.initial || vJobs.height)
{
if (vChild._isHeightEssential() && !vChild._computedHeightTypeNull)
{
vChild._applyRuntimeHeight(vChild.getHeightValue());
}
else
{
vChild._resetRuntimeHeight();
}
}
}
}
qx.Proto.layoutChild_locationX = function(vChild, vJobs)
{
var vWidget = this.getWidget();
// handle first child
if (vWidget.getFirstVisibleChild() == vChild)
{
switch(vWidget.getLayoutMode())
{
case "right":
case "left-reversed":
var vPos = vWidget.getPaddingRight() + vWidget.getAccumulatedChildrenOuterWidth() - vChild.getOuterWidth();
break;
case "center":
case "center-reversed":
var vPos = vWidget.getPaddingLeft() + Math.round((vWidget.getInnerWidth() - vWidget.getAccumulatedChildrenOuterWidth()) / 2);
break;
default:
var vPos = vWidget.getPaddingLeft();
}
}
// handle any following child
else
{
var vPrev = vChild.getPreviousVisibleSibling();
switch(vWidget.getLayoutMode())
{
case "right":
case "left-reversed":
var vPos = vPrev._cachedLocationHorizontal - vChild.getOuterWidth() - vWidget.getSpacing();
break;
default:
var vPos = vPrev._cachedLocationHorizontal + vPrev.getOuterWidth() + vWidget.getSpacing();
}
}
// store for next sibling
vChild._cachedLocationHorizontal = vPos;
// apply styles
switch(vWidget.getLayoutMode())
{
case "right":
case "right-reversed":
case "center-reversed":
// add relative positions (like 'position:relative' in css)
vPos += !vChild._computedRightTypeNull ? vChild.getRightValue() : !vChild._computedLeftTypeNull ? -(vChild.getLeftValue()) : 0;
vChild._resetRuntimeLeft();
vChild._applyRuntimeRight(vPos);
break;
default:
// add relative positions (like 'position:relative' in css)
vPos += !vChild._computedLeftTypeNull ? vChild.getLeftValue() : !vChild._computedRightTypeNull ? -(vChild.getRightValue()) : 0;
vChild._resetRuntimeRight();
vChild._applyRuntimeLeft(vPos);
}
}
qx.Proto.layoutChild_locationY = function(vChild, vJobs)
{
var vWidget = this.getWidget();
// special stretching support
if (qx.core.Client.getInstance().isGecko() && vChild.getAllowStretchY() && vWidget.getStretchChildrenOrthogonalAxis() && vChild._computedHeightTypeNull)
{
vChild._applyRuntimeTop(vWidget.getPaddingTop() || 0);
vChild._applyRuntimeBottom(vWidget.getPaddingBottom() || 0);
return;
}
// priority to childs internal alignment
var vAlign = vChild.getVerticalAlign() || vWidget.getVerticalChildrenAlign();
// handle middle alignment
var vPos = vAlign == "middle" ? Math.round((vWidget.getInnerHeight() - vChild.getOuterHeight()) / 2) : 0;
// the bottom alignment use the real 'bottom' styleproperty to
// use the best available method in modern browsers
if (vAlign == "bottom")
{
// add parent padding
vPos += vWidget.getPaddingBottom();
// relative positions (like 'position:relative' in css)
if (!vChild._computedBottomTypeNull) {
vPos += vChild.getBottomValue();
}
else if (!vChild._computedTopTypeNull) {
vPos -= vChild.getTopValue();
}
// apply styles
vChild._resetRuntimeTop();
vChild._applyRuntimeBottom(vPos);
}
else
{
// add parent padding
vPos += vWidget.getPaddingTop();
// relative positions (like 'position:relative' in css)
if (!vChild._computedTopTypeNull) {
vPos += vChild.getTopValue();
}
else if (!vChild._computedBottomTypeNull) {
vPos -= vChild.getBottomValue();
}
// apply styles
vChild._resetRuntimeBottom();
vChild._applyRuntimeTop(vPos);
}
}
|