OSDN Git Service

Version 0.6.138, working X.UI.ScrollBox!, fix Node.prev & Node.next.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 06_AbstractUINode.js
1 X.UI._AbstractUINode = X_EventDispatcher[ 'inherits' ](\r
2         'X.UI._AbstractUINode',\r
3         X_Class.ABSTRACT | X_Class.PRIVATE_DATA,\r
4         {\r
5                 phase             : 0,\r
6                 dirty             : X.UI.Dirty.CLEAN,\r
7                 \r
8                 root              : null,\r
9                 rootData          : null,\r
10                 hoverList         : null,\r
11                 parent            : null,\r
12                 parentData        : null,\r
13                 xnode             : null,\r
14 \r
15                 supportAttrs      : X.UI.Attr.Support,\r
16                 attrClass         : X.UI.AttrClass,\r
17                 attrObject        : null,\r
18                 unverifiedAttrs   : null,\r
19                 \r
20                 role              : 1,\r
21                 pointerDisabled   : false,\r
22                 hoverClassName    : null,\r
23                 hovering          : false,\r
24                 \r
25                 reserveEvents     : null,\r
26                 gesture           : null,\r
27 \r
28                 absoluteX         : 0,\r
29                 absoluteY         : 0,\r
30                 \r
31                 boxX              : 0,\r
32                 boxY              : 0,\r
33                 scrollWidth       : 0, // remove?\r
34                 scrollHeight      : 0, // remove?\r
35                 boxWidth          : X.UI.Attr.AUTO,\r
36                 minBoxWidth       : 0,\r
37                 maxBoxWidth       : X.UI.Attr.AUTO,     \r
38                 boxHeight         : X.UI.Attr.AUTO,\r
39                 minBoxHeight      : 0,\r
40                 maxBoxHeight      : X.UI.Attr.AUTO,\r
41                 contentL          : 0,\r
42                 contentT          : 0,\r
43                 contentR          : 0,\r
44                 contentB          : 0,\r
45                 boxSizingOffsetLR : 0,\r
46                 boxSizingOffsetTB : 0,          \r
47                 contentWidth      : X.UI.Attr.AUTO,\r
48                 minContentWidth   : 0,\r
49                 maxContentWidth   : X.UI.Attr.AUTO,\r
50                 lastContentWidth  : -1,\r
51                 contentHeight     : X.UI.Attr.AUTO,\r
52                 minContentHeight  : 0,\r
53                 maxContentHeight  : X.UI.Attr.AUTO,\r
54                 lastContentHeight : -1,\r
55                 \r
56                 constraintW       : false,\r
57                 constraintH       : false,\r
58                 autoWidth         : false,\r
59                 autoHeight        : false,\r
60                 percentWidth      : false,\r
61                 percentHeight     : false,\r
62                 // :hover, :focus, :disabled\r
63                 \r
64                 initialize : function( root, rootData, parent, parentData ){\r
65                         this.root       = root;\r
66                         this.rootData   = rootData;\r
67                         this.parent     = parent;\r
68                         this.parentData = parentData;\r
69                         //this.xnode      = X_Doc_create( 'div' );\r
70                         this.phase      = 1;\r
71                         \r
72                         this[ 'dispatch' ]( X.UI.Event.INIT );\r
73                 },\r
74                 \r
75                 addToParent : function( xnodeParent ){\r
76                         xnodeParent && xnodeParent[ 'append' ]( this.xnode );\r
77                         \r
78                         this.phase = 2;\r
79                         this[ 'dispatch' ]( X.UI.Event.ADDED );\r
80                 },\r
81                 \r
82                 creationComplete : function(){\r
83                         var events = this.reserveEvents,\r
84                                 l, i;\r
85                         \r
86                         this.phase = 3;\r
87                         this.User[ 'dispatch' ]( X.UI.Event.CREATION_COMPLETE );\r
88                         \r
89                         // html 要素が親に追加されるまで控えていたイベントの登録\r
90                         if( events && ( l = events.length ) ){\r
91                                 for( i = 0; i < l; ++i ){\r
92                                         this.listen.apply( this, events[ i ] );\r
93                                 };\r
94                                 events.length = 0;\r
95                                 delete this.reserveEvents;\r
96                         };                      \r
97                 },\r
98                 \r
99                 /*\r
100                  * _UINode への setAttr の他、attrClass.prototype への setAttr にも対応する\r
101                  * 親要素が変化した場合、unverifiedAttrs を元に attrObject を再設定.\r
102                  */\r
103                 setAttr : function( name, def, v ){\r
104                         var attrs      = X.UI.attrClassProto || this.attrObject,\r
105                                 propID     = def.No || def[ 5 ],\r
106                                 defaultVal = X.UI.attrClassProto ? attrs[ propID ] : this.attrClass.prototype[ propID ], // def[ 0 ],\r
107                                 currentVal = attrs ? attrs[ propID ] : defaultVal,\r
108                                 dirty      = def[ 1 ],\r
109                                 user       = def[ 2 ],\r
110                                 type       = def[ 3 ],\r
111                                 list       = def[ 4 ],\r
112                                 length     = !!( type & X.UI.Attr.Type.LENGTH        ),\r
113                                 minusLen   = !!( type & X.UI.Attr.Type.MINUS_LENGTH  ),\r
114                                 percent    = !!( type & X.UI.Attr.Type.PERCENT       ),\r
115                                 minusPct   = !!( type & X.UI.Attr.Type.MINUS_PERCENT ),\r
116                                 numerical  = !!( type & X.UI.Attr.Type.NUMERICAL     ),\r
117                                 auto       = !!( type & X.UI.Attr.Type.AUTO          ),\r
118                                 color      = !!( type & X.UI.Attr.Type.COLOR         ),\r
119                                 url        = !!( type & X.UI.Attr.Type.URL           ),\r
120                                 fontName   = !!( type & X.UI.Attr.Type.FONT_NAME     ),\r
121                                 flag       = !!( type & X.UI.Attr.Type.BOOLEAN       ),\r
122                                 combi      = !!( type & X.UI.Attr.Type.COMBI         ),\r
123                                 quartet    = !!( type & X.UI.Attr.Type.QUARTET       ),\r
124                                 _v, i, l, nodes, root, roots;\r
125                 \r
126                         if( X_Type_isString( v ) ){\r
127                                 //v = v.toLowercase();\r
128                                 if( url || fontName ){\r
129                                         // good\r
130                                 } else\r
131                                 if( auto && v === 'auto' ){\r
132                                         v = X.UI.Attr.AUTO;\r
133                                 } else\r
134                                 if( list && ( _v = list[ v ] ) ){\r
135                                         // good\r
136                                         console.log( v + ' ' + _v );\r
137                                         v = _v;\r
138                                 } else\r
139                                 if( ( percent || minusPct ) && v.lastIndexOf( '%' ) !== -1 && isFinite( _v = parseFloat( v ) ) && v === _v + '%' ){\r
140                                         // good\r
141                                 } else\r
142                                 if( ( length || minusLen ) && v.lastIndexOf( 'em' ) !== -1 && isFinite( _v = parseFloat( v ) ) && v === _v + 'em' ){\r
143                                         v = _v;\r
144                                 } else                          \r
145                                 if( v.indexOf( ' ' ) !== -1 ){\r
146                                         v = v.split( ' ' );\r
147                                 } else\r
148                                 if( color && X_Type_isNumber( _v = X_Node_CSS_objToIEFilterText( v ) ) ){\r
149                                         v = _v;\r
150                                 } else {\r
151                                         // bad\r
152                                         return;\r
153                                 };\r
154                         };\r
155                         \r
156                         if( ( quartet || combi ) && !X_Type_isArray( v ) ){\r
157                                 v = [ v ];\r
158                         };\r
159                         \r
160                         if( X_Type_isNumber( v ) ){\r
161                                 if( \r
162                                     ( length    && ( 0 <= v ) ) ||\r
163                                     ( minusLen  && ( v <= 0 ) ) ||\r
164                                     ( percent   && 0 <= v && v <= 1 ) ||\r
165                                         ( minusPct  && -1 <= v && v < 0 ) ||\r
166                                     ( numerical && 0 <= v ) ||\r
167                                     ( auto      && v === X.UI.Attr.AUTO ) ||\r
168                                     ( color     && 0 <= v && v <= 0xFFFFFF ) ||\r
169                                     ( list      && list[ v ] )\r
170                                 ){\r
171                                         // good\r
172                                 } else {\r
173                                         // bad\r
174                                         return;\r
175                                 };\r
176                         } else\r
177                         if( X_Type_isBoolean( v ) && !flag ){\r
178                                 return;\r
179                         } else\r
180                         if( X_Type_isArray( v ) ){\r
181                                 if( v.length <= 4 && quartet ){\r
182                                         type &= ~X.UI.Attr.Type.QUARTET;\r
183                                         switch( v.length ){\r
184                                                 case 1 :\r
185                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list,   propID ], v[ 0 ] );\r
186                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 0 ] );\r
187                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 0 ] );\r
188                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 0 ] );\r
189                                                         break;\r
190                                                 case 2 :\r
191                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list,   propID ], v[ 0 ] );\r
192                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 1 ] );\r
193                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 0 ] );\r
194                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 1 ] );\r
195                                                         break;\r
196                                                 case 3 :\r
197                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list,   propID ], v[ 0 ] );\r
198                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 1 ] );\r
199                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 2 ] );\r
200                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 1 ] );\r
201                                                         break;\r
202                                                 case 4 :\r
203                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list,   propID ], v[ 0 ] );\r
204                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 1 ] );\r
205                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 2 ] );\r
206                                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 3 ] );\r
207                                                         break;\r
208                                         };                                      \r
209                                 } else\r
210                                 if( v.length === 2 && combi ){\r
211                                         type &= ~X.UI.Attr.Type.COMBI;\r
212                                         this.setAttr( false, [ defaultVal, user, dirty, type, list,   propID ], v[ 0 ] );\r
213                                         this.setAttr( false, [ defaultVal, user, dirty, type, list, ++propID ], v[ 1 ] );\r
214                                 } else {\r
215                                         // bad\r
216                                         return;\r
217                                 };\r
218 \r
219                                 if( !X.UI.attrClassProto && user === X.UI.Attr.USER.XNODE && this.xnode ){\r
220                                         this.xnode[ 'css' ]( X.UI.Attr.Rename[ name ] || name, XUI_AbstractUINode_createCssText( this, name ) );\r
221                                         //console.log( ( X.UI.Attr.Rename[ name ] || name ) + ' ' + XUI_AbstractUINode_createCssText( this, name ) + ' ' + propID + ' ' + attrs[ propID ] );\r
222                                 };\r
223                                 return;\r
224                         };\r
225 \r
226                         if( !v && v !== 0 ) v = defaultVal;\r
227                         \r
228                         if( X.UI.attrClassProto ){\r
229                                 attrs[ propID ] = v;\r
230                                 return;                 \r
231                         };              \r
232 \r
233                         if( currentVal !== v ){\r
234                                 switch( propID ){\r
235                                         case X.UI.Attr.Support.left.No :\r
236                                                 this.constraintW = attrs[ X.UI.Attr.Support.right.No ] !== null;\r
237                                                 break;\r
238                                         case X.UI.Attr.Support.right.No :\r
239                                                 this.constraintW = attrs[ X.UI.Attr.Support.left.No ] !== null;\r
240                                                 break;\r
241                                         case X.UI.Attr.Support.top.No :\r
242                                                 this.constraintH = attrs[ X.UI.Attr.Support.bottom.No ] !== null;\r
243                                                 break;\r
244                                         case X.UI.Attr.Support.bottom.No :\r
245                                                 this.constraintH = attrs[ X.UI.Attr.Support.top.No ] !== null;\r
246                                                 break;\r
247                                         case X.UI.Attr.Support.width.No :\r
248                                                 this.autoWidth    = v === X.UI.Attr.AUTO;\r
249                                                 this.percentWidth = X_Type_isString( v );\r
250                                                 break;\r
251                                         case X.UI.Attr.Support.height.No :\r
252                                                 this.autoHeight    = v === X.UI.Attr.AUTO;\r
253                                                 this.percentHeight = X_Type_isString( v );\r
254                                                 break;\r
255                                 };\r
256                                 \r
257                                 if( defaultVal === v ){\r
258                                         if( attrs ) delete attrs[ propID ];\r
259                                 } else {\r
260                                         if( !attrs ) attrs = this.attrObject = new this.attrClass;\r
261                                         attrs[ propID ] = v;\r
262                                 };\r
263                                 \r
264                                 if( name && user === X.UI.Attr.USER.UINODE ){\r
265                                         this[ name ] = v;\r
266                                 };\r
267                                 \r
268                                 if( name && user === X.UI.Attr.USER.XNODE && this.xnode ){\r
269                                         this.xnode[ 'css' ]( X.UI.Attr.Rename[ name ] || name, XUI_AbstractUINode_createCssText( this, name ) );\r
270                                         //console.log( ( X.UI.Attr.Rename[ name ] || name ) + ' ' + XUI_AbstractUINode_createCssText( this, name ) + ' ' + propID + ' ' + attrs[ propID ] );\r
271                                 } else\r
272                                 if( this.dirty < dirty ) this.dirty = dirty;\r
273                         };\r
274                 },\r
275 \r
276                 getAttr : function( name ){\r
277                         var attrs   = this.attrObject || this.attrClass.prototype || X.UI.AttrClass,\r
278                                 support = this.supportAttrs[ name ],\r
279                 v, type, list;\r
280                         if( !support ) return;\r
281                         \r
282                         if( name.indexOf( 'border' ) === 0 ){\r
283                                 name = name.substr( 6 );\r
284                                 return [ this.getAttr( 'borderTop' + name ), this.getAttr( 'borderRight' + name ), this.getAttr( 'borderBottom' + name ), this.getAttr( 'borderLeft' + name ) ];\r
285                         };\r
286                         \r
287                         type = support[ 3 ];\r
288                         // Unit\r
289                         if( type & X.UI.Attr.Type.QUARTET ){\r
290                                 return [ this.getAttr( name + 'Top' ), this.getAttr( name + 'Right' ), this.getAttr( name + 'Bottom' ), this.getAttr( name + 'Left' ) ];\r
291                         };\r
292                         if( type & X.UI.Attr.Type.COMBI   ) return [ v, data[ ++propID ] ];\r
293                         \r
294                         v    = attrs[ support.No ];             \r
295                         if( type & X.UI.Attr.Type.AUTO && v === X.UI.Attr.AUTO ) return 'auto'; \r
296                         \r
297                         list = support[ 4 ];\r
298                         if( list ) return list[ v ];\r
299                         \r
300                         if( type & X.UI.Attr.Type.COLOR && X_Type_isNumber( v ) ) return v;\r
301                         if( !( type & X.UI.Attr.Type.NUMERICAL ) && X_Type_isNumber( v ) ) return v + 'em';\r
302                         return v;\r
303                 },\r
304                 \r
305                 // em, px, %\r
306                 getAttrWithUnit : function( prop, unit ){\r
307                         \r
308                 },\r
309 \r
310                 _remove : function(){\r
311                         switch( this.phase ){\r
312                                 case 4:\r
313                                 case 3:\r
314 \r
315                                 case 2:\r
316                                         \r
317                                 case 1:\r
318                                         this.xnode[ 'kill' ]();\r
319                                 \r
320                                         delete this.root;\r
321                                         delete this.rootData;\r
322                                         delete this.parent;\r
323                                         delete this.parentData;\r
324                                         delete this.xnode;\r
325                                         \r
326                                         delete this.phase;\r
327                         };\r
328                         \r
329                 },\r
330                 //killed\r
331 \r
332                 calculate : function( isNeedsDetection, x, y, allowedW, allowedH ){\r
333                         this.preMesure( allowedW, allowedH );\r
334                         \r
335                         if( this.boxWidth === X.UI.Attr.AUTO || this.boxHeight === X.UI.Attr.AUTO ){\r
336                                 this.mesure();\r
337                                 this.postMesure();\r
338                         };\r
339                         \r
340                         !isNeedsDetection && this.updateLayout( x, y );\r
341                 },\r
342                 \r
343                 /**\r
344                  * X_Node_BoxModel の情報を引きながら top,left,width,height,padding,border の設定\r
345                  */\r
346                 updateLayout : function( x, y ){\r
347                         this.boxX = x;\r
348                         this.boxY = y;\r
349                         this.xnode\r
350                                 [ 'css' ]( 'left',        x ? x + 'em' : 0 )\r
351                                 [ 'css' ]( 'top',         y ? y + 'em' : 0 )\r
352                                 [ 'css' ]( 'width',       this.contentWidth  ? XUI_AbstractUINode_ceil( this.contentWidth  ) + 'em' : 0 )\r
353                                 [ 'css' ]( 'height',      this.contentHeight ? XUI_AbstractUINode_ceil( this.contentHeight ) + 'em' : 0 )\r
354                                 [ 'css' ]( 'padding',     XUI_AbstractUINode_createCssText( this, 'padding' ) )\r
355                                 [ 'css' ]( 'borderWidth', XUI_AbstractUINode_createCssText( this, 'borderWidth' ) );\r
356                 },\r
357 \r
358                 /*\r
359                  * 親の サイズを元に自身のサイズを計算していく\r
360                  */\r
361                 preMesure : function( allowedW, allowedH ){\r
362                         var attrs = this.attrObject || this.attrClass.prototype || X.UI.AttrClass,\r
363                                 box   = attrs[ X.UI.Attr.Support.sizing.No ],\r
364                                 min, max,\r
365                                 boxL, boxT, boxR, boxB,\r
366                                 contentW, contentH, boxMinus,\r
367                                 paddingT, paddingR, paddingB, paddingL,\r
368                                 borderT, borderR, borderB, borderL;\r
369                         \r
370                         // Width が確定するパターン\r
371                         // 自身が constraintW の場合 親が AUTO ではない\r
372                         // 自身が constraintW でない場合自身が  AUTO はなくかつ親 が AUTO の場合 or 自身は % でない\r
373                         \r
374                         paddingR = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 1 ], allowedW );\r
375                         paddingL = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 3 ], allowedW );\r
376                         borderR  = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No + 1 ], allowedW );\r
377                         borderL  = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No + 3 ], allowedW );\r
378                         boxMinus = 0;\r
379                         switch( box ){\r
380                                 case 3 : // border-box\r
381                                          boxMinus -= borderR + borderL;\r
382                                 case 2 : // padding-box\r
383                                          boxMinus -= paddingR + paddingL;\r
384                                 // case 1 : // content-box\r
385                         };\r
386                         this.contentL = borderL + paddingL;\r
387                         this.contentR = borderR + paddingR;\r
388                         \r
389                         if( this.constraintW ? allowedW !== X.UI.Attr.AUTO : !this.autoWidth && ( allowedW !== X.UI.Attr.AUTO || !this.percentWidth ) ){\r
390                                 if( this.constraintW ){ // 制約レイアウト\r
391                                         contentW = allowedW - ( boxL = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.left.No ], allowedW ) ) - ( boxR = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.right.No ], allowedW ) );\r
392                                 } else {\r
393                                         contentW = XUI_AbstractUINode_calcFinalValue( attrs[ X.UI.Attr.Support.width.No ], attrs[ X.UI.Attr.Support.minWidth.No ], attrs[ X.UI.Attr.Support.maxWidth.No ], allowedW );                                  \r
394                                 };\r
395                                 this.contentWidth = contentW + boxMinus;\r
396                                 this.scrollWidth  = this.contentWidth + this.contentL + this.contentR;\r
397                                 this.boxWidth     = contentW - boxMinus + this.contentL + this.contentR;\r
398                                 this.boxSizingOffsetLR = boxMinus;\r
399                                 delete this.minContentWidth;\r
400                                 delete this.maxContentWidth;\r
401                                 delete this.minBoxWidth;\r
402                                 delete this.maxBoxWidth;\r
403                         } else {        \r
404                                 this.minContentWidth = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.minWidth.No ], allowedW ) + boxMinus;\r
405                                 this.maxContentWidth = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.maxWidth.No ], allowedW ) + boxMinus;\r
406                                 this.scrollWidth     = this.contentWidth + this.contentL + this.contentR;\r
407                                 this.minBoxWidth     = this.minContentWidth - boxMinus + this.contentL + this.contentR;\r
408                                 this.maxBoxWidth     = this.maxContentWidth - boxMinus + this.contentL + this.contentR;\r
409                                 //delete this.contentWidth;\r
410                                 //delete this.scrollWidth;\r
411                                 //delete this.boxWidth;\r
412                                 //delete this.boxSizingOffsetLR;\r
413                         };\r
414                         \r
415                         paddingT  = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 0 ], allowedH );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
416                         paddingB  = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 2 ], allowedH );\r
417                         borderT   = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No  + 0 ], allowedH );\r
418                         borderB   = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No  + 2 ], allowedH );\r
419                         boxMinus = 0;\r
420                         switch( box ){\r
421                                 case 3 : // border-box\r
422                                          boxMinus -= borderT + borderB;\r
423                                 case 2 : // padding-box\r
424                                          boxMinus -= paddingT + paddingB;\r
425                                 // case 1 : // content-box\r
426                         };\r
427                         this.contentT = borderT + paddingT;\r
428                         this.contentB = borderB + paddingB;\r
429                         \r
430                         // Height\r
431                         if( this.constraintH ? allowedH !== X.UI.Attr.AUTO : !this.autoHeight && ( allowedH !== X.UI.Attr.AUTO || !this.percentHeight ) ){\r
432                                 if( this.constraintH ){ // 制約レイアウト\r
433                                         contentH = allowedH - ( boxT = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.top.No ], allowedH ) ) - ( boxB = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.bottom.No ], allowedH ) );\r
434                                 } else {\r
435                                         contentH = XUI_AbstractUINode_calcFinalValue( attrs[ X.UI.Attr.Support.height.No ], attrs[ X.UI.Attr.Support.minHeight.No ], attrs[ X.UI.Attr.Support.maxHeight.No ], allowedH );\r
436                                 };                      \r
437                                 this.contentHeight = contentH + boxMinus;\r
438                                 this.scrollHeight  = this.contentHeight + this.contentT + this.contentB;\r
439                                 this.boxHeight     = contentH - boxMinus + this.contentT + this.contentB; // padding-box の場合 border だけ足される\r
440                                 this.boxSizingOffsetTB = boxMinus;\r
441                                 delete this.minContentHeight;\r
442                                 delete this.maxContentHeight;\r
443                                 delete this.minBoxHeight;\r
444                                 delete this.maxBoxHeight;\r
445                         } else {\r
446                                 this.minContentHeight = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.minHeight.No ], allowedH ) + boxMinus;\r
447                                 this.maxContentHeight = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.maxHeight.No ], allowedH ) + boxMinus;                           \r
448                                 this.minBoxHeight = this.minContentHeight - boxMinus + this.contentT + this.contentB;\r
449                                 this.maxBoxHeight = this.maxContentHeight - boxMinus + this.contentT + this.contentB;\r
450                 \r
451                                 //delete this.contentHeight;\r
452                                 //delete this.scrollHeight;\r
453                                 //delete this.boxHeight;\r
454                                 //delete this.boxSizingOffsetTB;\r
455                         };\r
456                         \r
457                         if( this.parentData && this.parentData.layout.overrideAttrsForChild.left ){\r
458                                 if( this.constraintW ){\r
459                                         this.boxX = ( boxL || boxL === 0 ) ? boxL : XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.left.No ], allowedW );\r
460                                 } else\r
461                                 if( attrs[ X.UI.Attr.Support.right.No ] === null ){\r
462                                         this.boxX = ( boxL || boxL === 0 ) ? boxL : XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.left.No ], allowedW );\r
463                                 } else {\r
464                                         this.boxX = alllowW - this.boxWidth - ( ( boxR || boxR === 0 ) ? boxR : XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.right.No ], allowedW ) );\r
465                                 };\r
466                         } else {\r
467                                 delete this.boxX;\r
468                         };\r
469                         \r
470                         if( this.parentData && this.parentData.layout.overrideAttrsForChild.top ){\r
471                                 if( this.constraintH ){\r
472                                         this.boxY = ( boxT || boxT === 0 ) ? boxT : XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.top.No ], allowedH );\r
473                                 } else\r
474                                 if( attrs[ X.UI.Attr.Support.bottom.No ] === null ){\r
475                                         this.boxY = ( boxT || boxT === 0 ) ? boxT : XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.top.No ], allowedH );\r
476                                 } else {\r
477                                         this.boxY = allowedH - this.boxHeight - ( ( boxB || boxB === 0 ) ? boxB : XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.bottom.No ], allowedH ) );\r
478                                 };\r
479                         } else {\r
480                                 delete this.boxY;\r
481                         };\r
482                 },\r
483                 \r
484                 /**\r
485                  * 描画・計測を行って、contentSize, scrollSize の決定\r
486                  */\r
487                 mesure : function(){\r
488                         var dirty = this.dirty,\r
489                                 w, h, xnode;\r
490                         \r
491                         if( dirty === X.UI.Dirty.CLEAN ){\r
492                                 if( this.percentWidth || this.percentHeight ){\r
493                                         \r
494                                 };\r
495                         };\r
496                         \r
497                         switch( dirty ){\r
498                                 \r
499                                 case X.UI.Dirty.CONTENT : // コンテンツが変更された\r
500                                 case X.UI.Dirty.FONT    : // フォントサイズが変更された\r
501                                         delete this.lastContentWidth;\r
502                                         delete this.lastContentHeight;\r
503                                         \r
504                                 case X.UI.Dirty.LAYOUT : // レイアウトの再計算が必要\r
505                                 \r
506                                 default : // TODO レイアウト崩れに対処 パフォーマンス悪い!\r
507                                 \r
508                                         w     = this.contentWidth;\r
509                                         h     = this.contentHeight;\r
510                                         xnode = this.xnode;\r
511                                         \r
512                                         /* http://web-designs.seesaa.net/article/188400668.html\r
513                                          * min-width の値が max-width の値より大きい場合は、max-width の値は min-width の値に設定される。\r
514                                          * \r
515                                          * テキストノードがあり\r
516                                          * 1. contentWidth === AUTO\r
517                                          *     style を更新して contentWidth の決定\r
518                                          *     min or max に引っかかったら style 更新\r
519                                          *     contentHeight === AUTO の場合\r
520                                          *     textHeight の決定\r
521                                          *     contentHeight !== AUTO の場合 scrollHeight のみ更新\r
522                                          * 2. contentHeight === AUTO かつ \r
523                                          *     コンテンツの高さの再取得が必要( contentWidth が最終計測時の contentWidth と一致 かつ フォント・コンテンツに変更無し の場合再取得不要)\r
524                                          *      style を更新して contentHeight の決定\r
525                                          *     必要でない\r
526                                          * 3. content のサイズがすでに決定している\r
527                                          *     コンテンツの高さの再取得が必要\r
528                                          *     必要でない\r
529                                          */\r
530                                         if( xnode[ '_xnodes' ] && xnode[ '_xnodes' ].length ){\r
531                                                 if( w === X.UI.Attr.AUTO ){\r
532                                                         w = this.contentWidth = xnode[ 'css' ]( 'width', 'auto' )[ 'width' ]() / X_Node_CSS_getCharSize( xnode );\r
533                                                         \r
534                                                         this.scrollWidth = w + this.contentL + this.contentR;\r
535                                                         if( this.maxContentWidth < w - this.boxSizingOffsetLR ) this.contentWidth = this.maxContentWidth + this.boxSizingOffsetLR;\r
536                                                         if( w - this.boxSizingOffsetLR < this.minContentWidth ) this.contentWidth = this.minContentWidth + this.boxSizingOffsetLR;\r
537                                                         this.lastContentWidth = this.contentWidth;\r
538                                                         \r
539                                                         w !== this.contentWidth && xnode[ 'css' ]( 'width', XUI_AbstractUINode_ceil( this.contentWidth ) + 'em' );\r
540                                                         \r
541                                                         if( h === X.UI.Attr.AUTO ){\r
542                                                                 this.contentHeight = h = xnode[ 'css' ]( 'height', 'auto' )[ 'scrollHeight' ]() / X_Node_CSS_getCharSize( xnode ); // scrollHeight() ??\r
543                                                                 this.scrollHeight  = h + this.contentT + this.contentB;\r
544                                                                 if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
545                                                                 if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB;\r
546                                                         } else {\r
547                                                                 this.scrollHeight = h + this.contentT + this.contentB;\r
548                                                         };\r
549                                                         \r
550                                                         this.lastContentHeight = h;\r
551                                                 } else\r
552                                                 if( h === X.UI.Attr.AUTO ){\r
553                                                         if( w !== this.lastContentWidth ){\r
554                                                                 xnode[ 'css' ]( 'width', XUI_AbstractUINode_ceil( w ) + 'em' );\r
555                                                                 \r
556                                                                 this.lastContentWidth  = w;\r
557                                                                 this.contentHeight = h = xnode[ 'css' ]( 'height', 'auto' )[ 'scrollHeight' ]() / X_Node_CSS_getCharSize( xnode );\r
558                                                                 this.scrollWidth       = w + this.contentL + this.contentR;\r
559                                                                 this.scrollHeight      = h + this.contentT + this.contentB;\r
560                                                                 if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
561                                                                 if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB;                                                           \r
562                                                         } else {\r
563                                                                 this.contentHeight = this.lastContentHeight = h =\r
564                                                                         this.lastContentHeight === -1 ? xnode[ 'css' ]( 'height', 'auto' )[ 'scrollHeight' ]() / X_Node_CSS_getCharSize( xnode ) : this.lastContentHeight;\r
565                                                                 this.scrollWidth   = w + this.contentL + this.contentR;\r
566                                                                 this.scrollHeight  = h + this.contentT + this.contentB;\r
567                                                         };\r
568                                                 } else\r
569                                                 if( dirty !== X.UI.Dirty.LAYOUT ){\r
570                                                         this.contentWidth  = this.lastContentWidth  = w; //xnode[ 'width' ]();\r
571                                                         this.contentHeight = this.lastContentHeight = xnode[ 'css' ]( 'height', 'auto' )[ 'scrollHeight' ]() / X_Node_CSS_getCharSize( xnode );\r
572                                                         this.scrollWidth   = this.contentWidth  + this.contentL + this.contentR;\r
573                                                         this.scrollHeight  = this.contentHeight + this.contentT + this.contentB;\r
574                                                 } else {\r
575                                                         this.scrollWidth  = w + this.contentL + this.contentR;\r
576                                                         this.scrollHeight = h + this.contentT + this.contentB;\r
577                                                 };              \r
578                                         } else {\r
579                                                 // コンテンツを持たないため基本のサイズは0\r
580                                                 if( w === X.UI.Attr.AUTO ) this.contentWidth  = w = 0 < this.minContentWidth  ? this.minContentWidth  : 0;\r
581                                                 if( h === X.UI.Attr.AUTO ) this.contentHeight = h = 0 < this.minContentHeight ? this.minContentHeight : 0;\r
582                                                 this.scrollWidth  = w + this.contentL + this.contentR;\r
583                                                 this.scrollHeight = h + this.contentT + this.contentB;\r
584                                         };\r
585                                         \r
586                                         delete this.dirty;\r
587                                         break;                  \r
588                                 //case X.UI.Dirty.PAINT : // 再描画のみ必要\r
589                                 //      break;\r
590                         };\r
591                 },\r
592                 /**\r
593                  * 自身の contentWidth, contentHeight を元に AUTO な width, height を確定していく\r
594                  */\r
595                 postMesure : function(){\r
596                         var     attrs = this.attrObject || this.attrClass.prototype || X.UI.AttrClass,\r
597                                 box   = attrs[ X.UI.Attr.Support.sizing.No ],\r
598                                 contentW, contentH,\r
599                                 contentPlus,\r
600                                 paddingT, paddingR, paddingB, paddingL,\r
601                                 borderT, borderR, borderB, borderL,\r
602                                 min, max;\r
603                                 \r
604                         // Width\r
605                         if( this.boxWidth === X.UI.Attr.AUTO ){\r
606                                 contentW = this.contentWidth;\r
607                                 paddingR = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 1 ], contentW );                                 \r
608                                 paddingL = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 3 ], contentW );                                 \r
609                                 borderR  = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No + 1 ], contentW );\r
610                                 borderL  = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No + 3 ], contentW );\r
611                                 contentPlus = 0;\r
612                                 switch( box ){\r
613                                         case 3 : // border-box\r
614                                                  contentPlus  = borderR + borderL;\r
615                                         case 2 : // padding-box\r
616                                                  contentPlus += paddingR + paddingL;\r
617                                         // case 1 : // content-box\r
618                                 };\r
619                                 \r
620                                 if( !this.constraintW ){\r
621                                         contentW += contentPlus;\r
622                                         min = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.minWidth.No ], contentW );\r
623                                         max = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.maxWidth.No ], contentW );\r
624                                         if( contentW < min && contentPlus < min ){\r
625                                                 this.contentWidth = min - contentPlus;\r
626                                         } else\r
627                                         if( max < contentW && contentPlus < max ){\r
628                                                 this.contentWidth = max - contentPlus;\r
629                                         };\r
630                                 };\r
631                                 this.contentL = borderL + paddingL;\r
632                                 this.contentR = borderR + paddingR;\r
633                                 this.boxWidth = this.contentWidth + this.contentL + this.contentR;\r
634                         };\r
635                         // Height\r
636                         if( this.boxHeight === X.UI.Attr.AUTO ){\r
637                                 contentH    = this.contentHeight;\r
638                                 paddingT    = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 0 ], contentH );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
639                                 paddingB    = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.padding.No + 2 ], contentH );\r
640                                 borderT     = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No  + 0 ], contentH );\r
641                                 borderB     = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.borderWidth.No  + 2 ], contentH );\r
642                                 contentPlus = 0;\r
643                                 switch( box ){\r
644                                         case 3 : // border-box\r
645                                                  contentPlus  = borderT + borderB;\r
646                                         case 2 : // padding-box\r
647                                                  contentPlus += paddingT + paddingB;\r
648                                         // case 1 : // content-box\r
649                                 };\r
650                                 if( !this.constraintH ){\r
651                                         contentH += contentPlus;\r
652                                         min = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.minHeight.No ], contentH );\r
653                                         max = XUI_AbstractUINode_calcValue( attrs[ X.UI.Attr.Support.maxHeight.No ], contentH );\r
654                                         if( contentH < min && contentPlus < min ){\r
655                                                 this.contentHeight = min - contentPlus;\r
656                                         } else\r
657                                         if( max < contentH && contentPlus < max ){\r
658                                                 this.contentHeight = max - contentPlus;\r
659                                         };\r
660                                 };\r
661                                 this.contentT  = borderT + paddingT;\r
662                                 this.contentB  = borderB + paddingB;\r
663                                 this.boxHeight = this.contentHeight + this.contentT + this.contentB;\r
664                         };\r
665                 },\r
666 \r
667                 capcher : function( x, y ){\r
668                         if( this.pointerDisabled ) return false;\r
669                         \r
670                         x -= this.boxX;\r
671                         y -= this.boxY;\r
672 \r
673                         if( 0 <= x && x < this.boxWidth && 0 <= y && y < this.boxHeight ){\r
674                                 !this.hovering && ( this.rootData.hoverList[ this.rootData.hoverList.length ] = this );\r
675                                 this.rootData.targetNodeData = this;\r
676                                 return true;\r
677                         };\r
678                 },\r
679                 \r
680                 /*\r
681                  * context を明示しない場合、User が context になる!\r
682                  */\r
683                 listen : function( type, arg1, arg2, arg3 ){\r
684                         var root, events, counter, f;\r
685                         if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){\r
686                                 if( this.phase < 3 ){\r
687                                         if( !( events = this.reserveEvents ) ) this.reserveEvents = events = [];\r
688                                         events[ events.length ] = [ type, arg1, arg2, arg3 ];\r
689                                         return this;\r
690                                 };\r
691                                 if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){\r
692                                         if( !this.gesture ){\r
693                                                 this.gesture = new X.UI.Gesture( this.rootData, this, type );\r
694                                         } else {\r
695                                                 this.gesture[ 'listen' ]( type );\r
696                                         };\r
697                                 } else {\r
698                                         //console.log( type );\r
699                                         root    = this.rootData;\r
700                                         counter = root.eventCounter;\r
701                                         if( counter[ type ] ){\r
702                                                 ++counter[ type ];\r
703                                         } else {\r
704                                                 counter[ type ] = 1;                            \r
705                                                 root.xnodeInteractiveLayer[ 'listen' ]( X.UI.Event.IdToName[ type ], X_UI_eventRellay );\r
706                                         };\r
707                                 };\r
708                         };\r
709                         arg1 && arg1.kind ? ( f = arg1 ) : ( f = X_Callback_classifyCallbackArgs( arg1, arg2, arg3 ) );\r
710                         if( !f.kind ){\r
711                                 return X_EventDispatcher_listen.call( this, type, this.User, f );\r
712                         } else\r
713                         if( f.kind === X_Callback_FUNC_ONLY ){\r
714                                 return X_EventDispatcher_listen.call( this, type, this.User, f.func, f.supplement );\r
715                         };\r
716                         return X_EventDispatcher_listen.apply( this, arguments );\r
717                 },\r
718                 unlisten : function( type, arg1, arg2, arg3 ){\r
719                         var root, events, i, ev, counter, f;\r
720                         if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){\r
721                                 if( this.phase < 3 ){\r
722                                         if( !( events = this.reserveEvents ) ) return this;\r
723                                         for( i = events.length; i; ){\r
724                                                 ev = events[ --i ];\r
725                                                 if( ev[ 0 ] === type && ev[ 1 ] === arg1 && ev[ 2 ] === arg2 ){\r
726                                                         events.split( i, 1 );\r
727                                                         return this;\r
728                                                 };\r
729                                         }; \r
730                                         return this;\r
731                                 };\r
732 \r
733                                 if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){\r
734                                         this.gesture && this.gesture[ 'unlisten' ]( type );\r
735                                 } else {\r
736                                         root    = this.rootData;\r
737                                         counter = root.eventCounter;\r
738                                         if( !counter[ type ] ) return this;\r
739                                         --counter[ type ];\r
740                                         if( counter[ type ] === 0 ){\r
741                                                 root.xnodeInteractiveLayer[ 'unlisten' ]( X.UI.Event.IdToName[ type ], X_UI_eventRellay );\r
742                                                 delete counter[ type ];\r
743                                         };\r
744                                 };\r
745                         };\r
746                         arg1 && arg1.kind ? ( f = arg1 ) : ( f = X_Callback_classifyCallbackArgs( arg1, arg2, arg3 ) );\r
747                         if( !f.kind ){\r
748                                 return X_EventDispatcher_unlisten.apply( this, [ type, this.User, f ] );\r
749                         } else\r
750                         if( f.kind === X_Callback_FUNC_ONLY ){\r
751                                 return X_EventDispatcher_unlisten.apply( this, [ type, this.User, f.func, f.supplement ] );\r
752                         };\r
753                         return X_EventDispatcher_unlisten.apply( this, arguments );\r
754                 },\r
755                 \r
756                 dispatch : function( e ){\r
757                         //console.log( e.type + ' ' + ( this[ '_listeners' ] && this[ '_listeners' ][ e.type ] ) );\r
758                         var xve  = X.UI.Event,\r
759                                 ret  = X_EventDispatcher_dispatch.call( this, e ),\r
760                                 type = e.type || e;\r
761                         \r
762                         // TODO captureEvent PointerEvent\r
763                         if( ret & X_Callback_MONOPOLY && !this.hitChildData && ( xve._POINTER_MOVE === type || xve._MOUSE_MOVE === type || xve.FILE_DRAG === type ) ){\r
764                                 this.rootData.monopolyNodeData = this;\r
765                                 return ret;\r
766                         };\r
767                         this.rootData.monopolyNodeData = null;\r
768                         if( xve._START_BUBLEUP < type && this.parentData && !( ret & X_Callback_STOP_PROPAGATION ) && !( ret & X_Callback_STOP_NOW ) ) return this.parentData[ 'dispatch' ]( e );\r
769                         return ret;\r
770                 }\r
771                 \r
772         }\r
773 );\r
774 \r
775 function XUI_AbstractUINode_createCssText( that, name ){\r
776         var attrs      = that.attrObject || that.attrClass.prototype || X.UI.AttrClass,\r
777                 def        = that.supportAttrs[ name ],\r
778                 no         = def.No,\r
779                 v          = attrs[ def.No ],\r
780                 type       = def[ 3 ],\r
781                 list       = def[ 4 ],\r
782                 flag       = !!( type & X.UI.Attr.Type.BOOLEAN ),\r
783                 combi      = !!( type & X.UI.Attr.Type.COMBI   ),\r
784                 quartet    = !!( type & X.UI.Attr.Type.QUARTET );\r
785 \r
786         if( quartet ){\r
787                 if( attrs[ no + 1 ] === attrs[ no + 3 ] ){\r
788                         if( v === attrs[ no + 2 ] ){\r
789                                 if( v === attrs[ no + 1 ] ){\r
790                                         return XUI_AbstractUINode_createCssValue( v, type, list );\r
791                                 };\r
792                                 return [\r
793                                         XUI_AbstractUINode_createCssValue( v, type, list ),\r
794                                         XUI_AbstractUINode_createCssValue( attrs[ no + 1 ], type, list )\r
795                                 ].join( ' ' );\r
796                         };\r
797                         return [\r
798                                 XUI_AbstractUINode_createCssValue( v, type, list ),\r
799                                 XUI_AbstractUINode_createCssValue( attrs[ no + 1 ], type, list ),\r
800                                 XUI_AbstractUINode_createCssValue( attrs[ no + 2 ], type, list )\r
801                         ].join( ' ' );\r
802                 };\r
803                 return [\r
804                         XUI_AbstractUINode_createCssValue( v, type, list ),\r
805                         XUI_AbstractUINode_createCssValue( attrs[ no + 1 ], type, list ),\r
806                         XUI_AbstractUINode_createCssValue( attrs[ no + 2 ], type, list ),\r
807                         XUI_AbstractUINode_createCssValue( attrs[ no + 3 ], type, list )\r
808                 ].join( ' ' );\r
809         } else\r
810         if( combi ){\r
811                 return [\r
812                         XUI_AbstractUINode_createCssValue( v, type, list ),\r
813                         XUI_AbstractUINode_createCssValue( attrs[ no + 1 ], type, list )\r
814                 ].join( ' ' );\r
815         } else\r
816         if( flag ){\r
817                 return v ? list : 'normal'; // \r
818         };\r
819         return XUI_AbstractUINode_createCssValue( v, type, list );\r
820 };\r
821 \r
822 function XUI_AbstractUINode_createCssValue( v, type, list ){\r
823         var length     = !!( type & X.UI.Attr.Type.LENGTH        ),\r
824                 minusLen   = !!( type & X.UI.Attr.Type.MINUS_LENGTH  ),\r
825                 percent    = !!( type & X.UI.Attr.Type.PERCENT       ),\r
826                 minusPct   = !!( type & X.UI.Attr.Type.MINUS_PERCENT ),\r
827                 numerical  = !!( type & X.UI.Attr.Type.NUMERICAL     ),\r
828                 auto       = !!( type & X.UI.Attr.Type.AUTO          ),\r
829                 color      = !!( type & X.UI.Attr.Type.COLOR         ),\r
830                 url        = !!( type & X.UI.Attr.Type.URL           ),\r
831                 fontName   = !!( type & X.UI.Attr.Type.FONT_NAME     );\r
832         \r
833         if( X_Type_isNumber( v ) ){\r
834                 if( auto && v === X.UI.Attr.AUTO ) return 'auto';\r
835                 if( length || minusLen ) return v + 'em';\r
836                 if( numerical ) return v;\r
837                 if( list && list[ v ] ) return list[ v ];\r
838                 if( color ){\r
839                         if( v < 0x100000 ){\r
840                                 v = '00000' + v.toString( 16 );\r
841                                 return '#' + v.substr( v.length - 6 );\r
842                         };\r
843                         return '#' + v.toString( 16 );\r
844                 };\r
845         };\r
846         if( X_Type_isString( v ) ){\r
847                 if( percent || minusPct || url || fontName ) return v;\r
848         };\r
849 };\r
850 \r
851 function XUI_AbstractUINode_calcValue( styleValue, srcValue ){\r
852         /*\r
853          * String の場合は必ず %\r
854          */     \r
855         if( X_Type_isString( styleValue ) ){\r
856                 return srcValue * parseFloat( styleValue ) / 100;\r
857         };\r
858         if( !X_Type_isNumber( styleValue ) ) return 0;\r
859         return styleValue;\r
860 };\r
861 \r
862 function XUI_AbstractUINode_calcFinalValue( styleValue, styleMin, styleMax, srcValue ){\r
863         var v    = XUI_AbstractUINode_calcValue( styleValue, srcValue ),\r
864                 min  = XUI_AbstractUINode_calcValue( styleMin, srcValue ),\r
865                 max  = XUI_AbstractUINode_calcValue( styleMax, srcValue );\r
866         return v <= min ? min : max <= v ? max : v;\r
867 };\r
868 function XUI_AbstractUINode_ceil( v ){\r
869         if( 0 <= v ){\r
870                 return ( v * 10 + 0.999 | 0 ) / 10;\r
871         };\r
872         return ( -v * 10 + 0.999 | 0 ) / -10;\r
873 };\r
874 \r
875 X.UI.AbstractUINode = X_Class_create(\r
876         'AbstractUINode',\r
877         X_Class.ABSTRACT | X_Class.SUPER_ACCESS,\r
878         {\r
879                 parent : function(){\r
880                         return X_Class_getPrivate( this ).parent;\r
881                 },\r
882                 root : function(){\r
883                         return X_Class_getPrivate( this ).root;\r
884                 },\r
885                 \r
886                 /*\r
887                  * unverifiedAttrs に全ての指定を控える\r
888                  * サポートされていない場合は無視される.親のレイアウトによって変わる\r
889                  */\r
890                 attr : function( nameOrObject, valueOrUnit ){\r
891                         var p = X_Class_getPrivate( this ),\r
892                                 layout, k, def, attrs, v;\r
893                         if( nameOrObject && X_Type_isObject( nameOrObject ) ){\r
894                                 // setter\r
895                                 layout = p.parentData && p.parentData.layout.overrideAttrsForChild; // root には parent がない\r
896                                 for( k in nameOrObject ){\r
897                                         if( X_EMPTY_OBJECT[ k ] ) continue;\r
898                                         // 親のレイアウトマネージャの許可しない\r
899                                         if( layout && !layout[ k ] ){\r
900                                                 continue;\r
901                                         };\r
902                                         if( def = p.supportAttrs[ k ] ){\r
903                                                 p.setAttr( k, def, nameOrObject[ k ] );\r
904                                         };\r
905                                 };\r
906                         } else\r
907                         if( X_Type_isString( nameOrObject ) ){\r
908                                 if( valueOrUnit !== undefined ){\r
909                                         if( 'em,%'.indexOf( valueOrUnit ) === -1 ){\r
910                                                 // setter\r
911                                                 p.setAttr( nameOrObject, valueOrUnit );\r
912                                         } else {\r
913                                                 // getter with unit\r
914                                                 return p.getAttrWithUnit( nameOrObject, valueOrUnit );\r
915                                         };\r
916                                 };\r
917                                 // getter\r
918                                 if( attrs = ( p.attrObject || p.attrClass.prototype || X.UI.AttrClass ) ){\r
919                                         def = p.supportAttrs[ nameOrObject ];\r
920                                         return def && attrs[ def.No ];\r
921                                 };\r
922                                 return v;\r
923                         };\r
924                         return this;\r
925                 },\r
926                 \r
927                 listen : function( type, arg1, arg2, arg3 ){\r
928                         X_Class_getPrivate( this )[ 'listen' ]( type, arg1, arg2, arg3 );\r
929                         return this;\r
930                 },\r
931                 listenOnce : function( type, arg1, arg2, arg3 ){\r
932                         X_Class_getPrivate( this )[ 'listenOnce' ]( type, arg1, arg2, arg3 );\r
933                         return this;\r
934                 },\r
935                 listening : function( type, arg1, arg2, arg3 ){\r
936                         return X_Class_getPrivate( this )[ 'listening' ]( type, arg1, arg2, arg3 );\r
937                 },\r
938                 unlisten : function( type, arg1, arg2, arg3 ){\r
939                         X_Class_getPrivate( this )[ 'unlisten' ]( type, arg1, arg2, arg3 );\r
940                         return this;\r
941                 },\r
942                 dispatch : function( e ){\r
943                         return X_Class_getPrivate( this )[ 'dispatch' ]( e );\r
944                 },\r
945                         \r
946                 nextNode : function(){\r
947                         \r
948                 },\r
949                 prevNode : function(){\r
950                         \r
951                 },\r
952                 nodeIndex : function( v ){\r
953                         var data = X_Class_getPrivate( this );\r
954                         if( typeof v === 'number' ){\r
955                                 // data.nodeIndex( v );\r
956                                 return this;\r
957                         };\r
958                         return data.parentData ? data.parentData.nodes.indexOf( data ) : 0;\r
959                 },\r
960                 displayIndex : function(){\r
961                         \r
962                 },\r
963                 getX : function(){\r
964                         // dirty の場合、rootData.calculate\r
965                         return X_Class_getPrivate( this ).boxX;\r
966                 },\r
967                 getY : function(){\r
968                         // dirty の場合、rootData.calculate\r
969                         return X_Class_getPrivate( this ).boxY;\r
970                 },\r
971                 getAbsoluteX : function(){\r
972                         // dirty の場合、rootData.calculate\r
973                         return X_Class_getPrivate( this ).absoluteX;\r
974                 },\r
975                 getAbsoluteY: function(){\r
976                         // dirty の場合、rootData.calculate\r
977                         return X_Class_getPrivate( this ).absoluteY;\r
978                 },\r
979                 getWidth : function(){\r
980                         // dirty の場合、rootData.calculate\r
981                         return X_Class_getPrivate( this ).boxWidth;\r
982                 },\r
983                 getHeight : function(){\r
984                         // dirty の場合、rootData.calculate\r
985                         return X_Class_getPrivate( this ).boxHeight;\r
986                 }\r
987         }\r
988 );\r
989 \r