Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 284713 | Differences between
and this patch

Collapse All | Expand All

(-)js/org/eclipse/rwt/HtmlUtil.js (+171 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
12
/* ************************************************************************
13
14
#require(qx.util.StringBuilder)
15
16
************************************************************************ */
17
18
qx.Class.define( "org.eclipse.rwt.HtmlUtil", {
19
20
  statics : {
21
    __helperDiv : null,
22
    __attributeHelper : new qx.util.StringBuilder(), 
23
    __innerHtmlHelper : new qx.util.StringBuilder(), 
24
    __styleRegExp : /([a-z])([A-Z])/g,
25
    
26
    getHelperDiv : function() {
27
      if( !this.__helperDiv ) {
28
        this.__helperDiv = document.createElement( "div" );
29
      }
30
      return this.__helperDiv;
31
    },
32
    
33
    createHtmlData : function( tag ) {
34
      var data = {
35
        startTagOpen : "<" + tag + " ",
36
        styleOpen : "style='",
37
        styleInner : [ {} ],
38
        styleClose : "' ",
39
        attributes : [ {} ],
40
        startTagClose : " >",
41
        innerHtml : [],
42
        endTag : "</" + tag + ">"
43
      }
44
      return data;
45
    },
46
    
47
    // maps should not contain attributes that are also other maps, or
48
    // they will be in the string twice! No checks there!
49
    // Multiple maps are only supported to avoid the copy-process
50
    // while also not touching the map. (Same for style-properties!)  
51
    addHtmlAttributes : function( htmlData, map ) {
52
      htmlData.attributes.push( map );
53
    },
54
    
55
    addStyleProperties : function( htmlData, map ) {
56
      htmlData.styleInner.push( map );
57
    },
58
    
59
    setHtmlAttribute : function( htmlData, attribute, value ) {
60
      htmlData.attributes[ 0 ][ attribute ] = value;
61
    },
62
63
    setStyleProperty : function( htmlData, attribute, value ) {
64
      htmlData.styleInner[ 0 ][ attribute ] = value;
65
    },
66
67
    addInnerHtml : function( htmlData, htmlDataInner ) {
68
      htmlData.innerHtml.push( htmlDataInner );
69
    },
70
71
    _joinHtmlAttributes : function( maps ) {
72
      var str = this.__attributeHelper;
73
      str.clear();
74
      var l = maps.length;
75
      var map = null;
76
      for( var i = 0; i < l; i++ ) {
77
        var map = maps[ i ];
78
        for( var attribute in map ) {
79
          str.add( attribute, '="', map[ attribute ], '" ');
80
        }
81
      }
82
      return str.get();
83
    },
84
85
    _joinStyleProperties : function( maps ) {
86
      // targetNode support with filter!
87
      var str = this.__attributeHelper;
88
      str.clear();
89
      var l = maps.length;
90
      var map = null;
91
      var value = null;
92
      for( var i = 0; i < l; i++ ) {
93
        var map = maps[ i ];
94
        for( var attribute in map ) {
95
          var value = map[ attribute ];
96
          if( value ) {
97
            str.add( attribute, ':', map[ attribute ], ';');
98
          }
99
        }
100
      }
101
      return str.get().replace( this.__styleRegExp, "$1-$2" ).toLowerCase();
102
    },
103
    
104
    _joinHtmlData : function( htmlData ) {
105
      this.__innerHtmlHelper.add( this.getStartTag( htmlData ) );
106
      this._joinInnerHtmlData( htmlData );
107
      this.__innerHtmlHelper.add( this.getEndTag( htmlData ) );
108
    },
109
    
110
    _joinInnerHtmlData : function( htmlData ) {
111
      var inner = htmlData.innerHtml;      
112
      var l = inner.length;
113
      var data = null;
114
      for( var i = 0; i < l; i++ ) {
115
        data = inner[ i ];        
116
        if( data instanceof Object ) {
117
          this._joinHtmlData( data );
118
        } else {
119
          this.__innerHtmlHelper.add( data );
120
        }
121
      }
122
    },
123
    
124
    getHtml : function( htmlData ) {
125
      var str = this.__innerHtmlHelper;
126
      str.clear();
127
      this._joinHtmlData( htmlData );
128
      return str.get(); 
129
    },
130
    
131
    getInnerHtml : function( htmlData ) {
132
      this.__innerHtmlHelper.clear();
133
      this._joinInnerHtmlData( htmlData );
134
      return this.__innerHtmlHelper.get();       
135
    },    
136
    
137
    getStartTag : function( htmlData ) {
138
      return   htmlData.startTagOpen 
139
             + htmlData.styleOpen
140
             + this._joinStyleProperties( htmlData.styleInner )
141
             + htmlData.styleClose
142
             + this._joinHtmlAttributes( htmlData.attributes )
143
             + htmlData.startTagClose;
144
    },
145
    
146
147
    getEndTag : function( htmlData ) {
148
      return  htmlData.endTag;
149
    },
150
    
151
    createDOM : qx.core.Variant.select("qx.client", {
152
      "mshtml" : function( htmlData ) {
153
        var outer = this.getStartTag( htmlData ) + this.getEndTag( htmlData );
154
        var inner = this.getInnerHtml( htmlData );
155
        var node = document.createElement( outer );
156
        if( inner != "" ) {
157
          node.innerHTML = inner;
158
        }
159
        return node;
160
      },
161
      "default" : function( htmlData ) {
162
        var html = this.getHtml( htmlData );        
163
        var helper = this.getHelperDiv();        
164
        helper.innerHTML = html;
165
        var node = helper.firstChild;
166
        helper.innerHTML = "";
167
        return node;
168
      }
169
    })
170
  }
171
} );
(-)js/org/eclipse/rwt/widgets/MultiCellWidget.js (+667 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
11
 
12
qx.Class.define("org.eclipse.rwt.widgets.MultiCellWidget",  {
13
  extend : qx.ui.basic.Terminator,
14
15
  
16
  /**
17
   * Examples for "cells"
18
   * [ "image" ]
19
   * [ "label" ]
20
   * [ "image", "label" ]
21
   * [ "image, "image", "label", "image" ]
22
   */  
23
  construct : function( cells ) {
24
    this.base( arguments );
25
    this.__createCellData( cells ); 
26
    this.__paddingCache = [ 0, 0, 0, 0 ];
27
    this.__fontCache = {};    
28
    this.initWidth();
29
    this.initHeight();    
30
    this.addToQueue( "createContent" );
31
    this.setOverflow( "hidden" );
32
  },
33
34
  /*
35
  *****************************************************************************
36
     PROPERTIES
37
  *****************************************************************************
38
  */
39
40
  properties : {
41
    
42
    spacing : {
43
      check : "Integer",
44
      init : 4,
45
      themeable : true,
46
      apply : "_applySpacing",
47
      event : "changeSpacing"
48
    },
49
50
    horizontalChildrenAlign : {
51
      check : [ "left", "center", "right" ],
52
      init : "center",
53
      themeable : true,
54
      apply : "_applyHorizontalChildrenAlign"
55
    },
56
57
    verticalChildrenAlign : {
58
      check : [ "top", "middle", "bottom" ],
59
      init : "middle",
60
      themeable : true,
61
      apply : "_applyVerticalChildrenAlign"
62
    },
63
      
64
    selectable : {
65
      refine : true,
66
      init : false
67
    },
68
69
    allowStretchX : {
70
      refine : true,
71
      init : false
72
    },
73
74
    allowStretchY : {
75
      refine : true,
76
      init : false
77
    },
78
79
    appearance : {
80
      refine : true,
81
      init : "atom"
82
    },
83
84
    width : {
85
      refine : true,
86
      init : "auto"
87
    },
88
89
    height : {
90
      refine : true,
91
      init : "auto"
92
    }
93
94
  },
95
  
96
  members : {
97
    __cellData : null,
98
    __cellNodes : null,
99
    __cellCount : null,
100
    __computedTotalSpacing : null,
101
    __paddingCache : null,
102
    __fontCache : null,
103
    _htmlUtil : org.eclipse.rwt.HtmlUtil,
104
105
    _applyEnabled : function( value, old ) {
106
      this.base( arguments, value, old );
107
      this._styleAllImagesEnabled();
108
      this._styleAllLabelsEnabled();
109
    },
110
    
111
    /*
112
    ---------------------------------------------------------------------------
113
      DOM/HTML
114
    ---------------------------------------------------------------------------
115
    */  
116
117
    
118
    _applyElement : function( value, old ) {
119
      this.base( arguments, value, old );
120
      if( value ) {     
121
        this._createSubelements(); 
122
        this._catchSubelements();
123
      }
124
    },
125
    
126
    _createSubelements : function() {
127
      var html = "";
128
      for( var i = 0; i < this.__cellCount; i++ ) {
129
        this.setCellNode( i, null );        
130
        if( this.cellHasContent( i ) ) {
131
          if( this.cellIsLabel( i ) ) {
132
            html += this._getLabelHtml( i );            
133
          } else if( this.cellIsImage( i ) ) {
134
            html += this._getImageHtml( i );            
135
          }
136
        }
137
      }
138
      this._getTargetNode().innerHTML = html;
139
    },
140
    
141
    _catchSubelements : function() {
142
      var el = this._getTargetNode();
143
      var childNumber = 0;
144
      for( var i = 0; i < this.__cellCount; i++ ) {
145
        if( this.cellHasContent( i ) ) {
146
          this.setCellNode( i, el.childNodes[ childNumber ] );              
147
          childNumber++;
148
        }        
149
      }             
150
      if( this.getEnabled() == false ) {
151
        this._applyEnabled( false );
152
      }
153
    },
154
    
155
    /*
156
    ---------------------------------------------------------------------------
157
      LAYOUT : _apply methods
158
    ---------------------------------------------------------------------------
159
    */
160
161
    _applySpacing : function( value, old ) {
162
      this._invalidateTotalSpacing();
163
      this.addToQueue( "layoutX" );
164
    },
165
    
166
    _applyHorizontalChildrenAlign : function( value, old ) {
167
      this.addToQueue( "layoutX" );
168
    },
169
    
170
    _applyVerticalChildrenAlign : function( value, old ) {
171
      this.addToLayoutChanges( "layoutY" );
172
    },    
173
174
    _applyPaddingTop : function(value, old) {
175
      this.addToLayoutChanges("paddingTop");
176
      this.__paddingCache[ 0 ] = value;
177
      this._invalidateFrameHeight();
178
    },
179
180
    _applyPaddingRight : function(value, old) {
181
      this.addToLayoutChanges("paddingRight");
182
      this.__paddingCache[ 1 ] = value;
183
      this._invalidateFrameWidth();
184
    },
185
186
    _applyPaddingBottom : function(value, old) {
187
      this.addToLayoutChanges("paddingBottom");
188
      this.__paddingCache[ 2 ] = value;
189
      this._invalidateFrameHeight();
190
    },
191
192
    _applyPaddingLeft : function(value, old) {
193
      this.addToLayoutChanges("paddingLeft");
194
      this.__paddingCache[ 3 ] = value;
195
      this._invalidateFrameWidth();
196
    },
197
    
198
    /*
199
    ---------------------------------------------------------------------------
200
      LAYOUT : public api
201
    ---------------------------------------------------------------------------
202
    */
203
    
204
    // This is either the URL (image) or the text (label)
205
    setCellContent : function( cell, value ) { 
206
      this.__updateComputedCellDimension( cell );
207
      if( this.cellHasContent( cell ) != ( value != null ) ) {
208
        this._invalidateTotalSpacing();
209
        this.addToQueue( "createContent" );
210
      } else {
211
        this.addToQueue( "updateContent" );
212
      }
213
      this.__cellData[ cell ][ 1 ] = value;
214
    },
215
     
216
    // The dimensions for the cell. Is mandatory for images (or 0x0 will
217
    // be assumed), optional for labels. Set a dimension to "null" to use the 
218
    // computed value.
219
    setCellDimension : function( cell, width, height ) {
220
      this.setCellWidth( cell, width );
221
      this.setCellHeight( cell, height );
222
    },
223
    
224
    setCellWidth : function( cell, width ) {
225
      this.__cellData[ cell ][ 2 ] = width;
226
      if( this.cellHasContent( cell ) ) {
227
        this._invalidatePreferredInnerWidth(); 
228
        this.addToQueue( "layoutX" );
229
      }      
230
    },
231
    
232
    setCellHeight : function( cell, height ) {
233
      this.__cellData[ cell ][ 3 ] = height;
234
      if( this.cellHasContent( cell ) ) {
235
        this._invalidatePreferredInnerHeigh();  
236
        this.addToQueue( "layoutY" );
237
      }            
238
    },
239
    
240
    getCellDimension : function( cell ) { 
241
      var width = this.getCellWidth( cell );
242
      var height = this.getCellHeight( cell );
243
      return [ width, height ];
244
    },
245
    
246
    getCellWidth : function( cell ) {
247
      var cellEntry = this.__cellData[ cell ]; 
248
      var width = ( cellEntry[ 2 ] != null ? cellEntry[ 2 ] : cellEntry[ 4 ] );
249
      if( width == null ) {
250
        var computed = this.__computeCellDimension( cellEntry );
251
        width = ( width != null ? width : computed[ 0 ] );
252
      }
253
      return width;      
254
    },
255
    
256
    getCellHeight : function( cell ) {
257
      var cellEntry = this.__cellData[ cell ]; 
258
      var height = ( cellEntry[ 3 ] != null ? cellEntry[ 3 ] : cellEntry[ 5 ] );
259
      if( height == null ) {
260
        var computed = this.__computeCellDimension( cellEntry );
261
        height = ( height != null ? height : computed[ 1 ] );
262
      }
263
      return height;      
264
    },
265
    
266
    setCellNode : function( cell, node ) {
267
      this.__cellNodes[ cell ] = node;
268
    },
269
    
270
    getCellNode : function( cell ) {
271
      return this.__cellNodes[ cell ];
272
    },
273
    
274
    cellHasNode : function( cell ) {
275
      return ( this.__cellNodes[ cell ] != null );
276
    },
277
278
    cellHasContent : function( cell ) {
279
      return ( this.__cellData[ cell ][ 1 ] != null );
280
    },
281
    
282
    getCellContent : function( cell ) {
283
      return this.__cellData[ cell ][ 1 ];
284
    },
285
    
286
    cellIsImage : function( cell ) {
287
      return ( this.__cellData[ cell ][ 0 ] == "image" );
288
    },
289
    
290
    cellIsLabel : function( cell ) {
291
      return ( this.__cellData[ cell ][ 0 ] == "label" );
292
    },
293
294
    /*
295
    ---------------------------------------------------------------------------
296
      LAYOUT : internals
297
    ---------------------------------------------------------------------------
298
    */
299
    
300
    __createCellData : function( cells ) {
301
      var data = [];
302
      var nodes = [];
303
      this.__cellCount = cells.length;
304
      for( var i = 0; i < this.__cellCount; i++ ) {
305
        nodes[ i ] = null;
306
        data[ i ] = [ cells[ i ], null, null, null, null, null ];
307
      }
308
      this.__cellNodes = nodes;
309
      this.__cellData = data;
310
    },
311
    
312
    __updateComputedCellDimension : function( cell ) {
313
      var cellEntry = this.__cellData[ cell ]; 
314
      if( cellEntry[ 2 ] == null ) { //uses computed width
315
        cellEntry[ 4 ] = null; //delete computedWidth
316
        this._invalidatePreferredInnerWidth();
317
        this.addToQueue( "layoutX" );
318
      }
319
      if( cellEntry[ 3 ] == null ) { //usses computedheight
320
        cellEntry[ 4 ] = null; //delete computedHeight
321
        this._invalidatePreferredInnerHeight();
322
        this.addToQueue( "layoutY" );
323
      }
324
    },
325
    
326
    __computeCellDimension : function( cellEntry ) {
327
      var dimension;
328
      if( cellEntry[ 0 ] == "label" ) {
329
        dimension = this._computeTextDimensions( cellEntry[ 1 ] );
330
      } else {
331
        dimension = [ 0, 0 ];
332
      }
333
      cellEntry[ 4 ] = dimension[ 0 ];
334
      cellEntry[ 5 ] = dimension[ 1 ];      
335
      return dimension;
336
    },
337
    
338
    _isWidthEssential : qx.lang.Function.returnTrue,
339
    _isHeightEssential : qx.lang.Function.returnTrue,    
340
    
341
    _computePreferredInnerWidth : function() {
342
      var space = this.getTotalSpacing();
343
      var content = 0;
344
      for( var i = 0; i < this.__cellCount; i++ ) {
345
        if( this.cellHasContent( i ) ) {
346
          content += this.getCellWidth( i );
347
        }
348
      } 
349
      return space + content;
350
    },
351
    
352
    _computePreferredInnerHeight : function() {
353
      var maxHeight = 0;
354
      for( var i = 0; i < this.__cellCount; i++ ) {
355
        if( this.cellHasContent( i ) ) {
356
          maxHeight = Math.max(
357
            maxHeight, 
358
            this.getCellHeight( i )
359
          );
360
        }
361
      } 
362
      return maxHeight;
363
    },
364
365
    getTotalSpacing : function() {
366
      if( this.__computedTotalSpacing == null ) {
367
        var spaces = Math.max( 0, ( this.getTotalVisibleCells() - 1 ) ); 
368
        this.__computedTotalSpacing = spaces * this.getSpacing();
369
      }
370
      return this.__computedTotalSpacing;
371
    },
372
    
373
    getTotalVisibleCells : function() {
374
      var ret = 0;
375
      for( var i = 0; i < this.__cellCount; i++ ) {
376
        if( this.cellHasContent( i ) ) {
377
          ret++;
378
        }
379
      }
380
      return ret;
381
    },
382
   
383
    _invalidateTotalSpacing : function() {
384
      this.__computedTotalSpacing = null;
385
      this._invalidatePreferredInnerWidth();
386
    },
387
388
    renderPadding : function( changes ) { },
389
390
    _layoutPost : function( changes ) {
391
      if( changes.createContent ){
392
        this._createSubelements();
393
        this._catchSubelements();
394
      }
395
      if( changes.updateContent && !changes.createContent ) {
396
        this._updateAllImages(); 
397
        this._updateAllLabels();
398
      }
399
      if (    changes.width 
400
           || changes.layoutX 
401
           || changes.frameWidth 
402
           || changes.initial
403
          ) {
404
        this._renderLayoutX(); 
405
      }
406
      if (    changes.height 
407
           || changes.layoutY 
408
           || changes.frameHeight 
409
           || changes.initial
410
          ) {
411
        this._renderLayoutY();
412
      }
413
      this.base( arguments, changes );
414
    },
415
    
416
    _renderLayoutX : function() {
417
      var space = this.getSpacing();
418
      var pad = this.__paddingCache;
419
      var align = this.getHorizontalChildrenAlign();
420
      var total = this.getPreferredInnerWidth();
421
      var inner = this.getInnerWidth();
422
      var firstCellLeft  = null;      
423
      
424
      switch( align ) {
425
        default:
426
        case "left":
427
          firstCellLeft  = pad[ 3 ];
428
        break;
429
        case "center":
430
          firstCellLeft  = Math.round( pad[ 3 ] + inner * 0.5 - total * 0.5 );              
431
        break;
432
        case "right":
433
          firstCellLeft  = pad[ 3 ] + inner - total;
434
        break;
435
      }
436
      
437
      var left = firstCellLeft ;
438
      var width = null;
439
      var style = null;
440
      for( var i = 0; i < this.__cellCount; i++ ) {
441
        if( this.cellHasContent( i ) ) {
442
          width = this.getCellWidth( i );
443
          style = this.getCellNode( i ).style;
444
          style.left = left;
445
          style.width = width;
446
          left += ( width + space );
447
        }
448
      }      
449
    },
450
451
    _renderLayoutY : function() {
452
      for( var i = 0; i < this.__cellCount; i++ ) {
453
        if( this.cellHasContent( i ) ) {
454
          this._renderCellLayoutY( i );
455
        }
456
      }      
457
    },
458
    
459
    _renderCellLayoutY : function( cell ) {
460
      var align = this.getVerticalChildrenAlign();
461
      var pad = this.__paddingCache;
462
      var inner = this.getInnerHeight();
463
      var height = this.getCellHeight( cell );
464
      var top = null;
465
466
      switch( align ) {
467
        default:
468
        case "top":
469
          top = pad[ 0 ];
470
        break;
471
        case "middle":
472
          top = Math.round( pad[ 0 ] + inner * 0.5 - height * 0.5 );      
473
        break;
474
        case "bottom":
475
          top = pad[ 0 ] + inner - height;
476
        break;
477
      }
478
      
479
      var style = this.getCellNode( cell ).style;
480
      style.top = top;
481
      style.height = height;
482
    },
483
484
485
    /*
486
    ---------------------------------------------------------------------------
487
      IMAGE
488
    ---------------------------------------------------------------------------
489
    */
490
491
492
    _getImageHtml : qx.core.Variant.select("qx.client", {
493
      "mshtml" : function( cell ) {
494
        return   '<div style="position:absolute;border:0 none;filter:'
495
               + " progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" 
496
               + this.getCellContent( cell )  
497
               + "',sizingMethod='crop')" + '"></div>';        
498
      },
499
      "default" : function( cell ) {
500
        return   "<div style='position:absolute;border:0 none;background-image:url("
501
               + this.getCellContent( cell )
502
               + ");background-repeat:no-repeat;' ></div>";
503
      }
504
    }),
505
            
506
    _updateImage : qx.core.Variant.select("qx.client", {
507
      "mshtml" : function( cell ) {        
508
        var version = qx.core.Client.getVersion();
509
        var node = this.getCellNode( cell );
510
        if( version >= 8 ) {
511
          node.style.filter = 
512
              "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" 
513
            + this.getCellContent( cell )
514
            + "',sizingMethod='crop')";
515
          if ( !this.getEnabled() ) {
516
            node.style.filter 
517
              += "progid:DXImageTransform.Microsoft.Alpha(opacity = 30)"; 
518
          }
519
        } else {
520
          if ( this.getEnabled() ) {
521
            node.style.backgroundImage = ""; 
522
            node.style.filter = 
523
                "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" 
524
              + this.getCellContent( cell )
525
              + "',sizingMethod='crop')";
526
          } else {
527
            node.style.backgroundImage = 
528
                "URL(" 
529
              + this.getCellContent( cell )
530
              + ")";
531
            node.style.backgroundRepeat = "no-repeat";
532
            node.style.filter = 
533
                this.getEnabled() 
534
              ? "" 
535
              : "Alpha(Opacity=30)"; // removed Gray()           
536
          }          
537
        }
538
      },
539
      "default" : function( cell ) {
540
        this.getCellNode( cell ).style.backgroundImage = 
541
            "URL(" 
542
          + this.getCellContent( cell ) 
543
          + ")";
544
      }
545
    }),
546
    
547
    _updateAllImages : function() {
548
      for( var i = 0; i < this.__cellCount; i++ ) {
549
        if( this.cellIsImage( i ) && this.cellHasContent( i ) ) {
550
          this._updateImage( i );
551
        }
552
      }
553
    },
554
555
    _styleImageEnabled : qx.core.Variant.select("qx.client", {
556
      "default" : function( cell ) {
557
        var opacity = ( this.getEnabled() === false ) ? 0.3 : "";
558
        var style = this.getCellNode( cell ).style;
559
        style.opacity = style.KhtmlOpacity = style.MozOpacity = opacity;
560
                
561
      },
562
      "mshtml" : function( cell ) {
563
        this._updateImage( cell );
564
      }
565
    }),
566
    
567
    _styleAllImagesEnabled : function() {
568
      for( var i = 0; i < this.__cellCount; i++ ) {
569
        if( this.cellIsImage( i ) && this.cellHasNode( i ) ) {
570
          this._styleImageEnabled( i );
571
        }
572
      }      
573
    },
574
        
575
            
576
    /*
577
    ---------------------------------------------------------------------------
578
      LABEL
579
    ---------------------------------------------------------------------------
580
    */
581
    
582
    _getLabelHtml : function( cell ) {
583
      return "<div style='position:absolute;border:0 none;overflow:hidden;"
584
             + this._htmlUtil._joinStyleProperties( [ this.__fontCache ] ) 
585
             + "'>"
586
             + this.getCellContent( cell )
587
             + "</div>";
588
    },
589
    
590
    _applyFont : function( value, old ) {           
591
      qx.theme.manager.Font.getInstance().connect(
592
       this._styleFont, 
593
       this, 
594
       value
595
      );      
596
    },
597
    
598
    _styleFont : function( font ) {
599
      if( font ) {
600
        font.renderStyle( this.__fontCache );
601
      } else { 
602
        qx.ui.core.Font.resetStyle( this.__fontCache );
603
      }            
604
      for( var i = 0; i < this.__cellCount; i++ ) {
605
        if( this.cellIsLabel( i ) && this.cellHasContent( i ) ) {
606
          if( this.cellHasNode( i ) ) {
607
            if( font ) {
608
              font.renderStyle( this.getCellNode( i ).style );
609
            } else { 
610
              qx.ui.core.Font.resetStyle( this.getCellNode( i ).style );
611
            }            
612
          }
613
          this.__updateComputedCellDimension( i );          
614
        }          
615
      }             
616
    },
617
    
618
    _updateLabel : function( cell ) {
619
      this.getCellNode( cell ).innerHTML = this.getCellContent( cell );
620
    },
621
    
622
    _updateAllLabels : function() {
623
      for( var i = 0; i < this.__cellCount; i++ ) {
624
        if( this.cellIsLabel( i ) && this.cellHasContent( i ) ) {
625
          this._updateLabel( i );
626
        }
627
      }
628
    },
629
    
630
    _styleLabelEnabled : qx.core.Variant.select("qx.client", {
631
      "default" : function( cell ) {
632
        var opacity = ( this.getEnabled() === false ) ? 0.3 : "";
633
        var style = this.getCellNode( cell ).style;
634
        style.opacity = style.KhtlOpacity = style.MozOpacity = opacity;        
635
      },
636
      "mshtml" : function( cell ) {
637
        var filter = 
638
            this.getEnabled() 
639
          ? "" 
640
          : "progid:DXImageTransform.Microsoft.Alpha(opacity = 30)"; 
641
        this.getCellNode( cell ).style.filter = filter;
642
      }
643
    }),
644
    
645
    _styleAllLabelsEnabled : function() {
646
      for( var i = 0; i < this.__cellCount; i++ ) {
647
        if( this.cellIsLabel( i ) && this.cellHasNode( i ) ) {
648
          this._styleLabelEnabled( i );
649
        }
650
      }      
651
    }, 
652
    
653
    _computeTextDimensions : function( text ) {
654
        var element = qx.ui.basic.Label._getMeasureNode();
655
        var style = element.style;
656
        var source = this.__fontCache;
657
        style.fontFamily = source.fontFamily || "";
658
        style.fontSize = source.fontSize || "";
659
        style.fontWeight = source.fontWeight || "";
660
        style.fontStyle = source.fontStyle || "";
661
        element.innerHTML = text;
662
        return [ element.scrollWidth, element.scrollHeight ];      
663
    }
664
665
  }
666
  
667
});

Return to bug 284713