2004/01/14 05:18:34
[org.ibex.core.git] / src / org / xwt / plat / Win32.cc
index 9cdb62b..248d555 100644 (file)
@@ -180,22 +180,31 @@ void org::xwt::plat::Win32::natInit() {
             sprintf(buf, "XWT_WINDOW_CLASS_%i", window_class_counter++);
 
             WNDCLASSEX wc;
-            wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+            wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
             wc.lpfnWndProc = WndProc;
             wc.cbClsExtra = 0;
             wc.cbSize = sizeof(WNDCLASSEX);
             wc.cbWndExtra = 0;
             wc.hInstance = GetModuleHandle(NULL);
-            wc.hIcon = NULL;
-            wc.hIconSm = NULL;
-            wc.hCursor = NULL;
-            wc.hbrBackground = (HBRUSH)(COLOR_SCROLLBAR + 1);
-            wc.lpszMenuName = NULL;
+            wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+            wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
+                                          MAKEINTRESOURCE(5),
+                                          IMAGE_ICON,
+                                          GetSystemMetrics(SM_CXSMICON),
+                                          GetSystemMetrics(SM_CYSMICON),
+                                          LR_DEFAULTCOLOR);
+            wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+            wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
+            wc.lpszMenuName = "menu";
             wc.lpszClassName = buf;
             RegisterClassEx(&wc);
+
+            surface->hwnd = (jint)CreateWindow(wc.lpszClassName, TEXT(""),
+                                               msg.wParam ? WS_NORMAL : WS_POPUP,
+                                               200, 200, 100, 100,
+                                               (HWND__*)NULL, (HMENU__*)NULL,
+                                               GetModuleHandle(NULL), (LPVOID)NULL);
             
-            surface->hwnd = (jint)CreateWindow(wc.lpszClassName, TEXT(""), msg.wParam ? WS_NORMAL : WS_POPUP, 200, 200, 100, 100,
-                                               (HWND__*)NULL, (HMENU__*)NULL, GetModuleHandle(NULL), (LPVOID)NULL);
             SetFocus((HWND)surface->hwnd);
             surface->hwndCreated->release();
             
@@ -467,18 +476,18 @@ void org::xwt::plat::Win32$Win32Picture::natInit() {
     BITMAPINFO bitmapinfo;
     memset(&bitmapinfo, 0, sizeof(BITMAPINFO));
     bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 
-    bitmapinfo.bmiHeader.biWidth = w;
-    bitmapinfo.bmiHeader.biHeight = -1 * h;
+    bitmapinfo.bmiHeader.biWidth = width;
+    bitmapinfo.bmiHeader.biHeight = -1 * height;
     bitmapinfo.bmiHeader.biPlanes = 1;
     bitmapinfo.bmiHeader.biBitCount = 32;
     bitmapinfo.bmiHeader.biCompression = BI_RGB;
 
-    hbitmap = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, w, h);
+    hbitmap = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, width, height);
     hdc = (jint)CreateCompatibleDC((HDC)org::xwt::plat::Win32::desktop_dc);
     SelectObject((HDC)hdc, (HBITMAP)hbitmap);
     uint32_t* dat = (uint32_t*)elements(data);
     for(int i=0; i<data->length; i++) if ((dat[i] & 0xFF000000) == 0x00000000) dat[i] = 0x00000000;
-    StretchDIBits((HDC)hdc, 0, 0, w, h, 0, 0, w, h, elements(data), &bitmapinfo, DIB_RGB_COLORS, SRCCOPY);
+    StretchDIBits((HDC)hdc, 0, 0, width, height, 0, 0, width, height, elements(data), &bitmapinfo, DIB_RGB_COLORS, SRCCOPY);
 
     jint _copy[min(1024, data->length)];
     jint* copy = data->length > 1024 ? (jint*)malloc(data->length * 4) : _copy;
@@ -503,10 +512,10 @@ void org::xwt::plat::Win32$Win32Picture::natInit() {
     }
 
     //    hmask = (jint)CreateBitmap(w, h, 1, 1, NULL);
-    hmask = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, w, h);
+    hmask = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, width, height);
     maskdc = (jint)CreateCompatibleDC(NULL);
     SelectObject((HDC)maskdc, (HBITMAP)hmask);
-    StretchDIBits((HDC)maskdc, 0, 0, w, h, 0, 0, w, h, copy, &bitmapinfo, DIB_RGB_COLORS, SRCCOPY);
+    StretchDIBits((HDC)maskdc, 0, 0, width, height, 0, 0, width, height, copy, &bitmapinfo, DIB_RGB_COLORS, SRCCOPY);
     if (data->length > 1024) free(copy);
 }
 
@@ -729,8 +738,8 @@ jint org::xwt::plat::Win32$Win32Surface::WndProc(jint _hwnd, jint _iMsg, jint _w
         mmi = (MINMAXINFO*)lParam;
         mmi->ptMinTrackSize.x = ((uint32_t)root->minwidth) + addwidth;
         mmi->ptMinTrackSize.y = ((uint32_t)root->minheight) + addheight;
-        mmi->ptMaxTrackSize.x = min(org::xwt::plat::Win32::getScreenWidth(), ((uint32_t)root->maxwidth) + addwidth);
-        mmi->ptMaxTrackSize.y = min(org::xwt::plat::Win32::getScreenHeight(), ((uint32_t)root->maxheight) + addheight);
+        mmi->ptMaxTrackSize.x = org::xwt::plat::Win32::getScreenWidth();
+        mmi->ptMaxTrackSize.y = org::xwt::plat::Win32::getScreenHeight();
         return 0;
         
     case WM_PAINT: