r20514: implement idl for DsGetNT4ChangeLog() which transferres the meta data
[ira/wip.git] / webapps / qooxdoo-0.6.3-sdk / frontend / framework / source / class / qx / ui / table / IconHeaderCellRenderer.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2006 by STZ-IDA, Germany, http://www.stz-ida.de
9
10    License:
11      LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
12
13    Authors:
14      * Til Schneider (til132)
15      * Carsten Lergenmueller (carstenl)
16
17 ************************************************************************ */
18
19 /* ************************************************************************
20
21 #module(ui_table)
22
23 ************************************************************************ */
24
25 /**
26  * A header cell renderer which renders an icon (only). The icon cannot be combined
27  * with text.
28  *
29  * @param iconUrl {string} URL to the icon to show
30  * @param tooltip {string ? ""} Text of the tooltip to show if the mouse hovers over the
31  *                             icon
32  *
33  */
34 qx.OO.defineClass("qx.ui.table.IconHeaderCellRenderer", qx.ui.table.DefaultHeaderCellRenderer,
35 function(iconUrl, tooltip) {
36   qx.ui.table.DefaultHeaderCellRenderer.call(this);
37   if (iconUrl == null){
38     iconUrl = "";
39   }
40   this.setIconUrl(iconUrl);
41   this.setToolTip(tooltip);
42 });
43
44 /**
45  * URL of the icon to show
46  */
47 qx.OO.addProperty({ name:"iconUrl", type:"string", defaultValue:"", allowNull:false });
48
49 /**
50  * ToolTip to show if the mouse hovers of the icon
51  */
52 qx.OO.addProperty({ name:"toolTip", type:"string", defaultValue:null, allowNull:true });
53
54 // overridden
55 qx.Proto.updateHeaderCell = function(cellInfo, cellWidget) {
56   qx.ui.table.DefaultHeaderCellRenderer.prototype.updateHeaderCell.call(this, cellInfo, cellWidget);
57
58   // Set URL to icon
59   var img = cellWidget.getUserData("qx_ui_table_IconHeaderCellRenderer_icon");
60   if (img == null){
61     img = new qx.ui.basic.Image();
62     cellWidget.setUserData("qx_ui_table_IconHeaderCellRenderer_icon", img);
63     cellWidget.addAtBegin(img);
64   }
65   img.setSource(this.getIconUrl());
66
67   // Set image tooltip if given
68   var widgetToolTip = cellWidget.getToolTip();
69   if (this.getToolTip() != null){
70
71     //Create tooltip if necessary
72     if (true || widgetToolTip == null ){
73       widgetToolTip = new qx.ui.popup.ToolTip(this.getToolTip());
74       cellWidget.setToolTip(widgetToolTip);
75       //this.debug("Creating tooltip");
76     }
77
78     //Set tooltip text
79     widgetToolTip.getAtom().setLabel(this.getToolTip());
80     //this.debug("Setting tooltip text " + this.getToolTip());
81   }
82
83 }
84