OSDN Git Service

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