Back to index

nux  3.0.0
Canvas.h
Go to the documentation of this file.
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 CANVAS_H
00020 #define CANVAS_H
00021 
00022 #include <cairo.h>
00023 
00024 #include "Nux/Nux.h"
00025 #include "Nux/View.h"
00026 
00027 namespace nux
00028 {
00029   class Canvas : public View
00030   {
00031     public:
00032       Canvas (NUX_FILE_LINE_DECL);
00033       ~Canvas ();
00034 
00035     protected:
00036       void Draw (GraphicsEngine& graphics_engine, bool forceDraw);
00037       void DrawContent (GraphicsEngine& graphics_engine, bool forceDraw);
00038       virtual void Paint ();
00039       void Invalidate ();
00040 
00041       cairo_surface_t* GetCairoSurface ();
00042       cairo_t*         GetCairoContext ();
00043       int              GetLastWidth ();
00044       int              GetLastHeight ();
00045 
00046     private:
00047       void             PreLayoutManagement ();
00048       long             PostLayoutManagement (long layoutResult);
00049       void             Recreate ();
00050       NBitmapData*     GetBitmap ();
00051 
00052     private:
00053       cairo_t*         _cr;
00054       cairo_surface_t* _surface;
00055       int              _last_width;
00056       int              _last_height;
00057       bool             _invalid;
00058       BaseTexture*     _texture;
00059   };
00060 }
00061 
00062 #endif // CANVAS_H