Thanks Daniel,
this helped me quite a lot, to get things much clearer.
Your idea of using data binding is also working quite well. As I'm
relatively new to qooxdoo I only experimented with it a bit and it never
occured to me, that it could be used in this way. The only thing that
does not work is minimizing an active window if the corresponding active
button is clicked, because the data binding is getting a little bit in
the way I think, but I didn't look into this that much, so hopefully
I'll find a way around this...
Here's the code for the working but still incomplete taskbar widget, if
someone is interested:
/**
* This class provides some well known operating system like taskbar
* behaviours. To every added window a toggle button is attached, that
* can switch the window between maximized and minimized state.
*
* *Example*
*
* Here is a little example of how to use the widget.
*
* <pre class='javascript'>
* var win = new qx.ui.window.Window("A window");
* var taskbar = new addressbook.widgets.Taskbar();
* taskbar.attachWindow(win);
* </pre>
*
*
*/
qx.Class.define("taskbar.Taskbar",
{
extend : qx.ui.core.Widget,
/*
*****************************************************************************
CONSTRUCTOR
*****************************************************************************
*/
construct : function()
{
this.base(arguments);
//the menu to which all the windows are added
var taskbar = new qx.ui.toolbar.ToolBar();
this.setHeight(26);
taskbar.setSpacing(0);
//TODO stop the bar from stretching if too many windows are added
this._setLayout(new qx.ui.layout.VBox());
this._add(taskbar);
this.__taskbar = taskbar;
},
/*
*****************************************************************************
PROPERTIES
*****************************************************************************
*/
properties :
{
/** Appearance of the widget */
appearance :
{
refine : true,
init : "taskbar"
}
},
/*
*****************************************************************************
MEMBERS
*****************************************************************************
*/
members : {
__taskbar : null,
/**
* Every window that is added gets an associated taskbar button
which can toggle
* it between minimized and maximized.
*/
attachWindow : function(window) {
var button = this.__newTaskbarItem(window);
this.__createWindowListeners(window);
this.__taskbar.add(button);
},
/*
---------------------------------------------------------------------------
LISTENERS
---------------------------------------------------------------------------
*/
/**
* Adds the Listeners to the given window.
*/
__createWindowListeners : function(window){
window.addListener("close", this.__close, this);
},
/**
* Listens to added windows and removes their taskbar button if they
are closed.
*/
__close : function(e) {
var button = e.getTarget().getUserData("taskbarButton");
if(button !==null){
button.destroy();
}
},
/**
* Switches the window between shown and hidden
*/
__toggleMinMax : function(e){
var window = e.getTarget().getUserData("window");
if(e.getTarget().get("value")){
window.open();
} else {
window.minimize();
}
},
/**
* Creates a taskbar button that represents the given window.
*/
__newTaskbarItem : function(window){
var button = new qx.ui.form.ToggleButton(window.get("caption"),
window.get("icon"));
//attach the window to this button, so it can be shown again if
the button is clicked
button.setUserData("window", window);
//attach the button to the window, so it can be removed, if the
window is closed
window.setUserData("taskbarButton", button);
//bind the active state of the window to button value
window.bind("active", button, "value");
button.setValue(window.get("active"));
//if the button is clicked switch the state of the window and the
button
button.addListener("click", this.__toggleMinMax, this);
return button;
}
}
});
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel