File indexing completed on 2024-05-05 17:40:39
0001 /* 0002 this file is part of the oxygen gtk engine 0003 SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "oxygencairocontext.h" 0009 #include <gdk/gdk.h> 0010 namespace Oxygen 0011 { 0012 0013 //_________________________________________- 0014 Cairo::Context::Context( GdkWindow* window, GdkRectangle* clipRect): 0015 _cr( 0L ) 0016 { 0017 0018 if( !GDK_IS_DRAWABLE(window) ) return; 0019 _cr= static_cast<cairo_t*>( gdk_cairo_create(window) ); 0020 setClipping( clipRect ); 0021 0022 } 0023 0024 //_________________________________________- 0025 Cairo::Context::Context( cairo_surface_t* surface, GdkRectangle* clipRect): 0026 _cr( 0L ) 0027 { 0028 0029 _cr= static_cast<cairo_t*>( cairo_create(surface) ); 0030 setClipping( clipRect ); 0031 0032 } 0033 0034 //_________________________________________________ 0035 void Cairo::Context::free( void ) 0036 { 0037 if( _cr ) { 0038 0039 cairo_destroy( _cr ); 0040 _cr = 0L; 0041 0042 } 0043 } 0044 0045 //_________________________________________________ 0046 void Cairo::Context::setClipping( GdkRectangle* clipRect ) const 0047 { 0048 if( !clipRect ) return; 0049 cairo_rectangle( _cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height ); 0050 cairo_clip( _cr ); 0051 } 0052 0053 }