-bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags),
- int width, int height, int WXUNUSED(depth))
-{
- M_BITMAPHANDLERDATA->m_width = width;
- M_BITMAPHANDLERDATA->m_height = height;
- M_BITMAPHANDLERDATA->m_depth = 1;
- M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
-
- Display *dpy = (Display*) wxGetDisplay();
- M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
-
- M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) XCreateBitmapFromData (dpy, RootWindow (dpy, DefaultScreen (dpy)), (char*) data, width, height);
- M_BITMAPHANDLERDATA->m_ok = (M_BITMAPHANDLERDATA->m_pixmap != (WXPixmap) 0) ;
-
- // code for wxControl. TODO: can we avoid doing this until we need it?
- // E.g. have CreateButtonPixmaps which is called on demand.
- XImage* image = (XImage *) XtMalloc (sizeof (XImage));
- image->width = width;
- image->height = height;
- image->data = (char*) data;
- image->depth = 1;
- image->xoffset = 0;
- image->format = XYBitmap;
- image->byte_order = LSBFirst;
- image->bitmap_unit = 8;
- image->bitmap_bit_order = LSBFirst;
- image->bitmap_pad = 8;
- image->bytes_per_line = (width + 7) >> 3;
-
- char tmp[128];
- sprintf (tmp, "Im%x", (unsigned int) image);
- XmInstallImage (image, tmp);
-
- // Build our manually stipped pixmap.
-
- int bpl = (width + 7) / 8;
- char *data1 = new char[height * bpl];
- char* bits = (char*) data;
- int i;
- for (i = 0; i < height; i++)
- {
- int mask = i % 2 ? 0x55 : 0xaa;
- int j;
- for (j = 0; j < bpl; j++)
- data1[i * bpl + j] = bits[i * bpl + j] & mask;
- }
- XImage* insensImage = (XImage *) XtMalloc (sizeof (XImage));
- insensImage->width = width;
- insensImage->height = height;
- insensImage->data = data1;
- insensImage->depth = 1;
- insensImage->xoffset = 0;
- insensImage->format = XYBitmap;
- insensImage->byte_order = LSBFirst;
- insensImage->bitmap_unit = 8;
- insensImage->bitmap_bit_order = LSBFirst;
- insensImage->bitmap_pad = 8;
- insensImage->bytes_per_line = bpl;
-
- sprintf (tmp, "Not%x", (unsigned int)insensImage);
- XmInstallImage (insensImage, tmp);
-
- M_BITMAPHANDLERDATA->m_image = (WXImage*) image;
- M_BITMAPHANDLERDATA->m_insensImage = (WXImage*) insensImage;