diff dwt/internal/BidiUtil.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children e2affbeb686d
line wrap: on
line diff
--- a/dwt/internal/BidiUtil.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/internal/BidiUtil.d	Sat May 17 17:34:28 2008 +0200
@@ -17,6 +17,7 @@
 import dwt.graphics.GC;
 import dwt.internal.win32.OS;
 
+import dwt.widgets.Control;
 import tango.util.Convert;
 import dwt.dwthelper.utils;
 import dwt.dwthelper.Runnable;
@@ -112,6 +113,9 @@
     languageMap[hwnd] = runnable;
     subclass(hwnd);
 }
+public static void addLanguageListener (Control control, Runnable runnable) {
+    addLanguageListener(control.handle, runnable);
+}
 /**
  * Proc used for OS.EnumSystemLanguageGroups call during isBidiPlatform test.
  */
@@ -407,11 +411,9 @@
  */
 public static int getKeyboardLanguage() {
     int layout = cast(int) OS.GetKeyboardLayout(0);
-    // only interested in low 2 bytes, which is the primary
-    // language identifier
-    layout = layout & 0x000000FF;
-    if (layout is LANG_HEBREW) return KEYBOARD_BIDI;
-    if (layout is LANG_ARABIC) return KEYBOARD_BIDI;
+    int langID = OS.PRIMARYLANGID(OS.LOWORD(layout));
+    if (langID is LANG_HEBREW) return KEYBOARD_BIDI;
+    if (langID is LANG_ARABIC) return KEYBOARD_BIDI;
     // return non-bidi for all other languages
     return KEYBOARD_NON_BIDI;
 }
@@ -482,7 +484,7 @@
 public static bool isKeyboardBidi() {
     void*[] list = getKeyboardLanguageList();
     for (int i=0; i<list.length; i++) {
-        int id = cast(int)list[i] & 0x000000FF;
+        int id = OS.PRIMARYLANGID(OS.LOWORD( cast(int) list[i]));
         if ((id is LANG_ARABIC) || (id is LANG_HEBREW)) {
             return true;
         }
@@ -499,6 +501,9 @@
     languageMap.remove(hwnd);
     unsubclass(hwnd);
 }
+public static void removeLanguageListener (Control control) {
+    removeLanguageListener(control.handle);
+}
 /**
  * Switch the keyboard language to the specified language type.  We do
  * not distinguish between multiple bidi or multiple non-bidi languages, so
@@ -517,7 +522,7 @@
         void*[] list = getKeyboardLanguageList();
         // set to first bidi language
         for (int i=0; i<list.length; i++) {
-            int id = cast(int)list[i] & 0x000000FF;
+            int id = OS.PRIMARYLANGID(OS.LOWORD( cast(int) list[i]));
             if ((id is LANG_ARABIC) || (id is LANG_HEBREW)) {
                 OS.ActivateKeyboardLayout(list[i], 0);
                 return;
@@ -529,7 +534,7 @@
         // set to the first non-bidi language (anything not
         // Hebrew or Arabic)
         for (int i=0; i<list.length; i++) {
-            int id = cast(int)list[i] & 0x000000FF;
+            int id = OS.PRIMARYLANGID(OS.LOWORD( cast(int) list[i]));
             if ((id !is LANG_HEBREW) && (id !is LANG_ARABIC)) {
                 OS.ActivateKeyboardLayout(list[i], 0);
                 return;
@@ -559,6 +564,9 @@
     OS.SetWindowLong (hwnd, OS.GWL_EXSTYLE, bits);
     return true;
 }
+public static bool setOrientation (Control control, int orientation) {
+    return setOrientation(control.handle, orientation);
+}
 /**
  * Override the window proc.
  *
@@ -567,10 +575,10 @@
 static void subclass(HWND hwnd) {
     HWND key = hwnd;
     if ( ( key in oldProcMap ) is null) {
-        int oldProc = OS.GetWindowLong(hwnd, OS.GWL_WNDPROC);
+        int /*long*/ oldProc = OS.GetWindowLongPtr(hwnd, OS.GWLP_WNDPROC);
         oldProcMap[key] = cast(WNDPROC)oldProc;
         WNDPROC t = &windowProc; // test signature
-        OS.SetWindowLong(hwnd, OS.GWL_WNDPROC, cast(int) &windowProc);
+        OS.SetWindowLongPtr(hwnd, OS.GWLP_WNDPROC, cast(LONG_PTR)&windowProc);
     }
 }
 /**
@@ -634,7 +642,7 @@
             oldProcMap.remove( key );
         }
         if (proc is null) return;
-        OS.SetWindowLong(hwnd, OS.GWL_WNDPROC, cast(int)proc );
+        OS.SetWindowLongPtr(hwnd, OS.GWLP_WNDPROC, cast(LONG_PTR) proc );
     }
 }
 /**
@@ -656,7 +664,7 @@
         default:
         }
     auto oldProc = oldProcMap[key];
-    return OS.CallWindowProc ( oldProc, hwnd, msg, wParam, lParam);
+    return oldProc( hwnd, msg, wParam, lParam);
 }
 
 }