]> git.saurik.com Git - wxWidgets.git/commitdiff
replace wxBitmap::SetPixbuf() with wxBitmap ctor taking pixbuf
authorPaul Cornett <paulcor@bullseye.com>
Sun, 25 Mar 2012 23:33:18 +0000 (23:33 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Sun, 25 Mar 2012 23:33:18 +0000 (23:33 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71006 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/bitmap.h
src/aui/tabartgtk.cpp
src/gtk/artgtk.cpp
src/gtk/bitmap.cpp
src/gtk/bmpcbox.cpp

index 8bc0ab32073f8a5db20b707e747bd7f56b8aec3a..c3245532de535fca9eff5c253efee31374eba896 100644 (file)
@@ -68,6 +68,7 @@ public:
     wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
         { (void)CreateFromImage(image, depth); }
 #endif // wxUSE_IMAGE
+    wxBitmap(GdkPixbuf* pixbuf);
     virtual ~wxBitmap();
 
     bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
@@ -108,7 +109,6 @@ public:
     void SetHeight( int height );
     void SetWidth( int width );
     void SetDepth( int depth );
-    void SetPixbuf(GdkPixbuf* pixbuf);
 
     GdkPixmap *GetPixmap() const;
     bool HasPixmap() const;
index 7b3e6aa1f08d60495f49f34cd26f382b29fb92c0..a7bc5e455118a03ffe77e39dc8c42d13443c927a 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Jens Lody and Teodor Petrov
 // Modified by:
 // Created:     2012-03-23
-// RCS-ID:      $Id:$
+// RCS-ID:      $Id$
 // Copyright:   (c) 2012 Jens Lody <jens@codeblocks.org>
 //                  and Teodor Petrov
 // Licence:     wxWindows licence
@@ -119,8 +119,7 @@ wxRect DrawCloseButton(wxDC& dc,
     int xthickness = style_button->xthickness;
     int ythickness = style_button->ythickness;
 
-    wxBitmap bmp;
-    bmp.SetPixbuf(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
+    wxBitmap bmp(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
 
     if(bmp.GetWidth() != s_CloseIconSize || bmp.GetHeight() != s_CloseIconSize)
     {
index c438a72a760bc452f6b18c023c8a147abb5365d9..c90d9609cbde5c5893f1c4ee7c3325062c5c1356 100644 (file)
@@ -259,7 +259,7 @@ wxIconBundle DoCreateIconBundle(const char *stockid,
             continue;
 
         wxIcon icon;
-        icon.SetPixbuf(pixbuf);
+        icon.CopyFromBitmap(wxBitmap(pixbuf));
         bundle.AddIcon(icon);
     }
 
@@ -296,11 +296,7 @@ wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id,
         }
     }
 
-    wxBitmap bmp;
-    if (pixbuf != NULL)
-        bmp.SetPixbuf(pixbuf);
-
-    return bmp;
+    return wxBitmap(pixbuf);
 }
 
 wxIconBundle
index 743e99c18a443ca1ea5b30997e6a1b912f4758d4..4519ea932e65da8389cd7f4c66136f05aeda7b1a 100644 (file)
@@ -309,6 +309,18 @@ wxBitmap::wxBitmap(const char* const* bits)
     }
 }
 
+wxBitmap::wxBitmap(GdkPixbuf* pixbuf)
+{
+    if (pixbuf)
+    {
+        wxBitmapRefData* bmpData = new wxBitmapRefData(
+            gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf),
+            gdk_pixbuf_get_n_channels(pixbuf) * 8);
+        m_refData = bmpData;
+        bmpData->m_pixbuf = pixbuf;
+    }
+}
+
 wxBitmap::~wxBitmap()
 {
 }
@@ -679,10 +691,7 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
     {
         wxUnusedVar(type); // The type is detected automatically by GDK.
 
-        UnRef();
-        GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(name.fn_str(), NULL);
-        if (pixbuf)
-            SetPixbuf(pixbuf);
+        *this = wxBitmap(gdk_pixbuf_new_from_file(name.fn_str(), NULL));
     }
 
     return IsOk();
@@ -802,22 +811,6 @@ bool wxBitmap::HasPixbuf() const
     return M_BMPDATA->m_pixbuf != NULL;
 }
 
-void wxBitmap::SetPixbuf(GdkPixbuf* pixbuf)
-{
-    UnRef();
-
-    if (!pixbuf)
-        return;
-
-    int depth = -1;
-    if (gdk_pixbuf_get_has_alpha(pixbuf))
-        depth = 32;
-    m_refData = new wxBitmapRefData(
-        gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), depth);
-
-    M_BMPDATA->m_pixbuf = pixbuf;
-}
-
 void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep)
 {
     if (keep == Pixmap && HasPixbuf())
index b625542b1084a0f62e3600af3885c105c248743b..7ac3b0ecdead07b95c67650c7d597a80cfe2f7bf 100644 (file)
@@ -224,7 +224,7 @@ wxBitmap wxBitmapComboBox::GetItemBitmap(unsigned int n) const
         if ( pixbuf )
         {
             g_object_ref( pixbuf );
-            bitmap.SetPixbuf( pixbuf );
+            bitmap = wxBitmap(pixbuf);
         }
         g_value_unset( &value );
     }