2004-08-02 21:50:17 +00:00
|
|
|
/*
|
|
|
|
* CairoContext.m
|
|
|
|
|
|
|
|
* Copyright (C) 2003 Free Software Foundation, Inc.
|
|
|
|
* August 31, 2003
|
|
|
|
* Written by Banlu Kemiyatorn <object at gmail dot com>
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
2005-05-26 22:51:53 +00:00
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
2004-08-02 21:50:17 +00:00
|
|
|
*/
|
|
|
|
#include "cairo/CairoContext.h"
|
|
|
|
#include "cairo/CairoGState.h"
|
2006-03-12 21:50:17 +00:00
|
|
|
#include "cairo/CairoSurface.h"
|
2005-07-27 23:25:32 +00:00
|
|
|
#include "cairo/CairoFontInfo.h"
|
|
|
|
#include "cairo/CairoFontEnumerator.h"
|
2005-08-28 00:48:12 +00:00
|
|
|
#include "x11/XGServer.h"
|
2006-03-12 21:50:17 +00:00
|
|
|
#include "config.h"
|
2004-08-02 21:50:17 +00:00
|
|
|
|
2006-03-12 21:50:17 +00:00
|
|
|
#ifdef USE_GLITZ
|
|
|
|
#include "cairo/XGCairoGlitzSurface.h"
|
|
|
|
#else
|
|
|
|
#include "cairo/XGCairoSurface.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CGSTATE ((CairoGState *)gstate)
|
2004-08-02 21:50:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
@implementation CairoContext
|
|
|
|
|
|
|
|
+ (void) initializeBackend
|
|
|
|
{
|
|
|
|
//NSLog (@"CairoContext : Initializing cairo backend");
|
2006-03-12 21:50:17 +00:00
|
|
|
[NSGraphicsContext setDefaultContextClass: self];
|
2004-08-02 21:50:17 +00:00
|
|
|
|
2006-03-12 21:50:17 +00:00
|
|
|
#ifdef USE_GLITZ
|
|
|
|
[CairoSurface setDefaultSurfaceClass: [XGCairoGlitzSurface class]];
|
|
|
|
#else
|
|
|
|
[CairoSurface setDefaultSurfaceClass: [XGCairoSurface class]];
|
|
|
|
#endif
|
2005-07-27 23:25:32 +00:00
|
|
|
[GSFontEnumerator setDefaultClass: [CairoFontEnumerator class]];
|
|
|
|
[GSFontInfo setDefaultClass: [CairoFontInfo class]];
|
2004-08-02 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) GSWSetViewIsFlipped: (BOOL)flipped
|
|
|
|
{
|
|
|
|
if (gstate)
|
|
|
|
{
|
2006-03-12 21:50:17 +00:00
|
|
|
CGSTATE->_viewIsFlipped = flipped;
|
2004-08-02 21:50:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithContextInfo: (NSDictionary *)info
|
|
|
|
{
|
|
|
|
NSString *contextType;
|
|
|
|
|
|
|
|
[super initWithContextInfo:info];
|
|
|
|
|
|
|
|
contextType = [info objectForKey:
|
|
|
|
NSGraphicsContextRepresentationFormatAttributeName];
|
|
|
|
if (contextType)
|
|
|
|
{
|
2005-08-28 00:48:12 +00:00
|
|
|
/* Most likely this is a PS or PDF context, so just return what
|
|
|
|
super gave us */
|
2004-08-02 21:50:17 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
gstate = [[CairoGState allocWithZone: [self zone]] initWithDrawContext: self];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) flushGraphics
|
|
|
|
{
|
2005-08-28 00:48:12 +00:00
|
|
|
XFlush([(XGServer *)server xDisplay]);
|
2004-08-02 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation CairoContext (Ops)
|
|
|
|
|
|
|
|
- (void) GSCurrentDevice: (void **)device : (int *)x : (int *)y
|
|
|
|
{
|
2006-03-12 21:50:17 +00:00
|
|
|
[CGSTATE GSCurrentDevice: device : x : y];
|
2004-08-02 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) GSSetDevice: (void *)device : (int)x : (int)y
|
|
|
|
{
|
2006-03-12 21:50:17 +00:00
|
|
|
[CGSTATE GSSetDevice: device : x : y];
|
2004-08-02 21:50:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|