forked from adlr/formulatepro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FPRectangle.m
58 lines (48 loc) · 1.39 KB
/
FPRectangle.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// FPRectangle.m
// FormulatePro
//
// Created by Andrew de los Reyes on 8/5/06.
// Copyright 2006 Andrew de los Reyes. All rights reserved.
//
#import "FPRectangle.h"
@implementation FPRectangle
+ (NSString *)archivalClassName;
{
return @"Rectangle";
}
- (NSDictionary *)archivalDictionary
{
return [super archivalDictionary];
}
- (void)draw:(BOOL)selected
{
NSBezierPath *path = [NSBezierPath bezierPathWithRect:[self bounds]];
[path setLineWidth:[self strokeWidth]];
if (_gFlags.drawsFill) {
[_fillColor set];
[path fill];
}
if (_gFlags.drawsStroke) {
[_strokeColor set];
[path stroke];
}
}
- (BOOL)placeWithEvent:(NSEvent *)theEvent
{
NSPoint point;
_page = [_docView pageForPointFromEvent:theEvent];
point = [_docView pagePointForPointFromEvent:theEvent page:_page];
_bounds.origin = point;
_bounds.size = NSMakeSize(0.0,0.0);
_naturalBounds.origin = point;
_naturalBounds.size = NSMakeSize(1.0, 1.0);
// if the next event is mouse up, then the user didn't drag at all, so scrap the shape.
theEvent = [[_docView window] nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask)];
if ([theEvent type] == NSLeftMouseUp)
return NO;
// ok, we have a shape, and user is dragging to size it
[self resizeWithEvent:theEvent byKnob:LowerRightKnob];
return YES;
}
@end