1 Clazz.declarePackage ("java.awt");
2 Clazz.load (["java.awt.LayoutManager2", "java.io.ObjectStreamField", "java.util.Hashtable", "$.Vector"], "java.awt.CardLayout", ["java.lang.IllegalArgumentException", "java.awt.Dimension"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 if (!Clazz.isClassDefined ("java.awt.CardLayout.Card")) {
6 java.awt.CardLayout.$CardLayout$Card$ ();
11 Clazz.instantialize (this, arguments);
12 }, java.awt, "CardLayout", null, [java.awt.LayoutManager2, java.io.Serializable]);
13 Clazz.prepareFields (c$, function () {
14 this.vector = new java.util.Vector ();
16 Clazz.makeConstructor (c$,
18 this.construct (0, 0);
20 Clazz.makeConstructor (c$,
21 function (hgap, vgap) {
25 Clazz.defineMethod (c$, "getHgap",
29 Clazz.defineMethod (c$, "setHgap",
33 Clazz.defineMethod (c$, "getVgap",
37 Clazz.defineMethod (c$, "setVgap",
41 Clazz.defineMethod (c$, "addLayoutComponent",
42 function (comp, constraints) {
44 if (constraints == null) {
46 }if (Clazz.instanceOf (constraints, String)) {
47 this.addLayoutComponent (constraints, comp);
49 throw new IllegalArgumentException ("cannot add to layout: constraint must be a string");
50 }}}, "java.awt.Component,~O");
51 Clazz.defineMethod (c$, "addLayoutComponent",
52 function (name, comp) {
54 if (!this.vector.isEmpty ()) {
55 comp.setVisible (false);
56 }for (var i = 0; i < this.vector.size (); i++) {
57 if ((this.vector.get (i)).name.equals (name)) {
58 (this.vector.get (i)).comp = comp;
61 this.vector.add (Clazz.innerTypeInstance (java.awt.CardLayout.Card, this, null, name, comp));
62 }}, "~S,java.awt.Component");
63 Clazz.overrideMethod (c$, "removeLayoutComponent",
66 for (var i = 0; i < this.vector.size (); i++) {
67 if ((this.vector.get (i)).comp === comp) {
68 if (comp.isVisible () && (comp.getParent () != null)) {
69 this.next (comp.getParent ());
70 }this.vector.remove (i);
71 if (this.currentCard > i) {
75 }}, "java.awt.Component");
76 Clazz.overrideMethod (c$, "preferredLayoutSize",
79 var insets = parent.getInsets ();
80 var ncomponents = parent.getComponentCount ();
83 for (var i = 0; i < ncomponents; i++) {
84 var comp = parent.getComponent (i);
85 var d = comp.getPreferredSize ();
91 return new java.awt.Dimension (insets.left + insets.right + w + this.hgap * 2, insets.top + insets.bottom + h + this.vgap * 2);
92 }}, "java.awt.Container");
93 Clazz.overrideMethod (c$, "minimumLayoutSize",
96 var insets = parent.getInsets ();
97 var ncomponents = parent.getComponentCount ();
100 for (var i = 0; i < ncomponents; i++) {
101 var comp = parent.getComponent (i);
102 var d = comp.getMinimumSize ();
108 return new java.awt.Dimension (insets.left + insets.right + w + this.hgap * 2, insets.top + insets.bottom + h + this.vgap * 2);
109 }}, "java.awt.Container");
110 Clazz.overrideMethod (c$, "maximumLayoutSize",
112 return new java.awt.Dimension (2147483647, 2147483647);
113 }, "java.awt.Container");
114 Clazz.overrideMethod (c$, "getLayoutAlignmentX",
117 }, "java.awt.Container");
118 Clazz.overrideMethod (c$, "getLayoutAlignmentY",
121 }, "java.awt.Container");
122 Clazz.overrideMethod (c$, "invalidateLayout",
124 }, "java.awt.Container");
125 Clazz.overrideMethod (c$, "layoutContainer",
128 var insets = parent.getInsets ();
129 var ncomponents = parent.getComponentCount ();
131 var currentFound = false;
132 for (var i = 0; i < ncomponents; i++) {
133 comp = parent.getComponent (i);
134 comp.setBounds (this.hgap + insets.left, this.vgap + insets.top, parent.width - (this.hgap * 2 + insets.left + insets.right), parent.height - (this.vgap * 2 + insets.top + insets.bottom));
135 if (comp.isVisible ()) {
138 if (!currentFound && ncomponents > 0) {
139 parent.getComponent (0).setVisible (true);
140 }}}, "java.awt.Container");
141 Clazz.defineMethod (c$, "checkLayout",
143 if (parent.getLayout () !== this) {
144 throw new IllegalArgumentException ("wrong parent for CardLayout");
145 }}, "java.awt.Container");
146 Clazz.defineMethod (c$, "first",
149 this.checkLayout (parent);
150 var ncomponents = parent.getComponentCount ();
151 for (var i = 0; i < ncomponents; i++) {
152 var comp = parent.getComponent (i);
153 if (comp.isVisible ()) {
154 comp.setVisible (false);
157 if (ncomponents > 0) {
158 this.currentCard = 0;
159 parent.getComponent (0).setVisible (true);
161 }}}, "java.awt.Container");
162 Clazz.defineMethod (c$, "next",
165 this.checkLayout (parent);
166 var ncomponents = parent.getComponentCount ();
167 for (var i = 0; i < ncomponents; i++) {
168 var comp = parent.getComponent (i);
169 if (comp.isVisible ()) {
170 comp.setVisible (false);
171 this.currentCard = (i + 1) % ncomponents;
172 comp = parent.getComponent (this.currentCard);
173 comp.setVisible (true);
177 this.showDefaultComponent (parent);
178 }}, "java.awt.Container");
179 Clazz.defineMethod (c$, "previous",
182 this.checkLayout (parent);
183 var ncomponents = parent.getComponentCount ();
184 for (var i = 0; i < ncomponents; i++) {
185 var comp = parent.getComponent (i);
186 if (comp.isVisible ()) {
187 comp.setVisible (false);
188 this.currentCard = ((i > 0) ? i - 1 : ncomponents - 1);
189 comp = parent.getComponent (this.currentCard);
190 comp.setVisible (true);
194 this.showDefaultComponent (parent);
195 }}, "java.awt.Container");
196 Clazz.defineMethod (c$, "showDefaultComponent",
198 if (parent.getComponentCount () > 0) {
199 this.currentCard = 0;
200 parent.getComponent (0).setVisible (true);
202 }}, "java.awt.Container");
203 Clazz.defineMethod (c$, "last",
206 this.checkLayout (parent);
207 var ncomponents = parent.getComponentCount ();
208 for (var i = 0; i < ncomponents; i++) {
209 var comp = parent.getComponent (i);
210 if (comp.isVisible ()) {
211 comp.setVisible (false);
214 if (ncomponents > 0) {
215 this.currentCard = ncomponents - 1;
216 parent.getComponent (this.currentCard).setVisible (true);
218 }}}, "java.awt.Container");
219 Clazz.defineMethod (c$, "show",
220 function (parent, name) {
222 this.checkLayout (parent);
224 var ncomponents = this.vector.size ();
225 for (var i = 0; i < ncomponents; i++) {
226 var card = this.vector.get (i);
227 if (card.name.equals (name)) {
229 this.currentCard = i;
232 if ((next != null) && !next.isVisible ()) {
233 ncomponents = parent.getComponentCount ();
234 for (var i = 0; i < ncomponents; i++) {
235 var comp = parent.getComponent (i);
236 if (comp.isVisible ()) {
237 comp.setVisible (false);
240 next.setVisible (true);
242 }}}, "java.awt.Container,~S");
243 Clazz.overrideMethod (c$, "toString",
245 return this.getClass ().getName () + "[hgap=" + this.hgap + ",vgap=" + this.vgap + "]";
247 c$.$CardLayout$Card$ = function () {
249 c$ = Clazz.decorateAsClass (function () {
250 Clazz.prepareCallback (this, arguments);
253 Clazz.instantialize (this, arguments);
254 }, java.awt.CardLayout, "Card", null, java.io.Serializable);
255 Clazz.makeConstructor (c$,
259 }, "~S,java.awt.Component");
262 c$.serialPersistentFields = c$.prototype.serialPersistentFields = Clazz.newArray (-1, [ new java.io.ObjectStreamField ("tab", java.util.Hashtable), new java.io.ObjectStreamField ("hgap", Integer.TYPE), new java.io.ObjectStreamField ("vgap", Integer.TYPE), new java.io.ObjectStreamField ("vector", java.util.Vector), new java.io.ObjectStreamField ("currentCard", Integer.TYPE)]);