| 1 |
// |
| 2 |
// TextureView.m |
| 3 |
// Alchemusica |
| 4 |
// |
| 5 |
/* |
| 6 |
Copyright (c) 2008-2011 Toshi Nagata. All rights reserved. |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation version 2 of the License. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
*/ |
| 17 |
|
| 18 |
#import "TextureView.h" |
| 19 |
|
| 20 |
@implementation TextureView |
| 21 |
|
| 22 |
- (id)initWithFrame:(NSRect)frameRect |
| 23 |
{ |
| 24 |
if ((self = [super initWithFrame:frameRect]) != nil) { |
| 25 |
// Add initialization code here |
| 26 |
} |
| 27 |
return self; |
| 28 |
} |
| 29 |
|
| 30 |
- (void)drawRect:(NSRect)rect |
| 31 |
{ |
| 32 |
static NSRectEdge mySides[] = {NSMinYEdge, NSMaxXEdge, NSMaxYEdge, NSMinXEdge, NSMinYEdge, NSMaxXEdge}; |
| 33 |
static NSColor *myColors[] = {NULL, NULL, NULL, NULL, NULL, NULL}; |
| 34 |
NSRect aRect = [self bounds]; |
| 35 |
if (myColors[0] == NULL) { |
| 36 |
static float myFloatColors[] = {0.5f, 0.5f, 0.92f, 0.92f, 0.85f, 0.85f}; |
| 37 |
int i; |
| 38 |
for (i = 0; i < sizeof(myFloatColors) / sizeof(myFloatColors[0]); i++) { |
| 39 |
float f = myFloatColors[i]; |
| 40 |
myColors[i] = [[NSColor colorWithDeviceWhite: f alpha: 1.0f] retain]; |
| 41 |
} |
| 42 |
} |
| 43 |
aRect = NSDrawColorTiledRects(aRect, rect, mySides, myColors, 6); |
| 44 |
[[NSColor colorWithDeviceWhite: 0.8f alpha: 1.0f] set]; |
| 45 |
NSRectFill(aRect); |
| 46 |
|
| 47 |
if ([[self window] firstResponder] == self) { |
| 48 |
NSSetFocusRingStyle(NSFocusRingOnly); |
| 49 |
NSRectFill([self bounds]); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
@end |