source: trunk/macosx/FilterBarView.m @ 11622

Last change on this file since 11622 was 11622, checked in by livings124, 11 years ago

always draw the top white line on the filter bar

File size: 2.8 KB
Line 
1/******************************************************************************
2 * $Id$
3 *
4 * Copyright (c) 2011 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#import "FilterBarView.h"
26
27@implementation FilterBarView
28
29- (id) initWithFrame: (NSRect) rect
30{
31    if ((self = [super initWithFrame: rect]))
32    {
33        NSColor * lightColor = [NSColor colorWithCalibratedRed: 235.0/255.0 green: 235.0/255.0 blue: 235.0/255.0 alpha: 1.0];
34        NSColor * darkColor = [NSColor colorWithCalibratedRed: 205.0/255.0 green: 205.0/255.0 blue: 205.0/255.0 alpha: 1.0];
35        fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
36    }
37    return self;
38}
39
40- (void) dealloc
41{
42    [fGradient release];
43    [super dealloc];
44}
45
46- (BOOL) mouseDownCanMoveWindow
47{
48    return NO;
49}
50
51- (void) drawRect: (NSRect) rect
52{
53    NSInteger count = 0;
54    NSRect gridRects[2];
55    NSColor * colorRects[2];
56   
57    NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
58    if (NSIntersectsRect(lineBorderRect, rect))
59    {
60        gridRects[count] = lineBorderRect;
61        colorRects[count] = [NSColor whiteColor];
62        ++count;
63       
64        rect.size.height -= 1.0;
65    }
66   
67    lineBorderRect.origin.y = 0.0;
68    if (NSIntersectsRect(lineBorderRect, rect))
69    {
70        gridRects[count] = lineBorderRect;
71        colorRects[count] = [NSColor colorWithCalibratedWhite: 0.65 alpha: 1.0];
72        ++count;
73       
74        rect.origin.y += 1.0;
75        rect.size.height -= 1.0;
76    }
77   
78    NSRectFillListWithColors(gridRects, colorRects, count);
79   
80    [fGradient drawInRect: rect angle: 270.0];
81}
82
83@end
Note: See TracBrowser for help on using the repository browser.