API
0.9.9
CPGraphicsContext.j
Go to the documentation of this file.
1
/*
2
* CPGraphicsContext.j
3
* AppKit
4
*
5
* Created by Francisco Tolmasky.
6
* Copyright 2008, 280 North, Inc.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License, or (at your option) any later version.
12
*
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
17
*
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
*/
22
23
24
25
26
var
CPGraphicsContextCurrent
= nil,
27
CPGraphicsContextThreadStack
= nil;
28
33
@implementation
CPGraphicsContext
:
CPObject
34
{
35
CGContext _graphicsPort;
36
}
37
41
+ (
CPGraphicsContext
)
currentContext
42
{
43
return
CPGraphicsContextCurrent
;
44
}
45
49
+ (void)setCurrentContext:(
CPGraphicsContext
)aGraphicsContext
50
{
51
CPGraphicsContextCurrent
= aGraphicsContext;
52
}
53
54
+ (void)
saveGraphicsState
55
{
56
if
(!
CPGraphicsContextCurrent
)
57
return
;
58
59
if
(!
CPGraphicsContextThreadStack
)
60
CPGraphicsContextThreadStack
= [
CPMutableArray
array];
61
62
[CPGraphicsContextThreadStack addObject:CPGraphicsContextCurrent];
63
[CPGraphicsContextCurrent saveGraphicsState];
64
}
65
66
+ (void)
restoreGraphicsState
67
{
68
var lastContext = [CPGraphicsContextThreadStack lastObject];
69
70
if
(lastContext)
71
{
72
[lastContext restoreGraphicsState];
73
[CPGraphicsContextThreadStack removeLastObject];
74
}
75
}
76
83
+ (
CPGraphicsContext
)graphicsContextWithGraphicsPort:(CGContext)aContext flipped:(BOOL)aFlag
84
{
85
return
[[
self
alloc
]
initWithGraphicsPort
:aContext];
86
}
87
93
- (id)initWithGraphicsPort:(CPContext)aGraphicsPort
94
{
95
self
= [
super
init
];
96
97
if
(
self
)
98
_graphicsPort = aGraphicsPort;
99
100
return
self
;
101
}
102
106
- (CGContext)
graphicsPort
107
{
108
return
_graphicsPort;
109
}
110
119
- (BOOL)
isFlipped
120
{
121
return
YES;
122
}
123
124
- (void)
saveGraphicsState
125
{
126
CGContextSaveGState
(_graphicsPort);
127
}
128
129
- (void)
restoreGraphicsState
130
{
131
CGContextRestoreGState
(_graphicsPort);
132
}
133
134
@end
CPObject
Definition:
CPObject.j:103
+[CPGraphicsContext restoreGraphicsState]
void restoreGraphicsState()
Definition:
CPGraphicsContext.j:66
+[CPGraphicsContext currentContext]
CPGraphicsContext currentContext()
Definition:
CPGraphicsContext.j:41
CGContextRestoreGState
function CGContextRestoreGState(aContext)
Definition:
CGContext.j:156
+[CPGraphicsContext saveGraphicsState]
void saveGraphicsState()
Definition:
CPGraphicsContext.j:54
CPGraphicsContextCurrent
var CPGraphicsContextCurrent
Definition:
CPGraphicsContext.j:26
CPMutableArray
Definition:
CPMutableArray.h:2
-[CPGraphicsContext graphicsPort]
CGContext graphicsPort()
Definition:
CPGraphicsContext.j:106
-[CPGraphicsContext initWithGraphicsPort:]
id initWithGraphicsPort:(CPContext aGraphicsPort)
Definition:
CPGraphicsContext.j:93
CPGraphicsContextThreadStack
var CPGraphicsContextThreadStack
Definition:
CPGraphicsContext.j:27
-[CPGraphicsContext isFlipped]
BOOL isFlipped()
Definition:
CPGraphicsContext.j:119
CGContextSaveGState
function CGContextSaveGState(aContext)
Definition:
CGContext.j:146
-[CPObject init]
id init()
Definition:
CPObject.j:145
CPGraphicsContext
Definition:
CPGraphicsContext.h:2
+[CPObject alloc]
id alloc()
Definition:
CPObject.j:130
AppKit
CPGraphicsContext.j
Generated on Fri Apr 1 2016 23:03:24 for API by
1.8.11