nux-1.16.0
CairoWrapper.h
00001 /*
00002  * Copyright (C) 2011 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Mirco Müller <mirco.mueller@canonical.com
00017  */
00018 
00019 #ifndef CAIRO_WRAPPER_H
00020 #define CAIRO_WRAPPER_H
00021 
00022 #include <cairo.h>
00023 
00024 #include "Nux/Nux.h"
00025 
00026 namespace nux
00027 {
00028   typedef sigc::slot<void, Geometry const&, cairo_t*> DrawCanvasCallback;
00029 
00030   class CairoWrapper
00031   {
00032     public:
00033       CairoWrapper (Geometry const& geom, DrawCanvasCallback callback);
00034       ~CairoWrapper ();
00035 
00036       bool               Invalidate (Geometry const& geom);
00037       void               SetDrawCanvasCallback (DrawCanvasCallback callback);
00038       cairo_surface_t*   GetCairoSurface () const;
00039       cairo_t*           GetCairoContext () const;
00040       bool               DumpToFile (std::string const& filename);
00041       BaseTexture*       GetTexture () const;
00042       NBitmapData*       GetBitmap () const;
00043       bool               Recreate ();
00044 
00045     private:
00046       bool               CreateBitmap ();
00047 
00048     private:
00049       Geometry           geometry_;
00050       DrawCanvasCallback draw_canvas_callback_;
00051       cairo_t*           cr_;
00052       cairo_surface_t*   surface_;
00053       NBitmapData*       bitmap_;
00054       BaseTexture*       texture_;
00055   };
00056 }
00057 
00058 #endif // CAIRO_WRAPPER_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends