Commit in reactos/lib/rosky/libskygi on MAIN
libskygi.c+200-231.4 -> 1.5
stubs.c+1-561.5 -> 1.6
+201-79
2 modified files
implemented a few window placement functions and more checks for NULL-pointers

reactos/lib/rosky/libskygi
libskygi.c 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- libskygi.c	13 Aug 2004 11:24:07 -0000	1.4
+++ libskygi.c	13 Aug 2004 12:29:18 -0000	1.5
@@ -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.4 2004/08/13 11:24:07 weiden Exp $
+/* $Id: libskygi.c,v 1.5 2004/08/13 12:29:18 weiden Exp $
  *
  * PROJECT:         SkyOS GI library
  * FILE:            lib/libskygi/libskygi.c
@@ -546,6 +546,111 @@
 /*
  * @implemented
  */
+int __cdecl
+GI_GetWindowX(s_window *win)
+{
+  RECT rc;
+  PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
+  if((skywnd != NULL) && GetWindowRect(skywnd->hWnd, &rc))
+  {
+    MapWindowPoints(HWND_DESKTOP, GetParent(skywnd->hWnd), (LPPOINT)&rc, 2);
+    DBG("GI_GetWindowS(0x%x) returns %d!\n", win, rc.left);
+    return rc.left;
+  }
+  #if DEBUG
+  else
+  {
+    DBG("GI_GetWindowS(0x%x) failed!\n", win);
+  }
+  #endif
+  return 0;
+}
+
+
+/*
+ * @implemented
+ */
+int __cdecl
+GI_GetWindowY(s_window *win)
+{
+  RECT rc;
+  PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
+  if((skywnd != NULL) && GetWindowRect(skywnd->hWnd, &rc))
+  {
+    MapWindowPoints(HWND_DESKTOP, GetParent(skywnd->hWnd), (LPPOINT)&rc, 2);
+    DBG("GI_GetWindowY(0x%x) returns %d!\n", win, rc.top);
+    return rc.left;
+  }
+  #if DEBUG
+  else
+  {
+    DBG("GI_GetWindowY(0x%x) failed!\n", win);
+  }
+  #endif
+  return 0;
+}
+
+
+/*
+ * @implemented
+ */
+int __cdecl
+GI_GetWindowWidth(s_window *win)
+{
+  RECT rc;
+  PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
+  if((skywnd != NULL) && GetWindowRect(skywnd->hWnd, &rc))
+  {
+    DBG("GI_GetWindowWidth(0x%x) returns %d!\n", win, (rc.right - rc.left));
+    return (rc.right - rc.left);
+  }
+  #if DEBUG
+  else
+  {
+    DBG("GI_GetWindowWidth(0x%x) failed!\n", win);
+  }
+  #endif
+  return 0;
+}
+
+
+/*
+ * @implemented
+ */
+int __cdecl
+GI_GetWindowHeight(s_window *win)
+{
+  RECT rc;
+  PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
+  if((skywnd != NULL) && GetWindowRect(skywnd->hWnd, &rc))
+  {
+    DBG("GI_GetWindowHeight(0x%x) returns %d!\n", win, (rc.bottom - rc.top));
+    return (rc.bottom - rc.top);
+  }
+  #if DEBUG
+  else
+  {
+    DBG("GI_GetWindowHeight(0x%x) failed!\n", win);
+  }
+  #endif
+  return 0;
+}
+
+
+/*
+ * @unimplemented
+ */
+s_window* __cdecl
+GI_GetTopLevelWindow(s_window *win)
+{
+  STUB("GI_GetTopLevelWindow(0x%x) returns 0x%x!\n", win, win);
+  return win;
+}
+
+
+/*
+ * @implemented
+ */
 DIB* __cdecl
 GI_create_DIB(void *Data,
               unsigned int Width,
@@ -618,13 +723,19 @@
 GC_create_connected(unsigned int Type,
                     unsigned int Width,
                     unsigned int Height,
-                    HANDLE Win)
+                    s_window *Win)
 {
    SKY_GC *Gc;
 
    DBG("GC_create_connected(0x%x, 0x%x, 0x%x, 0x%x)\n",
        Type, Width, Height, Win);
 
+   if(Win == NULL)
+   {
+     DBG("GC_create_connected: no window specified! returned NULL!\n");
+     return NULL;
+   }
+
    Gc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SKY_GC));
    if (Gc == NULL)
    {
@@ -659,6 +770,7 @@
    if (Gc->hDC == NULL)
    {
       HeapFree(GetProcessHeap(), 0, Gc);
+      return NULL;
    }
    else
    {
@@ -677,9 +789,19 @@
 GC_set_fg_color(GC *Gc,
                 COLOR Color)
 {
-   Gc->fg_color = Color;
-   SetDCPenColor(((PSKY_GC)Gc)->hDC, Color);
-   return 1;
+   if(Gc != NULL)
+   {
+     Gc->fg_color = Color;
+     SetDCPenColor(((PSKY_GC)Gc)->hDC, Color);
+     return 1;
+   }
+   #if DEBUG
+   else
+   {
+     DBG("GC_set_fg_color: Gc == NULL!\n");
+   }
+   #endif
+   return 0;
 }
 
 
@@ -690,9 +812,19 @@
 GC_set_bg_color(GC *Gc,
                 COLOR Color)
 {
-   Gc->bg_color = Color;
-   SetDCBrushColor(((PSKY_GC)Gc)->hDC, Color);
-   return 1;
+   if(Gc != NULL)
+   {
+     Gc->bg_color = Color;
+     SetDCBrushColor(((PSKY_GC)Gc)->hDC, Color);
+     return 1;
+   }
+   #if DEBUG
+   else
+   {
+     DBG("GC_set_bg_color: Gc == NULL!\n");
+   }
+   #endif
+   return 0;
 }
 
 
@@ -704,8 +836,18 @@
               int X,
               int Y)
 {
-   SetPixelV(((PSKY_GC)Gc)->hDC, X, Y, Gc->fg_color);
-   return 1;
+   if(Gc != NULL)
+   {
+     SetPixelV(((PSKY_GC)Gc)->hDC, X, Y, Gc->fg_color);
+     return 1;
+   }
+   #if DEBUG
+   else
+   {
+     DBG("GC_draw_pixel: Gc == NULL!\n");
+   }
+   #endif
+   return 0;
 }
 
 
@@ -757,17 +899,32 @@
                  int Width,
                  int Height)
 {
-   HBRUSH hBrush;
-   RECT Rect = {X, Y, X + Width, Y + Height};
-
    DBG("GC_draw_rect_fill(0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n",
        Gc, X, Y, Width, Height);
 
-   hBrush = CreateSolidBrush(Gc->bg_color);
-   FillRect(((PSKY_GC)Gc)->hDC, &Rect, hBrush);
-   DeleteObject(hBrush);
+   if(Gc != NULL)
+   {
+     HBRUSH hBrush;
+     RECT Rect;
+
+     Rect.left = X;
+     Rect.top = Y;
+     Rect.right = X + Width;
+     Rect.bottom = Y + Height;
+
+     hBrush = CreateSolidBrush(Gc->bg_color);
+     FillRect(((PSKY_GC)Gc)->hDC, &Rect, hBrush);
+     DeleteObject(hBrush);
 
-   return 1;
+     return 1;
+   }
+   #if DEBUG
+   else
+   {
+     DBG("GC_draw_rect_fill: Gc == NULL!\n");
+   }
+   #endif
+   return 0;
 }
 
 
@@ -782,9 +939,19 @@
              int y2)
 {
    DBG("GC_draw_line(0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n", Gc, x1, y1, x2, y2);
-   MoveToEx(((PSKY_GC)Gc)->hDC, x1, y1, NULL);
-   LineTo(((PSKY_GC)Gc)->hDC, x2, y2);
-   return 1;
+   if(Gc != NULL)
+   {
+     MoveToEx(((PSKY_GC)Gc)->hDC, x1, y1, NULL);
+     LineTo(((PSKY_GC)Gc)->hDC, x2, y2);
+     return 1;
+   }
+   #if DEBUG
+   else
+   {
+     DBG("GC_draw_line: Gc == NULL!\n");
+   }
+   #endif
+   return 0;
 }
 
 
@@ -795,9 +962,19 @@
 GC_destroy(GC *Gc)
 {
    DBG("GC_destroy(0x%x)\n", Gc);
-   DeleteDC(((PSKY_GC)Gc)->hDC);
-   HeapFree(GetProcessHeap(), 0, Gc);
-   return 1;
+   if(Gc != NULL)
+   {
+     DeleteDC(((PSKY_GC)Gc)->hDC);
+     HeapFree(GetProcessHeap(), 0, Gc);
+     return 1;
+   }
+   #if DEBUG
+   else
+   {
+     DBG("GC_destroy: Gc == NULL!\n");
+   }
+   #endif
+   return 0;
 }
 
 /* EOF */

reactos/lib/rosky/libskygi
stubs.c 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- stubs.c	13 Aug 2004 11:24:07 -0000	1.5
+++ stubs.c	13 Aug 2004 12:29:19 -0000	1.6
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.5 2004/08/13 11:24:07 weiden Exp $
+/* $Id: stubs.c,v 1.6 2004/08/13 12:29:19 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         SkyOS GI library
@@ -237,61 +237,6 @@
 /*
  * @unimplemented
  */
-HANDLE __cdecl
-GI_GetTopLevelWindow(HANDLE hWnd)
-{
-  STUB("GI_GetTopLevelWindow(0x%x) returns NULL!\n", hWnd);
-  return NULL;
-}
-
-
-/*
- * @unimplemented
- */
-int __cdecl
-GI_GetWindowX(HANDLE hWnd)
-{
-  STUB("GI_GetWindowX(0x%x) returns 0!\n", hWnd);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
-int __cdecl
-GI_GetWindowY(HANDLE hWnd)
-{
-  STUB("GI_GetWindowY(0x%x) returns 0!\n", hWnd);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
-int __cdecl
-GI_GetWindowWidth(HANDLE hWnd)
-{
-  STUB("GI_GetWindowWidth(0x%x) returns 0!\n", hWnd);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
-int __cdecl
-GI_GetWindowHeight(HANDLE hWnd)
-{
-  STUB("GI_GetWindowHeight(0x%x) returns 0!\n", hWnd);
-  return 0;
-}
-
-
-/*
- * @unimplemented
- */
 int __cdecl
 GI_create_font(unsigned char *family,
                unsigned char *style,
CVSspam 0.2.8