OSDN Git Service

Version 0.6.48, fix X.UA for s60 Safari.
[pettanr/clientJs.git] / 0.6.x / js / ui / 11_VBox.js
1 X.UI.Layout.Vertical = X.UI.Layout.create( {\r
2         \r
3         name : 'VerticalLayout',\r
4         \r
5         overrideAttrsForSelf : {\r
6                 selectable  : false,\r
7                 role        : [ 0,              X.UI.Dirty.CLEAN,  X.UI.Attr.USER.UINODE, X.UI.Attr.Type.INIT_ONLY | X.UI.Attr.Type.LIST, 'none,chrome,container' ],\r
8                 childWidth  : [ X.UI.Attr.AUTO, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH | X.UI.Attr.Type.PERCENT | X.UI.Attr.Type.AUTO ],\r
9                 childHeight : [ X.UI.Attr.AUTO, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH | X.UI.Attr.Type.PERCENT | X.UI.Attr.Type.AUTO ],\r
10                 gapY        : [ 0,              X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ]\r
11         },\r
12         \r
13         overrideAttrsForChild : {\r
14                 left   : true,\r
15                 right  : true,\r
16                 top    : false,\r
17                 bottom : false\r
18         },\r
19         \r
20         calculate : function( data, isNeedsDetection, x, y, w, h ){\r
21                 var attrs   = data.attrObject || data.attrClass.prototype,\r
22                         uinodes = data.uinodes,\r
23                         l       = uinodes && uinodes.length,            \r
24                         childW, childH, gapY,\r
25                         i, _x, _y, _w, node,\r
26             contentW, contentH, autoW, autoH, detectionPhase;\r
27 \r
28                 data.preMesure( w, h );\r
29                 \r
30                 contentW       = data.contentWidth;\r
31                 contentH       = data.contentHeight;\r
32                 autoW          = contentW === X.UI.Attr.AUTO;\r
33                 autoH          = contentH === X.UI.Attr.AUTO;\r
34                 detectionPhase = autoW || autoH;\r
35                 gapY           = _AbstractUINode.calcValue( attrs[ data.supportAttrs.gapY.No ], contentH );\r
36                 childW         = _AbstractUINode.calcValue( attrs[ data.supportAttrs.childWidth.No ], contentW );\r
37                 childH         = _AbstractUINode.calcValue( attrs[ data.supportAttrs.childHeight.No ], contentH );\r
38                 _x             = data.contentL;\r
39                 _y             = data.contentT;\r
40 \r
41                 if( l ){\r
42                         _w = 0;\r
43                         for( i = 0; i < l; ++i ){\r
44                                 node = uinodes[ i ];\r
45                                 node.calculate( detectionPhase, _x, _y, contentW, childH );\r
46                                 _y += node.boxHeight + gapY;\r
47                                 // 概算のみ\r
48                                 if( autoW ){\r
49                                         w = node.boxWidth !== X.UI.Attr.AUTO ?\r
50                                                         node.boxWidth :\r
51                                                 node.minBoxWidth !== X.UI.Attr.AUTO ?\r
52                                                         node.minBoxWidth : 0;\r
53                                         if( _w < w ) _w = w;                            \r
54                                 };      \r
55                         };\r
56                         _y -= gapY;\r
57                 } else {\r
58                         _y = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0;\r
59                 };\r
60 \r
61                 if( detectionPhase ){\r
62                         if( autoW ) data.contentWidth  = _w;\r
63                         if( autoH ) data.contentHeight = _y;\r
64                         data.postMesure();\r
65                 } else {\r
66                         //data.postMesure();\r
67                 };\r
68                 \r
69                 !isNeedsDetection && data.updateLayout( x, y );\r
70         }\r
71 });\r
72 \r
73 var VBox = Box.presets(\r
74         X.UI.Layout.Vertical,\r
75         'VBox',\r
76         {\r
77                 gapY       : '0.2em',\r
78                 childWidth : '100%'\r
79         }\r
80 );\r