OSDN Git Service

Version 0.6.41, fix for Opera8 & NN7.2+.
[pettanr/clientJs.git] / 0.6.x / js / ui / 13_TileBox.js
1 var TileLayoutManager = ( new LayoutManagerBase() ).define( {\r
2         allowForSelf : {\r
3                 childW  : true,\r
4                 childH  : true,\r
5                 gapX    : true,\r
6                 gapY    : true,\r
7                 padding : true\r
8         },\r
9         allowForChild : {\r
10                 x  : false,\r
11                 y  : false,\r
12                 w  : false,\r
13                 h  : false\r
14         },\r
15         calculate : function( data, x, y, w, h ){\r
16                 var nodes     = data.nodes,\r
17                         styleData = data.styleData,\r
18                         cssObj    = styleData._cssObj,\r
19                         childW    = cssObj.childW,\r
20                         childH    = cssObj.childH,\r
21                         gapX      = cssObj.gapX,\r
22                         gapY      = cssObj.gapY,\r
23                         padding   = cssObj.padding,\r
24                         _x        = padding,\r
25                         _y        = padding,\r
26                         i = 0, l = nodes.length, node;\r
27                 if( l === 0 ){\r
28                         styleData.layout( x, y, w, 0 );\r
29                         return;\r
30                 };\r
31                 for( ; i < l; ++i ){\r
32                         node = nodes[ i ];\r
33                         if( node.instanceOf( _Box ) ){\r
34                                 node.calculate( _x, _y, childW, childH );\r
35                         } else {\r
36                                 node.styleData.layout( _x, _y, childW, childH );\r
37                         };\r
38                         _x += childW + gapX;\r
39                         if( w < _x ){\r
40                                 _y += childH + gapY;\r
41                         };\r
42                 };\r
43                 styleData.layout( x, y, w, _y + childH + padding );\r
44         }\r
45 });\r
46 \r
47 var TileBox = Box.inherits(\r
48         'TileBox',\r
49         X.Class.SUPER_ACCESS,\r
50         {\r
51                 Constructor : function(){\r
52                         this.style = DisplayNodeStyle( this, X.Class._newPrivate( this, TileLayoutManager, arguments ) );\r
53                         this.style.addName( 'TileBox' );\r
54                 }\r
55         }\r
56 );