X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ea258ad3489638fbcf504a674f8793b1362bd2b5..ef70f0ecdbc4268923e132b257c95e8a2525f4ca:/src/xpm/create.c?ds=sidebyside diff --git a/src/xpm/create.c b/src/xpm/create.c index a40b9882f7..a667eb8f75 100644 --- a/src/xpm/create.c +++ b/src/xpm/create.c @@ -141,21 +141,9 @@ LFUNC(APutImagePixels, void, (XImage *ximage, unsigned int width, # endif/* AMIGA */ #else /* FOR_MSW */ /* FOR_MSW pixel routine */ -#ifdef __OS2__ -LFUNC(MSWPutImagePixels, void, ( - HPS hps -, Display* dc -, XImage* image -, unsigned int width -, unsigned int height -, unsigned int* pixelindex -, Pixel* pixels -)); -#else LFUNC(MSWPutImagePixels, void, (Display *dc, XImage *image, unsigned int width, unsigned int height, unsigned int *pixelindex, Pixel *pixels)); -#endif #endif /* FOR_MSW */ #ifdef NEED_STRCASECMP @@ -233,20 +221,15 @@ typedef struct { long closeness; } CloseColor; -#ifdef __OS2__ -/* Visual Age cannot deal with old, non-ansi, code */ +#ifndef FOR_MSW static int closeness_cmp(Const void* a, Const void* b) -#else -static int -closeness_cmp(a, b) - Const void *a, *b; -#endif { CloseColor *x = (CloseColor *) a, *y = (CloseColor *) b; /* cast to int as qsort requires */ return (int) (x->closeness - y->closeness); } +#endif /* default AllocColor function: @@ -267,7 +250,7 @@ AllocColor( static int AllocColor(display, colormap, colorname, xcolor, closure) Display *display; - Colormap* colormap; + Colormap colormap; char *colorname; XColor *xcolor; void *closure; /* not used */ @@ -563,9 +546,9 @@ SetColor(display, colormap, visual, colorname, color_index, *mask_pixel = 0; #else #ifdef __OS2__ - *mask_pixel = OS2RGB(0,0,0); + *mask_pixel = OS2RGB(255,255,255); #else - *mask_pixel = RGB(0,0,0); + *mask_pixel = RGB(255,255,255); #endif #endif /* store the color table index */ @@ -877,7 +860,7 @@ XpmCreateImageFromXpmImage(display, image, #endif { #ifdef __OS2__ - HAB hab; + HAB hab = WinQueryAnchorBlock(HWND_DESKTOP); HPS hps; SIZEL sizl = {0, 0}; #endif @@ -1008,14 +991,8 @@ XpmCreateImageFromXpmImage(display, image, image->data, image_pixels); # endif #else /* FOR_MSW */ -#ifdef __OS2__ - hps = GpiCreatePS(hab, *display, &sizl, GPIA_ASSOC|PU_PELS); - MSWPutImagePixels(hps, display, ximage, image->width, image->height, - image->data, image_pixels); -#else MSWPutImagePixels(display, ximage, image->width, image->height, image->data, image_pixels); -#endif #endif } /* create the shape mask image */ @@ -1034,14 +1011,8 @@ XpmCreateImageFromXpmImage(display, image, image->data, mask_pixels); # endif #else /* FOR_MSW */ -#ifdef __OS2__ - hps = GpiCreatePS(hab, *display, &sizl, GPIA_ASSOC|PU_PELS); - MSWPutImagePixels(hps, display, shapeimage, image->width, image->height, - image->data, mask_pixels); -#else MSWPutImagePixels(display, shapeimage, image->width, image->height, image->data, mask_pixels); -#endif #endif } @@ -1961,8 +1932,7 @@ APutImagePixels ( #ifdef __OS2__ /* Visual Age cannot deal with old, non-ansi, code */ static void MSWPutImagePixels( - HPS hps -, Display* dc + Display* dc , XImage* image , unsigned int width , unsigned int height @@ -1987,7 +1957,7 @@ MSWPutImagePixels(dc, image, width, height, pixelindex, pixels) #ifdef __OS2__ POINTL point; - obm = GpiSetBitmap(hps, image->bitmap); + obm = GpiSetBitmap(*dc, image->bitmap); #else obm = SelectObject(*dc, image->bitmap); #endif @@ -1997,8 +1967,8 @@ MSWPutImagePixels(dc, image, width, height, pixelindex, pixels) #ifdef __OS2__ point.x = x; point.y = y; - GpiSetColor(hps, (LONG)pixels[*(data++)]); - GpiSetPel(hps, &point); + GpiSetColor(*dc, (LONG)pixels[*(data++)]); + GpiSetPel(*dc, &point); #else SetPixel(*dc, x, y, pixels[*(data++)]); /* data is [x+y*width] */ @@ -2006,7 +1976,7 @@ MSWPutImagePixels(dc, image, width, height, pixelindex, pixels) } } #ifdef __OS2__ - GpiSetBitmap(hps, obm); + GpiSetBitmap(*dc, obm); #else SelectObject(*dc, obm); #endif @@ -2603,8 +2573,7 @@ ParseAndPutPixels( { unsigned int a, x, y; #ifdef __OS2__ - HAB hab; - HPS hps; + HAB hab = WinQueryAnchorBlock(HWND_DESKTOP); DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL}; SIZEL sizl = {0, 0}; POINTL point; @@ -2623,8 +2592,8 @@ ParseAndPutPixels( if ( shapeimage ) { #ifdef __OS2__ shapedc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); - hps = GpiCreatePS(hab, *dc, &sizl, GPIA_ASSOC | PU_PELS); - sobm = GpiSetBitmap(hps, shapeimage->bitmap); + *dc = GpiCreatePS(hab, shapedc, &sizl, GPIA_ASSOC | PU_PELS); + sobm = GpiSetBitmap(*dc, shapeimage->bitmap); #else shapedc = CreateCompatibleDC(*dc); sobm = SelectObject(shapedc, shapeimage->bitmap); @@ -2633,7 +2602,7 @@ ParseAndPutPixels( shapedc = NULL; } #ifdef __OS2__ - obm = GpiSetBitmap(hps, image->bitmap); + obm = GpiSetBitmap(*dc, image->bitmap); #else obm = SelectObject(*dc, image->bitmap); #endif @@ -2658,19 +2627,19 @@ ParseAndPutPixels( shape_pixels[colidx[c] - 1]); #else #ifdef __OS2__ - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)image_pixels[colidx[c] - 1]); - GpiSetPel(hps, &point); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)image_pixels[colidx[c] - 1]); + GpiSetPel(*dc, &point); #else SetPixel(*dc, x, y, image_pixels[colidx[c] - 1]); #endif if (shapedc) { #ifdef __OS2__ - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)shape_pixels[colidx[c] - 1]); - GpiSetPel(hps, &point); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)shape_pixels[colidx[c] - 1]); + GpiSetPel(*dc, &point); #else SetPixel(shapedc, x, y, shape_pixels[colidx[c] - 1]); #endif @@ -2683,15 +2652,16 @@ ParseAndPutPixels( #ifdef FOR_MSW if ( shapedc ) { #ifdef __OS2__ - GpiSetBitmap(hps, sobm); - DevCloseDC(shapedc); + GpiSetBitmap(*dc, sobm); + GpiDestroyPS(*dc); + DevCloseDC(shapedc); #else SelectObject(shapedc, sobm); - DeleteDC(shapedc); + DeleteDC(shapedc); #endif } #ifdef __OS2__ - GpiSetBitmap(hps, obm); + GpiSetBitmap(*dc, obm); #else SelectObject(*dc, obm); #endif @@ -2709,6 +2679,9 @@ if (cidx[f]) XpmFree(cidx[f]);} /* array of pointers malloced by need */ unsigned short *cidx[256]; int char1; +#ifdef __OS2__ + HDC shapedc; +#endif bzero((char *)cidx, 256 * sizeof(unsigned short *)); /* init */ for (a = 0; a < ncolors; a++) { @@ -2740,25 +2713,25 @@ if (cidx[f]) XpmFree(cidx[f]);} shape_pixels[cidx[cc1][cc2] - 1]); #else #ifdef __OS2__ - *dc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); - hps = GpiCreatePS(hab, *dc, &sizl, GPIA_ASSOC | PU_PELS); - - GpiSetBitmap(hps, image->bitmap); - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)image_pixels[cidx[cc1][cc2] - 1]); - GpiSetPel(hps, &point); + shapedc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); + *dc = GpiCreatePS(hab, shapedc, &sizl, GPIA_ASSOC | PU_PELS); + + GpiSetBitmap(*dc, image->bitmap); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)image_pixels[cidx[cc1][cc2] - 1]); + GpiSetPel(*dc, &point); #else - SelectObject(*dc, image->bitmap); - SetPixel(*dc, x, y, image_pixels[cidx[cc1][cc2] - 1]); + SelectObject(*dc, image->bitmap); + SetPixel(*dc, x, y, image_pixels[cidx[cc1][cc2] - 1]); #endif if (shapeimage) { #ifdef __OS2__ - GpiSetBitmap(hps, shapeimage->bitmap); - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)shape_pixels[cidx[cc1][cc2] - 1]); - GpiSetPel(hps, &point); + GpiSetBitmap(*dc, shapeimage->bitmap); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)shape_pixels[cidx[cc1][cc2] - 1]); + GpiSetPel(*dc, &point); #else SelectObject(*dc, shapeimage->bitmap); SetPixel(*dc, x, y, @@ -2785,6 +2758,9 @@ if (cidx[f]) XpmFree(cidx[f]);} { char *s; char buf[BUFSIZ]; +#ifdef __OS2__ + HDC shapedc; +#endif buf[cpp] = '\0'; if (USE_HASHTABLE) { @@ -2806,14 +2782,15 @@ if (cidx[f]) XpmFree(cidx[f]);} shape_pixels[HashColorIndex(slot)]); #else #ifdef __OS2__ - *dc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); - hps = GpiCreatePS(hab, *dc, &sizl, GPIA_ASSOC | PU_PELS); - GpiSetBitmap(hps, image->bitmap); - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)image_pixels[HashColorIndex(slot)]); - GpiSetPel(hps, &point); + shapedc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); + *dc = GpiCreatePS(hab, shapedc, &sizl, GPIA_ASSOC | PU_PELS); + + GpiSetBitmap(*dc, image->bitmap); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)image_pixels[HashColorIndex(slot)]); + GpiSetPel(*dc, &point); #else SelectObject(*dc, image->bitmap); SetPixel(*dc, x, y, @@ -2821,11 +2798,11 @@ if (cidx[f]) XpmFree(cidx[f]);} #endif if (shapeimage) { #ifdef __OS2__ - GpiSetBitmap(hps, shapeimage->bitmap); - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)shape_pixels[HashColorIndex(slot)]); - GpiSetPel(hps, &point); + GpiSetBitmap(*dc, shapeimage->bitmap); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)shape_pixels[HashColorIndex(slot)]); + GpiSetPel(*dc, &point); #else SelectObject(*dc, shapeimage->bitmap); SetPixel(*dc, x, y, @@ -2852,25 +2829,26 @@ if (cidx[f]) XpmFree(cidx[f]);} XPutPixel(shapeimage, x, y, shape_pixels[a]); #else #ifdef __OS2__ - *dc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); - hps = GpiCreatePS(hab, *dc, &sizl, GPIA_ASSOC | PU_PELS); - GpiSetBitmap(hps, image->bitmap); - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)image_pixels[a]); - GpiSetPel(hps, &point); + shapedc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); + *dc = GpiCreatePS(hab, shapedc, &sizl, GPIA_ASSOC | PU_PELS); + + GpiSetBitmap(*dc, image->bitmap); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)image_pixels[a]); + GpiSetPel(*dc, &point); #else SelectObject(*dc, image->bitmap); SetPixel(*dc, x, y, image_pixels[a]); #endif if (shapeimage) { #ifdef __OS2__ - GpiSetBitmap(hps, image->bitmap); - point.x = x; - point.y = y; - GpiSetColor(hps, (LONG)shape_pixels[a]); - GpiSetPel(hps, &point); + GpiSetBitmap(*dc, image->bitmap); + point.x = x; + point.y = y; + GpiSetColor(*dc, (LONG)shape_pixels[a]); + GpiSetPel(*dc, &point); #else SelectObject(*dc, shapeimage->bitmap); SetPixel(*dc, x, y, shape_pixels[a]);