r24958: This is the final text, and the final version. I'll send the release
[jelmer/samba4-debian.git] / webapps / qooxdoo-0.6.5-sdk / frontend / framework / source / class / qx / renderer / layout / MenuButtonLayoutImpl.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
9
10    License:
11      LGPL: http://www.gnu.org/licenses/lgpl.html
12      EPL: http://www.eclipse.org/org/documents/epl-v10.php
13      See the LICENSE file in the project's top-level directory for details.
14
15    Authors:
16      * Sebastian Werner (wpbasti)
17      * Andreas Ecker (ecker)
18
19 ************************************************************************ */
20
21 /* ************************************************************************
22
23 #module(ui_menu)
24
25 ************************************************************************ */
26
27 qx.OO.defineClass("qx.renderer.layout.MenuButtonLayoutImpl", qx.renderer.layout.HorizontalBoxLayoutImpl,
28 function(vWidget)
29 {
30   qx.renderer.layout.HorizontalBoxLayoutImpl.call(this, vWidget);
31
32   // We don't need flex support, should make things a bit faster,
33   // as this omits some additional loops in qx.renderer.layout.HorizontalBoxLayoutImpl.
34   this.setEnableFlexSupport(false);
35 });
36
37
38 /*!
39   Global Structure:
40   [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD
41   [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD
42   [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN
43   [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS
44   [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT
45   [06] UPDATE LAYOUT ON JOB QUEUE FLUSH
46   [07] UPDATE CHILDREN ON JOB QUEUE FLUSH
47   [08] CHILDREN ADD/REMOVE/MOVE HANDLING
48   [09] FLUSH LAYOUT QUEUES OF CHILDREN
49   [10] LAYOUT CHILD
50   [11] DISPOSER
51
52
53   Inherits from qx.renderer.layout.HorizontalBoxLayoutImpl:
54   [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD
55   [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD
56   [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT
57   [06] UPDATE LAYOUT ON JOB QUEUE FLUSH
58   [07] UPDATE CHILDREN ON JOB QUEUE FLUSH
59   [08] CHILDREN ADD/REMOVE/MOVE HANDLING
60   [09] FLUSH LAYOUT QUEUES OF CHILDREN
61   [11] DISPOSER
62 */
63
64
65
66
67
68 /*
69 ---------------------------------------------------------------------------
70   [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN
71 ---------------------------------------------------------------------------
72 */
73
74 /*!
75   Compute and return the width needed by all children of this widget
76 */
77 qx.Proto.computeChildrenNeededWidth = function()
78 {
79   // Caching the widget reference
80   var vWidget = this.getWidget();
81
82   // Ignore the verticalBoxLayout inside qx.ui.menu.Menu
83   var vMenu = vWidget.getParent().getParent();
84
85   // Let the menu do the real hard things
86   return vMenu.getMenuButtonNeededWidth();
87 }
88
89
90
91
92
93
94
95 /*
96 ---------------------------------------------------------------------------
97   [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS
98 ---------------------------------------------------------------------------
99 */
100
101 /*!
102   Things to do and layout when any of the childs changes its outer width.
103   Needed by layouts where the children depends on each-other, like flow- or box-layouts.
104 */
105 qx.Proto.updateSelfOnChildOuterWidthChange = function(vChild)
106 {
107   // Caching the widget reference
108   var vWidget = this.getWidget();
109
110   // Ignore the verticalBoxLayout inside qx.ui.menu.Menu
111   var vMenu = vWidget.getParent().getParent();
112
113   // Send out invalidate signals
114   switch(vChild)
115   {
116     case vWidget._iconObject:
117       vMenu._invalidateMaxIconWidth();
118       break;
119
120     case vWidget._labelObject:
121       vMenu._invalidateMaxLabelWidth();
122       break;
123
124     case vWidget._shortcutObject:
125       vMenu._invalidateMaxShortcutWidth();
126       break;
127
128     case vWidget._arrowObject:
129       vMenu._invalidateMaxArrowWidth();
130       break;
131   }
132
133   // Call superclass implementation
134   return qx.renderer.layout.HorizontalBoxLayoutImpl.prototype.updateSelfOnChildOuterWidthChange.call(this, vChild);
135 }
136
137
138
139
140
141
142
143 /*
144 ---------------------------------------------------------------------------
145   [10] LAYOUT CHILD
146 ---------------------------------------------------------------------------
147 */
148
149 qx.Proto.layoutChild_locationX = function(vChild, vJobs)
150 {
151   // Caching the widget reference
152   var vWidget = this.getWidget();
153
154   // Ignore the verticalBoxLayout inside qx.ui.menu.Menu
155   var vMenu = vWidget.getParent().getParent();
156
157   // Left position of the child
158   var vPos = null;
159
160   // Ask the menu instance for the correct location
161   switch(vChild)
162   {
163     case vWidget._iconObject:
164       vPos = vMenu.getIconPosition();
165       break;
166
167     case vWidget._labelObject:
168       vPos = vMenu.getLabelPosition();
169       break;
170
171     case vWidget._shortcutObject:
172       vPos = vMenu.getShortcutPosition();
173       break;
174
175     case vWidget._arrowObject:
176       vPos = vMenu.getArrowPosition();
177       break;
178   }
179
180   if (vPos != null)
181   {
182     vPos += vWidget.getPaddingLeft();
183     vChild._applyRuntimeLeft(vPos);
184   }
185 }