/* -*- mode:ObjC -*- XGContext - Drawing context using the Xlib Library. Copyright (C) 1998,1999,2002 Free Software Foundation, Inc. Written by: Adam Fedor Date: Nov 1998 This file is part of the GNU Objective C User Interface Library. 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 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "x11/XGServer.h" #include "xlib/XGContext.h" #include "xlib/XGPrivate.h" #include "xlib/XGGState.h" #ifdef HAVE_XFT #include "xlib/GSXftFontInfo.h" #endif #include #include #include /** XGContext

The documentation below mostly describes methods that are specific to this backend and wouldn't necessarily be used in other backends. The methods that this class does implement that would need to be in every backend are the methods of its NSGraphicContext superclass. See the documentation for NSGraphicContext for more information.

*/ @implementation XGContext /* Initialize AppKit backend */ + (void)initializeBackend { Class fontClass = Nil; Class fontEnumerator = Nil; NSDebugLog(@"Initializing GNUstep xlib backend.\n"); [NSGraphicsContext setDefaultContextClass: [XGContext class]]; #ifdef HAVE_XFT if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSFontAntiAlias"]) { fontClass = [GSXftFontInfo class]; #ifdef HAVE_FC fontEnumerator = [FcFontEnumerator class]; #endif } #endif if (fontClass == Nil) { fontClass = [XGFontInfo class]; } [GSFontInfo setDefaultClass: fontClass]; if (fontEnumerator == Nil) { fontEnumerator = [XGFontEnumerator class]; } [GSFontEnumerator setDefaultClass: fontEnumerator]; } - (id) initWithContextInfo: (NSDictionary *)info { NSString *contextType; contextType = [info objectForKey: NSGraphicsContextRepresentationFormatAttributeName]; self = [super initWithContextInfo: info]; if (contextType) { /* Most likely this is a PS or PDF context, so just return what super gave us */ return self; } /* Create a default gstate */ gstate = [[XGGState allocWithZone: [self zone]] initWithDrawContext: self]; return self; } - (void) flushGraphics { XFlush([(XGServer *)server xDisplay]); } // // Read the Color at a Screen Position // - (NSColor *) NSReadPixel: (NSPoint) location { [self notImplemented: _cmd]; return nil; } @end @implementation XGContext (Ops) /* ----------------------------------------------------------------------- */ /* Window system ops */ /* ----------------------------------------------------------------------- */ - (void) GSCurrentDevice: (void **)device : (int *)x : (int *)y { void *windevice = [(XGGState *)gstate windevice]; if (device) *device = windevice; if (x && y) { NSPoint offset = [gstate offset]; *x = offset.x; *y = offset.y; } } - (void) GSSetDevice: (void *)device : (int)x : (int)y { [(XGGState *)gstate setWindowDevice: device]; [gstate setOffset: NSMakePoint(x, y)]; } @end