nux-1.16.0
|
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 void Draw (GraphicsEngine& gfxContext, bool forceDraw); 00036 void DrawContent (GraphicsEngine& gfxContext, bool forceDraw); 00037 long ProcessEvent (IEvent& event, 00038 long traverseInfo, 00039 long processEventInfo); 00040 virtual void Paint (); 00041 void Invalidate (); 00042 00043 protected: 00044 cairo_surface_t* GetCairoSurface (); 00045 cairo_t* GetCairoContext (); 00046 int GetLastWidth (); 00047 int GetLastHeight (); 00048 00049 private: 00050 void PreLayoutManagement (); 00051 long PostLayoutManagement (long layoutResult); 00052 void Recreate (); 00053 NBitmapData* GetBitmap (); 00054 00055 private: 00056 cairo_t* _cr; 00057 cairo_surface_t* _surface; 00058 int _last_width; 00059 int _last_height; 00060 bool _invalid; 00061 BaseTexture* _texture; 00062 }; 00063 } 00064 00065 #endif // CANVAS_H