]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/graphicc.cpp
Added native wxInfoBar implementation for wxGTK.
[wxWidgets.git] / src / generic / graphicc.cpp
index af0031b53661348b821afd5c84a55c9ef295d3f5..50965a5b998ac4ba99c7a93fcb8d9a7335d1cd17 100644 (file)
@@ -290,6 +290,7 @@ class wxCairoBitmapData : public wxGraphicsObjectRefData
 {
 public:
     wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp );
+    wxCairoBitmapData( wxGraphicsRenderer* renderer, cairo_surface_t* bitmap );
     ~wxCairoBitmapData();
 
     virtual cairo_surface_t* GetCairoSurface() { return m_surface; }
@@ -1014,11 +1015,17 @@ void * wxCairoMatrixData::GetNativeMatrix() const
 // wxCairoBitmap implementation
 //-----------------------------------------------------------------------------
 
+wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, cairo_surface_t* bitmap ) :
+    wxGraphicsObjectRefData( renderer )
+{
+    m_surface = bitmap;
+    m_pattern = cairo_pattern_create_for_surface(m_surface);
+}
+
 wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitmap& bmp ) : wxGraphicsObjectRefData( renderer )
 {
     wxCHECK_RET( bmp.IsOk(), wxT("Invalid bitmap in wxCairoContext::DrawBitmap"));
 
-    cairo_surface_t* surface;
     int bw = bmp.GetWidth();
     int bh = bmp.GetHeight();
     wxBitmap bmpSource = bmp;  // we need a non-const instance
@@ -1085,12 +1092,17 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
             p.OffsetY(pixData, 1);
         }
     }
+    m_pattern = cairo_pattern_create_for_surface(m_surface);
 }
 
 wxCairoBitmapData::~wxCairoBitmapData()
 {
-    cairo_pattern_destroy(m_pattern);
-    cairo_surface_destroy(m_surface);
+    if (m_pattern)
+        cairo_pattern_destroy(m_pattern);
+    
+    if (m_surface)
+        cairo_surface_destroy(m_surface);
+    
     delete [] m_buffer;
 }
 
@@ -1704,6 +1716,9 @@ public :
     // create a native bitmap representation
     virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap );
 
+    // create a graphics bitmap from a native bitmap
+    virtual wxGraphicsBitmap CreateBitmapFromNativeBitmap( void* bitmap );
+
     // create a subimage from a native image representation
     virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h  );
 
@@ -1875,7 +1890,24 @@ wxGraphicsBitmap wxCairoRenderer::CreateBitmap( const wxBitmap& bmp )
         return wxNullGraphicsBitmap;
 }
 
-wxGraphicsBitmap wxCairoRenderer::CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h  )
+wxGraphicsBitmap wxCairoRenderer::CreateBitmapFromNativeBitmap( void* bitmap )
+{
+    if ( bitmap != NULL )
+    {
+        wxGraphicsBitmap p;
+        p.SetRefData(new wxCairoBitmapData( this , (cairo_surface_t*) bitmap ));
+        return p;
+    }
+    else
+        return wxNullGraphicsBitmap;
+}
+
+wxGraphicsBitmap
+wxCairoRenderer::CreateSubBitmap(const wxGraphicsBitmap& WXUNUSED(bitmap),
+                                 wxDouble WXUNUSED(x),
+                                 wxDouble WXUNUSED(y),
+                                 wxDouble WXUNUSED(w),
+                                 wxDouble WXUNUSED(h))
 {
     wxFAIL_MSG("wxCairoRenderer::CreateSubBitmap is not implemented.");
     return wxNullGraphicsBitmap;