2004/01/14 05:18:34
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:44:29 +0000 (07:44 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:44:29 +0000 (07:44 +0000)
darcs-hash:20040130074429-2ba56-907f2c9bd44a76fabc100c32dad5873805df31e0.gz

src/org/xwt/plat/Darwin.java
src/org/xwt/plat/OpenGL.java
src/org/xwt/plat/Win32.cc

index f3dd670..7743441 100644 (file)
@@ -101,20 +101,20 @@ public class Darwin extends POSIX {
     
     private final class CarbonOpenGL extends OpenGL {
         public RawData rawPixelFormat;
-        public RawData rawSharedInterpreter;
+        public RawData rawSharedContext;
         public int maxAglSurfaceTexSize;
         public int maxSurfaceWidth;
         public int maxSurfaceHeight;
         
         private native boolean initPixelFormat();
-        private native void initSharedInterpreter();
+        private native void initSharedContext();
         
         public CarbonOpenGL() throws NotSupportedException {
             if(!jaguar)
                 throw new NotSupportedException("OpenGL requires Mac OS X 10.2 or greater");
             if(!initPixelFormat())
                 throw new NotSupportedException("Couldn't get an acceptable pixel format");
-            initSharedInterpreter();
+            initSharedContext();
         }
         
         public void init() throws NotSupportedException {
@@ -126,7 +126,7 @@ public class Darwin extends POSIX {
             }
             maxSurfaceWidth = maxSurfaceHeight = maxAglSurfaceTexSize;
         }
-        protected native void activateSharedInterpreter();
+        protected native void activateSharedContext();
     }
     
     static abstract class CarbonSurface extends Surface.DoubleBufferedSurface {  
@@ -219,7 +219,7 @@ public class Darwin extends POSIX {
             CarbonMessage.add(new CarbonMessage() { public void perform() { GLCarbonPixelBuffer.this.natInit(); sem.release(); } });
             sem.block();
         }
-        public native void activateInterpreter();
+        public native void activateContext();
         protected void finalize() {
             CarbonMessage.add(new CarbonMessage() { public void perform() { natCleanup(rawWindowRef,rawCTX); } });
             gl.deleteTexture(textureName);
index 8abd903..3b8d689 100644 (file)
@@ -29,7 +29,7 @@ abstract class OpenGL {
         }
     }
     
-    // This MUST be called after OpenGL is instansiated (and activateSharedInterpreter is functioning)
+    // This MUST be called after OpenGL is instansiated (and activateSharedContext is functioning)
     public void init() throws NotSupportedException {
         natInit();
         glVersion = parseVersion(version);
@@ -47,7 +47,7 @@ abstract class OpenGL {
         Log.diag(this,"Max rectangular texture size: " + maxRectTexSize);
     }
     
-    protected abstract void activateSharedInterpreter();
+    protected abstract void activateSharedContext();
 
     public static class NotSupportedException extends Exception {
         public NotSupportedException(String s) { super(s); }
@@ -67,7 +67,7 @@ abstract class OpenGL {
         }
         
         // This should activate the drawing context and prepare the double buffer for drawing
-        protected abstract void activateInterpreter();
+        protected abstract void activateContext();
         
         protected static native void drawableInit(int w, int h);
         
@@ -89,7 +89,7 @@ abstract class OpenGL {
         }
 
         private void drawPicture_(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int color) {
-            activateInterpreter();
+            activateContext();
             setColor(color);
             GLPicture p = getInnerPicture(source, gl);
             p.draw(dx,dy,cx1,cy1,cx2,cy2);
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: