| 1 |
// |
| 2 |
// GraphicBackgroundView.m |
| 3 |
// Alchemusica |
| 4 |
// |
| 5 |
// Created by Toshi Nagata on 06/11/14. |
| 6 |
// Copyright 2006-2011 Toshi Nagata. All rights reserved. |
| 7 |
// |
| 8 |
/* |
| 9 |
This program is free software; you can redistribute it and/or modify |
| 10 |
it under the terms of the GNU General Public License as published by |
| 11 |
the Free Software Foundation version 2 of the License. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
*/ |
| 18 |
|
| 19 |
#import "GraphicBackgroundView.h" |
| 20 |
#import "GraphicWindowController.h" |
| 21 |
#import "GraphicClientView.h" |
| 22 |
|
| 23 |
@implementation GraphicBackgroundView |
| 24 |
|
| 25 |
- (id)initWithFrame:(NSRect)frame { |
| 26 |
self = [super initWithFrame:frame]; |
| 27 |
if (self) { |
| 28 |
// Initialization code here. |
| 29 |
} |
| 30 |
return self; |
| 31 |
} |
| 32 |
|
| 33 |
- (BOOL)acceptsFirstResponder |
| 34 |
{ |
| 35 |
return YES; |
| 36 |
} |
| 37 |
|
| 38 |
- (BOOL)becomeFirstResponder |
| 39 |
{ |
| 40 |
[self setNeedsDisplay: YES]; |
| 41 |
[self setKeyboardFocusRingNeedsDisplayInRect: [self bounds]]; |
| 42 |
return YES; |
| 43 |
} |
| 44 |
|
| 45 |
- (BOOL)resignFirstResponder |
| 46 |
{ |
| 47 |
[self setNeedsDisplay: YES]; |
| 48 |
[self setKeyboardFocusRingNeedsDisplayInRect: [self bounds]]; |
| 49 |
return YES; |
| 50 |
} |
| 51 |
|
| 52 |
- (void)drawRect:(NSRect)rect { |
| 53 |
NSRect bounds; |
| 54 |
[super drawRect: rect]; |
| 55 |
bounds = [self bounds]; |
| 56 |
if ([[self window] isMainWindow] && [[self window] firstResponder] == self) { |
| 57 |
NSSetFocusRingStyle(NSFocusRingOnly); |
| 58 |
NSRectFill(bounds); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize |
| 63 |
{ |
| 64 |
/* Call the window controller's "backgroundView:resizedWithOldSize:" */ |
| 65 |
id cont = [[self window] windowController]; |
| 66 |
if ([cont respondsToSelector: @selector(backgroundView:resizedWithOldSize:)]) { |
| 67 |
if (![cont backgroundView:self resizedWithOldSize:oldBoundsSize]) |
| 68 |
[super resizeSubviewsWithOldSize:oldBoundsSize]; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
- (void)flagsChanged:(NSEvent *)theEvent |
| 73 |
{ |
| 74 |
id clientView = [[[self window] windowController] lastMouseClientView]; |
| 75 |
if (clientView != nil) |
| 76 |
[clientView doFlagsChanged:theEvent]; |
| 77 |
else [super flagsChanged:theEvent]; |
| 78 |
} |
| 79 |
|
| 80 |
- (void)cursorUpdate:(NSEvent *)theEvent |
| 81 |
{ |
| 82 |
// Stop auto update of cursor |
| 83 |
// (Otherwise, the cursor sometimes automatically returns to the arrow cursor) |
| 84 |
} |
| 85 |
|
| 86 |
@end |