Index: gnu/java/awt/peer/gtk/GtkListPeer.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java,v retrieving revision 1.6 diff -u -r1.6 GtkListPeer.java --- gnu/java/awt/peer/gtk/GtkListPeer.java 17 Dec 2003 18:02:56 -0000 1.6 +++ gnu/java/awt/peer/gtk/GtkListPeer.java 2 Feb 2004 17:41:48 -0000 @@ -85,18 +85,12 @@ public Dimension getMinimumSize (int rows) { - int dims[] = new int[2]; - - getSize (rows, dims); - return (new Dimension (dims[0], dims[1])); + return minimumSize (rows); } public Dimension getPreferredSize (int rows) { - int dims[] = new int[2]; - - getSize (rows, dims); - return (new Dimension (dims[0], dims[1])); + return preferredSize (rows); } public native int[] getSelectedIndexes (); @@ -104,12 +98,18 @@ public Dimension minimumSize (int rows) { - return (getMinimumSize (rows)); + int dims[] = new int[2]; + + getSize (rows, dims); + return new Dimension (dims[0], dims[1]); } public Dimension preferredSize (int rows) { - return (getPreferredSize (rows)); + int dims[] = new int[2]; + + getSize (rows, dims); + return new Dimension (dims[0], dims[1]); } public void removeAll () Index: java/awt/BorderLayout.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/BorderLayout.java,v retrieving revision 1.10 diff -u -r1.10 BorderLayout.java --- java/awt/BorderLayout.java 10 Nov 2002 23:11:21 -0000 1.10 +++ java/awt/BorderLayout.java 2 Feb 2004 17:41:48 -0000 @@ -349,7 +349,28 @@ if (constraints != null && ! (constraints instanceof String)) throw new IllegalArgumentException("Constraint must be a string"); - String str = (String)constraints; + addLayoutComponent((String) constraints, component); +} + +/*************************************************************************/ + +/** + * Adds a component to the layout in the specified constraint position, + * which must be one of the string constants defined in this class. + * + * @param constraints The constraint string. + * @param component The component to add. + * + * @exception IllegalArgumentException If the constraint object is not + * one of the specified constants in this class. + * + * @deprecated This method is deprecated in favor of + * addLayoutComponent(Component, Object). + */ +public void +addLayoutComponent(String constraints, Component component) +{ + String str = constraints; if (str == null || str.equals(CENTER)) center = component; @@ -371,27 +392,6 @@ lastItem = component; else throw new IllegalArgumentException("Constraint value not valid: " + str); -} - -/*************************************************************************/ - -/** - * Adds a component to the layout in the specified constraint position, - * which must be one of the string constants defined in this class. - * - * @param constraints The constraint string. - * @param component The component to add. - * - * @exception IllegalArgumentException If the constraint object is not - * one of the specified constants in this class. - * - * @deprecated This method is deprecated in favor of - * addLayoutComponent(Component, Object). - */ -public void -addLayoutComponent(String constraints, Component component) -{ - addLayoutComponent(component, constraints); } /*************************************************************************/ Index: java/awt/CardLayout.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/CardLayout.java,v retrieving revision 1.8 diff -u -r1.8 CardLayout.java --- java/awt/CardLayout.java 15 Jan 2003 22:47:04 -0000 1.8 +++ java/awt/CardLayout.java 2 Feb 2004 17:41:48 -0000 @@ -90,7 +90,7 @@ if (! (constraints instanceof String)) throw new IllegalArgumentException ("Object " + constraints + " is not a string"); - tab.put (constraints, comp); + addLayoutComponent ((String) constraints, comp); } /** Add a new component to the layout. The name can be used later @@ -102,7 +102,7 @@ */ public void addLayoutComponent (String name, Component comp) { - addLayoutComponent (comp, name); + tab.put (name, comp); } /** Cause the first component in the container to be displayed. Index: java/awt/CheckboxGroup.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/CheckboxGroup.java,v retrieving revision 1.4 diff -u -r1.4 CheckboxGroup.java --- java/awt/CheckboxGroup.java 22 Jan 2002 22:40:04 -0000 1.4 +++ java/awt/CheckboxGroup.java 2 Feb 2004 17:41:48 -0000 @@ -95,8 +95,8 @@ public Checkbox getSelectedCheckbox() { - return(selectedCheckbox); -} + return getCurrent (); +} /*************************************************************************/ @@ -126,17 +126,7 @@ public void setSelectedCheckbox(Checkbox selectedCheckbox) { - if (this.selectedCheckbox != null) - { - if (this.selectedCheckbox.getCheckboxGroup() != this) - return; - - this.selectedCheckbox.setState(false); - } - - this.selectedCheckbox = selectedCheckbox; - if (selectedCheckbox != null) - selectedCheckbox.setState(true); + setCurrent (selectedCheckbox); } /*************************************************************************/ @@ -153,7 +143,17 @@ public void setCurrent(Checkbox selectedCheckbox) { - setSelectedCheckbox(selectedCheckbox); + if (this.selectedCheckbox != null) + { + if (this.selectedCheckbox.getCheckboxGroup() != this) + return; + + this.selectedCheckbox.setState(false); + } + + this.selectedCheckbox = selectedCheckbox; + if (selectedCheckbox != null) + selectedCheckbox.setState(true); } /*************************************************************************/ Index: java/awt/Choice.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/Choice.java,v retrieving revision 1.13 diff -u -r1.13 Choice.java --- java/awt/Choice.java 5 Jan 2004 21:18:06 -0000 1.13 +++ java/awt/Choice.java 2 Feb 2004 17:41:48 -0000 @@ -111,7 +111,7 @@ public int getItemCount() { - return(pItems.size()); + return countItems (); } /*************************************************************************/ Index: java/awt/Component.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/Component.java,v retrieving revision 1.34 diff -u -r1.34 Component.java --- java/awt/Component.java 26 Jan 2004 21:55:41 -0000 1.34 +++ java/awt/Component.java 2 Feb 2004 17:41:48 -0000 @@ -779,9 +779,7 @@ */ public void setEnabled(boolean b) { - this.enabled = b; - if (peer != null) - peer.setEnabled(b); + enable (b); } /** @@ -791,7 +789,9 @@ */ public void enable() { - setEnabled(true); + this.enabled = true; + if (peer != null) + peer.setEnabled (true); } /** @@ -802,7 +802,10 @@ */ public void enable(boolean b) { - setEnabled(b); + if (b) + enable (); + else + disable (); } /** @@ -812,7 +815,9 @@ */ public void disable() { - setEnabled(false); + this.enabled = false; + if (peer != null) + peer.setEnabled (false); } /** @@ -856,10 +861,7 @@ // Inspection by subclassing shows that Sun's implementation calls // show(boolean) which then calls show() or hide(). It is the show() // method that is overriden in subclasses like Window. - if (b) - show(); - else - hide(); + show (b); } /** @@ -887,7 +889,10 @@ */ public void show(boolean b) { - setVisible(b); + if (b) + show (); + else + hide (); } /** @@ -1083,7 +1088,7 @@ */ public Point getLocation() { - return new Point(x, y); + return location (); } /** @@ -1110,7 +1115,7 @@ */ public Point location() { - return getLocation(); + return new Point (x, y); } /** @@ -1125,13 +1130,7 @@ */ public void setLocation(int x, int y) { - if (this.x == x && this.y == y) - return; - invalidate(); - this.x = x; - this.y = y; - if (peer != null) - peer.setBounds(x, y, width, height); + move (x, y); } /** @@ -1145,7 +1144,13 @@ */ public void move(int x, int y) { - setLocation(x, y); + if (this.x == x && this.y == y) + return; + invalidate (); + this.x = x; + this.y = y; + if (peer != null) + peer.setBounds (x, y, width, height); } /** @@ -1173,7 +1178,7 @@ */ public Dimension getSize() { - return new Dimension(width, height); + return size (); } /** @@ -1184,7 +1189,7 @@ */ public Dimension size() { - return getSize(); + return new Dimension (width, height); } /** @@ -1197,13 +1202,7 @@ */ public void setSize(int width, int height) { - if (this.width == width && this.height == height) - return; - invalidate(); - this.width = width; - this.height = height; - if (peer != null) - peer.setBounds(x, y, width, height); + resize (width, height); } /** @@ -1215,7 +1214,13 @@ */ public void resize(int width, int height) { - setSize(width, height); + if (this.width == width && this.height == height) + return; + invalidate (); + this.width = width; + this.height = height; + if (peer != null) + peer.setBounds (x, y, width, height); } /** @@ -1229,7 +1234,7 @@ */ public void setSize(Dimension d) { - setSize(d.width, d.height); + resize (d); } /** @@ -1241,7 +1246,7 @@ */ public void resize(Dimension d) { - setSize(d.width, d.height); + resize (d.width, d.height); } /** @@ -1256,7 +1261,7 @@ */ public Rectangle getBounds() { - return new Rectangle(x, y, width, height); + return bounds (); } /** @@ -1269,7 +1274,7 @@ */ public Rectangle bounds() { - return getBounds(); + return new Rectangle (x, y, width, height); } /** @@ -1289,15 +1294,7 @@ */ public void setBounds(int x, int y, int w, int h) { - if (this.x == x && this.y == y && width == w && height == h) - return; - invalidate(); - this.x = x; - this.y = y; - width = w; - height = h; - if (peer != null) - peer.setBounds(x, y, w, h); + reshape (x, y, w, h); } /** @@ -1306,13 +1303,22 @@ * * @param x the X coordinate of the upper left corner of the rectangle * @param y the Y coordinate of the upper left corner of the rectangle - * @param w the width of the rectangle - * @param h the height of the rectangle + * @param width the width of the rectangle + * @param height the height of the rectangle * @deprecated use address@hidden #setBounds(int, int, int, int)} instead */ public void reshape(int x, int y, int width, int height) { - setBounds(x, y, width, height); + if (this.x == x && this.y == y + && this.width == width && this.height == height) + return; + invalidate (); + this.x = x; + this.y = y; + this.width = width; + this.height = height; + if (peer != null) + peer.setBounds (x, y, width, height); } /** @@ -1329,7 +1335,7 @@ */ public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); + setBounds (r.x, r.y, r.width, r.height); } /** @@ -1560,7 +1566,7 @@ */ public void doLayout() { - // nothing to do unless we're a container + layout (); } /** @@ -1571,7 +1577,7 @@ */ public void layout() { - doLayout(); + // Nothing to do unless we're a container. } /** @@ -2076,7 +2082,7 @@ */ public boolean contains(int x, int y) { - return x >= 0 && y >= 0 && x < width && y < height; + return inside (x, y); } /** @@ -2090,7 +2096,7 @@ */ public boolean inside(int x, int y) { - return contains(x, y); + return x >= 0 && y >= 0 && x < width && y < height; } /** @@ -2105,7 +2111,7 @@ */ public boolean contains(Point p) { - return contains(p.x, p.y); + return contains (p.x, p.y); } /** @@ -2120,7 +2126,7 @@ */ public Component getComponentAt(int x, int y) { - return contains(x, y) ? this : null; + return locate (x, y); } /** @@ -2135,7 +2141,7 @@ */ public Component locate(int x, int y) { - return getComponentAt(x, y); + return contains (x, y) ? this : null; } /** @@ -2151,7 +2157,7 @@ */ public Component getComponentAt(Point p) { - return getComponentAt(p.x, p.y); + return getComponentAt (p.x, p.y); } /** Index: java/awt/Container.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/Container.java,v retrieving revision 1.32 diff -u -r1.32 Container.java --- java/awt/Container.java 26 Jan 2004 21:55:41 -0000 1.32 +++ java/awt/Container.java 2 Feb 2004 17:41:48 -0000 @@ -106,7 +106,7 @@ */ public int getComponentCount() { - return ncomponents; + return countComponents (); } /** @@ -118,7 +118,7 @@ */ public int countComponents() { - return getComponentCount(); + return ncomponents; } /** @@ -186,10 +186,7 @@ */ public Insets getInsets() { - if (peer == null) - return new Insets(0, 0, 0, 0); - - return ((ContainerPeer) peer).getInsets(); + return insets (); } /** @@ -201,7 +198,10 @@ */ public Insets insets() { - return getInsets(); + if (peer == null) + return new Insets (0, 0, 0, 0); + + return ((ContainerPeer) peer).getInsets (); } /** @@ -463,8 +463,7 @@ */ public void doLayout() { - if (layoutMgr != null) - layoutMgr.layoutContainer(this); + layout (); } /** @@ -474,7 +473,8 @@ */ public void layout() { - doLayout(); + if (layoutMgr != null) + layoutMgr.layoutContainer (this); } /** @@ -555,7 +555,7 @@ */ public Dimension getPreferredSize() { - return preferredSize(); + return preferredSize (); } /** @@ -567,10 +567,10 @@ */ public Dimension preferredSize() { - if (layoutMgr != null) - return layoutMgr.preferredLayoutSize(this); - else - return super.preferredSize(); + if (layoutMgr != null) + return layoutMgr.preferredLayoutSize (this); + else + return super.preferredSize (); } /** @@ -580,7 +580,7 @@ */ public Dimension getMinimumSize() { - return minimumSize(); + return minimumSize (); } /** @@ -592,10 +592,10 @@ */ public Dimension minimumSize() { - if (layoutMgr != null) - return layoutMgr.minimumLayoutSize(this); - else - return super.minimumSize(); + if (layoutMgr != null) + return layoutMgr.minimumLayoutSize (this); + else + return super.minimumSize (); } /** @@ -833,23 +833,7 @@ */ public Component getComponentAt(int x, int y) { - synchronized (getTreeLock ()) - { - if (! contains(x, y)) - return null; - for (int i = 0; i < ncomponents; ++i) - { - // Ignore invisible children... - if (!component[i].isVisible()) - continue; - - int x2 = x - component[i].x; - int y2 = y - component[i].y; - if (component[i].contains(x2, y2)) - return component[i]; - } - return this; - } + return locate (x, y); } /** @@ -869,7 +853,23 @@ */ public Component locate(int x, int y) { - return getComponentAt(x, y); + synchronized (getTreeLock ()) + { + if (!contains (x, y)) + return null; + for (int i = 0; i < ncomponents; ++i) + { + // Ignore invisible children... + if (!component[i].isVisible ()) + continue; + + int x2 = x - component[i].x; + int y2 = y - component[i].y; + if (component[i].contains (x2, y2)) + return component[i]; + } + return this; + } } /** @@ -886,7 +886,7 @@ */ public Component getComponentAt(Point p) { - return getComponentAt(p.x, p.y); + return getComponentAt (p.x, p.y); } public Component findComponentAt(int x, int y) Index: java/awt/FontMetrics.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/FontMetrics.java,v retrieving revision 1.4 diff -u -r1.4 FontMetrics.java --- java/awt/FontMetrics.java 22 Jan 2002 22:58:08 -0000 1.4 +++ java/awt/FontMetrics.java 2 Feb 2004 17:41:48 -0000 @@ -195,7 +195,7 @@ public int getMaxDescent() { - return(getDescent()); + return getMaxDecent (); } /*************************************************************************/ @@ -212,7 +212,7 @@ public int getMaxDecent() { - return(getMaxDescent()); + return getDescent (); } /*************************************************************************/ Index: java/awt/GridBagLayout.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/GridBagLayout.java,v retrieving revision 1.6 diff -u -r1.6 GridBagLayout.java --- java/awt/GridBagLayout.java 14 Nov 2003 22:44:29 -0000 1.6 +++ java/awt/GridBagLayout.java 2 Feb 2004 17:41:48 -0000 @@ -149,7 +149,7 @@ public void layoutContainer (Container parent) { - arrangeGrid (parent); + arrangeGrid (parent); } public float getLayoutAlignmentX (Container target) @@ -302,7 +302,8 @@ */ protected void AdjustForGravity (GridBagConstraints gbc, Rectangle rect) { - adjustForGravity (gbc, rect); + // FIXME + throw new Error ("Not implemented"); } /** @@ -310,7 +311,115 @@ */ protected void ArrangeGrid (Container parent) { - arrangeGrid (parent); + Component[] components = parent.getComponents(); + + if (components.length == 0) + return; + + GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE); + if (info.cols == 0 && info.rows == 0) + return; + layoutInfo = info; + + // DEBUG + //dumpLayoutInfo (layoutInfo); + + for(int i = 0; i < components.length; i++) + { + Component component = components [i]; + + // If component is not visible we dont have to care about it. + if (!component.isVisible()) + continue; + + GridBagConstraints constraints = lookupConstraints (component); + + int cellx = sumIntArray(layoutInfo.colWidths, constraints.gridx); + int celly = sumIntArray(layoutInfo.rowHeights, constraints.gridy); + int cellw = sumIntArray(layoutInfo.colWidths, + constraints.gridx + constraints.gridwidth) - cellx; + int cellh = sumIntArray(layoutInfo.rowHeights, + constraints.gridy + constraints.gridheight) - celly; + + Insets insets = constraints.insets; + if (insets != null) + { + cellx += insets.left; + celly += insets.top; + cellw -= insets.left + insets.right; + cellh -= insets.top + insets.bottom; + } + + Dimension dim = component.getPreferredSize(); + + // Note: Documentation says that padding is added on both sides, but + // visual inspection shows that the Sun implementation only adds it + // once, so we do the same. + dim.width += constraints.ipadx; + dim.height += constraints.ipady; + + switch(constraints.fill) + { + case GridBagConstraints.HORIZONTAL: + dim.width = cellw; + break; + case GridBagConstraints.VERTICAL: + dim.height = cellh; + break; + case GridBagConstraints.BOTH: + dim.width = cellw; + dim.height = cellh; + break; + } + + int x; + int y; + + switch(constraints.anchor) + { + case GridBagConstraints.NORTH: + x = cellx + (cellw - dim.width) / 2; + y = celly; + break; + case GridBagConstraints.SOUTH: + x = cellx + (cellw - dim.width) / 2; + y = celly + cellh - dim.height; + break; + case GridBagConstraints.WEST: + x = cellx; + y = celly + (cellh - dim.height) / 2; + break; + case GridBagConstraints.EAST: + x = cellx + cellw - dim.width; + y = celly + (cellh - dim.height) / 2; + break; + case GridBagConstraints.NORTHEAST: + x = cellx + cellw - dim.width; + y = celly; + break; + case GridBagConstraints.NORTHWEST: + x = cellx; + y = celly; + break; + case GridBagConstraints.SOUTHEAST: + x = cellx + cellw - dim.width; + y = celly + cellh - dim.height; + break; + case GridBagConstraints.SOUTHWEST: + x = cellx; + y = celly + cellh - dim.height; + break; + default: + x = cellx + (cellw - dim.width) / 2; + y = celly + (cellh - dim.height) / 2; + break; + } + + component.setBounds(layoutInfo.pos_x + x, layoutInfo.pos_y + y, dim.width, dim.height); + } + + // DEBUG + //dumpLayoutInfo (layoutInfo); } /** @@ -318,7 +427,160 @@ */ protected GridBagLayoutInfo GetLayoutInfo (Container parent, int sizeflag) { - return getLayoutInfo (parent, sizeflag); + if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE) + throw new IllegalArgumentException(); + + Dimension parentDim = parent.getSize (); + Insets parentInsets = parent.getInsets (); + parentDim.width -= parentInsets.left + parentInsets.right; + parentDim.height -= parentInsets.top + parentInsets.bottom; + + int x = 0; + int y = 0; + int max_x = 0; + int max_y = 0; + + // first we figure out how many rows/columns + Component[] components = parent.getComponents(); + for (int i = 0; i < components.length; i++) + { + Component component = components [i]; + + // If component is not visible we dont have to care about it. + if (!component.isVisible()) + continue; + + GridBagConstraints constraints = lookupConstraints (component); + + if(constraints.gridx == GridBagConstraints.RELATIVE) + constraints.gridx = x; + + if(constraints.gridy == GridBagConstraints.RELATIVE) + constraints.gridy = y; + + max_x = Math.max(max_x, + constraints.gridx + Math.max(1, constraints.gridwidth)); + max_y = Math.max(max_y, + constraints.gridy + Math.max(1, constraints.gridheight)); + + if(constraints.gridwidth == GridBagConstraints.REMAINDER) + { + x = 0; + y++; + } + else + { + x = constraints.gridx + Math.max(1, constraints.gridwidth); + y = constraints.gridy; + } + } + + GridBagLayoutInfo info = new GridBagLayoutInfo(max_x, max_y); + + for (x = 0; x <= max_x; x++) + { + if(columnWidths != null && columnWidths.length > x) + { + info.colWidths[x] = columnWidths[x]; + } + if(columnWeights != null && columnWeights.length > x) + { + info.colWeights[x] = columnWeights[x]; + } + for (int i = 0; i < components.length; i++) + { + Component component = components [i]; + + // If component is not visible we dont have to care about it. + if (!component.isVisible()) + continue; + + GridBagConstraints constraints = lookupConstraints (component); + + // first we fix up any REMAINDER cells + if(constraints.gridwidth == GridBagConstraints.REMAINDER) + { + constraints.gridwidth = max_x - constraints.gridx; + } + if(constraints.gridheight == GridBagConstraints.REMAINDER) + { + constraints.gridheight = max_y - constraints.gridy; + } + + if(constraints.gridx + constraints.gridwidth - 1 == x) + { + int width = (sizeflag == PREFERREDSIZE) ? + component.getPreferredSize().width : + component.getMinimumSize().width; + if(constraints.insets != null) + { + width += constraints.insets.left + constraints.insets.right; + } + width += constraints.ipadx; + for(int w = 1; w < constraints.gridwidth; w++) + { + width -= info.colWidths[x - w]; + } + info.colWidths[x] = Math.max(info.colWidths[x], width); + info.colWeights[x] = + Math.max(info.colWeights[x], constraints.weightx); + } + } + } + + for (y = 0; y <= max_y; y++) + { + if(rowHeights != null && rowHeights.length > y) + { + info.rowHeights[y] = rowHeights[y]; + } + if(rowWeights != null && rowWeights.length > y) + { + info.rowWeights[y] = rowWeights[y]; + } + for (int i = 0; i < components.length; i++) + { + Component component = components [i]; + + // If component is not visible we dont have to care about it. + if (!component.isVisible()) + continue; + + GridBagConstraints constraints = lookupConstraints (component); + + if(constraints.gridy + constraints.gridheight - 1 == y) + { + int height = (sizeflag == PREFERREDSIZE) ? + component.getPreferredSize().height : + component.getMinimumSize().height; + if(constraints.insets != null) + { + height += constraints.insets.top + constraints.insets.bottom; + } + height += constraints.ipady; + for(int h = 1; h < constraints.gridheight; h++) + { + height -= info.rowHeights[y - h]; + } + info.rowHeights[y] = Math.max(info.rowHeights[y], height); + info.rowWeights[y] = + Math.max(info.rowWeights[y], constraints.weighty); + } + } + } + + calcCellSizes (info.colWidths, info.colWeights, parentDim.width); + calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height); + + int totalWidth = sumIntArray(info.colWidths); + int totalHeight = sumIntArray(info.rowHeights); + info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2; + info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2; + + // DEBUG + //dumpLayoutInfo (info); + + return info; } /** @@ -326,7 +588,13 @@ */ protected Dimension GetMinSize (Container parent, GridBagLayoutInfo info) { - return getMinSize (parent, info); + if (parent == null || info == null) + return new Dimension (0, 0); + + Insets insets = parent.getInsets(); + int width = sumIntArray (info.colWidths) + insets.left + insets.right; + int height = sumIntArray (info.rowHeights) + insets.top + insets.bottom; + return new Dimension (width, height); } /** @@ -334,13 +602,7 @@ */ protected Dimension getMinSize (Container parent, GridBagLayoutInfo info) { - if (parent == null || info == null) - return new Dimension (0, 0); - - Insets insets = parent.getInsets(); - int width = sumIntArray (info.colWidths) + insets.left + insets.right; - int height = sumIntArray (info.rowHeights) + insets.top + insets.bottom; - return new Dimension (width, height); + return GetMinSize (parent, info); } private void calcCellSizes (int[] sizes, double[] weights, int range) @@ -404,116 +666,7 @@ */ protected void arrangeGrid (Container parent) { - Component[] components = parent.getComponents(); - - if (components.length == 0) - return; - - GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE); - if (info.cols == 0 && info.rows == 0) - return; - layoutInfo = info; - - // DEBUG - //dumpLayoutInfo (layoutInfo); - - for(int i = 0; i < components.length; i++) - { - Component component = components [i]; - - // If component is not visible we dont have to care about it. - if (!component.isVisible()) - continue; - - GridBagConstraints constraints = lookupConstraints (component); - - int cellx = sumIntArray(layoutInfo.colWidths, constraints.gridx); - int celly = sumIntArray(layoutInfo.rowHeights, constraints.gridy); - int cellw = sumIntArray(layoutInfo.colWidths, - constraints.gridx + constraints.gridwidth) - cellx; - int cellh = sumIntArray(layoutInfo.rowHeights, - constraints.gridy + constraints.gridheight) - celly; - - Insets insets = constraints.insets; - if (insets != null) - { - cellx += insets.left; - celly += insets.top; - cellw -= insets.left + insets.right; - cellh -= insets.top + insets.bottom; - } - - Dimension dim = component.preferredSize(); - - // Note: Documentation says that padding is added on both sides, but - // visual inspection shows that the Sun implementation only adds it - // once, so we do the same. - dim.width += constraints.ipadx; - dim.height += constraints.ipady; - - switch(constraints.fill) - { - case GridBagConstraints.HORIZONTAL: - dim.width = cellw; - break; - case GridBagConstraints.VERTICAL: - dim.height = cellh; - break; - case GridBagConstraints.BOTH: - dim.width = cellw; - dim.height = cellh; - break; - } - - int x; - int y; - - switch(constraints.anchor) - { - case GridBagConstraints.NORTH: - x = cellx + (cellw - dim.width) / 2; - y = celly; - break; - case GridBagConstraints.SOUTH: - x = cellx + (cellw - dim.width) / 2; - y = celly + cellh - dim.height; - break; - case GridBagConstraints.WEST: - x = cellx; - y = celly + (cellh - dim.height) / 2; - break; - case GridBagConstraints.EAST: - x = cellx + cellw - dim.width; - y = celly + (cellh - dim.height) / 2; - break; - case GridBagConstraints.NORTHEAST: - x = cellx + cellw - dim.width; - y = celly; - break; - case GridBagConstraints.NORTHWEST: - x = cellx; - y = celly; - break; - case GridBagConstraints.SOUTHEAST: - x = cellx + cellw - dim.width; - y = celly + cellh - dim.height; - break; - case GridBagConstraints.SOUTHWEST: - x = cellx; - y = celly + cellh - dim.height; - break; - default: - x = cellx + (cellw - dim.width) / 2; - y = celly + (cellh - dim.height) / 2; - break; - } - - component.setBounds(layoutInfo.pos_x + x, layoutInfo.pos_y + y, dim.width, dim.height); - } - - // DEBUG - //dumpLayoutInfo (layoutInfo); - + ArrangeGrid (parent); } /** @@ -521,160 +674,7 @@ */ protected GridBagLayoutInfo getLayoutInfo (Container parent, int sizeflag) { - if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE) - throw new IllegalArgumentException(); - - Dimension parentDim = parent.size(); - Insets parentInsets = parent.insets(); - parentDim.width -= parentInsets.left + parentInsets.right; - parentDim.height -= parentInsets.top + parentInsets.bottom; - - int x = 0; - int y = 0; - int max_x = 0; - int max_y = 0; - - // first we figure out how many rows/columns - Component[] components = parent.getComponents(); - for (int i = 0; i < components.length; i++) - { - Component component = components [i]; - - // If component is not visible we dont have to care about it. - if (!component.isVisible()) - continue; - - GridBagConstraints constraints = lookupConstraints (component); - - if(constraints.gridx == GridBagConstraints.RELATIVE) - constraints.gridx = x; - - if(constraints.gridy == GridBagConstraints.RELATIVE) - constraints.gridy = y; - - max_x = Math.max(max_x, - constraints.gridx + Math.max(1, constraints.gridwidth)); - max_y = Math.max(max_y, - constraints.gridy + Math.max(1, constraints.gridheight)); - - if(constraints.gridwidth == GridBagConstraints.REMAINDER) - { - x = 0; - y++; - } - else - { - x = constraints.gridx + Math.max(1, constraints.gridwidth); - y = constraints.gridy; - } - } - - GridBagLayoutInfo info = new GridBagLayoutInfo(max_x, max_y); - - for (x = 0; x <= max_x; x++) - { - if(columnWidths != null && columnWidths.length > x) - { - info.colWidths[x] = columnWidths[x]; - } - if(columnWeights != null && columnWeights.length > x) - { - info.colWeights[x] = columnWeights[x]; - } - for (int i = 0; i < components.length; i++) - { - Component component = components [i]; - - // If component is not visible we dont have to care about it. - if (!component.isVisible()) - continue; - - GridBagConstraints constraints = lookupConstraints (component); - - // first we fix up any REMAINDER cells - if(constraints.gridwidth == GridBagConstraints.REMAINDER) - { - constraints.gridwidth = max_x - constraints.gridx; - } - if(constraints.gridheight == GridBagConstraints.REMAINDER) - { - constraints.gridheight = max_y - constraints.gridy; - } - - if(constraints.gridx + constraints.gridwidth - 1 == x) - { - int width = (sizeflag == PREFERREDSIZE) ? - component.preferredSize().width : - component.minimumSize().width; - if(constraints.insets != null) - { - width += constraints.insets.left + constraints.insets.right; - } - width += constraints.ipadx; - for(int w = 1; w < constraints.gridwidth; w++) - { - width -= info.colWidths[x - w]; - } - info.colWidths[x] = Math.max(info.colWidths[x], width); - info.colWeights[x] = - Math.max(info.colWeights[x], constraints.weightx); - } - } - } - - for (y = 0; y <= max_y; y++) - { - if(rowHeights != null && rowHeights.length > y) - { - info.rowHeights[y] = rowHeights[y]; - } - if(rowWeights != null && rowWeights.length > y) - { - info.rowWeights[y] = rowWeights[y]; - } - for (int i = 0; i < components.length; i++) - { - Component component = components [i]; - - // If component is not visible we dont have to care about it. - if (!component.isVisible()) - continue; - - GridBagConstraints constraints = lookupConstraints (component); - - if(constraints.gridy + constraints.gridheight - 1 == y) - { - int height = (sizeflag == PREFERREDSIZE) ? - component.preferredSize().height : - component.minimumSize().height; - if(constraints.insets != null) - { - height += constraints.insets.top + constraints.insets.bottom; - } - height += constraints.ipady; - for(int h = 1; h < constraints.gridheight; h++) - { - height -= info.rowHeights[y - h]; - } - info.rowHeights[y] = Math.max(info.rowHeights[y], height); - info.rowWeights[y] = - Math.max(info.rowWeights[y], constraints.weighty); - } - } - } - - calcCellSizes (info.colWidths, info.colWeights, parentDim.width); - calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height); - - int totalWidth = sumIntArray(info.colWidths); - int totalHeight = sumIntArray(info.rowHeights); - info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2; - info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2; - - // DEBUG - //dumpLayoutInfo (info); - - return info; + return GetLayoutInfo (parent, sizeflag); } /** @@ -682,7 +682,6 @@ */ protected void adjustForGravity (GridBagConstraints gbc, Rectangle rect) { - // FIXME - throw new Error ("Not implemented"); + AdjustForGravity (gbc, rect); } } Index: java/awt/LayoutManager2.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/LayoutManager2.java,v retrieving revision 1.6 diff -u -r1.6 LayoutManager2.java --- java/awt/LayoutManager2.java 9 Aug 2002 04:26:14 -0000 1.6 +++ java/awt/LayoutManager2.java 2 Feb 2004 17:41:48 -0000 @@ -52,12 +52,12 @@ { /** * Adds the specified component to the layout, with the specified - * constraint object. + * constraints object. * * @param component the component to add - * @param constraint the constraint to satisfy + * @param constraints the constraints to satisfy */ - void addLayoutComponent(Component component, Object contraint); + void addLayoutComponent(Component component, Object contraints); /** * Determines the maximum size of the specified target container. Index: java/awt/List.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/List.java,v retrieving revision 1.16 diff -u -r1.16 List.java --- java/awt/List.java 19 Dec 2003 02:53:36 -0000 1.16 +++ java/awt/List.java 2 Feb 2004 17:41:48 -0000 @@ -175,7 +175,7 @@ public int getItemCount() { - return(items.size()); + return countItems (); } /*************************************************************************/ @@ -191,7 +191,7 @@ public int countItems() { - return(getItemCount()); + return items.size (); } /*************************************************************************/ @@ -249,7 +249,7 @@ public boolean isMultipleMode() { - return(multipleMode); + return allowsMultipleSelections (); } /*************************************************************************/ @@ -266,7 +266,7 @@ public boolean allowsMultipleSelections() { - return(multipleMode); + return multipleMode; } /*************************************************************************/ @@ -281,12 +281,7 @@ public void setMultipleMode(boolean multipleMode) { - this.multipleMode = multipleMode; - if (peer != null) - { - ListPeer l = (ListPeer) peer; - l.setMultipleMode (multipleMode); - } + setMultipleSelections (multipleMode); } /*************************************************************************/ @@ -303,7 +298,11 @@ public void setMultipleSelections(boolean multipleMode) { - setMultipleMode(multipleMode); + this.multipleMode = multipleMode; + + ListPeer peer = (ListPeer) getPeer (); + if (peer != null) + peer.setMultipleMode (multipleMode); } /*************************************************************************/ @@ -316,7 +315,7 @@ public Dimension getMinimumSize() { - return(getMinimumSize(rows)); + return getMinimumSize (getRows ()); } /*************************************************************************/ @@ -332,7 +331,7 @@ public Dimension minimumSize() { - return(getMinimumSize(rows)); + return minimumSize (getRows ()); } /*************************************************************************/ @@ -348,11 +347,7 @@ public Dimension getMinimumSize(int rows) { - ListPeer lp = (ListPeer)getPeer(); - if (lp != null) - return(lp.minimumSize(rows)); - else - return(new Dimension(0,0)); + return minimumSize (rows); } /*************************************************************************/ @@ -371,7 +366,11 @@ public Dimension minimumSize(int rows) { - return(getMinimumSize(rows)); + ListPeer peer = (ListPeer) getPeer (); + if (peer != null) + return peer.minimumSize (rows); + else + return new Dimension (0, 0); } /*************************************************************************/ @@ -384,7 +383,7 @@ public Dimension getPreferredSize() { - return(getPreferredSize(rows)); + return getPreferredSize (getRows ()); } /*************************************************************************/ @@ -400,7 +399,7 @@ public Dimension preferredSize() { - return(getPreferredSize(rows)); + return preferredSize (getRows ()); } /*************************************************************************/ @@ -416,11 +415,7 @@ public Dimension getPreferredSize(int rows) { - ListPeer lp = (ListPeer)getPeer(); - if (lp != null) - return(lp.preferredSize(rows)); - else - return(new Dimension(0,0)); + return preferredSize (rows); } /*************************************************************************/ @@ -439,7 +434,11 @@ public Dimension preferredSize(int rows) { - return(getPreferredSize(rows)); + ListPeer peer = (ListPeer) getPeer (); + if (peer != null) + return peer.preferredSize (rows); + else + return new Dimension (0, 0); } /*************************************************************************/ @@ -452,7 +451,7 @@ public void add(String item) { - add(item, -1); + add (item, -1); } /*************************************************************************/ @@ -467,7 +466,7 @@ public void addItem(String item) { - addItem(item, -1); + addItem (item, -1); } /*************************************************************************/ @@ -484,16 +483,7 @@ public void add(String item, int index) { - if ((index == -1) || (index >= items.size())) - items.addElement(item); - else - items.insertElementAt(item, index); - - if (peer != null) - { - ListPeer l = (ListPeer) peer; - l.add (item, index); - } + addItem (item, index); } /*************************************************************************/ @@ -512,7 +502,14 @@ public void addItem(String item, int index) { - add(item, index); + if ((index == -1) || (index >= items.size ())) + items.addElement (item); + else + items.insertElementAt (item, index); + + ListPeer peer = (ListPeer) getPeer (); + if (peer != null) + peer.add (item, index); } /*************************************************************************/ @@ -529,7 +526,11 @@ public void delItem(int index) throws IllegalArgumentException { - remove(index); + items.removeElementAt (index); + + ListPeer peer = (ListPeer) getPeer (); + if (peer != null) + peer.delItems (index, index); } /*************************************************************************/ @@ -544,12 +545,7 @@ public void remove(int index) throws IllegalArgumentException { - items.removeElementAt (index); - if (peer != null) - { - ListPeer l = (ListPeer) peer; - l.delItems (index, index); - } + delItem (index); } /*************************************************************************/ @@ -613,12 +609,7 @@ public synchronized void removeAll() { - items.clear(); - if (peer != null) - { - ListPeer l = (ListPeer) peer; - l.removeAll (); - } + clear (); } /*************************************************************************/ @@ -631,7 +622,11 @@ public void clear() { - removeAll(); + items.clear(); + + ListPeer peer = (ListPeer) getPeer (); + if (peer != null) + peer.removeAll (); } /*************************************************************************/ @@ -782,13 +777,7 @@ public boolean isIndexSelected(int index) { - int[] indexes = getSelectedIndexes(); - - for (int i = 0; i < indexes.length; i++) - if (indexes[i] == index) - return(true); - - return(false); + return isSelected (index); } /*************************************************************************/ @@ -807,7 +796,13 @@ public boolean isSelected(int index) { - return(isIndexSelected(index)); + int[] indexes = getSelectedIndexes (); + + for (int i = 0; i < indexes.length; i++) + if (indexes[i] == index) + return true; + + return false; } /*************************************************************************/ Index: java/awt/Menu.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/Menu.java,v retrieving revision 1.15 diff -u -r1.15 Menu.java --- java/awt/Menu.java 27 Jan 2004 19:29:56 -0000 1.15 +++ java/awt/Menu.java 2 Feb 2004 17:41:48 -0000 @@ -171,7 +171,7 @@ public int getItemCount() { - return(items.size()); + return countItems (); } /** @@ -183,7 +183,7 @@ */ public int countItems () { - return getItemCount (); + return items.size (); } /*************************************************************************/ Index: java/awt/MenuBar.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/MenuBar.java,v retrieving revision 1.12 diff -u -r1.12 MenuBar.java --- java/awt/MenuBar.java 27 Jan 2004 19:29:56 -0000 1.12 +++ java/awt/MenuBar.java 2 Feb 2004 17:41:48 -0000 @@ -219,8 +219,7 @@ public int getMenuCount() { - // FIXME: How does the help menu fit in here? - return(menus.size()); + return countMenus (); } /*************************************************************************/ @@ -235,7 +234,8 @@ public int countMenus() { - return(getMenuCount()); + // FIXME: How does the help menu fit in here? + return menus.size (); } /*************************************************************************/ Index: java/awt/MenuItem.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/MenuItem.java,v retrieving revision 1.15 diff -u -r1.15 MenuItem.java --- java/awt/MenuItem.java 19 Jan 2004 14:27:45 -0000 1.15 +++ java/awt/MenuItem.java 2 Feb 2004 17:41:48 -0000 @@ -202,15 +202,7 @@ public synchronized void setEnabled(boolean enabled) { - if (enabled == this.enabled) - return; - - this.enabled = enabled; - if (peer != null) - { - MenuItemPeer mp = (MenuItemPeer) peer; - mp.setEnabled (enabled); - } + enable (enabled); } /*************************************************************************/ @@ -226,7 +218,10 @@ public void enable(boolean enabled) { - setEnabled(enabled); + if (enabled) + enable (); + else + disable (); } /*************************************************************************/ @@ -239,7 +234,12 @@ public void enable() { - setEnabled(true); + if (enabled) + return; + + this.enabled = true; + if (peer != null) + ((MenuItemPeer) peer).setEnabled (true); } /*************************************************************************/ @@ -252,7 +252,12 @@ public void disable() { - setEnabled(false); + if (!enabled) + return; + + this.enabled = false; + if (peer != null) + ((MenuItemPeer) peer).setEnabled (false); } /*************************************************************************/ Index: java/awt/Polygon.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/Polygon.java,v retrieving revision 1.3 diff -u -r1.3 Polygon.java --- java/awt/Polygon.java 8 Dec 2003 22:59:51 -0000 1.3 +++ java/awt/Polygon.java 2 Feb 2004 17:41:48 -0000 @@ -258,10 +258,24 @@ */ public Rectangle getBounds() { + return getBoundingBox (); + } + + /** + * Returns the bounding box of this polygon. This is the smallest + * rectangle with sides parallel to the X axis that will contain this + * polygon. + * + * @return the bounding box for this polygon + * @see #getBounds2D() + * @deprecated use address@hidden #getBounds()} instead + */ + public Rectangle getBoundingBox() + { if (bounds == null) { if (npoints == 0) - return bounds = new Rectangle(); + return bounds = new Rectangle (); int i = npoints - 1; int minx = xpoints[i]; int maxx = minx; @@ -280,23 +294,9 @@ else if (y > maxy) maxy = y; } - bounds = new Rectangle(minx, maxy, maxx - minx, maxy - miny); + bounds = new Rectangle (minx, maxy, maxx - minx, maxy - miny); } return bounds; - } - - /** - * Returns the bounding box of this polygon. This is the smallest - * rectangle with sides parallel to the X axis that will contain this - * polygon. - * - * @return the bounding box for this polygon - * @see #getBounds2D() - * @deprecated use address@hidden #getBounds()} instead - */ - public Rectangle getBoundingBox() - { - return getBounds(); } /** Index: java/awt/Rectangle.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/Rectangle.java,v retrieving revision 1.11 diff -u -r1.11 Rectangle.java --- java/awt/Rectangle.java 5 Jun 2003 19:58:39 -0000 1.11 +++ java/awt/Rectangle.java 2 Feb 2004 17:41:48 -0000 @@ -281,10 +281,7 @@ */ public void setBounds(Rectangle r) { - x = r.x; - y = r.y; - width = r.width; - height = r.height; + setBounds (r.x, r.y, r.width, r.height); } /** @@ -298,10 +295,7 @@ */ public void setBounds(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; + reshape (x, y, width, height); } /** @@ -333,7 +327,10 @@ */ public void reshape(int x, int y, int width, int height) { - setBounds(x, y, width, height); + this.x = x; + this.y = y; + this.width = width; + this.height = height; } /** @@ -360,8 +357,7 @@ */ public void setLocation(Point p) { - this.x = p.x; - this.y = p.y; + setLocation (p.x, p.y); } /** @@ -374,8 +370,7 @@ */ public void setLocation(int x, int y) { - this.x = x; - this.y = y; + move (x, y); } /** @@ -388,7 +383,8 @@ */ public void move(int x, int y) { - setLocation(x, y); + this.x = x; + this.y = y; } /** @@ -426,8 +422,7 @@ */ public void setSize(Dimension d) { - width = d.width; - height = d.height; + setSize (d.width, d.height); } /** @@ -439,8 +434,7 @@ */ public void setSize(int width, int height) { - this.width = width; - this.height = height; + resize (width, height); } /** @@ -452,7 +446,8 @@ */ public void resize(int width, int height) { - setSize(width, height); + this.width = width; + this.height = height; } /** @@ -469,9 +464,7 @@ */ public boolean contains(Point p) { - return width > 0 && height > 0 - && p.x >= x && p.x < x + width - && p.y >= y && p.y < y + height; + return contains (p.x, p.y); } /** @@ -487,9 +480,7 @@ */ public boolean contains(int x, int y) { - return width > 0 && height > 0 - && x >= this.x && x < this.x + width - && y >= this.y && y < this.y + height; + return inside (x, y); } /** @@ -504,9 +495,7 @@ */ public boolean contains(Rectangle r) { - return width > 0 && height > 0 && r.width > 0 && r.height > 0 - && r.x >= x && r.x + r.width <= x + width - && r.y >= y && r.y + r.height <= y + height; + return contains (r.x, r.y, r.width, r.height); } /** @@ -537,7 +526,9 @@ */ public boolean inside(int x, int y) { - return contains(x, y); + return width > 0 && height > 0 + && x >= this.x && x < this.x + width + && y >= this.y && y < this.y + height; } /** Index: java/awt/ScrollPane.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/ScrollPane.java,v retrieving revision 1.14 diff -u -r1.14 ScrollPane.java --- java/awt/ScrollPane.java 5 Jan 2004 21:35:32 -0000 1.14 +++ java/awt/ScrollPane.java 2 Feb 2004 17:41:48 -0000 @@ -446,10 +446,25 @@ public void doLayout() { - Component[] list = getComponents(); + layout (); +} + +/*************************************************************************/ + +/** + * Lays out this component. This consists of resizing the sole child + * component to its perferred size. + * + * @deprecated This method is deprecated in favor of + * doLayout(). + */ +public void +layout() +{ + Component[] list = getComponents (); if ((list != null) && (list.length > 0)) { - Dimension dim = list[0].getPreferredSize(); + Dimension dim = list[0].getPreferredSize (); Dimension vp = getViewportSize (); if (dim.width < vp.width) @@ -462,31 +477,16 @@ if (peer != null) peer.childResized (dim.width, dim.height); - list[0].resize (dim); + list[0].setSize (dim); - Point p = getScrollPosition(); + Point p = getScrollPosition (); if (p.x > dim.width) p.x = dim.width; if (p.y > dim.height) p.y = dim.height; - setScrollPosition(p); + setScrollPosition (p); } -} - -/*************************************************************************/ - -/** - * Lays out this component. This consists of resizing the sole child - * component to its perferred size. - * - * @deprecated This method is deprecated in favor of - * doLayout(). - */ -public void -layout() -{ - doLayout(); } /*************************************************************************/ Index: java/awt/Scrollbar.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/Scrollbar.java,v retrieving revision 1.15 diff -u -r1.15 Scrollbar.java --- java/awt/Scrollbar.java 5 Jun 2003 19:58:39 -0000 1.15 +++ java/awt/Scrollbar.java 2 Feb 2004 17:41:49 -0000 @@ -333,7 +333,7 @@ public int getVisibleAmount() { - return(visibleAmount); + return getVisible (); } /*************************************************************************/ @@ -350,7 +350,7 @@ public int getVisible() { - return(getVisibleAmount()); + return visibleAmount; } /*************************************************************************/ @@ -438,7 +438,7 @@ public int getUnitIncrement() { - return(lineIncrement); + return getLineIncrement (); } /*************************************************************************/ @@ -455,7 +455,7 @@ public int getLineIncrement() { - return(lineIncrement); + return lineIncrement; } /*************************************************************************/ @@ -469,26 +469,7 @@ public synchronized void setUnitIncrement(int unitIncrement) { - if (unitIncrement < 0) - throw new IllegalArgumentException("Unit increment less than zero."); - - int range = maximum - minimum; - if (unitIncrement > range) - { - if (range == 0) - unitIncrement = 1; - else - unitIncrement = range; - } - - if (unitIncrement == lineIncrement) - return; - - lineIncrement = unitIncrement; - - ScrollbarPeer sp = (ScrollbarPeer)getPeer(); - if (sp != null) - sp.setLineIncrement(lineIncrement); + setLineIncrement (unitIncrement); } /*************************************************************************/ @@ -505,7 +486,26 @@ public void setLineIncrement(int lineIncrement) { - setUnitIncrement(lineIncrement); + if (lineIncrement < 0) + throw new IllegalArgumentException ("Unit increment less than zero."); + + int range = maximum - minimum; + if (lineIncrement > range) + { + if (range == 0) + lineIncrement = 1; + else + lineIncrement = range; + } + + if (lineIncrement == this.lineIncrement) + return; + + this.lineIncrement = lineIncrement; + + ScrollbarPeer sp = (ScrollbarPeer) getPeer (); + if (sp != null) + sp.setLineIncrement (this.lineIncrement); } /*************************************************************************/ @@ -519,7 +519,7 @@ public int getBlockIncrement() { - return(pageIncrement); + return getPageIncrement (); } /*************************************************************************/ @@ -536,7 +536,7 @@ public int getPageIncrement() { - return(pageIncrement); + return pageIncrement; } /*************************************************************************/ @@ -550,26 +550,7 @@ public synchronized void setBlockIncrement(int blockIncrement) { - if (blockIncrement < 0) - throw new IllegalArgumentException("Block increment less than zero."); - - int range = maximum - minimum; - if (blockIncrement > range) - { - if (range == 0) - blockIncrement = 1; - else - blockIncrement = range; - } - - if (blockIncrement == pageIncrement) - return; - - pageIncrement = blockIncrement; - - ScrollbarPeer sp = (ScrollbarPeer)getPeer(); - if (sp != null) - sp.setPageIncrement(pageIncrement); + setPageIncrement (pageIncrement); } /*************************************************************************/ @@ -586,7 +567,26 @@ public void setPageIncrement(int pageIncrement) { - setBlockIncrement(pageIncrement); + if (pageIncrement < 0) + throw new IllegalArgumentException ("Block increment less than zero."); + + int range = maximum - minimum; + if (pageIncrement > range) + { + if (range == 0) + pageIncrement = 1; + else + pageIncrement = range; + } + + if (pageIncrement == this.pageIncrement) + return; + + this.pageIncrement = pageIncrement; + + ScrollbarPeer sp = (ScrollbarPeer) getPeer (); + if (sp != null) + sp.setPageIncrement (this.pageIncrement); } /*************************************************************************/ Index: java/awt/TextArea.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/TextArea.java,v retrieving revision 1.9 diff -u -r1.9 TextArea.java --- java/awt/TextArea.java 25 Jan 2004 18:36:04 -0000 1.9 +++ java/awt/TextArea.java 2 Feb 2004 17:41:49 -0000 @@ -288,13 +288,7 @@ */ public Dimension getMinimumSize (int rows, int columns) { - TextAreaPeer peer = (TextAreaPeer) getPeer (); - - // Sun returns Dimension (0,0) in this case. - if (peer == null) - return new Dimension (0, 0); - - return peer.getMinimumSize (rows, columns); + return minimumSize (rows, columns); } /** @@ -311,7 +305,7 @@ */ public Dimension minimumSize () { - return getMinimumSize (getRows (), getColumns ()); + return minimumSize (getRows (), getColumns ()); } /** @@ -333,7 +327,13 @@ */ public Dimension minimumSize (int rows, int columns) { - return getMinimumSize (rows, columns); + TextAreaPeer peer = (TextAreaPeer) getPeer (); + + // Sun returns Dimension (0,0) in this case. + if (peer == null) + return new Dimension (0, 0); + + return peer.getMinimumSize (rows, columns); } /** @@ -366,13 +366,7 @@ */ public Dimension getPreferredSize (int rows, int columns) { - TextAreaPeer peer = (TextAreaPeer) getPeer (); - - // Sun returns Dimension (0,0) in this case. - if (peer == null) - return new Dimension (0, 0); - - return peer.getPreferredSize (rows, columns); + return preferredSize (rows, columns); } /** @@ -389,7 +383,7 @@ */ public Dimension preferredSize () { - return getPreferredSize (getRows (), getColumns ()); + return preferredSize (getRows (), getColumns ()); } /** @@ -411,7 +405,13 @@ */ public Dimension preferredSize (int rows, int columns) { - return getPreferredSize (rows, columns); + TextAreaPeer peer = (TextAreaPeer) getPeer (); + + // Sun returns Dimension (0,0) in this case. + if (peer == null) + return new Dimension (0, 0); + + return peer.getPreferredSize (rows, columns); } /** @@ -440,59 +440,59 @@ /** * Append the specified text to the end of the current text. * - * @param text The text to append. + * @param str The text to append. */ public void append (String str) { - TextAreaPeer peer = (TextAreaPeer) getPeer (); - if (peer == null) - return; - - peer.insert (str, peer.getText().length ()); + appendText (str); } /** * Append the specified text to the end of the current text. * - * @param text The text to append. + * @param str The text to append. * * @deprecated This method is deprecated in favor of * append (). */ - public void appendText (String text) + public void appendText (String str) { - append (text); + TextAreaPeer peer = (TextAreaPeer) getPeer (); + if (peer == null) + return; + + peer.insert (str, peer.getText().length ()); } /** * Insert the specified text at the specified position. The first * character in the text area is at position zero. * - * @param text The text to insert. + * @param str The text to insert. * @param pos The position at which to insert text. */ - public void insert (String text, int pos) + public void insert (String str, int pos) { - TextAreaPeer peer = (TextAreaPeer) getPeer (); - if (peer == null) - return; - - peer.insert (text, pos); + insertText (str, pos); } /** * Insert the specified text at the specified position. The first * character in the text area is at position zero. * - * @param text The text to insert. + * @param str The text to insert. * @param pos The position at which to insert text. * - * @deprecated This method is depcreated in favor of + * @deprecated This method is deprecated in favor of * insert (). */ - public void insertText (String text, int pos) + public void insertText (String str, int pos) { - insert (text, pos); + TextAreaPeer peer = (TextAreaPeer) getPeer (); + if (peer == null) + return; + + peer.insert (str, pos); } /** @@ -503,17 +503,13 @@ * length of the replacement text may differ from the length of the * text that is replaced. * - * @param text The new text for the range. + * @param str The new text for the range. * @param start The start position of the replacement range. * @param end The end position of the replacement range. */ - public void replaceRange (String text, int start, int end) + public void replaceRange (String str, int start, int end) { - TextAreaPeer peer = (TextAreaPeer) getPeer (); - if (peer == null) - return; - - peer.replaceRange (text, start, end); + replaceText (str, start, end); } /** @@ -524,16 +520,20 @@ * length of the replacement text may differ from the length of the * text that is replaced. * - * @param text The new text for the range. + * @param str The new text for the range. * @param start The start position of the replacement range. * @param end The end position of the replacement range. * * @deprecated This method is deprecated in favor of * replaceRange (). */ - public void replaceText (String text, int start, int end) + public void replaceText (String str, int start, int end) { - replaceRange (text, start, end); + TextAreaPeer peer = (TextAreaPeer) getPeer (); + if (peer == null) + return; + + peer.replaceRange (str, start, end); } /** Index: java/awt/TextField.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/TextField.java,v retrieving revision 1.8 diff -u -r1.8 TextField.java --- java/awt/TextField.java 5 Jun 2003 19:58:39 -0000 1.8 +++ java/awt/TextField.java 2 Feb 2004 17:41:49 -0000 @@ -212,11 +212,7 @@ public void setEchoChar(char echoChar) { - this.echoChar = echoChar; - - TextFieldPeer tfp = (TextFieldPeer)getPeer(); - if (tfp != null) - tfp.setEchoChar(echoChar); + setEchoCharacter (echoChar); } /*************************************************************************/ @@ -233,7 +229,11 @@ public void setEchoCharacter(char echoChar) { - setEchoChar(echoChar); + this.echoChar = echoChar; + + TextFieldPeer peer = (TextFieldPeer) getPeer (); + if (peer != null) + peer.setEchoChar (echoChar); } /*************************************************************************/ @@ -264,7 +264,7 @@ public Dimension getMinimumSize() { - return(getMinimumSize(getColumns())); + return getMinimumSize (getColumns ()); } /*************************************************************************/ @@ -278,11 +278,7 @@ public Dimension getMinimumSize(int columns) { - TextFieldPeer tfp = (TextFieldPeer)getPeer(); - if (tfp == null) - return(null); // FIXME: What do we do if there is no peer? - - return(tfp.getMinimumSize(columns)); + return minimumSize (columns); } /*************************************************************************/ @@ -292,13 +288,13 @@ * * @return The minimum size for this text field. * - * @deprecated This method is depcreated in favor of + * @deprecated This method is deprecated in favor of * getMinimumSize(). */ public Dimension minimumSize() { - return(getMinimumSize(getColumns())); + return minimumSize (getColumns ()); } /*************************************************************************/ @@ -315,7 +311,11 @@ public Dimension minimumSize(int columns) { - return(getMinimumSize(columns)); + TextFieldPeer peer = (TextFieldPeer) getPeer (); + if (peer == null) + return null; // FIXME: What do we do if there is no peer? + + return peer.getMinimumSize (columns); } /*************************************************************************/ @@ -328,7 +328,7 @@ public Dimension getPreferredSize() { - return(getPreferredSize(getColumns())); + return getPreferredSize (getColumns ()); } /*************************************************************************/ @@ -342,12 +342,7 @@ public Dimension getPreferredSize(int columns) { - TextFieldPeer tfp = (TextFieldPeer)getPeer(); - if (tfp == null) - { - return new Dimension(0, 0); - } - return(tfp.getPreferredSize(columns)); + return preferredSize (columns); } /*************************************************************************/ @@ -363,7 +358,7 @@ public Dimension preferredSize() { - return(getPreferredSize(getColumns())); + return preferredSize (getColumns ()); } /*************************************************************************/ @@ -380,7 +375,11 @@ public Dimension preferredSize(int columns) { - return(getPreferredSize(columns)); + TextFieldPeer peer = (TextFieldPeer) getPeer (); + if (peer == null) + return new Dimension (0, 0); + + return peer.getPreferredSize (columns); } /*************************************************************************/ Index: java/awt/image/renderable/RenderContext.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/awt/image/renderable/RenderContext.java,v retrieving revision 1.1 diff -u -r1.1 RenderContext.java --- java/awt/image/renderable/RenderContext.java 9 Aug 2002 04:29:59 -0000 1.1 +++ java/awt/image/renderable/RenderContext.java 2 Feb 2004 17:41:49 -0000 @@ -87,24 +87,24 @@ public void preConcatenateTransform(AffineTransform pre) { - xform.preConcatenate(pre); + preConcetenateTransform (pre); } - /** @deprecated Sun can't spell concatenate */ + /** @deprecated */ public void preConcetenateTransform(AffineTransform pre) { - preConcetenateTransform(pre); + xform.preConcatenate (pre); } public void concatenateTransform(AffineTransform post) { - xform.concatenate(post); + concetenateTransform (post); } - /** @deprecated Sun can't spell concatenate */ + /** @deprecated */ public void concetenateTransform(AffineTransform post) { - concatenateTransform(post); + xform.concatenate (post); } public AffineTransform getTransform() Index: javax/swing/JApplet.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/javax/swing/JApplet.java,v retrieving revision 1.2 diff -u -r1.2 JApplet.java --- javax/swing/JApplet.java 11 Jun 2003 13:20:39 -0000 1.2 +++ javax/swing/JApplet.java 2 Feb 2004 17:41:50 -0000 @@ -80,7 +80,7 @@ public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); - System.out.println("JFrame.getPrefSize(): " + d + " , comp="+countComponents() + ", layout=" + getLayout()); + System.out.println("JFrame.getPrefSize(): " + d + " , comp="+ getComponentCount () + ", layout=" + getLayout()); return d; }