summaryrefslogtreecommitdiffstats
path: root/devel/charva
diff options
context:
space:
mode:
authorale <ale@FreeBSD.org>2007-01-29 08:53:12 +0000
committerale <ale@FreeBSD.org>2007-01-29 08:53:12 +0000
commit07cb4d4e6c325a0c5f8f575d3d58edc2ac230042 (patch)
tree3607dab9aa47f429420ba17a4f561bbd5bf20066 /devel/charva
parent624d7c4530d6fe63012ce5bedb27ed42bfba039d (diff)
downloadFreeBSD-ports-07cb4d4e6c325a0c5f8f575d3d58edc2ac230042.zip
FreeBSD-ports-07cb4d4e6c325a0c5f8f575d3d58edc2ac230042.tar.gz
- Add CardLayout and VerticalFlowLayout classes
- A lot of bug fixes Submitted by: Lapo Luchini <lapo@lapo.it>
Diffstat (limited to 'devel/charva')
-rw-r--r--devel/charva/Makefile2
-rw-r--r--devel/charva/files/patch-java_src_charva_awt_CardLayout.java118
-rw-r--r--devel/charva/files/patch-java_src_charva_awt_Component.java29
-rw-r--r--devel/charva/files/patch-java_src_charva_awt_Container.java100
-rw-r--r--devel/charva/files/patch-java_src_charva_awt_Toolkit.java113
-rw-r--r--devel/charva/files/patch-java_src_charva_awt_VerticalFlowLayout.java232
-rw-r--r--devel/charva/files/patch-java_src_charva_awt_Window.java56
-rw-r--r--devel/charva/files/patch-java_src_charva_awt_event_FocusAdapter.java20
-rw-r--r--devel/charva/files/patch-java_src_charvax_swing_AbstractButton.java90
-rw-r--r--devel/charva/files/patch-java_src_charvax_swing_ButtonGroup.java14
-rw-r--r--devel/charva/files/patch-java_src_charvax_swing_JLabel.java47
-rw-r--r--devel/charva/files/patch-java_src_charvax_swing_JPasswordField.java14
-rw-r--r--devel/charva/files/patch-java_src_charvax_swing_JTextArea.java40
-rw-r--r--devel/charva/files/patch-java_src_charvax_swing_JTextField.java43
-rw-r--r--devel/charva/files/patch-java_src_charvax_swing_text_JTextComponent.java28
15 files changed, 945 insertions, 1 deletions
diff --git a/devel/charva/Makefile b/devel/charva/Makefile
index da3e2a7..a9bf80e 100644
--- a/devel/charva/Makefile
+++ b/devel/charva/Makefile
@@ -7,7 +7,7 @@
PORTNAME= charva
PORTVERSION= 1.1.4
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= devel java
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE_EXTENDED}
MASTER_SITE_SUBDIR= ${PORTNAME}
diff --git a/devel/charva/files/patch-java_src_charva_awt_CardLayout.java b/devel/charva/files/patch-java_src_charva_awt_CardLayout.java
new file mode 100644
index 0000000..f6099f0
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charva_awt_CardLayout.java
@@ -0,0 +1,118 @@
+--- java/src/charva/awt/CardLayout.java.orig Mon Jan 29 09:39:30 2007
++++ java/src/charva/awt/CardLayout.java Mon Jan 29 09:39:30 2007
+@@ -0,0 +1,115 @@
++package charva.awt;
++
++import java.util.HashMap;
++
++/**
++ * Emulates @{java.awt.CardLayout}.
++ * @author lapo@lapo.it
++ */
++public class CardLayout implements LayoutManager2 {
++
++ protected HashMap names = new HashMap();
++ protected int current = -1;
++ protected int max = 0;
++
++ public void addLayoutComponent(Component component, Object constraints) {
++ if (!(constraints instanceof String))
++ throw new IllegalArgumentException("cannot add to layout: constraint must be a string");
++ String name = (String) constraints;
++ if ((max == 0) && (component.isVisible()))
++ current = 0;
++ if (max > 0)
++ component.setVisible(false); // initially only the first card may be visible
++ if (name != null)
++ names.put(name, Integer.valueOf(max));
++ ++max;
++ }
++
++ public void invalidateLayout(Container target) {
++ // this layout manager caches nothing
++ }
++
++ public Dimension minimumSize(Container container) {
++ Dimension min = new Dimension(0, 0);
++ for (int i = 0, j = container.getComponentCount(); i < j; ++i) {
++ Dimension t = container.getComponent(i).minimumSize();
++ if (t.width > min.width)
++ min.width = t.width;
++ if (t.height > min.height)
++ min.height = t.height;
++ }
++ Insets insets = container.getInsets();
++ min.width += insets.left + insets.right;
++ min.height += insets.top + insets.bottom;
++ return min;
++ }
++
++ public void doLayout(Container container) {
++ Dimension size = container.getSize();
++ Insets insets = container.getInsets();
++ Point cardOrigin = new Point(insets.left, insets.top);
++ Dimension cardSize = new Dimension(
++ size.width - (insets.left + insets.right),
++ size.height - (insets.top + insets.bottom));
++ for (int i = 0, j = container.getComponentCount(); i < j; ++i) {
++ Component c = container.getComponent(i);
++ c.setBounds(cardOrigin, cardSize);
++ if (c instanceof Container)
++ ((Container) c).doLayout();
++ }
++ }
++
++ /**
++ * Flips to the component with the given insertion index.
++ * If no such component exists, then nothing happens.
++ * @param container the parent container in which to do the layout
++ * @param index the component index
++ * @see charva.awt.CardLayout#addLayoutComponent(java.awt.Component, java.lang.Object)
++ */
++ public void show(Container container, int index) {
++ if ((index < 0) || (index >= max) || (index == current))
++ return;
++ for (int i = 0, j = container.getComponentCount(); i < j; ++i) {
++ Component c = container.getComponent(i);
++ if (c.isVisible())
++ c.setVisible(false);
++ }
++ current = index;
++ container.getComponent(index).setVisible(true);
++ container.getComponent(index).requestFocus();
++ container.validate();
++ }
++
++ /**
++ * Flips to the component that was added to this layout with the
++ * specified <code>name</code>, using <code>addLayoutComponent</code>.
++ * If no such component exists, then nothing happens.
++ * @param container the parent container in which to do the layout
++ * @param name the component name
++ * @see charva.awt.CardLayout#addLayoutComponent(java.awt.Component, java.lang.Object)
++ */
++ public void show(Container container, String name) {
++ Integer val = (Integer) names.get(name);
++ if (val != null)
++ show(container, val.intValue());
++ }
++
++ /**
++ * Flips to the first card of the container.
++ * @param container the parent container in which to do the layout
++ * @see charva.awt.CardLayout#last
++ */
++ public void first(Container container) {
++ show(container, 0);
++ }
++
++ /**
++ * Flips to the last card of the container.
++ * @param container the parent container in which to do the layout
++ * @see charva.awt.CardLayout#first
++ */
++ public void last(Container container) {
++ show(container, max - 1);
++ }
++
++}
diff --git a/devel/charva/files/patch-java_src_charva_awt_Component.java b/devel/charva/files/patch-java_src_charva_awt_Component.java
new file mode 100644
index 0000000..241cc07
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charva_awt_Component.java
@@ -0,0 +1,29 @@
+--- java/src/charva/awt/Component.java.orig Mon Aug 14 18:03:14 2006
++++ java/src/charva/awt/Component.java Mon Jan 29 09:39:30 2007
+@@ -118,6 +118,17 @@ public abstract class Component {
+ }
+
+ /**
++ * Determines whether this component will be displayed on the screen
++ * if it's displayable.
++ * @return <code>true</code> if the component and all of its ancestors
++ * are visible, <code>false</code> otherwise
++ */
++ public boolean isRecursivelyVisible() {
++ Container parent = getParent();
++ return _visible && (parent == null || parent.isRecursivelyVisible());
++ }
++
++ /**
+ * To be implemented by concrete subclasses.
+ */
+ public abstract void draw();
+@@ -449,7 +460,7 @@ public abstract class Component {
+ * traversal.
+ */
+ public boolean isFocusTraversable() {
+- return (_enabled && _visible);
++ return (_enabled && isRecursivelyVisible());
+ }
+
+ /**
diff --git a/devel/charva/files/patch-java_src_charva_awt_Container.java b/devel/charva/files/patch-java_src_charva_awt_Container.java
new file mode 100644
index 0000000..1c3f2d5
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charva_awt_Container.java
@@ -0,0 +1,100 @@
+--- java/src/charva/awt/Container.java.orig Mon Aug 7 12:07:52 2006
++++ java/src/charva/awt/Container.java Mon Jan 29 09:39:30 2007
+@@ -89,6 +89,23 @@ public abstract class Container
+ invalidate();
+ }
+
++ public void setBounds(int top_, int left_, int bottom_, int right_) {
++ super.setBounds(top_, left_, bottom_, right_);
++ setSize(right_ - left_ + 1, bottom_ - top_ + 1);
++ }
++
++ public void setBounds(Point topleft_, Dimension size_) {
++ super.setBounds(topleft_, size_);
++ setSize(size_);
++ }
++
++ public void setBounds(Rectangle bounds) {
++ super.setBounds(bounds);
++ setSize(
++ bounds.getRight() - bounds.getLeft() + 1,
++ bounds.getBottom() - bounds.getTop() + 1);
++ }
++
+ public Dimension minimumSize() {
+ if (_layoutMgr == null)
+ return _size;
+@@ -105,13 +122,30 @@ public abstract class Container
+ return (Component) _components.elementAt(n);
+ }
+
++ protected Component getComponentAt(int x, int y, boolean checkVisibility) {
++ Enumeration e = _components.elements();
++ while (e.hasMoreElements()) {
++ Component c = (Component) e.nextElement();
++ if ((!checkVisibility || c.isVisible()) && c.contains(x, y)) {
++ if (c instanceof Container) {
++ // Calculate the coordinates of the point relative
++ // to the origin of the container
++ Point origin = c.getLocation();
++ return ((Container) c).getComponentAt(x - origin.x, y - origin.y, checkVisibility);
++ } else
++ return c;
++ }
++ }
++ return null;
++ }
++
+ /**
+ * Returns the component that contains the specified point, or null
+ * if no component contains the point. The x and y coordinates of
+ * the point are relative to the origin of this container.
+ */
+ public Component getComponentAt(Point p) {
+- return getComponentAt(p.x, p.y);
++ return getComponentAt(p.x, p.y, false);
+ }
+
+ /**
+@@ -120,20 +154,27 @@ public abstract class Container
+ * the point are relative to the origin of this container.
+ */
+ public Component getComponentAt(int x, int y) {
+- Enumeration e = _components.elements();
+- while (e.hasMoreElements()) {
+- Component c = (Component) e.nextElement();
+- if (c.contains(x, y)) {
+- if (c instanceof Container) {
+- // Calculate the coordinates of the point relative
+- // to the origin of the container
+- Point origin = c.getLocation();
+- return ((Container) c).getComponentAt(x - origin.x, y - origin.y);
+- } else
+- return c;
+- }
+- }
+- return null;
++ return getComponentAt(x, y, false);
++ }
++
++ /**
++ * Returns the visible component that contains the specified point,
++ * or null if no visible component contains the point. The x and y
++ * coordinates of the point are relative to the origin of this container.
++ */
++ public final Component findComponentAt(Point p) {
++ return findComponentAt(p.x, p.y);
++ }
++
++ /**
++ * Returns the visible component that contains the specified point,
++ * or null if no visible component contains the point. The x and y
++ * coordinates of the point are relative to the origin of this container.
++ */
++ public final Component findComponentAt(int x, int y) {
++ if (!isRecursivelyVisible())
++ return null;
++ return(getComponentAt(x, y, true));
+ }
+
+ /**
diff --git a/devel/charva/files/patch-java_src_charva_awt_Toolkit.java b/devel/charva/files/patch-java_src_charva_awt_Toolkit.java
new file mode 100644
index 0000000..99317c2
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charva_awt_Toolkit.java
@@ -0,0 +1,113 @@
+--- java/src/charva/awt/Toolkit.java.orig Mon Aug 14 20:59:42 2006
++++ java/src/charva/awt/Toolkit.java Mon Jan 29 09:39:30 2007
+@@ -157,13 +157,9 @@ public class Toolkit {
+ * key as defined in the "VK_*" values.
+ */
+ public void fireKeystroke(int key_, Component source_) {
+- int id;
+- if (Toolkit.isActionKey(key_))
+- id = AWTEvent.KEY_TYPED;
+- else
+- id = AWTEvent.KEY_PRESSED;
+-
+- _evtQueue.postEvent(new KeyEvent(key_, id, source_));
++ _evtQueue.postEvent(new KeyEvent(key_, AWTEvent.KEY_PRESSED, source_));
++ if (!Toolkit.isActionKey(key_))
++ _evtQueue.postEvent(new KeyEvent(key_, AWTEvent.KEY_TYPED, source_));
+ }
+
+ public FocusEvent getLastFocusEvent() {
+@@ -225,7 +221,7 @@ public class Toolkit {
+ _lastMousePressTime = System.currentTimeMillis();
+
+ Component component =
+- top_window.getComponentAt(x - origin.x, y - origin.y);
++ top_window.findComponentAt(x - origin.x, y - origin.y);
+
+ if (component != null) {
+ _evtQueue.postEvent(new MouseEvent(component, modifiers, x, y, 0, button));
+@@ -796,43 +792,47 @@ public class Toolkit {
+ //public boolean isActionKey() { return (_key >= 256); }
+ public static boolean isActionKey( int _key )
+ {
+- boolean value = false;
+- if ( _key == charva.awt.event.KeyEvent.VK_ESCAPE ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_DOWN ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_UP ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_LEFT ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_RIGHT ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_HOME ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_BACK_SPACE ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F1 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F2 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F3 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F4 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F5 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F6 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F7 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F8 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F9 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F10 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F11 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F12 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F13 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F14 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F15 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F16 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F17 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F18 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F19 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_F20 ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_DELETE ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_INSERT ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_PAGE_DOWN ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_PAGE_UP ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_ENTER ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_BACK_TAB ) value=true;
+- if ( _key == charva.awt.event.KeyEvent.VK_END ) value=true;
+-
+- return (value);
++ switch (_key) {
++ case charva.awt.event.KeyEvent.VK_ESCAPE:
++ case charva.awt.event.KeyEvent.VK_DOWN:
++ case charva.awt.event.KeyEvent.VK_UP:
++ case charva.awt.event.KeyEvent.VK_LEFT:
++ case charva.awt.event.KeyEvent.VK_RIGHT:
++ case charva.awt.event.KeyEvent.VK_HOME:
++ case charva.awt.event.KeyEvent.VK_BACK_SPACE:
++ case charva.awt.event.KeyEvent.VK_F1:
++ case charva.awt.event.KeyEvent.VK_F2:
++ case charva.awt.event.KeyEvent.VK_F3:
++ case charva.awt.event.KeyEvent.VK_F4:
++ case charva.awt.event.KeyEvent.VK_F5:
++ case charva.awt.event.KeyEvent.VK_F6:
++ case charva.awt.event.KeyEvent.VK_F7:
++ case charva.awt.event.KeyEvent.VK_F8:
++ case charva.awt.event.KeyEvent.VK_F9:
++ case charva.awt.event.KeyEvent.VK_F10:
++ case charva.awt.event.KeyEvent.VK_F11:
++ case charva.awt.event.KeyEvent.VK_F12:
++ case charva.awt.event.KeyEvent.VK_F13:
++ case charva.awt.event.KeyEvent.VK_F14:
++ case charva.awt.event.KeyEvent.VK_F15:
++ case charva.awt.event.KeyEvent.VK_F16:
++ case charva.awt.event.KeyEvent.VK_F17:
++ case charva.awt.event.KeyEvent.VK_F18:
++ case charva.awt.event.KeyEvent.VK_F19:
++ case charva.awt.event.KeyEvent.VK_F20:
++ case charva.awt.event.KeyEvent.VK_DELETE:
++ case charva.awt.event.KeyEvent.VK_INSERT:
++ case charva.awt.event.KeyEvent.VK_PAGE_DOWN:
++ case charva.awt.event.KeyEvent.VK_PAGE_UP:
++ case charva.awt.event.KeyEvent.VK_ENTER:
++ case charva.awt.event.KeyEvent.VK_BACK_TAB:
++ case charva.awt.event.KeyEvent.VK_END:
++ return true;
++ default:
++ if ( _key < 32 )
++ return true;
++ return false;
++ }
+ }
+
+ //====================================================================
diff --git a/devel/charva/files/patch-java_src_charva_awt_VerticalFlowLayout.java b/devel/charva/files/patch-java_src_charva_awt_VerticalFlowLayout.java
new file mode 100644
index 0000000..46dddb4
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charva_awt_VerticalFlowLayout.java
@@ -0,0 +1,232 @@
+--- java/src/charva/awt/VerticalFlowLayout.java.orig Mon Jan 29 09:39:30 2007
++++ java/src/charva/awt/VerticalFlowLayout.java Mon Jan 29 09:39:30 2007
+@@ -0,0 +1,229 @@
++/* class FlowLayout
++ *
++ * Copyright (C) 2001 R M Pitman
++ * Copyright (C) 2007 Lapo Luchini
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ */
++
++package charva.awt;
++
++import java.util.Enumeration;
++import java.util.Vector;
++
++/**
++ * A concrete implementation of LayoutManager that lays out its
++ * components top-to-bottom.
++ */
++public class VerticalFlowLayout
++ implements LayoutManager {
++ /**
++ * Default constructor. Sets alignment to MIDDLE, hgap to 1,
++ * and vgap to 0.
++ */
++ public VerticalFlowLayout() {
++ this(MIDDLE, 1, 0);
++ }
++
++ /**
++ * Use this constructor when you want to set the alignment and the
++ * horizontal and vertical gaps.
++ */
++ public VerticalFlowLayout(int align_, int hgap_, int vgap_) {
++ _align = align_;
++ _hgap = hgap_;
++ _vgap = vgap_;
++ }
++
++ /**
++ * Sets the alignment for this layout. Allowable values are
++ * VerticalFlowLayout.TOP, VerticalFlowLayout.MIDDLE and
++ * VerticalFlowLayout.BOTTOM.
++ */
++ public void setAlignment(int align_) {
++ _align = align_;
++ }
++
++ /**
++ * Gets the alignment for this layout.
++ */
++ public int getAlignment() {
++ return _align;
++ }
++
++ /**
++ * Calculate the minimum-size rectangle that can enclose all the
++ * components in the given container.
++ */
++ public Dimension minimumSize(Container container_) {
++
++ int width = 0;
++ int height = 0;
++
++ Component[] components = container_.getComponents();
++ for (int i = 0; i < components.length; i++) {
++ Dimension d = components[i].minimumSize();
++
++ /* Make allowance for the gap between this component and the
++ * previous component.
++ */
++ if (i != 0)
++ height += _vgap;
++
++ height += d.height;
++ if (d.width > width)
++ width = d.width;
++ }
++
++ /* Take into account the border frame (if any).
++ */
++ Insets insets = container_.getInsets();
++ height += insets.top + insets.bottom;
++ width += insets.left + insets.right;
++
++ return new Dimension(width, height);
++ }
++
++ /**
++ * Lay out the components according to the specified alignment, hgap
++ * and vgap.
++ * This is called when the size of the container has already been
++ * calculated.
++ * It lays out the components in a column, one at a time, until it
++ * determines that there is not enough space left in the column.
++ * Then it moves to the next row. If there is not enough horizontal
++ * space in the container to lay out all of the components, it
++ * removes the remaining components from the container; they don't
++ * appear at all.
++ */
++ public void doLayout(Container container_) {
++
++ Insets insets = container_.getInsets();
++ int availableHeight = container_.getSize().height -
++ insets.top - insets.bottom;
++ int heightLeft = availableHeight;
++ int widthLeft = container_.getSize().width -
++ insets.left - insets.right;
++
++ int hoffset = insets.left;
++
++ Component[] components = container_.getComponents();
++ Vector localvector = new Vector();
++ for (int i = 0; i < components.length; i++) {
++ Component c = components[i];
++
++ /* Get the contained container to lay itself out at its
++ * preferred size, if it is not already laid out.
++ */
++ if (c instanceof Container) {
++ Container cont = (Container) c;
++ if (cont.isValid() == false) {
++ cont.setSize(cont.minimumSize());
++ cont.doLayout();
++ }
++ }
++
++ /* Determine the width required to lay out the current
++ * component (including the gap between this component and
++ * the previous component).
++ */
++ int requiredHeight = c.getSize().height;
++ if (i != 0)
++ requiredHeight += _vgap;
++
++ if (requiredHeight > heightLeft) {
++ int columnWidth = 0;
++ if (localvector.size() != 0) {
++ columnWidth = layoutColumn(container_, localvector,
++ widthLeft, heightLeft, hoffset);
++ localvector.removeAllElements();
++ }
++ hoffset += columnWidth + _hgap;
++ heightLeft = availableHeight;
++ widthLeft -= columnWidth + _hgap;
++ }
++ heightLeft -= requiredHeight;
++
++ // Build up a temporary list of components for this row.
++ localvector.add(c);
++ }
++ layoutColumn(container_, localvector, widthLeft, heightLeft, hoffset);
++
++ }
++
++ /**
++ * private function to layout a single column of components.
++ *
++ * @return The height of the laid-out column.
++ */
++ private int layoutColumn(Container container_, Vector components_,
++ int widthleft_, int heightleft_, int hoffset_) {
++
++ int voffset = 0;
++ int columnWidth = 0;
++ Insets insets = container_.getInsets();
++
++ switch (_align) {
++ case TOP:
++ voffset = insets.top;
++ break;
++ case MIDDLE:
++ voffset = insets.top + heightleft_ / 2;
++ break;
++ case BOTTOM:
++ voffset = insets.top + heightleft_;
++ break;
++ }
++
++ Enumeration e = components_.elements();
++ while (e.hasMoreElements()) {
++ Component c = (Component) e.nextElement();
++ if (c.getSize().width > columnWidth)
++ columnWidth = c.getSize().width;
++
++ if (columnWidth > widthleft_) {
++ container_.remove(c); // we have run out of space
++ continue;
++ }
++
++ c.setLocation(hoffset_, voffset);
++ voffset += c.getSize().height + _vgap;
++ }
++ return columnWidth;
++ }
++
++ //====================================================================
++ // INSTANCE VARIABLES
++
++ /**
++ * Alignment of components (TOP, BOTTOM or MIDDLE)
++ */
++ private int _align = MIDDLE;
++
++ /**
++ * Horizontal gap between components
++ */
++ private int _hgap = 1;
++
++ /**
++ * Vertical gap between components
++ */
++ private int _vgap = 0;
++
++ public static final int TOP = 1;
++ public static final int MIDDLE = 2;
++ public static final int BOTTOM = 3;
++
++}
diff --git a/devel/charva/files/patch-java_src_charva_awt_Window.java b/devel/charva/files/patch-java_src_charva_awt_Window.java
new file mode 100644
index 0000000..41f18aa
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charva_awt_Window.java
@@ -0,0 +1,56 @@
+--- java/src/charva/awt/Window.java.orig Mon Aug 14 17:38:56 2006
++++ java/src/charva/awt/Window.java Mon Jan 29 09:39:30 2007
+@@ -156,13 +156,21 @@ public class Window
+ */
+ SyncQueue.getInstance().postEvent(new SyncEvent(this));
+
+- if (_dispatchThreadRunning)
+- run();
+- else {
+- _dispatchThreadRunning = true;
+- Thread dispatchThread = new Thread(this);
+- dispatchThread.setName("event dispatcher");
+- dispatchThread.start();
++ if (_dispatchThread != null) {
++ if (Thread.currentThread() == _dispatchThread) {
++ // we are in the EDT, we must manage events
++ run();
++ } else {
++ // we are not the EDT, let's wait for him to ask us to close
++ synchronized (this) {
++ while (!_windowClosed)
++ try { wait(); } catch (InterruptedException e) { }
++ }
++ }
++ } else {
++ _dispatchThread = new Thread(this);
++ _dispatchThread.setName("event dispatcher");
++ _dispatchThread.start();
+
+ /* If "charva.script.playback" is defined, we start up
+ * a thread for playing back the script. Keys from both the
+@@ -270,7 +278,10 @@ public class Window
+ */
+ if (we.getID() == AWTEvent.WINDOW_CLOSING) {
+
+- we.getWindow()._windowClosed = true;
++ synchronized (we.getWindow()) {
++ we.getWindow()._windowClosed = true;
++ we.getWindow().notify();
++ }
+
+ /* Remove this window from the list of those displayed,
+ * and blank out the screen area where the window was
+@@ -407,10 +418,10 @@ public class Window
+
+ private Window _owner;
+ protected Toolkit _term;
+- private boolean _windowClosed = false;
++ private volatile boolean _windowClosed = false;
+
+ private Vector _windowListeners = null;
+
+- private static boolean _dispatchThreadRunning = false;
++ private static Thread _dispatchThread = null;
+
+ }
diff --git a/devel/charva/files/patch-java_src_charva_awt_event_FocusAdapter.java b/devel/charva/files/patch-java_src_charva_awt_event_FocusAdapter.java
new file mode 100644
index 0000000..5635c2e
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charva_awt_event_FocusAdapter.java
@@ -0,0 +1,20 @@
+--- java/src/charva/awt/event/FocusAdapter.java.orig Mon Jan 29 09:39:30 2007
++++ java/src/charva/awt/event/FocusAdapter.java Mon Jan 29 09:39:30 2007
+@@ -0,0 +1,17 @@
++package charva.awt.event;
++
++/**
++ * An abstract class for receiving key events. The methods provided in this
++ * class are empty; the class is provided as a convenience for implementing
++ * the KeyListener interface. You only have to implement the methods you
++ * are interested in.
++ */
++public abstract class FocusAdapter implements FocusListener {
++
++ public void focusGained(FocusEvent fe) {
++ }
++
++ public void focusLost(FocusEvent fe) {
++ }
++
++}
diff --git a/devel/charva/files/patch-java_src_charvax_swing_AbstractButton.java b/devel/charva/files/patch-java_src_charvax_swing_AbstractButton.java
new file mode 100644
index 0000000..ecc8db0
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charvax_swing_AbstractButton.java
@@ -0,0 +1,90 @@
+--- java/src/charvax/swing/AbstractButton.java.orig Sat Dec 17 15:27:30 2005
++++ java/src/charvax/swing/AbstractButton.java Mon Jan 29 09:39:30 2007
+@@ -19,15 +19,16 @@
+
+ package charvax.swing;
+
++import java.util.Enumeration;
++import java.util.Vector;
++
++import charva.awt.Container;
+ import charva.awt.EventQueue;
+ import charva.awt.ItemSelectable;
+ import charva.awt.Toolkit;
+ import charva.awt.Window;
+ import charva.awt.event.*;
+
+-import java.util.Enumeration;
+-import java.util.Vector;
+-
+ /**
+ * This forms the base class for components that exhibit button-like
+ * behavior.
+@@ -50,6 +51,12 @@ public abstract class AbstractButton
+ _label = label_;
+ }
+
++ protected void addKeyListenerToAncestor() {
++ Window ancestor = super.getAncestorWindow();
++ if (ancestor != null)
++ ancestor.addKeyListener(this);
++ }
++
+ /**
+ * Set the button's mnemonic character.
+ * The mnemonic is the key which will activate this button if focus
+@@ -76,10 +83,16 @@ public abstract class AbstractButton
+ */
+ public void setMnemonic(int mnemonic_) {
+ _mnemonic = mnemonic_;
+- Window ancestor = super.getAncestorWindow();
+- if (ancestor != null) {
+- ancestor.addKeyListener(this);
+- }
++ addKeyListenerToAncestor();
++ }
++
++ public void setParent(Container container_) {
++ if ((_mnemonic != 0) && (_parent != null) && (_parent.get() != null))
++ throw new RuntimeException("Removal from previous parent currently not implemented");
++ //removeKeyListenerFromAncestor();
++ super.setParent(container_);
++ if (_mnemonic != 0)
++ addKeyListenerToAncestor();
+ }
+
+ /**
+@@ -237,24 +250,23 @@ public abstract class AbstractButton
+ * character or a function key or cursor key was typed.
+ */
+ public void keyPressed(KeyEvent ke_) {
+- if (ke_.getKeyCode() == getMnemonic()) {
++ int code = ke_.getKeyCode();
++ int mnem = getMnemonic();
++ if (!ke_.isActionKey()) {
++ code = Character.toLowerCase(code);
++ mnem = Character.toLowerCase(mnem);
++ }
++ if (code == mnem) {
+ doClick();
+ ke_.consume();
+ }
+ }
+
+ /**
+- * Implements the KeyListener interface; this is called if a printable
+- * (ASCII or ISO8859-1) character was typed.
++ * Implements the KeyListener interface; this is called only if a
++ * printable (ASCII or ISO8859-1) character was typed.
+ */
+ public void keyTyped(KeyEvent ke_) {
+- // We must accept either uppercase or lowercase mnemonic characters.
+- char keyLower = Character.toLowerCase((char) ke_.getKeyChar());
+- char mnemonicLower = Character.toLowerCase((char) getMnemonic());
+- if (keyLower == mnemonicLower) {
+- doClick();
+- ke_.consume();
+- }
+ }
+
+ /**
diff --git a/devel/charva/files/patch-java_src_charvax_swing_ButtonGroup.java b/devel/charva/files/patch-java_src_charvax_swing_ButtonGroup.java
new file mode 100644
index 0000000..051e756
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charvax_swing_ButtonGroup.java
@@ -0,0 +1,14 @@
+--- java/src/charvax/swing/ButtonGroup.java.orig Sat Dec 17 15:27:30 2005
++++ java/src/charvax/swing/ButtonGroup.java Mon Jan 29 09:39:30 2007
+@@ -63,9 +63,10 @@ public class ButtonGroup
+ * Adds the specified button to the group.
+ */
+ public void add(AbstractButton button_) {
++ if (getSelection() != null)
++ button_.setSelected(false);
+ _buttons.add(button_);
+ button_.addItemListener(this);
+- button_.setSelected(false);
+ }
+
+ /**
diff --git a/devel/charva/files/patch-java_src_charvax_swing_JLabel.java b/devel/charva/files/patch-java_src_charvax_swing_JLabel.java
new file mode 100644
index 0000000..8abd344b
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charvax_swing_JLabel.java
@@ -0,0 +1,47 @@
+--- java/src/charvax/swing/JLabel.java.orig Sat Dec 17 15:27:30 2005
++++ java/src/charvax/swing/JLabel.java Mon Jan 29 09:39:30 2007
+@@ -20,6 +20,7 @@
+ package charvax.swing;
+
+ import charva.awt.Dimension;
++import charva.awt.Font;
+ import charva.awt.Insets;
+ import charva.awt.Point;
+ import charva.awt.Toolkit;
+@@ -79,6 +80,10 @@ public class JLabel
+ // Draw the border if it exists
+ super.draw();
+
++ int attrib = 0;
++ if (_bold)
++ attrib |= Toolkit.A_BOLD;
++
+ /* Get the absolute origin of this component.
+ */
+ Point origin = getLocationOnScreen();
+@@ -98,7 +103,7 @@ public class JLabel
+ buf.setLength(_width); // truncate
+
+ int colorpair = getCursesColor();
+- term.addString(buf.toString(), 0, colorpair);
++ term.addString(buf.toString(), attrib, colorpair);
+ }
+
+ /**
+@@ -169,10 +174,16 @@ public class JLabel
+ return "JLabel: [" + getText() + "]";
+ }
+
++ public void setFont(Font font_) {
++ _bold = ((font_.getStyle() & Font.BOLD) != 0);
++ }
++
+ //====================================================================
+ // INSTANCE VARIABLES
+
+ private String _labeltext;
+ private int _width;
++
++ protected boolean _bold = false;
+
+ }
diff --git a/devel/charva/files/patch-java_src_charvax_swing_JPasswordField.java b/devel/charva/files/patch-java_src_charvax_swing_JPasswordField.java
new file mode 100644
index 0000000..5da15a4
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charvax_swing_JPasswordField.java
@@ -0,0 +1,14 @@
+--- java/src/charvax/swing/JPasswordField.java.orig Sat Dec 17 15:27:30 2005
++++ java/src/charvax/swing/JPasswordField.java Mon Jan 29 09:39:30 2007
+@@ -133,8 +133,10 @@ public class JPasswordField
+ * UNDERLINE attribute.
+ */
+ int attrib = 0;
+- if (super._enabled)
++ if (_enabled)
+ attrib |= Toolkit.A_UNDERLINE;
++ if (_bold)
++ attrib |= Toolkit.A_BOLD;
+
+ term.setCursor(origin);
+ term.addString(_padding, attrib, colorpair);
diff --git a/devel/charva/files/patch-java_src_charvax_swing_JTextArea.java b/devel/charva/files/patch-java_src_charvax_swing_JTextArea.java
new file mode 100644
index 0000000..e81f770
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charvax_swing_JTextArea.java
@@ -0,0 +1,40 @@
+--- java/src/charvax/swing/JTextArea.java.orig Fri Dec 30 16:14:22 2005
++++ java/src/charvax/swing/JTextArea.java Mon Jan 29 09:39:30 2007
+@@ -412,6 +412,10 @@ public class JTextArea
+ Point tempCaret = null;
+ Point caret = _caret;
+
++ int attrib = 0;
++ if (_bold)
++ attrib |= Toolkit.A_BOLD;
++
+ /* Get the absolute origin of this component.
+ */
+ Point origin = getLocationOnScreen();
+@@ -458,7 +462,7 @@ public class JTextArea
+ _rows++;
+ term.setCursor(origin.addOffset(col, row));
+ } else {
+- term.addChar(chr, 0, colorpair);
++ term.addChar(chr, attrib, colorpair);
+ col++;
+ }
+ } else { // We have reached the right-hand column.
+@@ -470,7 +474,7 @@ public class JTextArea
+ _rows++;
+ term.setCursor(origin.addOffset(col, row));
+ } else {
+- term.addChar(chr, 0, colorpair);
++ term.addChar(chr, attrib, colorpair);
+ col++;
+ _columns++;
+ }
+@@ -482,7 +486,7 @@ public class JTextArea
+ _rows++;
+ term.setCursor(origin.addOffset(col, row));
+ if (chr != '\n') // thanks to Chris Rogers for this
+- term.addChar(chr, 0, colorpair);
++ term.addChar(chr, attrib, colorpair);
+ } else {
+ /* We must back-track until we get to whitespace, so
+ * that we can move the word to the next line.
diff --git a/devel/charva/files/patch-java_src_charvax_swing_JTextField.java b/devel/charva/files/patch-java_src_charvax_swing_JTextField.java
new file mode 100644
index 0000000..f687815
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charvax_swing_JTextField.java
@@ -0,0 +1,43 @@
+--- java/src/charvax/swing/JTextField.java.orig Fri Dec 30 16:15:12 2005
++++ java/src/charvax/swing/JTextField.java Mon Jan 29 09:39:30 2007
+@@ -118,11 +118,6 @@ public class JTextField
+ return _columns;
+ }
+
+- public void setFont(Font font_) {
+- _bold = ((font_.getStyle() & Font.BOLD) != 0);
+- }
+-
+-
+ /**
+ * Set the action command
+ */
+@@ -189,9 +184,8 @@ public class JTextField
+ * UNDERLINE attribute.
+ */
+ int attrib = 0;
+- if (super._enabled)
++ if (_enabled)
+ attrib |= Toolkit.A_UNDERLINE;
+-
+ if (_bold)
+ attrib |= Toolkit.A_BOLD;
+
+@@ -247,7 +241,7 @@ public class JTextField
+
+ /*
+ */
+- if (ke_.isActionKey() == false) {
++ if (!ke_.isActionKey() && (ke_.getID() == KeyEvent.KEY_TYPED)) {
+
+ /* If it is a control character, ignore it.
+ * @todo Do something more useful with control chars.
+@@ -414,8 +408,6 @@ public class JTextField
+
+ //====================================================================
+ // INSTANCE VARIABLES
+-
+- protected boolean _bold = false;
+
+ protected int _columns;
+
diff --git a/devel/charva/files/patch-java_src_charvax_swing_text_JTextComponent.java b/devel/charva/files/patch-java_src_charvax_swing_text_JTextComponent.java
new file mode 100644
index 0000000..eadcdd1
--- /dev/null
+++ b/devel/charva/files/patch-java_src_charvax_swing_text_JTextComponent.java
@@ -0,0 +1,28 @@
+--- java/src/charvax/swing/text/JTextComponent.java.orig Sat Dec 17 15:27:30 2005
++++ java/src/charvax/swing/text/JTextComponent.java Mon Jan 29 09:39:30 2007
+@@ -19,6 +19,7 @@
+
+ package charvax.swing.text;
+
++import charva.awt.Font;
+ import charvax.swing.JComponent;
+
+ /**
+@@ -72,6 +73,10 @@ public abstract class JTextComponent
+ _editable = editable_;
+ }
+
++ public void setFont(Font font_) {
++ _bold = ((font_.getStyle() & Font.BOLD) != 0);
++ }
++
+ //====================================================================
+ // INSTANCE VARIABLES
+
+@@ -84,4 +89,6 @@ public abstract class JTextComponent
+ protected StringBuffer _document;
+
+ protected boolean _editable = true;
++
++ protected boolean _bold = false;
+ }
OpenPOWER on IntegriCloud