Draw the dimple (though it is upside-down because the Cartesian is flipped)
[macgdbp.git] / Source / BSSplitView.m
1 /*
2 * MacGDBp
3 * Copyright (c) 2007 - 2008, Blue Static <http://www.bluestatic.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17 #import "BSSplitView.h"
18
19
20 @implementation BSSplitView
21
22 /**
23 * Override the drawing method for the divider so we can make it prettier
24 *
25 * @todo draw the dimple
26 */
27 - (void)drawDividerInRect:(NSRect)rect
28 {
29 NSColor *startColor = [NSColor colorWithDeviceRed:0.875 green:0.875 blue:0.875 alpha:1.0];
30 NSColor *endColor = [NSColor colorWithDeviceRed:0.812 green:0.812 blue:0.812 alpha:1.0];
31
32 // draw the gradient
33 NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor];
34 [gradient drawInRect:rect angle:([self isVertical] ? 0.0 : 90.0)];
35
36 // draw the stroke
37 NSColor *stroke = [NSColor colorWithDeviceRed:0.667 green:0.667 blue:0.667 alpha:1.0];
38 [stroke setStroke];
39 [NSBezierPath setDefaultLineWidth:0.5];
40 [NSBezierPath strokeRect:rect];
41
42 // draw the dimple
43 NSImage *dimple = [NSImage imageNamed:@"dimple.png"];
44 NSSize imgSize = [dimple size];
45 NSRect dimpleRect = NSMakeRect((rect.size.width / 2) - (imgSize.width / 2) + rect.origin.x, (rect.size.height / 2) - (imgSize.height / 2) + rect.origin.y, imgSize.width, imgSize.height);
46 [dimple drawInRect:dimpleRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
47 }
48
49 /**
50 * Returns the size of the divider to draw
51 */
52 - (CGFloat)dividerThickness;
53 {
54 return 6.0;
55 }
56
57 @end