X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0cad49b42cc28eb5c86cd0193c5bc4cba33f109d..6ea1280cb72eca20ee34d0c76e660d5cc0a482b7:/src/x11/bitmap.cpp diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp index cbee3462f6..10f3bc41e9 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 @@ -366,7 +366,7 @@ bool wxBitmap::Create(void *data, wxBitmapType type, wxBitmapHandler *handler = FindHandler(type); if ( handler == NULL ) { - wxLogWarning("no data bitmap handler for type %ld defined.", + wxLogWarning(wxT("no data bitmap handler for type %ld defined."), (long)type); return FALSE; @@ -375,9 +375,49 @@ 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") ); + wxCHECK_MSG( bits, FALSE, wxT("NULL pointer in wxBitmap::CreateFromXpm") ); return Create(bits, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } @@ -387,7 +427,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) #if wxUSE_NANOX if (!image.Ok()) { - wxASSERT_MSG(image.Ok(), "Invalid wxImage passed to wxBitmap::CreateFromImage."); + wxASSERT_MSG(image.Ok(), wxT("Invalid wxImage passed to wxBitmap::CreateFromImage.")); return FALSE; } @@ -518,7 +558,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) if (depth == 1) { - wxFAIL_MSG( "mono images later" ); + wxFAIL_MSG( wxT("mono images later") ); } else { @@ -583,7 +623,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) int b_mask = image.GetMaskBlue(); unsigned char* data = image.GetData(); - wxASSERT_MSG( data, "No image data" ); + wxASSERT_MSG( data, wxT("No image data") ); unsigned char *colorCube = wxTheApp->GetVisualInfo(M_BMPDATA->m_display)->m_colorCube; @@ -1280,8 +1320,8 @@ class wxXPMFileHandler : public wxBitmapHandler public: wxXPMFileHandler() { - m_name = "XPM file"; - m_extension = "xpm"; + m_name = wxT("XPM file"); + m_extension = wxT("xpm"); m_type = wxBITMAP_TYPE_XPM; }; @@ -1359,6 +1399,8 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, wxImage image(decoder.ReadFile(stream)); return image.Ok() && bitmap->CreateFromImage(image); } + + return FALSE; #else // !wxHAVE_LIB_XPM && !wxUSE_STREAMS return FALSE; #endif // wxHAVE_LIB_XPM / wxUSE_STREAMS @@ -1386,8 +1428,8 @@ class wxXPMDataHandler : public wxBitmapHandler public: wxXPMDataHandler() { - m_name = "XPM data"; - m_extension = "xpm"; + m_name = wxT("XPM data"); + m_extension = wxT("xpm"); m_type = wxBITMAP_TYPE_XPM_DATA; }; @@ -1487,8 +1529,8 @@ class WXDLLEXPORT wxXBMDataHandler: public wxBitmapHandler public: inline wxXBMDataHandler() { - m_name = "XBM data"; - m_extension = "xbm"; + m_name = wxT("XBM data"); + m_extension = wxT("xbm"); m_type = wxBITMAP_TYPE_XBM_DATA; }; @@ -1530,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()