Commit in reactos on MAIN
include/rosky/structs.h+5-51.2 -> 1.3
lib/rosky/libskygi/Makefile+2-21.1 -> 1.2
                  /libskygi.c+218-11.1 -> 1.2
                  /stubs.c+1-691.2 -> 1.3
+226-77
4 modified files
started an interface to emulate the skygi windowing but actually use win32 apis

reactos/include/rosky
structs.h 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- structs.h	12 Aug 2004 15:41:35 -0000	1.2
+++ structs.h	12 Aug 2004 19:27:12 -0000	1.3
@@ -191,7 +191,7 @@
   unsigned int width;
   unsigned int orgx;
   unsigned int orgy;
-  unsigned long (*win_func)(HANDLE win, s_gi_msg *m);
+  unsigned long (__cdecl *win_func)(HANDLE win, s_gi_msg *m);
   HANDLE handle;
 
   struct s_window *parent;
@@ -211,10 +211,10 @@
 typedef struct sCreateApplication
 {
   unsigned char ucApplicationName[255];
-  unsigned int  uiX;
-  unsigned int  uiY;
-  unsigned int  uiWidth;
-  unsigned int  uiHeight;
+  unsigned int uiX;
+  unsigned int uiY;
+  unsigned int uiWidth;
+  unsigned int uiHeight;
 
   void *fwndClient;
   unsigned int uiStyleApplication;

reactos/lib/rosky/libskygi
Makefile 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- Makefile	12 Aug 2004 02:50:35 -0000	1.1
+++ Makefile	12 Aug 2004 19:27:12 -0000	1.2
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.1 2004/08/12 02:50:35 weiden Exp $
+# $Id: Makefile,v 1.2 2004/08/12 19:27:12 weiden Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -18,7 +18,7 @@
 
 TARGET_LFLAGS = -nostartfiles -nostdlib
 
-TARGET_SDKLIBS = ntdll.a kernel32.a
+TARGET_SDKLIBS = ntdll.a kernel32.a user32.a
 
 TARGET_ENTRY = 0x00000000
 

reactos/lib/rosky/libskygi
libskygi.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- libskygi.c	12 Aug 2004 02:50:35 -0000	1.1
+++ libskygi.c	12 Aug 2004 19:27:12 -0000	1.2
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: libskygi.c,v 1.1 2004/08/12 02:50:35 weiden Exp $
+/* $Id: libskygi.c,v 1.2 2004/08/12 19:27:12 weiden Exp $
  *
  * PROJECT:         SkyOS GI library
  * FILE:            lib/libskygi/libskygi.c
@@ -30,5 +30,222 @@
 #include "libskygi.h"
 #include "resource.h"
 
+typedef struct
+{
+  s_window Window;
+  MSG LastMsg;
+  HWND hWnd;
+  s_gi_msg DispatchMsg;
+} SKY_WINDOW, *PSKY_WINDOW;
+
+static ATOM SkyClassAtom;
+static BOOL SkyClassRegistered = FALSE;
+
+LRESULT CALLBACK
+SkyWndDefaultWin32Proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+  PSKY_WINDOW skw = (PSKY_WINDOW)GetWindowLong(hWnd, GWL_USERDATA);
+  
+  if(skw != NULL)
+  {
+    switch(msg)
+    {
+      case WM_CLOSE:
+        PostQuitMessage(0);
+        break;
+      case WM_NCDESTROY:
+        /* free the SKY_WINDOW structure */
+        HeapFree(GetProcessHeap(), 0, skw);
+        break;
+    }
+  }
+  return DefWindowProc(hWnd, msg, wParam, lParam);
+}
+
+ATOM
+SkyWndRegisterClass(void)
+{
+  WNDCLASS wc;
+  
+  wc.lpszClassName = "ROSkyWindow";
+  wc.lpfnWndProc = SkyWndDefaultWin32Proc;
+  wc.style = CS_VREDRAW | CS_HREDRAW;
+  wc.hInstance = GetModuleHandle(NULL);
+  wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
+  wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
+  wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
+  wc.lpszMenuName = NULL;
+  wc.cbClsExtra = 0;
+  wc.cbWndExtra = 0;
+  
+  return RegisterClass(&wc);
+}
+
+
+/*
+ * @implemented
+ */
+s_window* __cdecl
+GI_create_app(app_para *p)
+{
+  PSKY_WINDOW skw;
+  
+  DBG("GI_create_app(0x%x)\n", p);
+
+  /* FIXME - lock */
+  if(!SkyClassRegistered)
+  {
+    SkyClassAtom = SkyWndRegisterClass();
+    SkyClassRegistered = SkyClassAtom != 0;
+
+    if(!SkyClassRegistered)
+    {
+      DBG("Unable to register the ROSkyWindow class\n");
+      return NULL;
+    }
+  }
+  /* FIXME - unlock */
+  
+  skw = (PSKY_WINDOW)HeapAlloc(GetProcessHeap(),
+                               HEAP_ZERO_MEMORY,
+                               sizeof(SKY_WINDOW));
+  if(skw == NULL)
+  {
+    DBG("Not enough memory to allocate a SKY_WINDOW structure!\n");
+    return NULL;
+  }
+  
+  skw->hWnd = CreateWindow("ROSkyWindow",
+                           (p->cpName[0] != '\0' ? (char*)p->cpName : ""),
+                           WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
+                           p->ulX,
+                           p->ulY,
+                           p->ulWidth,
+                           p->ulHeight,
+                           NULL,
+                           NULL,
+                           GetModuleHandle(NULL),
+                           NULL);
+
+  if(skw->hWnd == NULL)
+  {
+    DBG("CreateWindow() failed!\n");
+    HeapFree(GetProcessHeap(), 0, skw);
+    return NULL;
+  }
+
+  skw->Window.win_func = p->win_func;
+  /* FIXME - fill the window structure */
+  
+  /* save the pointer to the structure so we can access it later when dispatching
+     the win32 messages so we know which sky window it is and dispatch the right
+     messages */
+  SetWindowLong(skw->hWnd, GWL_USERDATA, (LONG)skw);
+  
+  DBG("Created Win32 window: 0x%x\n", skw->hWnd);
+  
+  return &skw->Window;
+}
+
+/*
+ * @implemented
+ */
+int __cdecl
+GI_destroy_window(s_window *win)
+{
+  PSKY_WINDOW skw = (PSKY_WINDOW)win;
+
+  DBG("GI_destroy_window(0x%x)\n", win);
+  
+  return (int)DestroyWindow(skw->hWnd);
+}
+
+
+/*
+ * @implemented
+ */
+unsigned int __cdecl
+GI_wait_message(s_gi_msg *m,
+                s_window* w)
+{
+  MSG Msg;
+  BOOL Ret;
+  HWND hwndFilter;
+  PSKY_WINDOW msgwnd, filterwnd;
+  
+  DBG("GI_wait_message(0x%x, 0x%x)\n", m, w);
+  
+  filterwnd = (w != NULL ? (PSKY_WINDOW)w : NULL);
+  
+  hwndFilter = (w != NULL ? filterwnd->hWnd : NULL);
+  Ret = GetMessage(&Msg, hwndFilter, 0, 0);
+  if(Ret)
+  {
+    if(Msg.hwnd != NULL)
+    {
+      msgwnd = (PSKY_WINDOW)GetWindowLong(Msg.hwnd, GWL_USERDATA);
+      msgwnd->LastMsg = Msg;
+    }
+    else
+    {
+      msgwnd = NULL;
+    }
+  }
+  
+  RtlZeroMemory(m, sizeof(s_gi_msg));
+  m->win = (msgwnd != NULL ? &msgwnd->Window : NULL);
+  /* FIXME - fill in the other messags */
+  
+  return (int)Ret;
+}
+
+
+/*
+ * @implemented
+ */
+int __cdecl
+GI_dispatch_message(s_window *win,
+                    s_gi_msg *m)
+{
+  PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
+  DBG("GI_dispatch_message(0x%x, 0x%x)\n", win, m);
+  
+  skywnd->DispatchMsg = *m;
+  DispatchMessage(&skywnd->LastMsg);
+  
+  return 1;
+}
+
+
+/*
+ * @implemented
+ */
+HRESULT __cdecl
+GI_ShowApplicationWindow(s_window *win)
+{
+  PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
+  DBG("GI_ShowApplicationWindow(0x%x)\n", win);
+  
+  DBG("->0x%x\n", skywnd->hWnd);
+  ShowWindow(skywnd->hWnd, SW_SHOW);
+  return 1;
+}
+
+
+/*
+ * @implemented
+ */
+sCreateApplication* __cdecl
+GI_CreateApplicationStruct(void)
+{
+  sCreateApplication *app;
+  
+  app = (sCreateApplication*)HeapAlloc(GetProcessHeap(),
+                                       HEAP_ZERO_MEMORY,
+                                       sizeof(sCreateApplication));
+  STUB("GI_CreateApplicationStruct() returns 0x%x (allocated structure on the heap)!\n", app);
+
+  return app;
+}
 
 /* EOF */

reactos/lib/rosky/libskygi
stubs.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- stubs.c	12 Aug 2004 15:41:36 -0000	1.2
+++ stubs.c	12 Aug 2004 19:27:12 -0000	1.3
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.2 2004/08/12 15:41:36 weiden Exp $
+/* $Id: stubs.c,v 1.3 2004/08/12 19:27:12 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         SkyOS GI library
@@ -119,17 +119,6 @@
 /*
  * @unimplemented
  */
-HRESULT __cdecl
-GI_ShowApplicationWindow(HANDLE hWnd)
-{
-  STUB("GI_ShowApplicationWindow(0x%x) returns 0!\n", hWnd);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
 int __cdecl
 GI_add_menu_item(widget_menu *menu,
                  widget_menu_item *item)
@@ -166,17 +155,6 @@
 /*
  * @unimplemented
  */
-HANDLE __cdecl
-GI_create_app(app_para *p)
-{
-  STUB("GI_create_app(0x%x) returns NULL!\n", p);
-  return NULL;
-}
-
-
-/*
- * @unimplemented
- */
 widget_menu* __cdecl
 GI_create_menu(HANDLE win)
 {
@@ -203,29 +181,6 @@
  * @unimplemented
  */
 int __cdecl
-GI_destroy_window(s_window *win)
-{
-  STUB("GI_destroy_window(0x%x) returns 0!\n", win);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
-int __cdecl
-GI_dispatch_message(s_window *win,
-                    s_gi_msg *m)
-{
-  STUB("GI_dispatch_message(0x%x, 0x%x) returns 0!\n", win, m);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
-int __cdecl
 GI_kill_timer(unsigned int uiID)
 {
   STUB("GI_kill_timer(0x%x) returns 0!\n", uiID);
@@ -283,18 +238,6 @@
 /*
  * @unimplemented
  */
-unsigned int __cdecl
-GI_wait_message(s_gi_msg *m,
-                s_window* w)
-{
-  STUB("GI_wait_message(0x%x, 0x%x) returns 0!\n", m, w);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
 int __cdecl
 GC_draw_text(GC *gc,
              s_region *rect,
@@ -371,17 +314,6 @@
 /*
  * @unimplemented
  */
-sCreateApplication* __cdecl
-GI_CreateApplicationStruct(void)
-{
-  STUB("GI_CreateApplicationStruct() returns NULL!\n");
-  return NULL;
-}
-
-
-/*
- * @unimplemented
- */
 HANDLE __cdecl
 GI_CreateApplication(sCreateApplication *application)
 {
CVSspam 0.2.8