Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 86 lines (66 sloc) 2.543 kB
a516cc8 Initial check-in.
uli authored
1 //
2 // UKPaintTempRoundrectTool.m
3 // UKPaintView
4 //
5 // Created by Uli Kusterer on Wed Feb 04 2004.
6 // Copyright (c) 2004 M. Uli Kusterer. All rights reserved.
7 //
6a767a7 @uliwitness Big clean-up. Adopted new prefix. Fixed support for line and fill col…
authored
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
26 //
a516cc8 Initial check-in.
uli authored
27
6a767a7 @uliwitness Big clean-up. Adopted new prefix. Fixed support for line and fill col…
authored
28 #import "ULIPaintTempRoundrectTool.h"
29 #import "ULIPaintView.h"
a516cc8 Initial check-in.
uli authored
30 #import "NSBezierPath+RoundRect.h"
31
32
6a767a7 @uliwitness Big clean-up. Adopted new prefix. Fixed support for line and fill col…
authored
33 @implementation ULIPaintTempRoundrectTool
a516cc8 Initial check-in.
uli authored
34
35 /* Override this to draw a shape during tracking:
36 The drawings you do in here will be undone before you're called again.
37 This is also called when tracking has finished by drawFinalToolShapeFrom:to: by default. */
38 -(void) drawTemporaryTrackingToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos
39 {
40 NSRect box = [self rectFrom: [owner initialPos] to: currPos];
41 NSRect oldBox = [self rectWithLineSizeFrom: [owner initialPos] to: *prevPos];
42
43 [[owner lineColor] set];
44 [NSBezierPath setDefaultLineWidth: [owner lineSize].width];
45 [NSBezierPath strokeRoundRectInRect: box radius: 8];
46
47 box = [self rectWithLineSizeFrom: [owner initialPos] to: currPos];
48
49 [owner setNeedsDisplayInRect: oldBox];
50 [owner setNeedsDisplayInRect: box];
51
52 *prevPos = currPos;
53 }
54
55
56 -(NSString*) toolIconName
57 {
58 return @"UKPaintTempRoundrectTool";
59 }
60
61
62 -(void) drawDisposableToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos
63 {
64 [self drawTemporaryTrackingToolShapeFrom: prevPos to: currPos];
65 }
66
67 -(void) drawFinalToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos
68 {
69 // The default calls drawTemporaryTrackingToolShapeFrom:to:, which we don't want here.
70 }
71
72
73 -(void) trackingWillStart
74 {
75 [owner setNeedsDisplay: YES]; // Make sure previous marker's area is redrawn.
76 }
77
78
79 -(void) paintToolWillUnload: (id)sender
80 {
81 [owner clearMarkersBuffer: nil];
82 }
83
84
85 @end
Something went wrong with that request. Please try again.