2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
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 License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #import "AIListThemePreviewCell.h"
18 #import "AIListThemeWindowController.h"
19 #import <AIUtilities/AIColorAdditions.h>
20 #import <AIUtilities/AIGradient.h>
21 #import <Adium/AIAbstractListController.h>
23 @implementation AIListThemePreviewCell
26 - (id)copyWithZone:(NSZone *)zone
28 AIListThemePreviewCell *newCell = [super copyWithZone:zone];
30 newCell->themeDict = nil;
31 [newCell setThemeDict:themeDict];
33 newCell->colorKeyArray = [colorKeyArray retain];
40 if ((self = [super init]))
43 colorKeyArray = [[NSArray arrayWithObjects:
46 KEY_LABEL_TYPING_COLOR,
47 KEY_LABEL_SIGNED_OFF_COLOR,
48 KEY_LABEL_SIGNED_ON_COLOR,
49 KEY_LABEL_UNVIEWED_COLOR,
50 KEY_LABEL_ONLINE_COLOR,
51 KEY_LABEL_IDLE_AWAY_COLOR,
52 KEY_LABEL_OFFLINE_COLOR,
64 KEY_LIST_THEME_BACKGROUND_COLOR,
65 KEY_LIST_THEME_GRID_COLOR,
67 KEY_LIST_THEME_GROUP_BACKGROUND,
68 KEY_LIST_THEME_GROUP_BACKGROUND_GRADIENT,
78 [colorKeyArray release];
82 - (void)setThemeDict:(NSDictionary *)inDict
84 if (inDict != themeDict) {
86 themeDict = [inDict retain];
90 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
92 cellFrame.origin.y += 2;
93 cellFrame.size.height -= 4;
95 NSEnumerator *enumerator = [colorKeyArray objectEnumerator];
97 NSRect segmentRect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y,
98 (cellFrame.size.width / [colorKeyArray count]), cellFrame.size.height);
100 [[NSColor whiteColor] set];
101 [NSBezierPath fillRect:cellFrame];
103 while ((key = [enumerator nextObject])) {
104 [[[themeDict objectForKey:key] representedColor] set];
105 [NSBezierPath fillRect:segmentRect];
106 segmentRect.origin.x += segmentRect.size.width;
109 [[NSColor blackColor] set];
110 [NSBezierPath strokeRect:NSOffsetRect(cellFrame, .5, .5)];
114 //Draw with the selected-control colours.
115 - (void)_drawHighlightWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
118 AIGradient *gradient = [AIGradient selectedControlGradientWithDirection:AIVertical];
119 [gradient drawInRect:cellFrame];
121 //Draw a line at the light side, to make it look a lot cleaner
122 cellFrame.size.height = 1;
123 [[NSColor alternateSelectedControlColor] set];
124 NSRectFillUsingOperation(cellFrame,NSCompositeSourceOver);