3 * Copyright(c) 2006-2011 Sencha Inc.
5 * http://www.sencha.com/license
9 * @class Ext.ux.desktop.TaskBar
10 * @extends Ext.toolbar.Toolbar
12 Ext.define('Ext.ux.desktop.TaskBar', {
13 extend: 'Ext.toolbar.Toolbar', // TODO - make this a basic hbox panel...
17 'Ext.resizer.Splitter',
20 'Ext.ux.desktop.StartMenu'
23 alias: 'widget.taskbar',
28 * @cfg {String} startBtnText
29 * The text for the Start Button.
31 startBtnText: 'Start',
33 initComponent: function () {
36 me.startMenu = new Ext.ux.desktop.StartMenu(me.startConfig);
38 me.quickStart = new Ext.toolbar.Toolbar(me.getQuickStart());
40 me.windowBar = new Ext.toolbar.Toolbar(me.getWindowBarConfig());
42 me.tray = new Ext.toolbar.Toolbar(me.getTrayConfig());
47 cls: 'ux-start-button',
48 iconCls: 'ux-start-button-icon',
55 xtype: 'splitter', html: ' ',
56 height: 14, width: 2, // TODO - there should be a CSS way here
57 cls: 'x-toolbar-separator x-toolbar-separator-horizontal'
68 afterLayout: function () {
71 me.windowBar.el.on('contextmenu', me.onButtonContextMenu, me);
75 * This method returns the configuration object for the Quick Start toolbar. A derived
76 * class can override this method, call the base version to build the config and
77 * then modify the returned object before returning it.
79 getQuickStart: function () {
80 var me = this, ret = {
87 Ext.each(this.quickStart, function (item) {
89 tooltip: { text: item.name, align: 'bl-tl' },
91 overflowText: item.name,
92 iconCls: item.iconCls,
94 handler: me.onQuickStartClick,
103 * This method returns the configuration object for the Tray toolbar. A derived
104 * class can override this method, call the base version to build the config and
105 * then modify the returned object before returning it.
107 getTrayConfig: function () {
110 items: this.trayItems
112 delete this.trayItems;
116 getWindowBarConfig: function () {
119 cls: 'ux-desktop-windowbar',
121 layout: { overflowHandler: 'Scroller' }
125 getWindowBtnFromEl: function (el) {
126 var c = this.windowBar.getChildByElement(el);
130 onQuickStartClick: function (btn) {
131 var module = this.app.getModule(btn.module);
133 module.createWindow();
137 onButtonContextMenu: function (e) {
138 var me = this, t = e.getTarget(), btn = me.getWindowBtnFromEl(t);
141 me.windowMenu.theWin = btn.win;
142 me.windowMenu.showBy(t);
146 onWindowBtnClick: function (btn) {
149 if (win.minimized || win.hidden) {
151 } else if (win.active) {
158 addTaskButton: function(win) {
160 iconCls: win.iconCls,
164 text: Ext.util.Format.ellipsis(win.title, 20),
166 click: this.onWindowBtnClick,
172 var cmp = this.windowBar.add(config);
177 removeTaskButton: function (btn) {
178 var found, me = this;
179 me.windowBar.items.each(function (item) {
186 me.windowBar.remove(found);
191 setActiveButton: function(btn) {
195 this.windowBar.items.each(function (item) {
205 * @class Ext.ux.desktop.TrayClock
206 * @extends Ext.toolbar.TextItem
207 * This class displays a clock on the toolbar.
209 Ext.define('Ext.ux.desktop.TrayClock', {
210 extend: 'Ext.toolbar.TextItem',
212 alias: 'widget.trayclock',
214 cls: 'ux-desktop-trayclock',
222 initComponent: function () {
227 if (typeof(me.tpl) == 'string') {
228 me.tpl = new Ext.XTemplate(me.tpl);
232 afterRender: function () {
234 Ext.Function.defer(me.updateTime, 100, me);
238 onDestroy: function () {
242 window.clearTimeout(me.timer);
249 updateTime: function () {
250 var me = this, time = Ext.Date.format(new Date(), me.timeFormat),
251 text = me.tpl.apply({ time: time });
252 if (me.lastText != text) {
256 me.timer = Ext.Function.defer(me.updateTime, 10000, me);