OSDN Git Service

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