Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 90 lines (69 sloc) 2.72 kb
a516cc8b » uli
2009-07-04 Initial check-in.
1 //
2 // UKPaintEraseRectTool.m
3 // UKPaintView
4 //
5 // Created by Uli Kusterer on Sat Nov 01 2003.
6 // Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
7 //
6a767a74 »
2011-05-01 Big clean-up. Adopted new prefix. Fixed support for line and fill col…
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 //
a516cc8b » uli
2009-07-04 Initial check-in.
27
6a767a74 »
2011-05-01 Big clean-up. Adopted new prefix. Fixed support for line and fill col…
28 #import "ULIPaintEraseRectTool.h"
29 #import "ULIPaintView.h"
a516cc8b » uli
2009-07-04 Initial check-in.
30 #import "NSCursor+CrossHair.h"
31
32
6a767a74 »
2011-05-01 Big clean-up. Adopted new prefix. Fixed support for line and fill col…
33 @implementation ULIPaintEraseRectTool
a516cc8b » uli
2009-07-04 Initial check-in.
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 [[NSColor blackColor] set];
44 [NSBezierPath setDefaultLineWidth: 1];
45 [[NSColor colorWithCalibratedRed: NSLightGray green: NSLightGray blue: 1.0 alpha: NSDarkGray] set];
46 [NSBezierPath fillRect: box];
47 [[NSColor blackColor] set];
48 [NSBezierPath strokeRect: box];
49
50 box = [self rectWithLineSizeFrom: [owner initialPos] to: currPos];
51
52 [owner setNeedsDisplayInRect: oldBox];
53 [owner setNeedsDisplayInRect: box];
54
55 *prevPos = currPos;
56 }
57
58
59 -(void) drawFinalToolShapeFrom: (NSPoint*)prevPos to: (NSPoint)currPos
60 {
61 NSRect box = [self rectFrom: [owner initialPos] to: currPos];
62 NSRect oldBox = [self rectWithLineSizeFrom: [owner initialPos] to: *prevPos];
63
64 [[NSColor colorWithCalibratedWhite: 1.0 alpha: 0.0] set];
65 [NSBezierPath setDefaultLineWidth: 1];
66 NSRectFill(box);
67
68 box = [self rectWithLineSizeFrom: [owner initialPos] to: currPos];
69
70 [owner setNeedsDisplayInRect: oldBox];
71 [owner setNeedsDisplayInRect: box];
72
73 *prevPos = currPos;
74 }
75
76
77 -(NSCursor*) drawingCursor
78 {
79 return [NSCursor crossHairCursor];
80 }
81
82
83 -(NSString*) toolIconName
84 {
85 return @"UKPaintEraseRectTool";
86 }
87
88
89
90 @end
Something went wrong with that request. Please try again.