summaryrefslogtreecommitdiff
path: root/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/table/IconHeaderCellRenderer.js
blob: 51e653f5c4f9ff7a9a35ed2ab8dd16bdeff7d412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* ************************************************************************

   qooxdoo - the new era of web development

   http://qooxdoo.org

   Copyright:
     2006 by STZ-IDA, Germany, http://www.stz-ida.de

   License:
     LGPL 2.1: http://www.gnu.org/licenses/lgpl.html

   Authors:
     * Til Schneider (til132)
     * Carsten Lergenmueller (carstenl)

************************************************************************ */

/* ************************************************************************

#module(ui_table)

************************************************************************ */

/**
 * A header cell renderer which renders an icon (only). The icon cannot be combined
 * with text.
 *
 * @param iconUrl {string} URL to the icon to show
 * @param tooltip {string ? ""} Text of the tooltip to show if the mouse hovers over the
 *                             icon
 *
 */
qx.OO.defineClass("qx.ui.table.IconHeaderCellRenderer", qx.ui.table.DefaultHeaderCellRenderer,
function(iconUrl, tooltip) {
  qx.ui.table.DefaultHeaderCellRenderer.call(this);
  if (iconUrl == null){
    iconUrl = "";
  }
  this.setIconUrl(iconUrl);
  this.setToolTip(tooltip);
});

/**
 * URL of the icon to show
 */
qx.OO.addProperty({ name:"iconUrl", type:"string", defaultValue:"", allowNull:false });

/**
 * ToolTip to show if the mouse hovers of the icon
 */
qx.OO.addProperty({ name:"toolTip", type:"string", defaultValue:null, allowNull:true });

// overridden
qx.Proto.updateHeaderCell = function(cellInfo, cellWidget) {
  qx.ui.table.DefaultHeaderCellRenderer.prototype.updateHeaderCell.call(this, cellInfo, cellWidget);

  // Set URL to icon
  var img = cellWidget.getUserData("qx_ui_table_IconHeaderCellRenderer_icon");
  if (img == null){
    img = new qx.ui.basic.Image();
    cellWidget.setUserData("qx_ui_table_IconHeaderCellRenderer_icon", img);
    cellWidget.addAtBegin(img);
  }
  img.setSource(this.getIconUrl());

  // Set image tooltip if given
  var widgetToolTip = cellWidget.getToolTip();
  if (this.getToolTip() != null){

    //Create tooltip if necessary
    if (true || widgetToolTip == null ){
      widgetToolTip = new qx.ui.popup.ToolTip(this.getToolTip());
      cellWidget.setToolTip(widgetToolTip);
      //this.debug("Creating tooltip");
    }

    //Set tooltip text
    widgetToolTip.getAtom().setLabel(this.getToolTip());
    //this.debug("Setting tooltip text " + this.getToolTip());
  }

}