changeset 38:4d6511d2441f

Canvas
author Frank Benoit <benoit@tionex.de>
date Fri, 01 Feb 2008 16:16:51 +0100
parents e3a5d61b33cd
children f5e70f9aeeda
files dwt/internal/win32/OS.d dwt/internal/win32/WINAPI.d dwt/widgets/Canvas.d dwt/widgets/Caret.d dwt/widgets/Scrollable.d
diffstat 5 files changed, 58 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Fri Feb 01 14:26:47 2008 +0100
+++ b/dwt/internal/win32/OS.d	Fri Feb 01 16:16:51 2008 +0100
@@ -4280,6 +4280,7 @@
 alias WINAPI.GetStockObject GetStockObject;
 alias WINAPI.GetSysColor GetSysColor;
 alias WINAPI.GetSysColorBrush GetSysColorBrush;
+alias WINAPI.GetSystemDefaultUILanguage GetSystemDefaultUILanguage;
 alias WINAPI.GetSystemMenu GetSystemMenu;
 alias WINAPI.GetSystemMetrics GetSystemMetrics;
 alias WINAPI.GetSystemPaletteEntries GetSystemPaletteEntries;
@@ -4393,6 +4394,7 @@
 alias WINAPI.MsgWaitForMultipleObjectsEx MsgWaitForMultipleObjectsEx;
 alias WINAPI.MultiByteToWideChar MultiByteToWideChar;
 alias WINAPI.NotifyWinEvent NotifyWinEvent;
+alias STDWIN.OffsetRect OffsetRect;
 alias WINAPI.OffsetRgn OffsetRgn;
 //alias WINAPI.OleInitialize OleInitialize;
 //alias WINAPI.OleUninitialize OleUninitialize;
@@ -4412,6 +4414,7 @@
 alias WINAPI.PostThreadMessageW PostThreadMessageW;
 alias WINAPI.PrintDlgA PrintDlgA;
 alias WINAPI.PrintDlgW PrintDlgW;
+alias WINAPI.PRIMARYLANGID PRIMARYLANGID;
 alias WINAPI.PtInRect PtInRect;
 alias WINAPI.PtInRegion PtInRegion;
 alias WINAPI.RealizePalette RealizePalette;
--- a/dwt/internal/win32/WINAPI.d	Fri Feb 01 14:26:47 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Fri Feb 01 16:16:51 2008 +0100
@@ -132,6 +132,10 @@
     HPAINTBUFFER hBufferedPaint,
     BOOL fUpdateTarget
 );
+LANGID GetSystemDefaultUILanguage();
+WORD PRIMARYLANGID(
+  WORD lgid
+);
 }
 //--------------------------------------------------------------------------------------
 
--- a/dwt/widgets/Canvas.d	Fri Feb 01 14:26:47 2008 +0100
+++ b/dwt/widgets/Canvas.d	Fri Feb 01 16:16:51 2008 +0100
@@ -14,20 +14,18 @@
 
 import dwt.widgets.Composite;
 
-class Canvas : Composite {
-}
 
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.graphics.Font;
 import dwt.graphics.GC;
 import dwt.graphics.Rectangle;
-import dwt.internal.win32.COMPOSITIONFORM;
-import dwt.internal.win32.LRESULT;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.POINT;
-import dwt.internal.win32.RECT;
+import dwt.widgets.Caret;
+import dwt.widgets.Control;
+import dwt.widgets.Display;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class provide a surface for drawing
@@ -49,13 +47,16 @@
  * @see Composite
  */
 
-public class Canvas extends Composite {
+public class Canvas : Composite {
+
+    alias Composite.drawBackground drawBackground;
+
     Caret caret;
 
 /**
  * Prevents uninitialized instances from being created outside the package.
  */
-Canvas () {
+this () {
 }
 
 /**
@@ -85,17 +86,17 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Canvas (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (parent, style);
 }
 
 void clearArea (int x, int y, int width, int height) {
     checkWidget ();
     if (OS.IsWindowVisible (handle)) {
-        RECT rect = new RECT ();
-        OS.SetRect (rect, x, y, x + width, y + height);
-        int hDC = OS.GetDCEx (handle, 0, OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS);
-        drawBackground (hDC, rect);
+        RECT rect;
+        OS.SetRect (&rect, x, y, x + width, y + height);
+        auto hDC = OS.GetDCEx (handle, null, OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS);
+        drawBackground (hDC, &rect);
         OS.ReleaseDC (handle, hDC);
     }
 }
@@ -156,11 +157,11 @@
     checkWidget ();
     if (gc is null) error (DWT.ERROR_NULL_ARGUMENT);
     if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
-    RECT rect = new RECT ();
-    OS.SetRect (rect, x, y, x + width, y + height);
-    int hDC = gc.handle;
+    RECT rect;
+    OS.SetRect (&rect, x, y, x + width, y + height);
+    auto hDC = gc.handle;
     int pixel = background is -1 ? gc.getBackground ().handle : -1;
-    drawBackground (hDC, rect, pixel);
+    drawBackground (hDC, &rect, pixel);
 }
 
 /**
@@ -190,34 +191,34 @@
     forceResize ();
     bool isFocus = caret !is null && caret.isFocusCaret ();
     if (isFocus) caret.killFocus ();
-    RECT sourceRect = new RECT ();
-    OS.SetRect (sourceRect, x, y, x + width, y + height);
-    RECT clientRect = new RECT ();
-    OS.GetClientRect (handle, clientRect);
-    if (OS.IntersectRect (clientRect, sourceRect, clientRect)) {
+    RECT sourceRect;
+    OS.SetRect (&sourceRect, x, y, x + width, y + height);
+    RECT clientRect;
+    OS.GetClientRect (handle, &clientRect);
+    if (OS.IntersectRect (&clientRect, &sourceRect, &clientRect)) {
         if (OS.IsWinCE) {
             OS.UpdateWindow (handle);
         } else {
             int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
-            OS.RedrawWindow (handle, null, 0, flags);
+            OS.RedrawWindow (handle, null, null, flags);
         }
     }
     int deltaX = destX - x, deltaY = destY - y;
     if (findImageControl () !is null) {
         if (OS.IsWinCE) {
-            OS.InvalidateRect (handle, sourceRect, true);
+            OS.InvalidateRect (handle, &sourceRect, true);
         } else {
             int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
             if (all) flags |= OS.RDW_ALLCHILDREN;
-            OS.RedrawWindow (handle, sourceRect, 0, flags);
+            OS.RedrawWindow (handle, &sourceRect, null, flags);
         }
-        OS.OffsetRect (sourceRect, deltaX, deltaY);
+        OS.OffsetRect (&sourceRect, deltaX, deltaY);
         if (OS.IsWinCE) {
-            OS.InvalidateRect (handle, sourceRect, true);
+            OS.InvalidateRect (handle, &sourceRect, true);
         } else {
             int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
             if (all) flags |= OS.RDW_ALLCHILDREN;
-            OS.RedrawWindow (handle, sourceRect, 0, flags);
+            OS.RedrawWindow (handle, &sourceRect, null, flags);
         }
     } else {
         int flags = OS.SW_INVALIDATE | OS.SW_ERASE;
@@ -236,7 +237,7 @@
         * explicitly after scrolling.
         */
 //      if (all) flags |= OS.SW_SCROLLCHILDREN;
-        OS.ScrollWindowEx (handle, deltaX, deltaY, sourceRect, null, 0, null, flags);
+        OS.ScrollWindowEx (handle, deltaX, deltaY, &sourceRect, null, null, null, flags);
     }
     if (all) {
         Control [] children = _getChildren ();
@@ -292,7 +293,7 @@
     super.setFont (font);
 }
 
-int windowProc (int hwnd, int msg, int wParam, int lParam) {
+override int windowProc (HWND hwnd, int msg, int wParam, int lParam) {
     if (msg is Display.SWT_RESTORECARET) {
         if ((state & CANVAS) !is 0) {
             if (caret !is null) {
@@ -321,14 +322,14 @@
             short primaryLang = OS.PRIMARYLANGID (langID);
             if (primaryLang is OS.LANG_KOREAN) {
                 if (caret !is null && caret.isFocusCaret ()) {
-                    POINT ptCurrentPos = new POINT ();
-                    if (OS.GetCaretPos (ptCurrentPos)) {
-                        COMPOSITIONFORM lpCompForm = new COMPOSITIONFORM ();
+                    POINT ptCurrentPos;
+                    if (OS.GetCaretPos (&ptCurrentPos)) {
+                        COMPOSITIONFORM lpCompForm;
                         lpCompForm.dwStyle = OS.CFS_POINT;
-                        lpCompForm.x = ptCurrentPos.x;
-                        lpCompForm.y = ptCurrentPos.y;
-                        int hIMC = OS.ImmGetContext (handle);
-                        OS.ImmSetCompositionWindow (hIMC, lpCompForm);
+                        lpCompForm.ptCurrentPos.x = ptCurrentPos.x;
+                        lpCompForm.ptCurrentPos.y = ptCurrentPos.y;
+                        auto hIMC = OS.ImmGetContext (handle);
+                        OS.ImmSetCompositionWindow (hIMC, &lpCompForm);
                         OS.ImmReleaseContext (handle, hIMC);
                     }
                 }
@@ -367,7 +368,7 @@
 
 LRESULT WM_WINDOWPOSCHANGED (int wParam, int lParam) {
     LRESULT result  = super.WM_WINDOWPOSCHANGED (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Bug in Windows.  When a window with style WS_EX_LAYOUTRTL
     * that contains a caret is resized, Windows does not move the
@@ -382,7 +383,7 @@
 
 LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
     LRESULT result  = super.WM_WINDOWPOSCHANGING (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Bug in Windows.  When a window with style WS_EX_LAYOUTRTL
     * that contains a caret is resized, Windows does not move the
@@ -396,4 +397,3 @@
 }
 
 }
-++/
\ No newline at end of file
--- a/dwt/widgets/Caret.d	Fri Feb 01 14:26:47 2008 +0100
+++ b/dwt/widgets/Caret.d	Fri Feb 01 16:16:51 2008 +0100
@@ -13,9 +13,16 @@
 module dwt.widgets.Caret;
 
 import dwt.widgets.Widget;
+import dwt.graphics.Font;
 
 class Caret : Widget {
     this( Widget, int );
+bool isFocusCaret () ;
+void killFocus () ;
+void setFocus () ;
+public void setFont (Font font) ;
+void setIMEFont () ;
+void resizeIME () ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/Scrollable.d	Fri Feb 01 14:26:47 2008 +0100
+++ b/dwt/widgets/Scrollable.d	Fri Feb 01 16:16:51 2008 +0100
@@ -38,6 +38,9 @@
  */
 
 public abstract class Scrollable : Control {
+
+    alias Control.windowProc windowProc;
+
     ScrollBar horizontalBar, verticalBar;
 
 /**