diff dwt/widgets/Caret.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents 0f25be5cbe6f
children fd9c62a2998e
line wrap: on
line diff
--- a/dwt/widgets/Caret.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/Caret.d	Sat May 17 17:34:28 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -24,6 +24,7 @@
 
 import dwt.widgets.Widget;
 import dwt.widgets.Canvas;
+import dwt.widgets.IME;
 
 import dwt.dwthelper.utils;
 
@@ -122,6 +123,13 @@
     if (image !is null) {
         Rectangle rect = image.getBounds ();
         return new Rectangle (x, y, rect.width, rect.height);
+    } else {
+        if (!OS.IsWinCE && width is 0) {
+            int buffer;
+            if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, &buffer, 0)) {
+                return new Rectangle (x, y, buffer, height);
+            }
+        }
     }
     return new Rectangle (x, y, width, height);
 }
@@ -206,6 +214,13 @@
     if (image !is null) {
         Rectangle rect = image.getBounds ();
         return new Point (rect.width, rect.height);
+    } else {
+        if (!OS.IsWinCE && width is 0) {
+            int buffer;
+            if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, &buffer, 0)) {
+                return new Point (buffer, height);
+            }
+        }
     }
     return new Point (width, height);
 }
@@ -275,18 +290,29 @@
     POINT ptCurrentPos;
     if (!OS.GetCaretPos (&ptCurrentPos)) return;
     auto hwnd = parent.handle;
-    RECT rect;
-    OS.GetClientRect (hwnd, &rect);
-    COMPOSITIONFORM lpCompForm;
-    lpCompForm.dwStyle = OS.CFS_RECT;
-    lpCompForm.ptCurrentPos.x = ptCurrentPos.x;
-    lpCompForm.ptCurrentPos.y = ptCurrentPos.y;
-    lpCompForm.rcArea.left = rect.left;
-    lpCompForm.rcArea.right = rect.right;
-    lpCompForm.rcArea.top = rect.top;
-    lpCompForm.rcArea.bottom = rect.bottom;
     auto hIMC = OS.ImmGetContext (hwnd);
-    OS.ImmSetCompositionWindow (hIMC, &lpCompForm);
+    IME ime = parent.getIME ();
+    if (ime !is null && ime.isInlineEnabled ()) {
+        Point size = getSize ();
+        CANDIDATEFORM lpCandidate;
+        lpCandidate.dwStyle = OS.CFS_EXCLUDE;
+        lpCandidate.ptCurrentPos = ptCurrentPos;
+        //lpCandidate.rcArea = new RECT ();
+        OS.SetRect (&lpCandidate.rcArea, ptCurrentPos.x, ptCurrentPos.y, ptCurrentPos.x + size.x, ptCurrentPos.y + size.y);
+        OS.ImmSetCandidateWindow (hIMC, &lpCandidate);
+    } else {
+        RECT rect;
+        OS.GetClientRect (hwnd, &rect);
+        COMPOSITIONFORM lpCompForm;
+        lpCompForm.dwStyle = OS.CFS_RECT;
+        lpCompForm.ptCurrentPos.x = ptCurrentPos.x;
+        lpCompForm.ptCurrentPos.y = ptCurrentPos.y;
+        lpCompForm.rcArea.left = rect.left;
+        lpCompForm.rcArea.right = rect.right;
+        lpCompForm.rcArea.top = rect.top;
+        lpCompForm.rcArea.bottom = rect.bottom;
+        OS.ImmSetCompositionWindow (hIMC, &lpCompForm);
+    }
     OS.ImmReleaseContext (hwnd, hIMC);
 }
 
@@ -308,6 +334,13 @@
     auto hwnd = parent.handle;
     OS.DestroyCaret ();
     auto hBitmap = image !is null ? image.handle : null;
+    int width = this.width;
+    if (!OS.IsWinCE && image is null && width is 0) {
+        int buffer;
+        if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, &buffer, 0)) {
+            width = buffer;
+        }
+    }
     OS.CreateCaret (hwnd, hBitmap, width, height);
     OS.SetCaretPos (x, y);
     OS.ShowCaret (hwnd);
@@ -345,8 +378,10 @@
     bool samePosition = this.x is x && this.y is y;
     bool sameExtent = this.width is width && this.height is height;
     if (samePosition && sameExtent) return;
-    this.x = x;  this.y = y;
-    this.width = width;  this.height = height;
+    this.x = x;
+    this.y = y;
+    this.width = width;
+    this.height = height;
     if (sameExtent) {
         moved = true;
         if (isVisible_ && hasFocus ()) move ();
@@ -378,6 +413,13 @@
     auto hwnd = parent.handle;
     HBITMAP hBitmap;
     if (image !is null) hBitmap = image.handle;
+    int width = this.width;
+    if (!OS.IsWinCE && image is null && width is 0) {
+        int buffer;
+        if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, &buffer, 0)) {
+            width = buffer;
+        }
+    }
     OS.CreateCaret (hwnd, hBitmap, width, height);
     move ();
     setIMEFont ();