This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui] Patch: javax.swing.text - test ui


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I just commited the attached patch to implement some more text UI 
stuff. Its get complete soon.


Michael


2004-06-23  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicTextUI.java
	(installUI): Call specialized install methods.
	(installDefaults): New method.
	(installListeners): Likewise.
	(installKeyboardActions): Likewise.
	(uninstallUI): Likewise.
	(uninstallDefaults): New method.
	(uninstallListeners): Likewise.
	(uninstallKeyboardActions): Likewise.
	(getPropertyPrefix): New abstract method.
	(paint): Made final, just call paintSafely().
	(paintSavely): New method.
	(paintBackground): Likewise.
	(getVisibleEditorRect): Likewise.
	* javax/swing/text/LayeredHighlighter.java,
	javax/swing/text/TabExpander.java: New files.
	* Makefile.am: Added javax/swing/text/LayeredHighlighter.java
	and javax/swing/text/TabExpander.java.
	* Makefile.in: Regenerated.
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA2YKmWSOgCCdjSDsRAjBCAKCBviTeuPhHc3NLAYEylPiOYzE7fwCgoMiO
/+rBTuFI5vm6y8HeTm6XJi4=
=8mP5
-----END PGP SIGNATURE-----
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.4.16.2
diff -u -b -B -r1.4.16.2 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java	23 Jun 2004 09:01:37 -0000	1.4.16.2
+++ javax/swing/plaf/basic/BasicTextUI.java	23 Jun 2004 13:08:46 -0000
@@ -41,6 +41,7 @@
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Insets;
 import java.awt.Point;
 import java.awt.Rectangle;
 
@@ -54,6 +55,7 @@
 import javax.swing.text.DefaultEditorKit;
 import javax.swing.text.EditorKit;
 import javax.swing.text.Element;
+import javax.swing.text.Highlighter;
 import javax.swing.text.JTextComponent;
 import javax.swing.text.Position;
 import javax.swing.text.View;
@@ -95,8 +97,48 @@
     super.installUI(c);
 
     textComponent = (JTextComponent) c;
+    
+    installDefaults();
+    installListeners();
+    installKeyboardActions();
+  }
+
+  protected void installDefaults()
+  {
+  }
+
+  protected void installListeners()
+  {
+  }
+
+  protected void installKeyboardActions()
+  {
+  }
+  
+  public void uninstallUI(final JComponent c)
+  {
+    super.uninstallUI(c);
+    view = null;
+
+    uninstallDefaults();
+    uninstallListeners();
+    uninstallKeyboardActions();
+  }
+
+  protected void uninstallDefaults()
+  {
+  }
+
+  protected void uninstallListeners()
+  {
   }
 
+  protected void uninstallKeyboardActions()
+  {
+  }
+  
+  protected abstract String getPropertyPrefix();
+
   public Dimension getPreferredSize(JComponent c)
   {
     View v = getRootView(textComponent);
@@ -107,9 +149,32 @@
     return new Dimension((int) w, (int) h);
   }
 
-  public void paint(Graphics g, JComponent c)
+  public final void paint(Graphics g, JComponent c)
+  {
+    paintSafely(g);
+  }
+
+  protected void paintSafely(Graphics g)
+  {
+    Caret caret = textComponent.getCaret();
+    Highlighter highlighter = textComponent.getHighlighter();
+    
+    if (textComponent.isOpaque())
+      paintBackground(g);
+    
+    view.paint(g, getVisibleEditorRect());
+
+    if (highlighter != null)
+      highlighter.paint(g);
+
+    if (caret != null)
+      caret.paint(g);
+  }
+
+  protected void paintBackground(Graphics g)
   {
-    //	view.paint(
+    g.setColor(Color.WHITE); // FIXME: set background color
+    g.fillRect(0, 0, textComponent.getWidth(), textComponent.getHeight());
   }
 
   public void damageRange(JTextComponent t, int p0, int p1)
@@ -174,6 +239,20 @@
     return null;
   }
 
+  protected Rectangle getVisibleEditorRect()
+  {
+    int width = textComponent.getWidth();
+    int height = textComponent.getHeight();
+
+    if (width <= 0 || height <= 0)
+      return null;
+	
+    Insets insets = textComponent.getInsets();
+    return new Rectangle(insets.left, insets.top,
+			 width - insets.left + insets.right,
+			 height - insets.top + insets.bottom);
+  }
+
   protected final void setView(View v)
   {
     view = v;
Index: javax/swing/text/LayeredHighlighter.java
===================================================================
RCS file: javax/swing/text/LayeredHighlighter.java
diff -N javax/swing/text/LayeredHighlighter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ javax/swing/text/LayeredHighlighter.java	23 Jun 2004 13:08:46 -0000
@@ -0,0 +1,61 @@
+/* LayeredHighlighter.java --
+   Copyright (C) 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.text;
+
+import java.awt.Graphics;
+import java.awt.Shape;
+
+import javax.swing.text.JTextComponent;
+import javax.swing.text.View;
+
+
+public abstract class LayeredHighlighter
+  implements Highlighter
+{
+  public abstract static class LayerPainter
+    implements Highlighter.HighlightPainter
+  {
+    public abstract Shape paintLayer(Graphics g, int p0, int p1,
+				     Shape viewBounds, JTextComponent editor,
+				     View view);
+  }
+  
+  public abstract void paintLayeredHighlights(Graphics g, int p0, int p1,
+                                              Shape viewBounds,
+                                              JTextComponent editor, View view);
+}
Index: javax/swing/text/TabExpander.java
===================================================================
RCS file: javax/swing/text/TabExpander.java
diff -N javax/swing/text/TabExpander.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ javax/swing/text/TabExpander.java	23 Jun 2004 13:08:46 -0000
@@ -0,0 +1,43 @@
+/* TabExpander.java --
+   Copyright (C) 2004  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.text;
+
+public interface TabExpander
+{
+  float nextTabStop(float x, int tabOffset);
+}
\ No newline at end of file
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.361.2.18
diff -u -b -B -r1.361.2.18 Makefile.am
--- Makefile.am	18 Jun 2004 15:00:36 -0000	1.361.2.18
+++ Makefile.am	23 Jun 2004 13:08:48 -0000
@@ -1455,11 +1455,13 @@
 javax/swing/text/Highlighter.java \
 javax/swing/text/JTextComponent.java \
 javax/swing/text/Keymap.java \
+javax/swing/text/LayeredHighlighter.java \
 javax/swing/text/PlainDocument.java \
 javax/swing/text/PlainEditorKit.java \
 javax/swing/text/Position.java \
 javax/swing/text/Segment.java \
 javax/swing/text/Style.java \
+javax/swing/text/TabExpander.java \
 javax/swing/text/View.java \
 javax/swing/text/ViewFactory.java \
 javax/swing/text/MutableAttributeSet.java \
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.in,v
retrieving revision 1.385.2.18
diff -u -b -B -r1.385.2.18 Makefile.in
--- Makefile.in	18 Jun 2004 15:00:36 -0000	1.385.2.18
+++ Makefile.in	23 Jun 2004 13:08:51 -0000
@@ -1160,11 +1160,13 @@
 javax/swing/text/Highlighter.java \
 javax/swing/text/JTextComponent.java \
 javax/swing/text/Keymap.java \
+javax/swing/text/LayeredHighlighter.java \
 javax/swing/text/PlainDocument.java \
 javax/swing/text/PlainEditorKit.java \
 javax/swing/text/Position.java \
 javax/swing/text/Segment.java \
 javax/swing/text/Style.java \
+javax/swing/text/TabExpander.java \
 javax/swing/text/View.java \
 javax/swing/text/ViewFactory.java \
 javax/swing/text/MutableAttributeSet.java \
@@ -3154,10 +3156,12 @@
 javax/swing/text/EditorKit.lo javax/swing/text/Element.lo \
 javax/swing/text/GapContent.lo javax/swing/text/Highlighter.lo \
 javax/swing/text/JTextComponent.lo javax/swing/text/Keymap.lo \
+javax/swing/text/LayeredHighlighter.lo \
 javax/swing/text/PlainDocument.lo javax/swing/text/PlainEditorKit.lo \
 javax/swing/text/Position.lo javax/swing/text/Segment.lo \
-javax/swing/text/Style.lo javax/swing/text/View.lo \
-javax/swing/text/ViewFactory.lo javax/swing/text/MutableAttributeSet.lo \
+javax/swing/text/Style.lo javax/swing/text/TabExpander.lo \
+javax/swing/text/View.lo javax/swing/text/ViewFactory.lo \
+javax/swing/text/MutableAttributeSet.lo \
 javax/swing/text/NavigationFilter.lo javax/swing/text/StyledDocument.lo \
 javax/swing/text/StyledEditorKit.lo javax/swing/text/TextAction.lo \
 javax/swing/text/html/HTML.lo \
@@ -5166,6 +5170,7 @@
 .deps/javax/swing/text/GapContent.P \
 .deps/javax/swing/text/Highlighter.P \
 .deps/javax/swing/text/JTextComponent.P .deps/javax/swing/text/Keymap.P \
+.deps/javax/swing/text/LayeredHighlighter.P \
 .deps/javax/swing/text/MutableAttributeSet.P \
 .deps/javax/swing/text/NavigationFilter.P \
 .deps/javax/swing/text/PlainDocument.P \
@@ -5173,6 +5178,7 @@
 .deps/javax/swing/text/Position.P .deps/javax/swing/text/Segment.P \
 .deps/javax/swing/text/Style.P .deps/javax/swing/text/StyledDocument.P \
 .deps/javax/swing/text/StyledEditorKit.P \
+.deps/javax/swing/text/TabExpander.P \
 .deps/javax/swing/text/TextAction.P .deps/javax/swing/text/View.P \
 .deps/javax/swing/text/ViewFactory.P .deps/javax/swing/text/html/HTML.P \
 .deps/javax/swing/text/html/parser/ParserDelegator.P \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]