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

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents 07e8963537b7
children fd9c62a2998e
line wrap: on
line diff
--- a/dwt/widgets/ColorDialog.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/ColorDialog.d	Sat May 17 17:34:28 2008 +0200
@@ -65,7 +65,7 @@
  * @see Widget#getStyle
  */
 public this (Shell parent) {
-    this (parent, DWT.PRIMARY_MODAL);
+    this (parent, DWT.APPLICATION_MODAL);
 }
 
 /**
@@ -97,7 +97,7 @@
  * @see Widget#getStyle
  */
 public this (Shell parent, int style) {
-    super (parent, style);
+    super (parent, checkStyle (parent, style));
     checkSubclass ();
 }
 
@@ -165,6 +165,35 @@
 
     /* Get the owner HWND for the dialog */
     auto hwndOwner = parent.handle;
+    auto hwndParent = parent.handle;
+
+    /*
+    * Feature in Windows.  There is no API to set the orientation of a
+    * color dialog.  It is always inherited from the parent.  The fix is
+    * to create a hidden parent and set the orientation in the hidden
+    * parent for the dialog to inherit.
+    */
+    bool enabled = false;
+    if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) {
+        int dialogOrientation = style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT);
+        int parentOrientation = parent.style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT);
+        if (dialogOrientation !is parentOrientation) {
+            int exStyle = OS.WS_EX_NOINHERITLAYOUT;
+            if (dialogOrientation is DWT.RIGHT_TO_LEFT) exStyle |= OS.WS_EX_LAYOUTRTL;
+            hwndOwner = OS.CreateWindowEx (
+                exStyle,
+                Shell.DialogClass.ptr,
+                null,
+                0,
+                OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
+                hwndParent,
+                null,
+                OS.GetModuleHandle (null),
+                null);
+            enabled = OS.IsWindowEnabled (hwndParent) !is 0;
+            if (enabled) OS.EnableWindow (hwndParent, false);
+        }
+    }
 
     /* Create the CCHookProc */
     //Callback callback = new Callback (this, "CCHookProc", 4); //$NON-NLS-1$
@@ -196,10 +225,10 @@
     }
 
     /* Make the parent shell be temporary modal */
-    Shell oldModal = null;
+    Dialog oldModal = null;
     if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) {
-        oldModal = display.getModalDialogShell ();
-        display.setModalDialogShell (parent);
+        oldModal = display.getModalDialog ();
+        display.setModalDialog (this);
     }
 
     /* Open the dialog */
@@ -212,7 +241,7 @@
 
     /* Clear the temporary dialog modal parent */
     if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) {
-        display.setModalDialogShell (oldModal);
+        display.setModalDialog (oldModal);
     }
 
     if (success) {
@@ -234,6 +263,13 @@
     */
 //  if (lpCustColors !is 0) OS.HeapFree (hHeap, 0, lpCustColors);
 
+    /* Destroy the BIDI orientation window */
+    if (hwndParent !is hwndOwner) {
+        if (enabled) OS.EnableWindow (hwndParent, true);
+        OS.SetActiveWindow (hwndParent);
+        OS.DestroyWindow (hwndOwner);
+    }
+
     /*
     * This code is intentionally commented.  On some
     * platforms, the owner window is repainted right
@@ -242,6 +278,7 @@
     */
 //  if (hwndOwner !is 0) OS.UpdateWindow (hwndOwner);
 
+    display = null;
     if (!success) return null;
     return rgb;
 }