source: trunk/Cocoa/DockCam/NJRVendingImageView.m@ 265

Last change on this file since 265 was 5, checked in by Nicholas Riley, 22 years ago

Initial import.

File size: 2.1 KB
Line 
1//
2// NJRVendingImageView.m
3// DockCam
4//
5// Created by Nicholas Riley on Fri Jun 28 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "NJRVendingImageView.h"
10
11@implementation NJRVendingImageView
12
13NSCursor *openHandCursor = nil, *closedHandCursor = nil;
14
15+ (void)initialize;
16{
17 openHandCursor = [[NSCursor alloc] initWithImage: [NSImage imageNamed: @"Open hand"] hotSpot: NSMakePoint(7, 7)];
18 closedHandCursor = [[NSCursor alloc] initWithImage: [NSImage imageNamed: @"Closed hand"] hotSpot: NSMakePoint(7, 7)];
19}
20
21- (void)putImageOnPasteboard:(NSPasteboard *)pboard;
22{
23 [pboard declareTypes: [NSArray arrayWithObject: NSTIFFPboardType] owner: self];
24 [pboard setData: [[self image] TIFFRepresentation] forType: NSTIFFPboardType];
25}
26
27- (void)mouseDown:(NSEvent *)event;
28{
29 NSPasteboard *pboard = [NSPasteboard pasteboardWithName: NSDragPboard];
30 NSImage *image = [self image];
31 NSRect viewRect = { NSZeroPoint, [self bounds].size };
32 NSRect imageRect = { NSZeroPoint, [image size] };
33 NSImage *draggingImage = [[NSImage alloc] initWithSize: viewRect.size];
34
35 [draggingImage lockFocus];
36 [image drawInRect: viewRect fromRect: imageRect operation: NSCompositeCopy fraction: 0.6];
37 [draggingImage unlockFocus];
38
39 [self putImageOnPasteboard: pboard];
40
41 [NSApp currentEvent];
42
43 [closedHandCursor push]; // XXX doesn't always work, bug 2976315
44
45 [self dragImage: draggingImage at: NSZeroPoint offset: NSZeroSize event: event pasteboard: pboard source: self slideBack: YES];
46
47 [closedHandCursor pop];
48}
49
50// XXX guess at size of resize corner
51#define RESIZE_CORNER_EDGE 15
52
53// XXX assumes that the view takes up the entire window, fine for this app but not in general
54- (void)resetCursorRects;
55{
56 NSRect rect = [self bounds];
57
58 rect.origin.y += RESIZE_CORNER_EDGE;
59 rect.size.height -= RESIZE_CORNER_EDGE;
60 [self addCursorRect: rect cursor: openHandCursor];
61
62 rect.origin.y -= RESIZE_CORNER_EDGE;
63 rect.size.height = RESIZE_CORNER_EDGE;
64 rect.size.width -= RESIZE_CORNER_EDGE;
65 [self addCursorRect: rect cursor: openHandCursor];
66}
67
68@end
Note: See TracBrowser for help on using the repository browser.