OSDN Git Service

Version 0.6.122, add xnode._flags & fix X.Util.NinjaIframe.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 06_AbstractUINode.js
1 X.UI._AbstractUINode = X.EventDispatcher.inherits(\r
2         'X.UI._AbstractUINode',\r
3         X.Class.ABSTRACT | X.Class.PRIVATE_DATA,\r
4         {\r
5                 phase             : 0,\r
6                 dirty             : X.UI.Dirty.CLEAN,\r
7                 \r
8                 root              : null,\r
9                 rootData          : null,\r
10                 hoverList         : null,\r
11                 parent            : null,\r
12                 parentData        : null,\r
13                 xnode             : null,\r
14 \r
15                 supportAttrs      : X.UI.Attr.Support,\r
16                 attrClass         : X.UI.AttrClass,\r
17                 attrObject        : null,\r
18                 unverifiedAttrs   : null,\r
19                 \r
20                 role              : 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                         this.root       = root;\r
66                         this.rootData   = rootData;\r
67                         this.parent     = parent;\r
68                         this.parentData = parentData;\r
69                         //this.xnode      = X_Doc_create( 'div' );\r
70                         this.phase      = 1;\r
71                         \r
72                         this.dispatch( X.UI.Event.INIT );\r
73                 },\r
74                 \r
75                 addToParent : function( xnodeParent ){\r
76                         xnodeParent && xnodeParent.append( this.xnode );\r
77                         \r
78                         this.phase = 2;\r
79                         this.dispatch( X.UI.Event.ADDED );\r
80                 },\r
81                 \r
82                 creationComplete : function(){\r
83                         var events = this.reserveEvents,\r
84                                 l, i;\r
85                         \r
86                         this.phase = 3;\r
87                         this.User.dispatch( X.UI.Event.CREATION_COMPLETE );\r
88                         \r
89                         // html 要素が親に追加されるまで控えていたイベントの登録\r
90                         if( events && ( l = events.length ) ){\r
91                                 for( i = 0; i < l; ++i ){\r
92                                         this.listen.apply( this, events[ i ] );\r
93                                 };\r
94                                 events.length = 0;\r
95                                 delete this.reserveEvents;\r
96                         };                      \r
97                 },\r
98                 \r
99                 /*\r
100                  * _UINode への setAttr の他、attrClass.prototype への setAttr にも対応する\r
101                  * 親要素が変化した場合、unverifiedAttrs を元に attrObject を再設定.\r
102                  */\r
103                 setAttr : function( name, def, v ){\r
104                         var attrs      = X.UI.attrClassProto || this.attrObject,\r
105                                 propID     = def.No || def[ 5 ],\r
106                                 defaultVal = X.UI.attrClassProto ? attrs[ propID ] : this.attrClass.prototype[ propID ], // def[ 0 ],\r
107                                 currentVal = attrs ? attrs[ propID ] : defaultVal,\r
108                                 dirty      = def[ 1 ],\r
109                                 user       = def[ 2 ],\r
110                                 type       = def[ 3 ],\r
111                                 list       = def[ 4 ],\r
112                                 length     = !!( type & X.UI.Attr.Type.LENGTH        ),\r
113                                 minusLen   = !!( type & X.UI.Attr.Type.MINUS_LENGTH  ),\r
114                                 percent    = !!( type & X.UI.Attr.Type.PERCENT       ),\r
115                                 minusPct   = !!( type & X.UI.Attr.Type.MINUS_PERCENT ),\r
116                                 numerical  = !!( type & X.UI.Attr.Type.NUMERICAL     ),\r
117                                 auto       = !!( type & X.UI.Attr.Type.AUTO          ),\r
118                                 color      = !!( type & X.UI.Attr.Type.COLOR         ),\r
119                                 url        = !!( type & X.UI.Attr.Type.URL           ),\r
120                                 fontName   = !!( type & X.UI.Attr.Type.FONT_NAME     ),\r
121                                 flag       = !!( type & X.UI.Attr.Type.BOOLEAN       ),\r
122                                 combi      = !!( type & X.UI.Attr.Type.COMBI         ),\r
123                                 quartet    = !!( type & X.UI.Attr.Type.QUARTET       ),\r
124                                 _v, i, l, nodes, root, roots;\r
125                 \r
126                         if( X.Type.isString( v ) ){\r
127                                 //v = v.toLowercase();\r
128                                 if( url || fontName ){\r
129                                         // good\r
130                                 } else\r
131                                 if( auto && v === 'auto' ){\r
132                                         v = X.UI.Attr.AUTO;\r
133                                 } else\r
134                                 if( list && ( _v = list[ v ] ) ){\r
135                                         // good\r
136                                         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_Node_CSS_objToIEFilterText( 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_Node_BoxModel の情報を引きながら top,left,width,height,padding,border の設定\r
416                  */\r
417                 updateLayout : function( x, y ){\r
418                         this.boxX = x;\r
419                         this.boxY = y;\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  ? X.UI._AbstractUINode.ceil( this.contentWidth  )  + 'em' : 0 )\r
424                                 .css( 'height',      this.contentHeight ? X.UI._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  = X.UI._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 = X.UI._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 = X.UI._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() / X_Node_CSS_getCharSize( xnode );\r
605                                                         \r
606                                                         this.scrollWidth = w + this.contentL + this.contentR;\r
607                                                         if( this.maxContentWidth < w - this.boxSizingOffsetLR ) this.contentWidth = this.maxContentWidth + this.boxSizingOffsetLR;\r
608                                                         if( w - this.boxSizingOffsetLR < this.minContentWidth ) this.contentWidth = this.minContentWidth + this.boxSizingOffsetLR;\r
609                                                         this.lastContentWidth = this.contentWidth;\r
610                                                         \r
611                                                         w !== this.contentWidth && xnode.css( 'width', X.UI._AbstractUINode.ceil( this.contentWidth ) + 'em' );\r
612                                                         \r
613                                                         if( h === X.UI.Attr.AUTO ){\r
614                                                                 this.contentHeight = h = xnode.css( 'height', 'auto' ).scrollHeight() / X_Node_CSS_getCharSize( xnode ); // scrollHeight() ??\r
615                                                                 this.scrollHeight  = h + this.contentT + this.contentB;\r
616                                                                 if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
617                                                                 if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB;\r
618                                                         } else {\r
619                                                                 this.scrollHeight = h + this.contentT + this.contentB;\r
620                                                         };\r
621                                                         \r
622                                                         this.lastContentHeight = h;\r
623                                                 } else\r
624                                                 if( h === X.UI.Attr.AUTO ){\r
625                                                         if( w !== this.lastContentWidth ){\r
626                                                                 xnode.css( 'width', X.UI._AbstractUINode.ceil( w ) + 'em' );\r
627                                                                 \r
628                                                                 this.lastContentWidth  = w;\r
629                                                                 this.contentHeight = h = xnode.css( 'height', 'auto' ).scrollHeight() / X_Node_CSS_getCharSize( xnode );\r
630                                                                 this.scrollWidth       = w + this.contentL + this.contentR;\r
631                                                                 this.scrollHeight      = h + this.contentT + this.contentB;\r
632                                                                 if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
633                                                                 if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB;                                                           \r
634                                                         } else {\r
635                                                                 this.contentHeight = this.lastContentHeight = h =\r
636                                                                         this.lastContentHeight === -1 ? xnode.css( 'height', 'auto' ).scrollHeight() / X_Node_CSS_getCharSize( xnode ) : this.lastContentHeight;\r
637                                                                 this.scrollWidth   = w + this.contentL + this.contentR;\r
638                                                                 this.scrollHeight  = h + this.contentT + this.contentB;\r
639                                                         };\r
640                                                 } else\r
641                                                 if( dirty !== X.UI.Dirty.LAYOUT ){\r
642                                                         this.contentWidth  = this.lastContentWidth  = w; //xnode.width();\r
643                                                         this.contentHeight = this.lastContentHeight = xnode.css( 'height', 'auto' ).scrollHeight() / X_Node_CSS_getCharSize( xnode );\r
644                                                         this.scrollWidth   = this.contentWidth  + this.contentL + this.contentR;\r
645                                                         this.scrollHeight  = this.contentHeight + this.contentT + this.contentB;\r
646                                                 } else {\r
647                                                         this.scrollWidth  = w + this.contentL + this.contentR;\r
648                                                         this.scrollHeight = h + this.contentT + this.contentB;\r
649                                                 };              \r
650                                         } else {\r
651                                                 // コンテンツを持たないため基本のサイズは0\r
652                                                 if( w === X.UI.Attr.AUTO ) this.contentWidth  = w = 0 < this.minContentWidth  ? this.minContentWidth  : 0;\r
653                                                 if( h === X.UI.Attr.AUTO ) this.contentHeight = h = 0 < this.minContentHeight ? this.minContentHeight : 0;\r
654                                                 this.scrollWidth  = w + this.contentL + this.contentR;\r
655                                                 this.scrollHeight = h + this.contentT + this.contentB;\r
656                                         };\r
657                                         \r
658                                         delete this.dirty;\r
659                                         break;                  \r
660                                 //case X.UI.Dirty.PAINT : // 再描画のみ必要\r
661                                 //      break;\r
662                         };\r
663                 },\r
664                 /**\r
665                  * 自身の contentWidth, contentHeight を元に AUTO な width, height を確定していく\r
666                  */\r
667                 postMesure : function(){\r
668                         var     attrs = this.attrObject || this.attrClass.prototype || X.UI.AttrClass,\r
669                                 calc  = X.UI._AbstractUINode.calcValue,\r
670                                 box   = attrs[ X.UI.Attr.Support.sizing.No ],\r
671                                 contentW, contentH,\r
672                                 contentPlus,\r
673                                 paddingT, paddingR, paddingB, paddingL,\r
674                                 borderT, borderR, borderB, borderL,\r
675                                 min, max;\r
676                                 \r
677                         // Width\r
678                         if( this.boxWidth === X.UI.Attr.AUTO ){\r
679                                 contentW = this.contentWidth;\r
680                                 paddingR = calc( attrs[ X.UI.Attr.Support.padding.No + 1 ], contentW );                                 \r
681                                 paddingL = calc( attrs[ X.UI.Attr.Support.padding.No + 3 ], contentW );                                 \r
682                                 borderR  = calc( attrs[ X.UI.Attr.Support.borderWidth.No + 1 ], contentW );\r
683                                 borderL  = calc( attrs[ X.UI.Attr.Support.borderWidth.No + 3 ], contentW );\r
684                                 contentPlus = 0;\r
685                                 switch( box ){\r
686                                         case 3 : // border-box\r
687                                                  contentPlus  = borderR + borderL;\r
688                                         case 2 : // padding-box\r
689                                                  contentPlus += paddingR + paddingL;\r
690                                         // case 1 : // content-box\r
691                                 };\r
692                                 \r
693                                 if( !this.constraintW ){\r
694                                         contentW += contentPlus;\r
695                                         min = calc( attrs[ X.UI.Attr.Support.minWidth.No ], contentW );\r
696                                         max = calc( attrs[ X.UI.Attr.Support.maxWidth.No ], contentW );\r
697                                         if( contentW < min && contentPlus < min ){\r
698                                                 this.contentWidth = min - contentPlus;\r
699                                         } else\r
700                                         if( max < contentW && contentPlus < max ){\r
701                                                 this.contentWidth = max - contentPlus;\r
702                                         };\r
703                                 };\r
704                                 this.contentL = borderL + paddingL;\r
705                                 this.contentR = borderR + paddingR;\r
706                                 this.boxWidth = this.contentWidth + this.contentL + this.contentR;\r
707                         };\r
708                         // Height\r
709                         if( this.boxHeight === X.UI.Attr.AUTO ){\r
710                                 contentH    = this.contentHeight;\r
711                                 paddingT    = calc( attrs[ X.UI.Attr.Support.padding.No + 0 ], contentH );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
712                                 paddingB    = calc( attrs[ X.UI.Attr.Support.padding.No + 2 ], contentH );\r
713                                 borderT     = calc( attrs[ X.UI.Attr.Support.borderWidth.No  + 0 ], contentH );\r
714                                 borderB     = calc( attrs[ X.UI.Attr.Support.borderWidth.No  + 2 ], contentH );\r
715                                 contentPlus = 0;\r
716                                 switch( box ){\r
717                                         case 3 : // border-box\r
718                                                  contentPlus  = borderT + borderB;\r
719                                         case 2 : // padding-box\r
720                                                  contentPlus += paddingT + paddingB;\r
721                                         // case 1 : // content-box\r
722                                 };\r
723                                 if( !this.constraintH ){\r
724                                         contentH += contentPlus;\r
725                                         min = calc( attrs[ X.UI.Attr.Support.minHeight.No ], contentH );\r
726                                         max = calc( attrs[ X.UI.Attr.Support.maxHeight.No ], contentH );\r
727                                         if( contentH < min && contentPlus < min ){\r
728                                                 this.contentHeight = min - contentPlus;\r
729                                         } else\r
730                                         if( max < contentH && contentPlus < max ){\r
731                                                 this.contentHeight = max - contentPlus;\r
732                                         };\r
733                                 };\r
734                                 this.contentT  = borderT + paddingT;\r
735                                 this.contentB  = borderB + paddingB;\r
736                                 this.boxHeight = this.contentHeight + this.contentT + this.contentB;\r
737                         };\r
738                 },\r
739 \r
740                 capcher : function( x, y ){\r
741                         if( this.pointerDisabled ) return false;\r
742                         \r
743                         x -= this.boxX;\r
744                         y -= this.boxY;\r
745 \r
746                         if( 0 <= x && x < this.boxWidth && 0 <= y && y < this.boxHeight ){\r
747                                 !this.hovering && ( this.rootData.hoverList[ this.rootData.hoverList.length ] = this );\r
748                                 this.rootData.targetNodeData = this;\r
749                                 return true;\r
750                         };\r
751                 },\r
752                 \r
753                 \r
754                 listen : function( type, arg1, arg2, arg3 ){\r
755                         var root, events, counter, f;\r
756                         if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){\r
757                                 if( this.phase < 3 ){\r
758                                         if( !( events = this.reserveEvents ) ) this.reserveEvents = events = [];\r
759                                         events[ events.length ] = [ type, arg1, arg2, arg3 ];\r
760                                         return this;\r
761                                 };\r
762                                 if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){\r
763                                         if( !this.gesture ){\r
764                                                 this.gesture = new X.UI.Gesture( this.rootData, this, type );\r
765                                         } else {\r
766                                                 this.gesture.listen( type );\r
767                                         };\r
768                                 } else {\r
769                                         //console.log( type );\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 ], X.UI._eventRellay );\r
777                                         };\r
778                                 };\r
779                         };\r
780                         f = X_Callback_classifyCallbackArgs( arg1, arg2, arg3 );\r
781                         if( !f.k ){\r
782                                 return X_EventDispatcher_listen.call( this, type, this.User, f );\r
783                         } else\r
784                         if( f.k === X_Callback_FUNC_ONLY ){\r
785                                 return X_EventDispatcher_listen.call( this, type, this.User, f.f, f.s );\r
786                         };\r
787                         return X_EventDispatcher_listen.apply( this, arguments );\r
788                 },\r
789                 unlisten : function( type, arg1, arg2, arg3 ){\r
790                         var root, events, i, ev, counter, f;\r
791                         if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){\r
792                                 if( this.phase < 3 ){\r
793                                         if( !( events = this.reserveEvents ) ) return this;\r
794                                         for( i = events.length; i; ){\r
795                                                 ev = events[ --i ];\r
796                                                 if( ev[ 0 ] === type && ev[ 1 ] === arg1 && ev[ 2 ] === arg2 ){\r
797                                                         events.split( i, 1 );\r
798                                                         return this;\r
799                                                 };\r
800                                         }; \r
801                                         return this;\r
802                                 };\r
803 \r
804                                 if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){\r
805                                         this.gesture && this.gesture.unlisten( type );\r
806                                 } else {\r
807                                         root    = this.rootData;\r
808                                         counter = root.eventCounter;\r
809                                         if( !counter[ type ] ) return this;\r
810                                         --counter[ type ];\r
811                                         if( counter[ type ] === 0 ){\r
812                                                 root.xnodeInteractiveLayer.unlisten( X.UI.Event.IdToName[ type ], X.UI._eventRellay );\r
813                                                 delete counter[ type ];\r
814                                         };\r
815                                 };\r
816                         };\r
817                         f = X_Callback_classifyCallbackArgs( arg1, arg2, arg3 );\r
818                         if( !f.k ){\r
819                                 return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, f ] );\r
820                         } else\r
821                         if( f.k === X_Callback_FUNC_ONLY ){\r
822                                 return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, f.f, f.s ] );\r
823                         };\r
824                         return X.EventDispatcher.prototype.unlisten.apply( this, arguments );\r
825                 },\r
826                 \r
827                 dispatch : function( e ){\r
828                         //console.log( e.type + ' ' + ( this._listeners && this._listeners[ e.type ] ) );\r
829                         var xve  = X.UI.Event,\r
830                                 ret  = X_EventDispatcher_dispatch.call( this, e ),\r
831                                 type = e.type || e;\r
832                         \r
833                         // TODO captureEvent PointerEvent\r
834                         if( ret & X.Callback.MONOPOLY && !this.hitChildData && ( xve._POINTER_MOVE === type || xve._MOUSE_MOVE === type || xve.FILE_DRAG === type ) ){\r
835                                 this.rootData.monopolyNodeData = this;\r
836                                 return ret;\r
837                         };\r
838                         this.rootData.monopolyNodeData = null;\r
839                         if( xve._START_BUBLEUP < type && this.parentData && !( ret & X.Callback.STOP_PROPAGATION ) && !( ret & X.Callback.STOP_NOW ) ) return this.parentData.dispatch( e );\r
840                         return ret;\r
841                 }\r
842                 \r
843         }\r
844 );\r
845 \r
846 X.UI._AbstractUINode.calcValue = function( styleValue, srcValue ){\r
847         /*\r
848          * String の場合は必ず %\r
849          */     \r
850         if( X.Type.isString( styleValue ) ){\r
851                 return srcValue * parseFloat( styleValue ) / 100;\r
852         };\r
853         if( !X.Type.isNumber( styleValue ) ) return 0;\r
854         return styleValue;\r
855 };\r
856 \r
857 X.UI._AbstractUINode.finalValue = function( styleValue, styleMin, styleMax, srcValue ){\r
858         var calc = X.UI._AbstractUINode.calcValue,\r
859                 v    = calc( styleValue, srcValue ),\r
860                 min  = calc( styleMin, srcValue ),\r
861                 max  = calc( styleMax, srcValue );\r
862         return v <= min ? min : max <= v ? max : v;\r
863 };\r
864 X.UI._AbstractUINode.ceil = function( v ){\r
865         if( 0 <= v ){\r
866                 return ( v * 10 + 0.999 | 0 ) / 10;\r
867         };\r
868         return ( -v * 10 + 0.999 | 0 ) / -10;\r
869 };\r
870 \r
871 X.UI.AbstractUINode = X.Class.create(\r
872         'AbstractUINode',\r
873         X.Class.ABSTRACT | X.Class.SUPER_ACCESS,\r
874         {\r
875                 parent : function(){\r
876                         return X_Class_getPrivate( this ).parent;\r
877                 },\r
878                 root : function(){\r
879                         return X_Class_getPrivate( this ).root;\r
880                 },\r
881                 \r
882                 /*\r
883                  * unverifiedAttrs に全ての指定を控える\r
884                  * サポートされていない場合は無視される.親のレイアウトによって変わる\r
885                  */\r
886                 attr : function( nameOrObject, valueOrUnit ){\r
887                         var p = X_Class_getPrivate( this ),\r
888                                 layout, k, def, attrs, v;\r
889                         if( nameOrObject && X.Type.isObject( nameOrObject ) ){\r
890                                 // setter\r
891                                 layout = p.parentData && p.parentData.layout.overrideAttrsForChild; // root には parent がない\r
892                                 for( k in nameOrObject ){\r
893                                         if( X_EMPTY_OBJECT[ k ] ) continue;\r
894                                         // 親のレイアウトマネージャの許可しない\r
895                                         if( layout && !layout[ k ] ){\r
896                                                 continue;\r
897                                         };\r
898                                         if( def = p.supportAttrs[ k ] ){\r
899                                                 p.setAttr( k, def, nameOrObject[ k ] );\r
900                                         };\r
901                                 };\r
902                         } else\r
903                         if( X.Type.isString( nameOrObject ) ){\r
904                                 if( valueOrUnit !== undefined ){\r
905                                         if( 'em,%'.indexOf( valueOrUnit ) === -1 ){\r
906                                                 // setter\r
907                                                 p.setAttr( nameOrObject, valueOrUnit );\r
908                                         } else {\r
909                                                 // getter with unit\r
910                                                 return p.getAttrWithUnit( nameOrObject, valueOrUnit );\r
911                                         };\r
912                                 };\r
913                                 // getter\r
914                                 if( attrs = ( p.attrObject || p.attrClass.prototype || X.UI.AttrClass ) ){\r
915                                         def = p.supportAttrs[ nameOrObject ];\r
916                                         return def && attrs[ def.No ];\r
917                                 };\r
918                                 return v;\r
919                         };\r
920                         return this;\r
921                 },\r
922                 \r
923                 listen : function( type, arg1, arg2, arg3 ){\r
924                         X_Class_getPrivate( this ).listen( type, arg1, arg2, arg3 );\r
925                         return this;\r
926                 },\r
927                 listenOnce : function( type, arg1, arg2, arg3 ){\r
928                         X_Class_getPrivate( this ).listenOnce( type, arg1, arg2, arg3 );\r
929                         return this;\r
930                 },\r
931                 listening : function( type, arg1, arg2, arg3 ){\r
932                         return X_Class_getPrivate( this ).listening( type, arg1, arg2, arg3 );\r
933                 },\r
934                 unlisten : function( type, arg1, arg2, arg3 ){\r
935                         X_Class_getPrivate( this ).unlisten( type, arg1, arg2, arg3 );\r
936                         return this;\r
937                 },\r
938                 dispatch : function( e ){\r
939                         return X_Class_getPrivate( this ).dispatch( e );\r
940                 },\r
941                         \r
942                 getNextNode : function(){\r
943                         \r
944                 },\r
945                 getPrevNode : function(){\r
946                         \r
947                 },\r
948                 nodeIndex : function( v ){\r
949                         var data = X_Class_getPrivate( this );\r
950                         if( typeof v === 'number' ){\r
951                                 // data.nodeIndex( v );\r
952                                 return this;\r
953                         };\r
954                         return data.parentData ? data.parentData.nodes.indexOf( data ) : 0;\r
955                 },\r
956                 displayIndex : function(){\r
957                         \r
958                 },\r
959                 getX : function(){\r
960                         // dirty の場合、rootData.calculate\r
961                         return X_Class_getPrivate( this ).boxX;\r
962                 },\r
963                 getY : function(){\r
964                         // dirty の場合、rootData.calculate\r
965                         return X_Class_getPrivate( this ).boxY;\r
966                 },\r
967                 getAbsoluteX : function(){\r
968                         // dirty の場合、rootData.calculate\r
969                         return X_Class_getPrivate( this ).absoluteX;\r
970                 },\r
971                 getAbsoluteY: function(){\r
972                         // dirty の場合、rootData.calculate\r
973                         return X_Class_getPrivate( this ).absoluteY;\r
974                 },\r
975                 getWidth : function(){\r
976                         // dirty の場合、rootData.calculate\r
977                         return X_Class_getPrivate( this ).boxWidth;\r
978                 },\r
979                 getHeight : function(){\r
980                         // dirty の場合、rootData.calculate\r
981                         return X_Class_getPrivate( this ).boxHeight;\r
982                 },\r
983                 scrollTo : function( x, y ){\r
984                         X_Class_getPrivate( this ).scrollTo( x, y );\r
985                 },\r
986                 getScrollX : function( v ){\r
987                         // dirty の場合、rootData.calculate\r
988                         return X_Class_getPrivate( this ).scrollX( v );\r
989                 },\r
990                 getScrollY : function( v ){\r
991                         // dirty の場合、rootData.calculate\r
992                         return X_Class_getPrivate( this ).scrollY( v );\r
993                 },\r
994                 disabled : function( v ){\r
995                         return X_Class_getPrivate( this ).disabled( v );\r
996                 },\r
997                 cursor : function( v ){\r
998                         return X_Class_getPrivate( this ).cursor( v );\r
999                 }\r
1000         }\r
1001 );\r
1002 \r