From e617e7739c57830b586bb99c74e9abfc4e7efa11 Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Fri, 7 Sep 2001 20:46:23 +0000 Subject: *** empty log message *** --- .../photon/org/eclipse/swt/widgets/Caret.java | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'bundles/org.eclipse.swt') diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java index a8271df354..478d68fc86 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java @@ -11,6 +11,7 @@ import org.eclipse.swt.graphics.*; public /*final*/ class Caret extends Widget { Canvas parent; + Image image; int x, y, width, height; boolean moved, resized; boolean isVisible, isShowing; @@ -53,9 +54,14 @@ boolean drawCaret () { OS.PgSetRegion (OS.PtWidgetRid (handle)); OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR); OS.PgSetFillColor (color); - int nWidth = width; + int nWidth = width, nHeight = height; + if (image != null) { + Rectangle rect = image.getBounds (); + nWidth = rect.width; + nHeight = rect.height; + } if (nWidth <= 0) nWidth = 2; - OS.PgDrawIRect (x, y, x + nWidth - 1, y + height - 1, OS.Pg_DRAW_FILL); + OS.PgDrawIRect (x, y, x + nWidth - 1, y + nHeight - 1, OS.Pg_DRAW_FILL); OS.PgSetGC (prevContext); OS.PgDestroyGC (phGC); return true; @@ -63,6 +69,10 @@ boolean drawCaret () { public Rectangle getBounds () { checkWidget(); + if (image != null) { + Rectangle rect = image.getBounds (); + return new Rectangle (x, y, rect.width, rect.height); + } return new Rectangle (x, y, width, height); } @@ -77,6 +87,11 @@ public Font getFont () { return parent.getFont (); } +public Image getImage () { + checkWidget(); + return image; +} + public Point getLocation () { checkWidget(); return new Point (x, y); @@ -89,6 +104,10 @@ public Canvas getParent () { public Point getSize () { checkWidget(); + if (image != null) { + Rectangle rect = image.getBounds (); + return new Point (rect.width, rect.height); + } return new Point (width, height); } @@ -130,6 +149,7 @@ void releaseWidget () { // display.setCurrentCaret (null); // } parent = null; + image = null; } public void setBounds (int x, int y, int width, int height) { @@ -167,6 +187,13 @@ public void setFont (Font font) { checkWidget(); } +public void setImage (Image image) { + checkWidget(); + if (isShowing) hideCaret (); + this.image = image; + if (isShowing) showCaret (); +} + public void setLocation (int x, int y) { checkWidget(); setBounds (x, y, width, height); -- cgit v1.2.3