OS/2 updates for XPM
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9213 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
151
src/xpm/create.c
151
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
|
||||
@@ -1008,14 +996,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 +1016,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 +1937,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 +1962,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 +1972,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 +1981,7 @@ MSWPutImagePixels(dc, image, width, height, pixelindex, pixels)
|
||||
}
|
||||
}
|
||||
#ifdef __OS2__
|
||||
GpiSetBitmap(hps, obm);
|
||||
GpiSetBitmap(*dc, obm);
|
||||
#else
|
||||
SelectObject(*dc, obm);
|
||||
#endif
|
||||
@@ -2604,7 +2579,6 @@ ParseAndPutPixels(
|
||||
unsigned int a, x, y;
|
||||
#ifdef __OS2__
|
||||
HAB hab;
|
||||
HPS hps;
|
||||
DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
SIZEL sizl = {0, 0};
|
||||
POINTL point;
|
||||
@@ -2623,8 +2597,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 +2607,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 +2632,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 +2657,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 +2684,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 +2718,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);
|
||||
shapedc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
||||
*dc = GpiCreatePS(hab, shapedc, &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);
|
||||
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 +2763,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 +2787,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 +2803,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 +2834,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]);
|
||||
|
@@ -273,11 +273,8 @@ XpmCreateXpmImageFromImage(display, image, shapeimage,
|
||||
# endif /* AMIGA */
|
||||
#else
|
||||
|
||||
#ifndef __OS2__
|
||||
ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,
|
||||
&pmap, storeMaskPixel);
|
||||
/* calling convention all messed up OS/2 -- figure out later */
|
||||
#endif
|
||||
|
||||
#endif /* ndef for FOR_MSW */
|
||||
|
||||
@@ -318,10 +315,8 @@ XpmCreateXpmImageFromImage(display, image, shapeimage,
|
||||
# endif /* AMIGA */
|
||||
#else
|
||||
|
||||
#ifndef __VISAGECPP30__
|
||||
ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap,
|
||||
storePixel);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -601,7 +596,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) {
|
||||
@@ -1026,7 +1021,7 @@ MSWGetImagePixels(display, image, width, height, pmap, storeFunc)
|
||||
Pixel pixel;
|
||||
#ifdef __OS2__
|
||||
HAB hab;
|
||||
HPS hps;
|
||||
HDC shapedc;
|
||||
DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
SIZEL sizl = {0, 0};
|
||||
POINTL point;
|
||||
@@ -1035,8 +1030,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
|
||||
@@ -1046,7 +1042,7 @@ 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
|
||||
|
@@ -137,6 +137,7 @@ XDefaultDepth(Display *display, Screen *screen)
|
||||
DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes);
|
||||
DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitsPerPixel);
|
||||
b = (int)lBitsPerPixel;
|
||||
WinReleasePS(hpsScreen);
|
||||
#else
|
||||
b = GetDeviceCaps(*display, BITSPIXEL);
|
||||
d = GetDeviceCaps(*display, PLANES);
|
||||
@@ -294,7 +295,8 @@ XCreateImage(Display *d, Visual *v,
|
||||
img->bitmap = CreateCompatibleBitmap(*d, width, height);
|
||||
} else*/ {
|
||||
#ifdef __OS2__
|
||||
img->bitmap = GpiCreateBitmap(hps, &bmih, 0L, NULL, NULL);
|
||||
img->bitmap = GpiCreateBitmap(hps, &bmih, 0L, NULL, NULL);
|
||||
WinReleasePS(hps);
|
||||
#else
|
||||
img->bitmap = CreateBitmap(width, height, 1 /* plane */ ,
|
||||
depth /* bits per pixel */ , NULL);
|
||||
|
@@ -44,18 +44,29 @@
|
||||
#else
|
||||
#define INCL_PM
|
||||
#define INCL_GPI
|
||||
#define INCL_DEV
|
||||
#include<os2.h>
|
||||
typedef unsigned long COLORREF;
|
||||
/*
|
||||
// RGB under OS2 is more like a PALETTEENTRY struct under Windows so we need a real RGB def
|
||||
//#define OS2RGB(r,g,b) ((ULONG ((BYTE) (r) | ((UINT) (g) << 8)) | (((ULONG)(BYTE)(b)) << 16)))
|
||||
#define OS2RGB(r,g,b) ((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b)
|
||||
|
||||
#define GetBValue(rgb) ((BYTE)((rgb) >> 16))
|
||||
#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
|
||||
#define GetRValue(rgb) ((BYTE)(rgb))
|
||||
typedef UINT WORD;
|
||||
// #define OS2RGB(r,g,b) ((ULONG ((BYTE) (r) | ((UINT) (g) << 8)) | (((ULONG)(BYTE)(b)) << 16)))
|
||||
*/
|
||||
#ifndef OS2RGB
|
||||
# define OS2RGB(r,g,b) ((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b)
|
||||
#endif
|
||||
|
||||
#ifndef GetBValue
|
||||
# define GetBValue(rgb) ((BYTE)((rgb) >> 16))
|
||||
#endif
|
||||
#ifndef GetGValue
|
||||
# define GetGValue(rgb) ((BYTE)(((UINT)(rgb)) >> 8))
|
||||
#endif
|
||||
#ifndef GetRValue
|
||||
# define GetRValue(rgb) ((BYTE)(rgb))
|
||||
#endif
|
||||
typedef UINT WORD;
|
||||
#endif /* else __OS2__ */
|
||||
|
||||
|
||||
/*
|
||||
* minimal portability layer between ansi and KR C
|
||||
@@ -80,7 +91,12 @@ FUNC(boundCheckingRealloc, void *, (void *p, long s));
|
||||
/* define MSW types for X window types,
|
||||
I don't know much about MSW, but the following defines do the job */
|
||||
|
||||
#if !defined(__OS2__)
|
||||
typedef HDC Display; /* this should be similar */
|
||||
#else
|
||||
typedef HPS Display;
|
||||
#endif
|
||||
|
||||
typedef void *Screen; /* not used */
|
||||
typedef void *Visual; /* not used yet, is for GRAY, COLOR,
|
||||
* MONO */
|
||||
|
Reference in New Issue
Block a user