Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover2001-09-07 17:07:27 +0000
committerSteve Northover2001-09-07 17:07:27 +0000
commit3a536d5e61fea15caaccca66cc9f09a5ea13ebdf (patch)
tree4716a702bcdad101376d20afa2ec0d3d0f69fd19
parentd89ec4349accd69b28e82163cda5a238cac055d6 (diff)
downloadeclipse.platform.swt-3a536d5e61fea15caaccca66cc9f09a5ea13ebdf.tar.gz
eclipse.platform.swt-3a536d5e61fea15caaccca66cc9f09a5ea13ebdf.tar.xz
eclipse.platform.swt-3a536d5e61fea15caaccca66cc9f09a5ea13ebdf.zip
*** empty log message ***
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java51
1 files changed, 49 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
index 276cb08483..0788bb5ef5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
@@ -29,6 +29,7 @@ public class Caret extends Widget {
int x, y, width, height;
boolean moved, resized;
boolean isVisible;
+ Image image;
Font font;
LOGFONT oldFont;
@@ -93,6 +94,10 @@ int defaultFont () {
*/
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);
}
@@ -119,6 +124,21 @@ public Font getFont () {
}
/**
+ * Returns the image that the receiver will use to paint the caret.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
+/**
* Returns a point describing the receiver's location relative
* to its parent (or its display if its parent is null).
*
@@ -161,6 +181,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);
}
@@ -242,6 +266,7 @@ void releaseChild () {
void releaseWidget () {
super.releaseWidget ();
parent = null;
+ image = null;
font = null;
oldFont = null;
}
@@ -250,7 +275,9 @@ void resize () {
resized = false;
int hwnd = parent.handle;
OS.DestroyCaret ();
- OS.CreateCaret (hwnd, 0, width, height);
+ int hBitmap = 0;
+ if (image != null) hBitmap = image.handle;
+ OS.CreateCaret (hwnd, hBitmap, width, height);
OS.SetCaretPos (x, y);
OS.ShowCaret (hwnd);
move ();
@@ -328,7 +355,9 @@ public void setBounds (Rectangle rect) {
void setFocus () {
int hwnd = parent.handle;
- OS.CreateCaret (hwnd, 0, width, height);
+ int hBitmap = 0;
+ if (image != null) hBitmap = image.handle;
+ OS.CreateCaret (hwnd, hBitmap, width, height);
move ();
if (font != null) {
int hFont = font.handle;
@@ -362,6 +391,24 @@ public void setFont (Font font) {
}
}
+/**
+ * Sets the image that the receiver will use to paint the caret
+ * to the image specified by the argument, or to the default
+ * which is a filled rectangle if the argument is null
+ *
+ * @param font the new font (or null)
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+ checkWidget();
+ this.image = image;
+ if (isVisible && parent.hasFocus ()) resize ();
+}
+
void setIMEFont (int hFont) {
if (!IsDBLocale) return;
LOGFONT logFont = new LOGFONT ();

Back to the top