summaryrefslogtreecommitdiff
path: root/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/MenuButtonLayoutImpl.js
blob: c62b60e18e7eccd0a783553a7a24dc921fbeacf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* ************************************************************************

   qooxdoo - the new era of web development

   http://qooxdoo.org

   Copyright:
     2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org

   License:
     LGPL 2.1: http://www.gnu.org/licenses/lgpl.html

   Authors:
     * Sebastian Werner (wpbasti)
     * Andreas Ecker (ecker)

************************************************************************ */

/* ************************************************************************

#module(ui_menu)

************************************************************************ */

qx.OO.defineClass("qx.renderer.layout.MenuButtonLayoutImpl", qx.renderer.layout.HorizontalBoxLayoutImpl,
function(vWidget)
{
  qx.renderer.layout.HorizontalBoxLayoutImpl.call(this, vWidget);

  // We don't need flex support, should make things a bit faster,
  // as this omits some additional loops in qx.renderer.layout.HorizontalBoxLayoutImpl.
  this.setEnableFlexSupport(false);
});


/*!
  Global Structure:
  [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD
  [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD
  [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN
  [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS
  [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT
  [06] UPDATE LAYOUT ON JOB QUEUE FLUSH
  [07] UPDATE CHILDREN ON JOB QUEUE FLUSH
  [08] CHILDREN ADD/REMOVE/MOVE HANDLING
  [09] FLUSH LAYOUT QUEUES OF CHILDREN
  [10] LAYOUT CHILD
  [11] DISPOSER


  Inherits from qx.renderer.layout.HorizontalBoxLayoutImpl:
  [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD
  [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD
  [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT
  [06] UPDATE LAYOUT ON JOB QUEUE FLUSH
  [07] UPDATE CHILDREN ON JOB QUEUE FLUSH
  [08] CHILDREN ADD/REMOVE/MOVE HANDLING
  [09] FLUSH LAYOUT QUEUES OF CHILDREN
  [11] DISPOSER
*/





/*
---------------------------------------------------------------------------
  [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN
---------------------------------------------------------------------------
*/

/*!
  Compute and return the width needed by all children of this widget
*/
qx.Proto.computeChildrenNeededWidth = function()
{
  // Caching the widget reference
  var vWidget = this.getWidget();

  // Ignore the verticalBoxLayout inside qx.ui.menu.Menu
  var vMenu = vWidget.getParent().getParent();

  // Let the menu do the real hard things
  return vMenu.getMenuButtonNeededWidth();
}







/*
---------------------------------------------------------------------------
  [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS
---------------------------------------------------------------------------
*/

/*!
  Things to do and layout when any of the childs changes its outer width.
  Needed by layouts where the children depends on each-other, like flow- or box-layouts.
*/
qx.Proto.updateSelfOnChildOuterWidthChange = function(vChild)
{
  // Caching the widget reference
  var vWidget = this.getWidget();

  // Ignore the verticalBoxLayout inside qx.ui.menu.Menu
  var vMenu = vWidget.getParent().getParent();

  // Send out invalidate signals
  switch(vChild)
  {
    case vWidget._iconObject:
      vMenu._invalidateMaxIconWidth();
      break;

    case vWidget._labelObject:
      vMenu._invalidateMaxLabelWidth();
      break;

    case vWidget._shortcutObject:
      vMenu._invalidateMaxShortcutWidth();
      break;

    case vWidget._arrowObject:
      vMenu._invalidateMaxArrowWidth();
      break;
  }

  // Call superclass implementation
  return qx.renderer.layout.HorizontalBoxLayoutImpl.prototype.updateSelfOnChildOuterWidthChange.call(this, vChild);
}







/*
---------------------------------------------------------------------------
  [10] LAYOUT CHILD
---------------------------------------------------------------------------
*/

qx.Proto.layoutChild_locationX = function(vChild, vJobs)
{
  // Caching the widget reference
  var vWidget = this.getWidget();

  // Ignore the verticalBoxLayout inside qx.ui.menu.Menu
  var vMenu = vWidget.getParent().getParent();

  // Left position of the child
  var vPos = null;

  // Ask the menu instance for the correct location
  switch(vChild)
  {
    case vWidget._iconObject:
      vPos = vMenu.getIconPosition();
      break;

    case vWidget._labelObject:
      vPos = vMenu.getLabelPosition();
      break;

    case vWidget._shortcutObject:
      vPos = vMenu.getShortcutPosition();
      break;

    case vWidget._arrowObject:
      vPos = vMenu.getArrowPosition();
      break;
  }

  if (vPos != null)
  {
    vPos += vWidget.getPaddingLeft();
    vChild._applyRuntimeLeft(vPos);
  }
}