-
Notifications
You must be signed in to change notification settings - Fork 10
/
NSBrowserCell+Rik.m
99 lines (82 loc) · 2.38 KB
/
NSBrowserCell+Rik.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "Rik.h"
@interface NSBrowserCell(RikTheme)
@end
@implementation NSBrowserCell(RikTheme)
/*
* Displaying
*/
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{
NSRect title_rect = cellFrame;
NSImage *branch_image = nil;
NSImage *cell_image = [self image];
if (_cell.is_highlighted || _cell.state)
{
if (!_browsercell_is_leaf)
branch_image = [object_getClass(self) highlightedBranchImage];
if (nil != [self alternateImage])
cell_image = [self alternateImage];
// If we are highlighted, fill the background
[[self highlightColorInView: controlView] setFill];
NSRectFill(cellFrame);
}
else
{
if (!_browsercell_is_leaf)
branch_image = [object_getClass(self) branchImage];
// (Don't fill the background)
}
// Draw the branch image if there is one
if (branch_image)
{
NSRect imgRect;
imgRect.size = [branch_image size];
imgRect.origin.x = MAX(NSMaxX(title_rect) - imgRect.size.width - 4.0, 0.);
imgRect.origin.y = MAX(NSMidY(title_rect) - (imgRect.size.height/2.), 0.);
if (controlView != nil)
{
imgRect = [controlView centerScanRect: imgRect];
}
[branch_image drawInRect: imgRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0
respectFlipped: YES
hints: nil];
title_rect.size.width -= imgRect.size.width + 8;
}
// Skip 2 points from the left border
title_rect.origin.x += 2;
title_rect.size.width -= 2;
// Draw the cell image if there is one
if (cell_image)
{
NSRect imgRect;
imgRect.size = [cell_image size];
imgRect.origin.x = NSMinX(title_rect);
imgRect.origin.y = MAX(NSMidY(title_rect) - (imgRect.size.height/2.),0.);
if (controlView != nil)
{
imgRect = [controlView centerScanRect: imgRect];
}
[cell_image drawInRect: imgRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0
respectFlipped: YES
hints: nil];
title_rect.origin.x += imgRect.size.width + 4;
title_rect.size.width -= imgRect.size.width + 4;
}
// Draw the body of the cell
if (_cell.in_editing)
{
[self _drawEditorWithFrame: cellFrame inView: controlView];
}
else
{
[self _drawAttributedText: [self attributedStringValue]
inFrame: title_rect];
}
}
@end