2 // VLCHUDTableHeaderCell.m
5 // Created by BinaryGod on 6/17/08.
7 // Copyright (c) 2008, Tim Davis (BinaryMethod.com, binary.god@gmail.com)
8 // All rights reserved.
10 // Redistribution and use in source and binary forms, with or without modification,
11 // are permitted provided that the following conditions are met:
13 // Redistributions of source code must retain the above copyright notice, this
14 // list of conditions and the following disclaimer.
16 // Redistributions in binary form must reproduce the above copyright notice,
17 // this list of conditions and the following disclaimer in the documentation and/or
18 // other materials provided with the distribution.
20 // Neither the name of the BinaryMethod.com nor the names of its contributors
21 // may be used to endorse or promote products derived from this software without
22 // specific prior written permission.
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
25 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
30 // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 // POSSIBILITY OF SUCH DAMAGE.
35 #import "VLCHUDTableHeaderCell.h"
37 @interface NSTableHeaderCell (AppKitPrivate)
38 - (void)_drawSortIndicatorIfNecessaryWithFrame:(NSRect)arg1 inView:(id)arg2;
41 @implementation VLCHUDTableHeaderCell
43 #pragma mark Drawing Functions
45 - (instancetype)initWithCoder:(NSCoder *)coder
47 self = [super initWithCoder:coder];
49 _cellTextColor = [NSColor whiteColor];
50 _disabledCellTextColor = [NSColor colorWithDeviceRed:1 green:1 blue:1 alpha:0.2f];
51 _tableHeaderCellBorderColor = [NSColor colorWithDeviceRed:0.349f green:0.361f blue:0.388f alpha:1.0f];
52 _tableHeaderCellNormalFill = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.251f green:0.251f blue:0.255f alpha:1.0f]
53 endingColor:[NSColor colorWithDeviceRed:0.118f green:0.118f blue:0.118f alpha:1.0f]];
54 _tableHeaderCellSelectedFill = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.651f green:0.651f blue:0.655f alpha:1.0f]
55 endingColor:[NSColor colorWithDeviceRed:0.518f green:0.518f blue:0.518f alpha:1.0f]];
65 - (void)_drawThemeContents:(NSRect)frame highlighted:(BOOL)flag inView:(id)view {
68 [_tableHeaderCellBorderColor set];
72 // frame.origin.x += 1; - Removed to fix Issue #31
73 frame.size.width -= 1;
75 frame.size.height -= 2;
78 [_tableHeaderCellSelectedFill drawInRect: frame angle: 90];
80 [_tableHeaderCellNormalFill drawInRect: frame angle: 90];
83 // Adjust so text aligns correctly
85 frame.size.width += 1;
87 frame.size.height += 2;
89 // REMOVED - Enabling this line draws two sort arrows, frame alignment issue here.
90 // Not needed since the Apple drawing routines seem to be updating sort
92 /*if ([self respondsToSelector:@selector(_drawSortIndicatorIfNecessaryWithFrame:inView:)])
93 [super _drawSortIndicatorIfNecessaryWithFrame: frame inView: view];*/
95 frame.origin.y += (NSMidY(frame) - ([[self font] pointSize] /2)) - 2;
100 [super drawInteriorWithFrame: frame inView: view];
103 - (void)drawSortIndicatorWithFrame:(NSRect) frame inView:(id) controlView ascending:(BOOL) ascFlag priority:(NSInteger) priInt {
106 frame.size.height += 2;
110 NSRect arrowRect = [self sortIndicatorRectForBounds: frame];
113 arrowRect.size.width -= 2;
114 arrowRect.size.height -= 1;
116 NSBezierPath *arrow = [[NSBezierPath alloc] init];
121 arrowRect.origin.y -= 2;
122 points[0] = NSMakePoint(NSMinX(arrowRect), NSMinY(arrowRect) +2);
123 points[1] = NSMakePoint(NSMaxX(arrowRect), NSMinY(arrowRect) +2);
124 points[2] = NSMakePoint(NSMidX(arrowRect), NSMaxY(arrowRect));
126 points[0] = NSMakePoint(NSMinX(arrowRect), NSMaxY(arrowRect) -2);
127 points[1] = NSMakePoint(NSMaxX(arrowRect), NSMaxY(arrowRect) -2);
128 points[2] = NSMakePoint(NSMidX(arrowRect), NSMinY(arrowRect));
131 [arrow appendBezierPathWithPoints: points count: 3];
133 if ([self isEnabled]) {
134 [_cellTextColor set];
136 [_disabledCellTextColor set];
143 frame.size.height -= 2;