1 /* ************************************************************************
3 qooxdoo - the new era of web development
8 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
11 LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
14 * Sebastian Werner (wpbasti)
15 * Andreas Ecker (ecker)
17 ************************************************************************ */
19 /* ************************************************************************
23 ************************************************************************ */
25 qx.OO.defineClass("qx.ui.toolbar.ToolBar", qx.ui.layout.HorizontalBoxLayout,
28 qx.ui.layout.HorizontalBoxLayout.call(this);
30 this.addEventListener("keypress", this._onkeypress);
36 ---------------------------------------------------------------------------
38 ---------------------------------------------------------------------------
41 qx.OO.addProperty({ name : "openMenu", type : "object", instance : "qx.ui.menu.Menu" });
44 Appearance of the widget
46 qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "toolbar" });
57 ---------------------------------------------------------------------------
59 ---------------------------------------------------------------------------
62 qx.Proto.getAllButtons = function()
64 var vChildren = this.getChildren();
65 var vLength = vChildren.length;
66 var vDeepChildren = [];
69 for (var i=0; i<vLength; i++)
71 vCurrent = vChildren[i];
73 if (vCurrent instanceof qx.ui.toolbar.MenuButton)
75 vDeepChildren.push(vCurrent);
77 else if (vCurrent instanceof qx.ui.toolbar.Part)
79 vDeepChildren = vDeepChildren.concat(vCurrent.getChildren());
93 ---------------------------------------------------------------------------
95 ---------------------------------------------------------------------------
99 Wraps key events to target functions
101 qx.Proto._onkeypress = function(e)
103 switch(e.getKeyIdentifier())
106 return this._onkeypress_left();
109 return this._onkeypress_right();
113 qx.Proto._onkeypress_left = function()
115 var vMenu = this.getOpenMenu();
120 var vOpener = vMenu.getOpener();
125 var vChildren = this.getAllButtons();
126 var vChildrenLength = vChildren.length;
127 var vIndex = vChildren.indexOf(vOpener);
129 var vPrevButton = null;
131 for (var i=vIndex-1; i>=0; i--)
133 vCurrent = vChildren[i];
135 if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled())
137 vPrevButton = vCurrent;
142 // If none found, try again from the begin (looping)
145 for (var i=vChildrenLength-1; i>vIndex; i--)
147 vCurrent = vChildren[i];
149 if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled())
151 vPrevButton = vCurrent;
160 qx.manager.object.MenuManager.getInstance().update();
162 // show previous menu
163 vPrevButton._showMenu(true);
167 qx.Proto._onkeypress_right = function()
169 var vMenu = this.getOpenMenu();
174 var vOpener = vMenu.getOpener();
179 var vChildren = this.getAllButtons();
180 var vChildrenLength = vChildren.length;
181 var vIndex = vChildren.indexOf(vOpener);
183 var vNextButton = null;
185 for (var i=vIndex+1; i<vChildrenLength; i++)
187 vCurrent = vChildren[i];
189 if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled())
191 vNextButton = vCurrent;
196 // If none found, try again from the begin (looping)
199 for (var i=0; i<vIndex; i++)
201 vCurrent = vChildren[i];
203 if (vCurrent instanceof qx.ui.toolbar.MenuButton && vCurrent.getEnabled())
205 vNextButton = vCurrent;
214 qx.manager.object.MenuManager.getInstance().update();
217 vNextButton._showMenu(true);
228 ---------------------------------------------------------------------------
230 ---------------------------------------------------------------------------
233 qx.Proto.dispose = function()
235 if (this.getDisposed()) {
239 this.removeEventListener("keypress", this._onkeypress);
241 return qx.ui.layout.HorizontalBoxLayout.prototype.dispose.call(this);