Repository navigation
Expand file tree
/
Copy pathCPFileReferenceCell.m
More file actions
121 lines (96 loc) · 4.02 KB
/
Copy pathCPFileReferenceCell.m
File metadata and controls
121 lines (96 loc) · 4.02 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// FileSelectionCell.m
// CodePilot
//
// Created by Zbigniew Sobiecki on 2/10/10.
// Copyright 2010 Macoscope. All rights reserved.
//
#import "CPFileReferenceCell.h"
#import "CPCodePilotConfig.h"
#import "CPFileReference.h"
@implementation CPFileReferenceCell
@dynamic cpFileReference;
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
[super drawWithFrame:cellFrame inView:controlView];
[self drawIconWithFrame:cellFrame];
[self drawFileNameWithFrame:cellFrame];
if (self.extendedDisplay) {
[self drawGroupNameWithFrame:cellFrame];
}
}
- (void)drawIconWithFrame:(NSRect)cellFrame
{
[self drawIconImage:[self.cpFileReference icon] withFrame:cellFrame];
}
- (void)drawFileNameWithFrame:(NSRect)cellFrame
{
NSMutableDictionary *fileNameStringAttributes = [[self defaultStringAttributes] mutableCopy];
[fileNameStringAttributes setObject:[NSFont fontWithName:FILE_SELECTION_CELL_FONT_NAME
size:FILE_SELECTION_CELL_FONT_SIZE]
forKey:NSFontAttributeName];
if ([self isHighlighted]) {
[fileNameStringAttributes setObject:FILE_SELECTION_CELL_HIGHLIGHTED_FONT_COLOR forKey:NSForegroundColorAttributeName];
} else {
[fileNameStringAttributes setObject:FILE_SELECTION_CELL_FONT_COLOR forKey:NSForegroundColorAttributeName];
}
NSMutableAttributedString *fileNameAttributedString = [[self queryHitAttributedStringWithString:[self.cpFileReference fileName]] mutableCopy];
[fileNameAttributedString addAttributes:fileNameStringAttributes range:NSMakeRange(0, [fileNameAttributedString length])];
// odstep miedzy ikona a nazwa pliku;
CGFloat fileNameMargin;
if (self.extendedDisplay) {
fileNameMargin = RESULT_CELL_FILE_EXTENDED_ICON_WIDTH;
} else {
fileNameMargin = RESULT_CELL_FILE_ICON_WIDTH;
}
[fileNameAttributedString drawInRect:NSMakeRect(cellFrame.origin.x + fileNameMargin,
cellFrame.origin.y + 4,
cellFrame.size.width - fileNameMargin,
cellFrame.size.height)];
}
- (void)drawGroupNameWithFrame:(NSRect)cellFrame
{
if ([self.cpFileReference groupName]) {
NSMutableDictionary *groupNameStringAttributes = [[self defaultStringAttributes] mutableCopy];
[groupNameStringAttributes setObject:[NSFont fontWithName:FILE_SELECTION_CELL_EXTENDED_INFO_FONT_NAME
size:FILE_SELECTION_CELL_EXTENDED_INFO_FONT_SIZE]
forKey:NSFontAttributeName];
if ([self isHighlighted]) {
[groupNameStringAttributes setObject:FILE_SELECTION_CELL_HIGHLIGHTED_FONT_COLOR forKey:NSForegroundColorAttributeName];
} else {
[groupNameStringAttributes setObject:FILE_SELECTION_CELL_FONT_COLOR forKey:NSForegroundColorAttributeName];
}
NSString *groupNameString = [self.cpFileReference groupName];
NSString *projectName = [self.cpFileReference projectName];
if ([self.cpFileReference subprojectFile]) {
groupNameString = [NSString stringWithFormat:@"%@ (%@)", groupNameString, projectName];
}
NSAttributedString *groupNameAttributedString = [[NSAttributedString alloc] initWithString:groupNameString
attributes:groupNameStringAttributes];
[groupNameAttributedString drawInRect:NSMakeRect(cellFrame.origin.x + RESULT_CELL_FILE_EXTENDED_ICON_WIDTH,
cellFrame.origin.y + FILE_SELECTION_CELL_FONT_SIZE + 9,
cellFrame.size.width - RESULT_CELL_FILE_EXTENDED_ICON_WIDTH,
cellFrame.size.height - (FILE_SELECTION_CELL_FONT_SIZE + 9))];
}
}
- (CPFileReference *)cpFileReference
{
return (CPFileReference *)self.objectValue;
}
- (NSUInteger)requiredHeight
{
if (self.extendedDisplay) {
return FILE_SELECTION_CELL_EXTENDED_HEIGHT;
} else {
return FILE_SELECTION_CELL_HEIGHT;
}
}
- (NSRect)expansionFrameWithFrame:(NSRect)cellFrame inView:(NSView *)view
{
return NSZeroRect;
}
- (void)drawWithExpansionFrame:(NSRect)cellFrame inView:(NSView *)view
{
return;
}
@end