Author: rmottola
Date: Sun Oct 4 22:07:52 2015
New Revision: 39027
URL: http://svn.gna.org/viewcvs/gnustep?rev=39027&view=rev
Log:
add first cgcontext functions
Added:
devmodules/dev-libs/mica/Sources/CGContext.m
Modified:
devmodules/dev-libs/mica/GNUmakefile
devmodules/dev-libs/mica/Headers/CoreGraphics/CGContext.h
Modified: devmodules/dev-libs/mica/GNUmakefile
URL:
http://svn.gna.org/viewcvs/gnustep/devmodules/dev-libs/mica/GNUmakefile?rev=39027&r1=39026&r2=39027&view=diff
==============================================================================
--- devmodules/dev-libs/mica/GNUmakefile (original)
+++ devmodules/dev-libs/mica/GNUmakefile Sun Oct 4 22:07:52 2015
@@ -38,6 +38,7 @@
# Class files
#
Mica_OBJC_FILES = \
+Sources/CGContext.m \
Sources/CGColorSpace.m \
Sources/CGPath.m \
Modified: devmodules/dev-libs/mica/Headers/CoreGraphics/CGContext.h
URL:
http://svn.gna.org/viewcvs/gnustep/devmodules/dev-libs/mica/Headers/CoreGraphics/CGContext.h?rev=39027&r1=39026&r2=39027&view=diff
==============================================================================
--- devmodules/dev-libs/mica/Headers/CoreGraphics/CGContext.h (original)
+++ devmodules/dev-libs/mica/Headers/CoreGraphics/CGContext.h Sun Oct 4
22:07:52 2015
@@ -27,11 +27,34 @@
#ifndef CGCONTEXT_H_
#define CGCONTEXT_H_
+#include <CoreGraphics/CGColorSpace.h>
+#include <CoreGraphics/CGImage.h>
+#include <CoreGraphics/CGPath.h>
+
+#ifdef __OBJC__
+
+@class CGContext;
+typedef CGContext *CGContextRef;
+
+#else /* standard C */
+
typedef struct CGContext *CGContextRef;
-#include <CoreGraphics/CGColorSpace.h>
-#include <CoreGraphics/CGImage.h>
+#endif
+
+
+/* managing */
void CGContextRelease( CGContextRef c);
+CGContextRef CGContextRetain( CGContextRef c);
+
+/* constructing paths */
+
+void CGContextAddPath ( CGContextRef c, CGPathRef path );
+
+/* painting paths */
+
+void CGContextDrawPath ( CGContextRef c, CGPathDrawingMode mode );
+void CGContextFillPath ( CGContextRef c );
#endif /* CGCONTEXT_H_ */
Added: devmodules/dev-libs/mica/Sources/CGContext.m
URL:
http://svn.gna.org/viewcvs/gnustep/devmodules/dev-libs/mica/Sources/CGContext.m?rev=39027&view=auto
==============================================================================
--- devmodules/dev-libs/mica/Sources/CGContext.m (added)
+++ devmodules/dev-libs/mica/Sources/CGContext.m Sun Oct 4 22:07:52 2015
@@ -0,0 +1,151 @@
+/**
+ Mica: Implementation of CoreGraphics on top of AppKit
+ CGContext.m
+
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ Written by: Riccardo Mottola <[email protected]>
+
+ This file is part of the Mica Framework.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser 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 Lesser General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02111 USA.
+ */
+
+#import <CoreGraphics/CGContext.h>
+
+#import <AppKit/NSGraphicsContext.h>
+#import <AppKit/NSBezierPath.h>
+
+@interface CGContext : NSGraphicsContext
+{
+ NSBezierPath *_path;
+}
+
+- (void)setPath:(NSBezierPath *)p;
+- (NSBezierPath *)path;
+
+@end
+
+@implementation CGContext
+
+- (void)dealloc
+{
+ [_path release];
+}
+
+- (void)setPath:(NSBezierPath *)p
+{
+ if (_path != p)
+ {
+ [_path release];
+ _path = p;
+ [_path retain];
+ }
+}
+
+- (NSBezierPath *)path
+{
+ return _path;
+}
+
+@end
+
+/* managing */
+
+void CGContextRelease
+(
+ CGContextRef c
+)
+{
+ NSGraphicsContext *nsGc;
+
+ nsGc = c;
+ if (nsGc)
+ [nsGc release];
+}
+
+CGContextRef CGContextRetain
+(
+ CGContextRef c
+)
+{
+ NSGraphicsContext *nsGc;
+
+ nsGc = c;
+ if (nsGc)
+ [nsGc retain];
+
+ return (CGContextRef)nsGc;
+}
+
+
+void CGContextAddPath
+(
+ CGContextRef c, CGPathRef path
+)
+{
+ NSGraphicsContext *nsGc;
+
+ nsGc = c;
+}
+
+
+void CGContextDrawPath
+(
+ CGContextRef c, CGPathDrawingMode mode
+)
+{
+ NSGraphicsContext *nsGc;
+ NSBezierPath *p;
+
+ nsGc = c;
+ p = [c path];
+
+ switch (mode)
+ {
+ kCGPathFill:
+ [p setWindingRule:NSNonZeroWindingRule];
+ [p fill];
+ break;
+ kCGPathEOFFill:
+ [p setWindingRule:NSEvenOddWindingRule];
+ [p fill];
+ break;
+ kCGPathStroke:
+ [p stroke];
+ break;
+ kCGPathFillStroke:
+ [p setWindingRule:NSNonZeroWindingRule];
+ [p fill];
+ [p stroke];
+ break;
+ kCGPathEOFFillStroke:
+ [p setWindingRule:NSEvenOddWindingRule];
+ [p fill];
+ [p stroke];
+ break;
+ default:
+ NSLog(@"CGContextDrawPath: unexpected CGPathDrawingMode");
+ }
+}
+
+void CGContextFillPath
+(
+ CGContextRef c
+ )
+{
+ CGContextDrawPath (c, kCGPathFill);
+}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs