| 1 | #import "VoxRoundedView.h" |
|---|
| 2 | #import "Vox.h" |
|---|
| 3 | |
|---|
| 4 | @implementation VoxRoundedView |
|---|
| 5 | |
|---|
| 6 | - (id)initWithFrame:(NSRect)frameRect { |
|---|
| 7 | if ((self = [super initWithFrame:frameRect]) != nil) { |
|---|
| 8 | [self registerForDraggedTypes:[NSArray arrayWithObjects: |
|---|
| 9 | NSURLPboardType, |
|---|
| 10 | NSStringPboardType, |
|---|
| 11 | NSFilenamesPboardType, |
|---|
| 12 | NSHTMLPboardType, |
|---|
| 13 | nil |
|---|
| 14 | ] |
|---|
| 15 | ]; |
|---|
| 16 | } |
|---|
| 17 | return self; |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | - (void)drawRect:(NSRect)rect { |
|---|
| 21 | NSColor *bgColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.35]; |
|---|
| 22 | NSRect bgRect = rect; |
|---|
| 23 | int minX = NSMinX(bgRect); |
|---|
| 24 | int midX = NSMidX(bgRect); |
|---|
| 25 | int maxX = NSMaxX(bgRect); |
|---|
| 26 | int minY = NSMinY(bgRect); |
|---|
| 27 | int midY = NSMidY(bgRect); |
|---|
| 28 | int maxY = NSMaxY(bgRect); |
|---|
| 29 | float radius = 25.0; |
|---|
| 30 | NSBezierPath *bgPath = [NSBezierPath bezierPath]; |
|---|
| 31 | [bgPath moveToPoint:NSMakePoint(midX, minY)]; |
|---|
| 32 | [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, minY) toPoint:NSMakePoint(maxX, midY) radius:radius]; |
|---|
| 33 | [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, maxY) toPoint:NSMakePoint(midX, maxY) radius:radius]; |
|---|
| 34 | [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(minX, maxY) toPoint:NSMakePoint(minX, midY) radius:radius]; |
|---|
| 35 | [bgPath appendBezierPathWithArcFromPoint:bgRect.origin toPoint:NSMakePoint(midX, minY) radius:radius]; |
|---|
| 36 | [bgPath closePath]; |
|---|
| 37 | [bgColor set]; |
|---|
| 38 | [bgPath fill]; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender { |
|---|
| 42 | /* NSLog(@"- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender - called\n"); */ |
|---|
| 43 | |
|---|
| 44 | /* |
|---|
| 45 | NSPasteboard *pboard = [sender draggingPasteboard]; |
|---|
| 46 | NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType]; |
|---|
| 47 | NSLog(@"draggingEntered: filenames: %@\n", [filenames description]); |
|---|
| 48 | */ |
|---|
| 49 | |
|---|
| 50 | if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric) { |
|---|
| 51 | return NSDragOperationGeneric; |
|---|
| 52 | } |
|---|
| 53 | if ((NSDragOperationCopy & [sender draggingSourceOperationMask]) == NSDragOperationCopy) { |
|---|
| 54 | return NSDragOperationCopy; |
|---|
| 55 | } |
|---|
| 56 | return NSDragOperationNone; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | - (void)draggingExited:(id <NSDraggingInfo>)sender { } |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | - (void)draggingEnded:(id <NSDraggingInfo>)sender { } |
|---|
| 63 | |
|---|
| 64 | - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender { |
|---|
| 65 | return YES; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender { |
|---|
| 69 | /* NSLog(@"- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender - called\n"); */ |
|---|
| 70 | Vox *vx = [[[Vox alloc] init] autorelease]; |
|---|
| 71 | [vx dispatchAction:[sender draggingPasteboard]]; |
|---|
| 72 | [self setNeedsDisplay:YES]; |
|---|
| 73 | return YES; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | - (void)dealloc { |
|---|
| 77 | [self unregisterDraggedTypes]; |
|---|
| 78 | [super dealloc]; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | @end |
|---|