]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xpm/scan.c
AddBook ignores wxMac paths (still won't work)
[wxWidgets.git] / src / xpm / scan.c
index 93c7f72a1df8f0f53f1ec4b065d939114f0373a0..f5e61bb78df26043c069793d643cf12a57ebad60 100644 (file)
@@ -96,16 +96,25 @@ LFUNC(AGetImagePixels, int, (XImage *image, unsigned int width,
                             int (*storeFunc) ()));
 # endif/* AMIGA */
 #else  /* ndef FOR_MSW */
+
+#if defined(__OS2__) && defined(__VISAGECPP30__)
+LFUNC(MSWGetImagePixels, int, (Display* display, XImage* image, unsigned int width,
+                               unsigned int height, PixelsMap* pmap,
+                               int (*storeFunc) (Pixel, PixelsMap*, unsigned int*)));
+#else
 LFUNC(MSWGetImagePixels, int, (Display *d, XImage *image, unsigned int width,
-                              unsigned int height, PixelsMap *pmap,
-                              int (*storeFunc) ()));
+                   unsigned int height, PixelsMap *pmap,
+                   int (*storeFunc) ()));
 #endif
+
+#endif
+
 LFUNC(ScanTransparentColor, int, (XpmColor *color, unsigned int cpp,
-                                 XpmAttributes *attributes));
+                  XpmAttributes *attributes));
 
 LFUNC(ScanOtherColors, int, (Display *display, XpmColor *colors, int ncolors,
-                            Pixel *pixels, unsigned int mask,
-                            unsigned int cpp, XpmAttributes *attributes));
+                 Pixel *pixels, unsigned int mask,
+                 unsigned int cpp, XpmAttributes *attributes));
 
 /*
  * This function stores the given pixel in the given arrays which are grown
@@ -261,24 +270,23 @@ XpmCreateXpmImageFromImage(display, image, shapeimage,
     /*
      * scan shape mask if any
      */
-    if (shapeimage) {
+    if (shapeimage)
+    {
 #ifndef FOR_MSW
 # ifndef AMIGA
-       ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap,
-                                     storeMaskPixel);
+           ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap,
+                                     storeMaskPixel);
 # else
-       ErrorStatus = AGetImagePixels(shapeimage, width, height, &pmap,
-                                     storeMaskPixel);
-# endif
+           ErrorStatus = AGetImagePixels(shapeimage, width, height, &pmap,
+                                     storeMaskPixel);
+# endif /* AMIGA */
 #else
 
-#ifndef __OS2__
-       ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,
-                                       &pmap, storeMaskPixel);
-/* calling convention all messed up OS/2 -- figure out later */
-#endif
+           ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,
+                                       &pmap, storeMaskPixel);
+
+#endif /* ndef for FOR_MSW */
 
-#endif
        if (ErrorStatus != XpmSuccess)
            RETURN(ErrorStatus);
     }
@@ -291,36 +299,38 @@ XpmCreateXpmImageFromImage(display, image, shapeimage,
      *
      */
 
-    if (image) {
+    if (image)
+    {
 #ifndef FOR_MSW
 # ifndef AMIGA
-       if (((image->bits_per_pixel | image->depth) == 1)  &&
-           (image->byte_order == image->bitmap_bit_order))
-           ErrorStatus = GetImagePixels1(image, width, height, &pmap,
-                                         storePixel);
-       else if (image->format == ZPixmap) {
-           if (image->bits_per_pixel == 8)
-               ErrorStatus = GetImagePixels8(image, width, height, &pmap);
-           else if (image->bits_per_pixel == 16)
-               ErrorStatus = GetImagePixels16(image, width, height, &pmap);
-           else if (image->bits_per_pixel == 32)
-               ErrorStatus = GetImagePixels32(image, width, height, &pmap);
-       } else
-           ErrorStatus = GetImagePixels(image, width, height, &pmap);
+           if (((image->bits_per_pixel | image->depth) == 1)  &&
+               (image->byte_order == image->bitmap_bit_order))
+           ErrorStatus = GetImagePixels1(image, width, height, &pmap,
+                                         storePixel);
+           else if (image->format == ZPixmap)
+       {
+               if (image->bits_per_pixel == 8)
+                   ErrorStatus = GetImagePixels8(image, width, height, &pmap);
+               else if (image->bits_per_pixel == 16)
+                       ErrorStatus = GetImagePixels16(image, width, height, &pmap);
+           else if (image->bits_per_pixel == 32)
+                       ErrorStatus = GetImagePixels32(image, width, height, &pmap);
+       }
+           else
+               ErrorStatus = GetImagePixels(image, width, height, &pmap);
 # else
-       ErrorStatus = AGetImagePixels(image, width, height, &pmap,
-                                     storePixel);
-# endif
+           ErrorStatus = AGetImagePixels(image, width, height, &pmap,
+                                     storePixel);
+# endif /* AMIGA */
 #else
 
-#ifndef __OS2__
-       ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap,
-                                       storePixel);
-#endif
+           ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap,
+                                       storePixel);
 
 #endif
-       if (ErrorStatus != XpmSuccess)
-           RETURN(ErrorStatus);
+
+           if (ErrorStatus != XpmSuccess)
+               RETURN(ErrorStatus);
     }
 
     /*
@@ -500,7 +510,7 @@ ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes)
        return (XpmNoMemory);
 
     for (i = 0, i2 = mask, color = colors, xcolor = xcolors;
-        i < ncolors; i++, i2++, color++, xcolor++, pixels++) {
+        i < (unsigned)ncolors; i++, i2++, color++, xcolor++, pixels++) {
 
        if (!(s = color->string = (char *) XpmMalloc(cpp + 1))) {
            XpmFree(xcolors);
@@ -543,7 +553,7 @@ ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes)
     }
 /* end 3.2 bc */
 
-    for (i = 0, color = colors, xcolor = xcolors; i < ncolors;
+    for (i = 0, color = colors, xcolor = xcolors; i < (unsigned)ncolors;
                                                  i++, color++, xcolor++) {
 
        /* look for related info from the attributes if any */
@@ -595,7 +605,7 @@ ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes)
 #else
                sprintf(buf, "#%02x%02x%02x",
                        xcolor->red, xcolor->green, xcolor->blue);
-#endif                 
+#endif
                color->c_color = (char *) xpmstrdup(buf);
            }
            if (!color->c_color) {
@@ -644,22 +654,12 @@ static unsigned long Const low_bits_table[] = {
  *
  */
 
-#ifdef __OS2__
-/* Visual Age cannot deal with old, non-ansi, code */
-static int GetImagePixels(
-  XImage*      image
-, unsigned int width
-, unsigned int height
-, PixelsMap*   pmap
-)
-#else
 static int
 GetImagePixels(image, width, height, pmap)
     XImage *image;
     unsigned int width;
     unsigned int height;
     PixelsMap *pmap;
-#endif
 {
     char *src;
     char *dst;
@@ -757,22 +757,12 @@ GetImagePixels(image, width, height, pmap)
 static unsigned long byteorderpixel = MSBFirst << 24;
 #endif
 
-#ifdef __OS2__
-/* Visual Age cannot deal with old, non-ansi, code */
-static int GetImagePixels32(
-  XImage*      image
-, unsigned int width
-, unsigned int height
-, PixelsMap*   pmap
-)
-#else
 static int
 GetImagePixels32(image, width, height, pmap)
     XImage *image;
     unsigned int width;
     unsigned int height;
     PixelsMap *pmap;
-#endif
 {
     unsigned char *addr;
     unsigned char *data;
@@ -832,22 +822,12 @@ GetImagePixels32(image, width, height, pmap)
  * scan pixels of a 16-bits Z image data structure
  */
 
-#ifdef __OS2__
-/* Visual Age cannot deal with old, non-ansi, code */
-static int GetImagePixels16(
-  XImage*      image
-, unsigned int width
-, unsigned int height
-, PixelsMap*   pmap
-)
-#else
 static int
 GetImagePixels16(image, width, height, pmap)
     XImage *image;
     unsigned int width;
     unsigned int height;
     PixelsMap *pmap;
-#endif
 {
     unsigned char *addr;
     unsigned char *data;
@@ -888,23 +868,12 @@ GetImagePixels16(image, width, height, pmap)
  * scan pixels of a 8-bits Z image data structure
  */
 
-#ifdef __OS2__
-/* Visual Age cannot deal with old, non-ansi, code */
-static int
-GetImagePixels8(image, width, height, pmap)
-  XImage*      image
-, unsigned int width
-, unsigned int height
-, PixelsMap*   pmap
-)
-#else
 static int
 GetImagePixels8(image, width, height, pmap)
     XImage *image;
     unsigned int width;
     unsigned int height;
     PixelsMap *pmap;
-#endif
 {
     unsigned int *iptr;
     unsigned char *data;
@@ -932,17 +901,6 @@ GetImagePixels8(image, width, height, pmap)
  * scan pixels of a 1-bit depth Z image data structure
  */
 
-#ifdef __OS2__
-/* Visual Age cannot deal with old, non-ansi, code */
-static int
-GetImagePixels1(
-  XImage*      image
-, unsigned int width
-, unsigned int height
-, PixelsMap*   pmap
-, int          (*storeFunc) ()
-)
-#else
 static int
 GetImagePixels1(image, width, height, pmap, storeFunc)
     XImage *image;
@@ -950,7 +908,6 @@ GetImagePixels1(image, width, height, pmap, storeFunc)
     unsigned int height;
     PixelsMap *pmap;
     int (*storeFunc) ();
-#endif
 {
     unsigned int *iptr;
     int x, y;
@@ -1034,10 +991,20 @@ AGetImagePixels (
 
 # endif/* AMIGA */
 #else  /* ndef FOR_MSW */
+
 #ifdef __OS2__
-/* Visual Age cannot deal with old, non-ansi, code */
-static int
-MSWGetImagePixels(
+
+#ifdef __VISAGECPP30__
+static int MSWGetImagePixels(
+  Display*     display
+, XImage*      image
+, unsigned int width
+, unsigned int height
+, PixelsMap*   pmap
+, int          (*storeFunc) (Pixel, PixelsMap*, unsigned int*)
+)
+#else
+static int MSWGetImagePixels(
   Display*     display
 , XImage*      image
 , unsigned int width
@@ -1045,6 +1012,8 @@ MSWGetImagePixels(
 , PixelsMap*   pmap
 , int          (*storeFunc) ()
 )
+#endif
+
 #else
 static int
 MSWGetImagePixels(display, image, width, height, pmap, storeFunc)
@@ -1060,8 +1029,8 @@ MSWGetImagePixels(display, image, width, height, pmap, storeFunc)
     unsigned int x, y;
     Pixel pixel;
 #ifdef __OS2__
-     HAB          hab;
-     HPS          hps;
+     HAB          hab = WinQueryAnchorBlock(HWND_DESKTOP);
+     HDC          shapedc;
      DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL};
      SIZEL        sizl = {0, 0};
      POINTL       point;
@@ -1070,8 +1039,9 @@ MSWGetImagePixels(display, image, width, height, pmap, storeFunc)
     iptr = pmap->pixelindex;
 
 #ifdef __OS2__
-    hps = GpiCreatePS(hab, *display, &sizl, GPIA_ASSOC | PU_PELS);
-    GpiSetBitmap(hps, image->bitmap);
+    shapedc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
+    *display = GpiCreatePS(hab, shapedc, &sizl, GPIA_ASSOC | PU_PELS);
+    GpiSetBitmap(*display, image->bitmap);
 #else
     SelectObject(*display, image->bitmap);
 #endif
@@ -1081,15 +1051,13 @@ MSWGetImagePixels(display, image, width, height, pmap, storeFunc)
 #ifdef __OS2__
      point.x = x;
      point.y = y;
-     pixel = GpiQueryPel(hps, &point);
+     pixel = GpiQueryPel(*display, &point);
 #else
            pixel = GetPixel(*display, x, y);
 #endif
-#ifndef __OS2__
-/* calling convention all messed up under OS/2 */
+
            if ((*storeFunc) (pixel, pmap, iptr))
                return (XpmNoMemory);
-#endif
        }
     }
     return (XpmSuccess);