X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6cee329241bc37e110e3514ef4f99b2dbd301dbb..1978421a6d8b81c1f8a961da4b8ddf544fec7b1b:/src/x11/bitmap.cpp diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp index 8f8ba22e1c..12a782db43 100644 --- a/src/x11/bitmap.cpp +++ b/src/x11/bitmap.cpp @@ -9,7 +9,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "bitmap.h" #endif @@ -375,6 +375,46 @@ bool wxBitmap::Create(void *data, wxBitmapType type, return handler->Create(this, data, type, width, height, depth); } +bool wxBitmap::Create(WXPixmap pixmap) +{ + UnRef(); + Pixmap xpixmap = (Pixmap)pixmap; + Display* xdisplay = wxGlobalDisplay(); + int xscreen = DefaultScreen( xdisplay ); + Window xroot = RootWindow( xdisplay, xscreen ); + + // make a copy of the Pixmap + Window root; + Pixmap copy; + int x, y; + unsigned width, height, border, depth; + + XGetGeometry( xdisplay, (Drawable)xpixmap, &root, &x, &y, + &width, &height, &border, &depth ); + copy = XCreatePixmap( xdisplay, xroot, width, height, depth ); + + GC gc = XCreateGC( xdisplay, copy, 0, NULL ); + XCopyArea( xdisplay, xpixmap, copy, gc, 0, 0, width, height, 0, 0 ); + XFreeGC( xdisplay, gc ); + + // fill in ref data + wxBitmapRefData* ref = new wxBitmapRefData(); + + if( depth == 1 ) + ref->m_bitmap = (WXPixmap)copy; + else + ref->m_pixmap = (WXPixmap)copy; + + ref->m_display = (WXDisplay*)xdisplay; + ref->m_width = width; + ref->m_height = height; + ref->m_bpp = depth; + + m_refData = ref; + + return true; +} + bool wxBitmap::CreateFromXpm( const char **bits ) { wxCHECK_MSG( bits, FALSE, _T("NULL pointer in wxBitmap::CreateFromXpm") ); @@ -1532,9 +1572,10 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *bits, M_BMPHANDLERDATA->m_bpp = 1; return TRUE; -#endif - wxCHECK_MSG( M_BMPHANDLERDATA->m_bitmap, FALSE, +#else + wxCHECK_MSG( M_BMPHANDLERDATA->m_bitmap, FALSE, wxT("couldn't create bitmap") ); +#endif } void wxBitmap::InitStandardHandlers()