X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a4294b7832a5aed3c1cccc06aecd227d43da8830..793f619f7f0e5b1eaba6a9e3f731462c1893b7f7:/src/motif/bitmap.cpp diff --git a/src/motif/bitmap.cpp b/src/motif/bitmap.cpp index 237b73924e..78272ccdf0 100644 --- a/src/motif/bitmap.cpp +++ b/src/motif/bitmap.cpp @@ -20,6 +20,7 @@ #include "wx/icon.h" #include "wx/log.h" #include "wx/control.h" +#include "wx/dcmemory.h" #include @@ -396,7 +397,7 @@ wxMask::~wxMask() } // Create a mask from a mono bitmap (copies the bitmap). -bool wxMask::Create(const wxBitmap& bitmap) +bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap)) { // TODO return FALSE; @@ -404,7 +405,7 @@ bool wxMask::Create(const wxBitmap& bitmap) // Create a mask from a bitmap and a palette index indicating // the transparent area -bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) +bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap), int WXUNUSED(paletteIndex)) { // TODO return FALSE; @@ -412,7 +413,7 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) // Create a mask from a bitmap and a colour indicating // the transparent area -bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) +bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap), const wxColour& WXUNUSED(colour)) { // TODO return FALSE; @@ -424,18 +425,20 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject) -bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) +bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), void *WXUNUSED(data), long WXUNUSED(type), + int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth)) { return FALSE; } -bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long type, - int desiredWidth, int desiredHeight) +bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), long WXUNUSED(type), + int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) { return FALSE; } -bool wxBitmapHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) +bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), int WXUNUSED(type), + const wxPalette *WXUNUSED(palette)) { return FALSE; } @@ -460,8 +463,8 @@ public: }; IMPLEMENT_DYNAMIC_CLASS(wxXBMFileHandler, wxBitmapHandler) -bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) +bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags), + int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight)) { M_BITMAPHANDLERDATA->m_freePixmap = TRUE; @@ -507,7 +510,8 @@ public: }; IMPLEMENT_DYNAMIC_CLASS(wxXBMDataHandler, wxBitmapHandler) -bool wxXBMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth) +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; @@ -593,8 +597,8 @@ public: IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler) -bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) +bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags), + int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight) ) { Display *dpy = (Display*) wxGetDisplay(); M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy; @@ -619,8 +623,17 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla M_BITMAPHANDLERDATA->m_bitmapMask->SetPixmap((WXPixmap) mask); } + unsigned int depthRet; + int xRet, yRet; + unsigned int widthRet, heightRet, borderWidthRet; + Window rootWindowRet; + XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet, + &widthRet, &heightRet, &borderWidthRet, &depthRet); + M_BITMAPHANDLERDATA->m_width = xpmAttr.width; M_BITMAPHANDLERDATA->m_height = xpmAttr.height; + + /* if ( xpmAttr.npixels > 2 ) { M_BITMAPHANDLERDATA->m_depth = 8; // TODO: next time not just a guess :-) ... @@ -628,6 +641,9 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla { M_BITMAPHANDLERDATA->m_depth = 1; // mono } + */ + + M_BITMAPHANDLERDATA->m_depth = depthRet; M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; @@ -643,7 +659,8 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla } } -bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) +bool wxXPMFileHandler::SaveFile( wxBitmap *bitmap, const wxString& name, int WXUNUSED(type), + const wxPalette *WXUNUSED(palette)) { if (M_BITMAPHANDLERDATA->m_ok && M_BITMAPHANDLERDATA->m_pixmap) { @@ -676,7 +693,8 @@ public: }; IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler) -bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth) +bool wxXPMDataHandler::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; @@ -714,6 +732,15 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt // Set attributes M_BITMAPHANDLERDATA->m_width = xpmAttr.width; M_BITMAPHANDLERDATA->m_height = xpmAttr.height; + + unsigned int depthRet; + int xRet, yRet; + unsigned int widthRet, heightRet, borderWidthRet; + Window rootWindowRet; + XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet, + &widthRet, &heightRet, &borderWidthRet, &depthRet); + + /* if ( xpmAttr.npixels > 2 ) { M_BITMAPHANDLERDATA->m_depth = 8; // next time not just a guess :-) ... @@ -721,6 +748,10 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt { M_BITMAPHANDLERDATA->m_depth = 1; // mono } + */ + + M_BITMAPHANDLERDATA->m_depth = depthRet; + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; XpmFreeAttributes(&xpmAttr); M_BITMAPHANDLERDATA->m_ok = TRUE; @@ -846,6 +877,18 @@ WXPixmap wxBitmap::GetInsensPixmap (WXWidget w) { Display *dpy = (Display*) M_BITMAPDATA->m_display; + if (M_BITMAPDATA->m_insensPixmap) + return M_BITMAPDATA->m_insensPixmap; + + if (!w) + { + M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap); + if (M_BITMAPDATA->m_insensPixmap) + return M_BITMAPDATA->m_insensPixmap; + else + return M_BITMAPDATA->m_pixmap; + } + if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0) return M_BITMAPDATA->m_pixmap; @@ -966,3 +1009,23 @@ static return ipixmap; } +// Creates a bitmap with transparent areas drawn in +// the given colour. +wxBitmap wxCreateMaskedBitmap(wxBitmap& bitmap, wxColour& colour) +{ + wxBitmap newBitmap(bitmap.GetWidth(), + bitmap.GetHeight(), + bitmap.GetDepth()); + wxMemoryDC destDC; + wxMemoryDC srcDC; + srcDC.SelectObject(bitmap); + destDC.SelectObject(newBitmap); + + wxBrush brush(colour, wxSOLID); + destDC.SetOptimization(FALSE); + destDC.SetBackground(brush); + destDC.Clear(); + destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE); + + return newBitmap; +}