File indexing completed on 2024-05-05 17:40:39
0001 #ifndef oxygencairocontext_h 0002 #define oxygencairocontext_h 0003 /* 0004 * this file is part of the oxygen gtk engine 0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #include <cairo.h> 0011 #include <gdk/gdk.h> 0012 0013 #include <cassert> 0014 0015 namespace Oxygen 0016 { 0017 namespace Cairo 0018 { 0019 0020 //! wrapper class around cairo_t structure 0021 class Context 0022 { 0023 public: 0024 0025 //! constructor 0026 explicit Context( GdkWindow*, GdkRectangle* = 0L ); 0027 0028 //! constructor 0029 explicit Context( cairo_surface_t*, GdkRectangle* = 0L ); 0030 0031 //! destructor 0032 virtual ~Context( void ) 0033 { free(); } 0034 0035 //! free the context 0036 /*! 0037 it should not be necessary to call this method 0038 since it is already handled in destructor 0039 */ 0040 void free( void ); 0041 0042 //! cast to cairo_t 0043 operator cairo_t* (void) const 0044 { return _cr; } 0045 0046 //! context accessor 0047 cairo_t* cr( void ) const 0048 { return _cr; } 0049 0050 //! set clipping 0051 void setClipping( GdkRectangle* ) const; 0052 0053 private: 0054 0055 //! empty constructor is private 0056 explicit Context( void ): 0057 _cr( 0L ) 0058 { assert( false ); } 0059 0060 //! copy constructor is private 0061 Context( const Context& other ): 0062 _cr( 0L ) 0063 { assert( false ); } 0064 0065 //! equal to operator is private 0066 Context& operator = (const Context& other ) 0067 { 0068 _cr = other._cr; 0069 assert( false ); 0070 return *this; 0071 } 0072 0073 //! equal to operator is private 0074 Context& operator = (cairo_t* other ) 0075 { 0076 assert( false ); 0077 return *this; 0078 } 0079 0080 //! cairo contect 0081 cairo_t* _cr; 0082 0083 }; 0084 0085 } 0086 } 0087 #endif