OSDN Git Service

Version 0.6.23, remove AbstractBox(AbstractDisplayContainer), working ie-filter-fix.
[pettanr/clientJs.git] / 0.6.x / js / ui / 07_LayoutManagerBase.js
1 var LayoutManagerBase = X.Class.create(
2         'LayoutManagerBase',
3         {
4                 allowForSelf  : null,
5                 allowForChild : null,
6                 define : function( src ){
7                         return X.Class._override( this, src, true );
8                 },
9                 
10                 
11                 reflow : function( nodeData, allowW, allowH ){
12                         nodeData.preMesure( allowW, allowH );
13                         
14                         var children = nodeData.children,                               
15                                 contentW = nodeData.contentWidth,
16                                 contentH = nodeData.contentHeight,
17                                 autoW    = contentW === AUTO,
18                                 autoH    = contentH === AUTO,
19                                 auto, calc, childW, childH, child, i, style, data,
20                                 t, r, b, l;                     
21                         if( children ){
22                                 auto     = autoW && autoH;
23                                 childW   = 0;
24                                 childH   = 0;
25                                 calc     = BasicLayoutManager.calcValue;                        
26                                 for( i = children.length; i; ){
27                                         child = children[ --i ];
28                                         style = child.__style;
29                                         if( style ){
30                                                 data = style.data;
31                                                 t = calc( data[ X.Css.AttrNo.top ],    contentH );
32                                                 r = calc( data[ X.Css.AttrNo.right ],  contentW );
33                                                 b = calc( data[ X.Css.AttrNo.bottom ], contentH );
34                                                 l = calc( data[ X.Css.AttrNo.left ],   contentW );
35                                         } else {
36                                                 t = r = b = l = 0;
37                                         };
38                                         if( child.instanceOf( LayoutBoxPrivate ) ){
39                                                 child.layoutManager.reflow( child, contentW - r - l, contentH - t - b );
40                                         } else {
41                                                 child.preMesure( contentW - r - l, contentH - t - b );
42                                                 child.mesure();
43                                                 child.postMesure();
44                                         };
45                                         if( !auto ) continue;
46                                         if( autoW && childW < child.boxWidth  + r + l ) childW = child.boxWidth  + r + l;
47                                         if( autoH && childH < child.boxHeight + t + b ) childH = child.boxHeight + t + b;                                               
48                                 };
49                                 if( autoW )     nodeData.contentWidth  = childW;
50                                 if( autoH ) nodeData.contentHeight = childH;
51                         };
52                         ( autoW || autoH ) && nodeData.postMesure();
53                         
54                         delete nodeData.dirty;
55                 },
56                 redraw : function( nodeData ){
57                         var root = nodeData.rootData;
58                         root.dirty === X.Css.Dirty.REFLOW && this.reflow( root );
59                         
60                         // draw
61                 }
62         }
63 );