-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVerticallyAlignedTextFieldCell.m
More file actions
34 lines (27 loc) · 995 Bytes
/
Copy pathVerticallyAlignedTextFieldCell.m
File metadata and controls
34 lines (27 loc) · 995 Bytes
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
//
// VerticallyAlignedTextFieldCell.m
// Add Folder Icons
//
// Created by Andrew Hodgkinson on 27/02/16.
// Copyright © 2016 Hipposoft. All rights reserved.
//
// Vertically centred text for NSTextFieldCell-based table cells in
// cell-based NSTableViews. See:
//
// http://stackoverflow.com/questions/2103125/vertically-aligning-text-in-nstableview-row
//
#import "VerticallyAlignedTextFieldCell.h"
@implementation VerticallyAlignedTextFieldCell
- ( NSRect ) titleRectForBounds: ( NSRect ) theRect
{
NSRect titleFrame = [ super titleRectForBounds: theRect ];
NSSize titleSize = [ [ self attributedStringValue ] size ];
titleFrame.origin.y = theRect.origin.y - .5 + ( theRect.size.height - titleSize.height ) / 2.0;
return titleFrame;
}
- ( void ) drawInteriorWithFrame: ( NSRect ) cellFrame inView: ( NSView * ) controlView
{
NSRect titleRect = [ self titleRectForBounds: cellFrame ];
[ [ self attributedStringValue ] drawInRect: titleRect ];
}
@end