-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapImageView.m
executable file
·80 lines (58 loc) · 1.48 KB
/
MapImageView.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// MapView.m
// agemap1
//
// Created by Peter Appel on 24/03/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "MapImageView.h"
@implementation MapImageView
- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];
}
- (void)broadcast
{
NSNotificationCenter *notify;
notify =[NSNotificationCenter defaultCenter];
[notify postNotificationName:@"transformChanged" object:nil];
}
// NSResponder methods.
-(void)mouseDown:(NSEvent *)event
{
[self mouseDragged:event];
}
// there is a much better method also dealing with colors in "Color Sampler" sample code
-(void)mouseDragged:(NSEvent *)event
{
// NSPoint p = [event locationInWindow];
// lastPoint = [self convertPoint:p fromView:self];
NSPoint pos = [self convertPoint:[event locationInWindow] fromView:nil];
if (!([event modifierFlags] & NSControlKeyMask))
{
// NSLog(@"mouseDragged: %@", event);
[self setPosition:pos];
[self broadcast];
[self setNeedsDisplay:YES];
}
/* from color sampler
NSPoint pos = [self convertPoint:[event locationInWindow] fromView:nil];
[self lockFocus];
int pixelValue = NSReadPixel(pos);
[self unlockFocus];
[reportText setStringValue:[NSString stringWithFormat:@"At: (%.0f,%.0f) V = %.2f", pos.x, pos.y, pixelValue]];
*/
}
- (void) mouseUp:(NSEvent *) theEvent
{
// NSLog(@"mouseUp:");
}
- (NSPoint)position
{
return position;
}
- (void)setPosition:(NSPoint)value;
{
position = value;
}
@end