2002/08/07 04:41:10
[org.ibex.core.git] / src / org / xwt / plat / Win32.cc
index 195171b..a286863 100644 (file)
@@ -236,6 +236,17 @@ void org::xwt::plat::Win32::natInit() {
 
 // Platform Methods ///////////////////////////////////////////////////////////////////
 
+jstring org::xwt::plat::Win32::_getEnv(jstring key) {
+    int len = JvGetStringUTFLength(key);
+    char buf[len + 1];
+    JvGetStringUTFRegion(key, 0, len, buf);
+    buf[len] = '\0';
+    char buf2[1024];
+    DWORD ret = GetEnvironmentVariable(buf, buf2, 1024);
+    if (ret > 0 && ret < 1024) return JvNewStringLatin1(buf2);
+    return NULL;
+}
+
 jstring org::xwt::plat::Win32::_fileDialog(jstring suggestedFileName, jboolean write) {
 
     char buf[1024];
@@ -625,9 +636,9 @@ void org::xwt::plat::Win32$Win32Surface::setSize(jint w, jint h) {
     RECT client_rect, window_rect;
     GetClientRect((HWND)hwnd, &client_rect);
     GetWindowRect((HWND)hwnd, &window_rect);
-    int addwidth = (window_rect.right - window_rect.left) - (client_rect.right - client_rect.left);
-    int addheight = (window_rect.bottom - window_rect.top) - (client_rect.bottom - client_rect.top);
-    SetWindowPos((HWND)hwnd, NULL, 0, 0, w + addwidth, h + addheight, SWP_NOZORDER | SWP_NOMOVE);
+    int width = (window_rect.right - window_rect.left) - (client_rect.right - client_rect.left) + w;
+    int height = (window_rect.bottom - window_rect.top) - (client_rect.bottom - client_rect.top) + h;
+    SetWindowPos((HWND)hwnd, NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
 }
 
 void org::xwt::plat::Win32$Win32Surface::setTitleBarText(java::lang::String* title) {
@@ -684,9 +695,11 @@ jint org::xwt::plat::Win32$Win32Surface::WndProc(jint _hwnd, jint _iMsg, jint _w
     POINT point;
     HWND hwnd2;
     RECT rect, rect2;
+    RECT client_rect, window_rect;
     jboolean newinside;
     int16_t mouse_x;
     int16_t mouse_y;
+    int addwidth, addheight;
 
     switch(iMsg) {
     case WM_DEVMODECHANGE: break;    // FEATURE: color depth changed
@@ -793,11 +806,15 @@ jint org::xwt::plat::Win32$Win32Surface::WndProc(jint _hwnd, jint _iMsg, jint _w
         return 0;
 
     case WM_GETMINMAXINFO:
+        GetClientRect((HWND)hwnd, &client_rect);
+        GetWindowRect((HWND)hwnd, &window_rect);
+        addwidth = (window_rect.right - window_rect.left) - (client_rect.right - client_rect.left);
+        addheight = (window_rect.bottom - window_rect.top) - (client_rect.bottom - client_rect.top);
         mmi = (MINMAXINFO*)lParam;
-        mmi->ptMinTrackSize.x = root->dmin(0);
-        mmi->ptMinTrackSize.y = root->dmin(1);
-        mmi->ptMaxTrackSize.x = root->dmax(0);
-        mmi->ptMaxTrackSize.y = root->dmax(1);
+        mmi->ptMinTrackSize.x = ((uint32_t)root->dmin(0)) + addwidth;
+        mmi->ptMinTrackSize.y = ((uint32_t)root->dmin(1)) + addheight;
+        mmi->ptMaxTrackSize.x = min(org::xwt::plat::Win32::getScreenWidth(), ((uint32_t)root->dmax(0)) + addwidth);
+        mmi->ptMaxTrackSize.y = min(org::xwt::plat::Win32::getScreenHeight(), ((uint32_t)root->dmax(1)) + addheight);
         return 0;
         
     case WM_PAINT: