2002/05/28 18:30:30
[org.ibex.core.git] / src / org / xwt / plat / Win32.cc
index 3bb342e..e03526c 100644 (file)
@@ -25,6 +25,7 @@
 #include <org/xwt/Surface.h>
 #include <org/xwt/DoubleBuffer.h>
 #include <org/xwt/Picture.h>
+#include <org/xwt/ByteStream.h>
 #include <org/xwt/Platform.h>
 #include <org/xwt/Platform$ParsedFont.h>
 #include <org/xwt/plat/Win32.h>
@@ -32,6 +33,7 @@
 #include <org/xwt/plat/Win32$Win32Surface.h>
 #include <org/xwt/plat/Win32$Win32DoubleBuffer.h>
 #include <org/xwt/plat/Win32$Win32Picture.h>
+#include <org/xwt/util/Log.h>
 #include <org/xwt/util/Semaphore.h>
 
 // for debugging
@@ -237,6 +239,29 @@ void org::xwt::plat::Win32::natInit() {
 
 // Platform Methods ///////////////////////////////////////////////////////////////////
 
+jstring org::xwt::plat::Win32::_fileDialog(jstring suggestedFileName, jboolean write) {
+
+    char buf[1024];
+    OPENFILENAME ofn;
+    memset(buf, 0, 1024);
+    memset(&ofn, 0, sizeof(OPENFILENAME));
+
+    if (suggestedFileName != NULL)
+        JvGetStringUTFRegion(suggestedFileName, 0, min(1023, JvGetStringUTFLength(suggestedFileName)), buf);
+    
+    ofn.lStructSize = sizeof(OPENFILENAME);
+    ofn.nMaxCustFilter = 0;
+    ofn.lpstrFile = buf;
+    ofn.nMaxFile = 1024;
+
+    if (write) ofn.Flags |= OFN_OVERWRITEPROMPT;
+    ofn.Flags |= OFN_NOCHANGEDIR;
+    ofn.Flags |= OFN_HIDEREADONLY;
+
+    int ret = write ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn);
+    return ret == 0 ? NULL : JvNewStringLatin1(buf);
+}
+
 void org::xwt::plat::Win32::__detectProxy(JArray<jstring>* container) {
 
     HKEY hkey;