X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/68567a967bc8afd37a40cb9a7ee5021b9ee6cd96..a2a7ad6ccdff5423bb4d86f51b2d7222b406ac81:/src/gtk/bitmap.cpp diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 7f0b385f9b..b04bbe3905 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -10,15 +10,17 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/defs.h" - #include "wx/bitmap.h" -#include "wx/palette.h" -#include "wx/icon.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/dcmemory.h" + #include "wx/palette.h" + #include "wx/icon.h" +#endif + #include "wx/filefn.h" #include "wx/image.h" -#include "wx/dcmemory.h" -#include "wx/app.h" #include "wx/rawbmp.h" // need this to get gdk_image_new_bitmap() @@ -82,7 +84,7 @@ wxMask::wxMask( const wxBitmap& bitmap ) wxMask::~wxMask() { if (m_bitmap) - gdk_bitmap_unref( m_bitmap ); + g_object_unref (m_bitmap); } bool wxMask::Create( const wxBitmap& bitmap, @@ -90,7 +92,7 @@ bool wxMask::Create( const wxBitmap& bitmap, { if (m_bitmap) { - gdk_bitmap_unref( m_bitmap ); + g_object_unref (m_bitmap); m_bitmap = (GdkBitmap*) NULL; } @@ -173,7 +175,7 @@ bool wxMask::Create( const wxBitmap& bitmap, gdk_draw_line( m_bitmap, gc, start_x, j, i, j ); } - gdk_gc_unref( gc ); + g_object_unref (gc); return true; } @@ -196,7 +198,7 @@ bool wxMask::Create( const wxBitmap& bitmap ) { if (m_bitmap) { - gdk_bitmap_unref( m_bitmap ); + g_object_unref (m_bitmap); m_bitmap = (GdkBitmap*) NULL; } @@ -212,7 +214,7 @@ bool wxMask::Create( const wxBitmap& bitmap ) gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetBitmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); - gdk_gc_unref( gc ); + g_object_unref (gc); return true; } @@ -257,11 +259,11 @@ wxBitmapRefData::wxBitmapRefData() wxBitmapRefData::~wxBitmapRefData() { if (m_pixmap) - gdk_pixmap_unref( m_pixmap ); + g_object_unref (m_pixmap); if (m_bitmap) - gdk_bitmap_unref( m_bitmap ); + g_object_unref (m_bitmap); if (m_pixbuf) - gdk_pixbuf_unref( m_pixbuf ); + g_object_unref (m_pixbuf); delete m_mask; #if wxUSE_PALETTE delete m_palette; @@ -298,7 +300,7 @@ bool wxBitmap::Create( int width, int height, int depth ) depth = visual->depth; wxCHECK_MSG( (depth == visual->depth) || (depth == 1) || (depth == 32), false, - wxT("invalid bitmap depth") ) + wxT("invalid bitmap depth") ); m_refData = new wxBitmapRefData(); M_BMPDATA->m_mask = (wxMask *) NULL; @@ -328,7 +330,7 @@ bool wxBitmap::CreateFromXpm( const char **bits ) { UnRef(); - wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ) + wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ); GdkVisual *visual = wxTheApp->GetGdkVisual(); @@ -346,7 +348,7 @@ bool wxBitmap::CreateFromXpm( const char **bits ) M_BMPDATA->m_mask->m_bitmap = mask; } - gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); + gdk_drawable_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ? @@ -400,7 +402,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, GdkPixmap *dstpix = NULL; if (GetPixmap()) { - GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); + GdkVisual *visual = gdk_drawable_get_visual( GetPixmap() ); if (visual == NULL) visual = wxTheApp->GetGdkVisual(); @@ -455,7 +457,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, old_x = x; } - if (bpp == 1) + if ( dst ) { if (!pixval) { @@ -480,14 +482,14 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, } // do not forget the last byte - if ((bpp == 1) && (width % 8 != 0)) + if ( dst && (width % 8 != 0) ) dst[h*dstbyteperline+width/8] = outbyte; } - gdk_image_destroy( img ); - if (gc) gdk_gc_unref( gc ); + g_object_unref (img); + if (gc) g_object_unref (gc); - if (bpp == 1) + if ( dst ) { bmp = wxBitmap( (const char *)dst, width, height, 1 ); free( dst ); @@ -543,7 +545,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, bmp.SetMask(mask); free( dst ); - gdk_image_destroy( img ); + g_object_unref (img); } free( tablex ); @@ -557,8 +559,8 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth) { UnRef(); - wxCHECK_MSG( image.Ok(), false, wxT("invalid image") ) - wxCHECK_MSG( depth == -1 || depth == 1, false, wxT("invalid bitmap depth") ) + wxCHECK_MSG( image.Ok(), false, wxT("invalid image") ); + wxCHECK_MSG( depth == -1 || depth == 1, false, wxT("invalid bitmap depth") ); if (image.GetWidth() <= 0 || image.GetHeight() <= 0) return false; @@ -660,8 +662,8 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img) gdk_draw_image( GetBitmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); - gdk_image_destroy( data_image ); - gdk_gc_unref( data_gc ); + g_object_unref (data_image); + g_object_unref (data_gc); // Blit mask @@ -671,8 +673,8 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img) gdk_draw_image( GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - gdk_image_destroy( mask_image ); - gdk_gc_unref( mask_gc ); + g_object_unref (mask_image); + g_object_unref (mask_gc); } return true; @@ -731,7 +733,7 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img) image.GetData(), width*3 ); - gdk_gc_unref( gc ); + g_object_unref (gc); return true; } @@ -900,8 +902,8 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img) gdk_draw_image( GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); - gdk_image_destroy( data_image ); - gdk_gc_unref( data_gc ); + g_object_unref (data_image); + g_object_unref (data_gc); // Blit mask @@ -911,8 +913,8 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img) gdk_draw_image( GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - gdk_image_destroy( mask_image ); - gdk_gc_unref( mask_gc ); + g_object_unref (mask_image); + g_object_unref (mask_gc); } return true; @@ -1053,7 +1055,7 @@ wxImage wxBitmap::ConvertToImage() const if (GetPixmap()) { - GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); + GdkVisual *visual = gdk_drawable_get_visual( GetPixmap() ); if (visual == NULL) visual = wxTheApp->GetGdkVisual(); @@ -1136,19 +1138,13 @@ wxImage wxBitmap::ConvertToImage() const } } - gdk_image_destroy( gdk_image ); - if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); + g_object_unref (gdk_image); + if (gdk_image_mask) g_object_unref (gdk_image_mask); } return image; } -wxBitmap::wxBitmap( const wxBitmap& bmp ) - : wxBitmapBase() -{ - Ref( bmp ); -} - wxBitmap::wxBitmap( const wxString &filename, wxBitmapType type ) { LoadFile( filename, type ); @@ -1180,14 +1176,6 @@ wxBitmap::~wxBitmap() { } -wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp ) -{ - if ( m_refData != bmp.m_refData ) - Ref( bmp ); - - return *this; -} - bool wxBitmap::operator == ( const wxBitmap& bmp ) const { return m_refData == bmp.m_refData; @@ -1275,8 +1263,8 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const if (ret.GetPixmap()) { GdkGC *gc = gdk_gc_new( ret.GetPixmap() ); - gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); + gdk_draw_drawable( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); + g_object_unref (gc); } else { @@ -1287,7 +1275,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const col.pixel = 0; gdk_gc_set_background( gc, &col ); gdk_wx_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); + g_object_unref (gc); } } @@ -1303,7 +1291,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const col.pixel = 0; gdk_gc_set_background( gc, &col ); gdk_wx_draw_bitmap( mask->m_bitmap, gc, M_BMPDATA->m_mask->m_bitmap, rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); + g_object_unref (gc); ret.SetMask( mask ); } @@ -1353,7 +1341,7 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type ) M_BMPDATA->m_mask->m_bitmap = mask; } - gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); + gdk_drawable_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); M_BMPDATA->m_bpp = visual->depth; } @@ -1499,7 +1487,7 @@ GdkPixbuf *wxBitmap::GetPixbuf() const } } - gdk_pixbuf_unref(pmask); + g_object_unref (pmask); } } } @@ -1527,12 +1515,12 @@ void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep) { if (keep == Pixmap && HasPixbuf()) { - gdk_pixbuf_unref( M_BMPDATA->m_pixbuf ); + g_object_unref (M_BMPDATA->m_pixbuf); M_BMPDATA->m_pixbuf = NULL; } if (keep == Pixbuf && HasPixmap()) { - gdk_pixmap_unref( M_BMPDATA->m_pixmap ); + g_object_unref (M_BMPDATA->m_pixmap); M_BMPDATA->m_pixmap = NULL; } }