changeset 182:811e926196d6

merge
author Frank Benoit <benoit@tionex.de>
date Mon, 10 Mar 2008 04:58:09 +0100
parents 772f75da6a52 (current diff) 52c185ec49e8 (diff)
children c4643827733c
files dwt/widgets/DirectoryDialog.d
diffstat 4 files changed, 76 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Sun Mar 09 11:03:57 2008 +0100
+++ b/dwt/internal/win32/OS.d	Mon Mar 10 04:58:09 2008 +0100
@@ -3994,6 +3994,7 @@
 // Unicode/Ansi alias
 version(ANSI) {
     alias WINAPI.AddFontResourceExA AddFontResourceEx;
+    alias WINAPI.AssocQueryStringA AssocQueryString;
     alias WINAPI.CallWindowProcA CallWindowProc;
     alias WINAPI.CharLowerA CharLower;
     alias WINAPI.CharUpperA CharUpper;
@@ -4095,6 +4096,7 @@
     alias WINAPI.VkKeyScanA VkKeyScan;
 }else{
     alias WINAPI.AddFontResourceExW AddFontResourceEx;
+    alias WINAPI.AssocQueryStringW AssocQueryString;
     alias WINAPI.CallWindowProcW CallWindowProc;
     alias WINAPI.CharLowerW CharLower;
     alias WINAPI.CharUpperW CharUpper;
--- a/dwt/internal/win32/WINAPI.d	Sun Mar 09 11:03:57 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Mon Mar 10 04:58:09 2008 +0100
@@ -13,6 +13,9 @@
 
 extern(Windows)
 {
+    HRESULT AssocQueryStringA(ASSOCF flags, int str, LPCTSTR pszAssoc, LPCTSTR pszExtra, LPTSTR pszOut, DWORD *pcchOut);
+    HRESULT AssocQueryStringW(ASSOCF flags, int str, LPCTSTR pszAssoc, LPCTSTR pszExtra, LPTSTR pszOut, DWORD *pcchOut);
+
 //     BOOL GetWindowInfo(HWND, PWINDOWINFO);
 //     BOOL EnumDisplayMonitors(HDC, RECT*, MONITORENUMPROC, LPARAM);
 //     BOOL GetMonitorInfoA(HMONITOR, LPMONITORINFO);
--- a/dwt/internal/win32/WINTYPES.d	Sun Mar 09 11:03:57 2008 +0100
+++ b/dwt/internal/win32/WINTYPES.d	Mon Mar 10 04:58:09 2008 +0100
@@ -201,6 +201,20 @@
 //  BYTE[8] Data4;
 // }
 
+enum {ASSOCF_INIT_BYEXENAME,
+    ASSOCF_OPEN_BYEXENAME,
+    ASSOCF_INIT_DEFAULTTOSTAR,
+    ASSOCF_INIT_DEFAULTTOFOLDER,
+    ASSOCF_NOUSERSETTINGS,
+    ASSOCF_NOTRUNCATE,
+    ASSOCF_VERIFY,
+    ASSOCF_REMAPRUNDLL,
+    ASSOCF_NOFIXUPS,
+    ASSOCF_IGNOREBASECLASS
+};
+
+alias DWORD ASSOCF;
+
 enum { AclRevisionInformation = 1, AclSizeInformation,  };
 alias ACL_INFORMATION_CLASS _ACL_INFORMATION_CLASS;
 alias int MEDIA_TYPE;
--- a/dwt/widgets/DirectoryDialog.d	Sun Mar 09 11:03:57 2008 +0100
+++ b/dwt/widgets/DirectoryDialog.d	Mon Mar 10 04:58:09 2008 +0100
@@ -12,22 +12,17 @@
  *******************************************************************************/
 module dwt.widgets.DirectoryDialog;
 
+import dwt.widgets.Display;
 import dwt.widgets.Dialog;
 import dwt.widgets.Shell;
 
-class DirectoryDialog : Dialog {
-    public this (Shell parent, int style) {
-        super (parent, style);
-    }
-}
-
-/++
 import dwt.DWT;
 import dwt.DWTException;
-import dwt.internal.Callback;
-import dwt.internal.win32.BROWSEINFO;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.TCHAR;
+import dwt.internal.C;
+
+import dwt.dwthelper.utils;
+static import tango.text.Text;
 
 /**
  * Instances of this class allow the user to navigate
@@ -44,9 +39,10 @@
  * </p>
  */
 
-public class DirectoryDialog extends Dialog {
-    String message = "", filterPath = "";  //$NON-NLS-1$//$NON-NLS-2$
-    String directoryPath;
+public class DirectoryDialog : Dialog {
+    static char[] message = "";
+    static char[] filterPath = "";  //$NON-NLS-1$//$NON-NLS-2$
+    static char[] directoryPath;
 
 /**
  * Constructs a new instance of this class given only its parent.
@@ -61,7 +57,7 @@
  *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
  * </ul>
  */
-public DirectoryDialog (Shell parent) {
+public this (Shell parent) {
     this (parent, DWT.PRIMARY_MODAL);
 }
 
@@ -89,33 +85,35 @@
  *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
  * </ul>
  */
-public DirectoryDialog (Shell parent, int style) {
+public this (Shell parent, int style) {
     super (parent, style);
     checkSubclass ();
 }
 
-int BrowseCallbackProc (int hwnd, int uMsg, int lParam, int lpData) {
+extern(Windows)static int BrowseCallbackProc (HWND hwnd, uint uMsg, int lParam, int lpData) {
+    DirectoryDialog pThis = cast(DirectoryDialog)cast(void*)lpData;
     switch (uMsg) {
         case OS.BFFM_INITIALIZED:
-            if (filterPath !is null && filterPath.length () !is 0) {
+            if (pThis.filterPath !is null && pThis.filterPath.length !is 0) {
                 /* Use the character encoding for the default locale */
-                TCHAR buffer = new TCHAR (0, filterPath.replace ('/', '\\'), true);
-                OS.SendMessage (hwnd, OS.BFFM_SETSELECTION, 1, buffer);
+                TCHAR[] buffer = StrToTCHARs (0, pThis.filterPath.replace ('/', '\\'), true);
+                OS.SendMessage (hwnd, OS.BFFM_SETSELECTION, 1, buffer.ptr);
             }
-            if (title !is null && title.length () !is 0) {
+            if (pThis.title !is null && pThis.title.length !is 0) {
                 /* Use the character encoding for the default locale */
-                TCHAR buffer = new TCHAR (0, title, true);
-                OS.SetWindowText (hwnd, buffer);
+                TCHAR[] buffer = StrToTCHARs (0, pThis.title, true);
+                OS.SetWindowText (hwnd, buffer.ptr);
             }
             break;
         case OS.BFFM_VALIDATEFAILEDA:
         case OS.BFFM_VALIDATEFAILEDW:
             /* Use the character encoding for the default locale */
-            int length = OS.IsUnicode ? OS.wcslen (lParam) : OS.strlen (lParam);
-            TCHAR buffer = new TCHAR (0, length);
-            int byteCount = buffer.length () * TCHAR.sizeof;
-            OS.MoveMemory (buffer, lParam, byteCount);
-            directoryPath = buffer.toString (0, length);
+//            int length = OS.IsUnicode ? OS.wcslen (lParam) : OS.strlen (lParam);
+//            TCHAR buffer = new TCHAR (0, length);
+//            int byteCount = buffer.length * TCHAR.sizeof;
+//            OS.MoveMemory (buffer, lParam, byteCount);
+//            directoryPath = buffer.toString (0, length);
+            pThis.directoryPath = TCHARzToStr( cast(TCHAR*)lParam );
             break;
         default:
     }
@@ -130,7 +128,7 @@
  *
  * @see #setFilterPath
  */
-public String getFilterPath () {
+public char[] getFilterPath () {
     return filterPath;
 }
 
@@ -141,7 +139,7 @@
  *
  * @return the message
  */
-public String getMessage () {
+public char[] getMessage () {
     return message;
 }
 
@@ -157,21 +155,21 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
  * </ul>
  */
-public String open () {
+public char[] open () {
     if (OS.IsWinCE) DWT.error (DWT.ERROR_NOT_IMPLEMENTED);
 
-    int hHeap = OS.GetProcessHeap ();
+    auto hHeap = OS.GetProcessHeap ();
 
     /* Get the owner HWND for the dialog */
-    int hwndOwner = 0;
+    HWND hwndOwner;
     if (parent !is null) hwndOwner = parent.handle;
 
     /* Copy the message to OS memory */
-    int lpszTitle = 0;
-    if (message.length () !is 0) {
-        String string = message;
+    TCHAR* lpszTitle;
+    if (message.length !is 0) {
+        char[] string = message;
         if (string.indexOf ('&') !is -1) {
-            int length = string.length ();
+            int length = string.length;
             char [] buffer = new char [length * 2];
             int index = 0;
             for (int i=0; i<length; i++) {
@@ -179,19 +177,20 @@
                 if (ch is '&') buffer [index++] = '&';
                 buffer [index++] = ch;
             }
-            string = new String (buffer, 0, index);
+//            string = new String (buffer, 0, index);
         }
         /* Use the character encoding for the default locale */
-        TCHAR buffer = new TCHAR (0, string, true);
-        int byteCount = buffer.length () * TCHAR.sizeof;
-        lpszTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-        OS.MoveMemory (lpszTitle, buffer, byteCount);
+        TCHAR[] buffer = StrToTCHARs (0, string, true);
+        int byteCount = buffer.length * TCHAR.sizeof;
+        lpszTitle = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+        OS.MoveMemory (lpszTitle, buffer.ptr, byteCount);
     }
 
     /* Create the BrowseCallbackProc */
-    Callback callback = new Callback (this, "BrowseCallbackProc", 4); //$NON-NLS-1$
-    int lpfn = callback.getAddress ();
-    if (lpfn is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
+/+    Callback callback = new Callback (this, "BrowseCallbackProc", 4); //$NON-NLS-1$
+    int lpfn = callback.getAddress ();+/
+    BFFCALLBACK lpfn = &BrowseCallbackProc;
+    if (lpfn is null) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
 
     /* Make the parent shell be temporary modal */
     Shell oldModal = null;
@@ -202,11 +201,12 @@
     }
 
     directoryPath = null;
-    BROWSEINFO lpbi = new BROWSEINFO ();
+    BROWSEINFO lpbi;
     lpbi.hwndOwner = hwndOwner;
     lpbi.lpszTitle = lpszTitle;
     lpbi.ulFlags = OS.BIF_NEWDIALOGSTYLE | OS.BIF_RETURNONLYFSDIRS | OS.BIF_EDITBOX | OS.BIF_VALIDATE;
     lpbi.lpfn = lpfn;
+    lpbi.lParam = cast(int)cast(void*)this;
     /*
     * Bug in Windows.  On some hardware configurations, SHBrowseForFolder()
     * causes warning dialogs with the message "There is no disk in the drive
@@ -239,7 +239,7 @@
     */
     bool oldRunMessages = display.runMessages;
     if (OS.COMCTL32_MAJOR < 6) display.runMessages = false;
-    int lpItemIdList = OS.SHBrowseForFolder (lpbi);
+    ITEMIDLIST* lpItemIdList = OS.SHBrowseForFolder (&lpbi);
     if (OS.COMCTL32_MAJOR < 6) display.runMessages = oldRunMessages;
     OS.SetErrorMode (oldErrorMode);
 
@@ -248,27 +248,27 @@
         display.setModalDialogShell (oldModal);
     }
 
-    bool success = lpItemIdList !is 0;
+    bool success = lpItemIdList !is null;
     if (success) {
         /* Use the character encoding for the default locale */
-        TCHAR buffer = new TCHAR (0, OS.MAX_PATH);
-        if (OS.SHGetPathFromIDList (lpItemIdList, buffer)) {
-            directoryPath = buffer.toString (0, buffer.strlen ());
+        TCHAR[OS.MAX_PATH] buffer;
+        if (OS.SHGetPathFromIDList (lpItemIdList, buffer.ptr)) {
+            directoryPath = TCHARzToStr (buffer.ptr);
             filterPath = directoryPath;
         }
     }
 
     /* Free the BrowseCallbackProc */
-    callback.dispose ();
+//    callback.dispose ();
 
     /* Free the OS memory */
-    if (lpszTitle !is 0) OS.HeapFree (hHeap, 0, lpszTitle);
+    if (lpszTitle !is null) OS.HeapFree (hHeap, 0, lpszTitle);
 
     /* Free the pointer to the ITEMIDLIST */
-    int [] ppMalloc = new int [1];
-    if (OS.SHGetMalloc (ppMalloc) is OS.S_OK) {
+    LPVOID ppMalloc;
+    if (OS.SHGetMalloc (&ppMalloc) is OS.S_OK) {
         /* void Free (struct IMalloc *this, void *pv); */
-        OS.VtblCall (5, ppMalloc [0], lpItemIdList);
+        OS.VtblCall (5, ppMalloc , cast(int)lpItemIdList);
     }
 
     /*
@@ -297,7 +297,7 @@
  *
  * @param string the filter path
  */
-public void setFilterPath (String string) {
+public void setFilterPath (char[] string) {
     filterPath = string;
 }
 
@@ -312,10 +312,9 @@
  *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
  * </ul>
  */
-public void setMessage (String string) {
+public void setMessage (char[] string) {
     if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     message = string;
 }
 
 }
-++/
\ No newline at end of file