-
Notifications
You must be signed in to change notification settings - Fork 34
/
NoodleTableView.h
94 lines (73 loc) · 3.6 KB
/
NoodleTableView.h
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
//
// NoodleRowSpanningTableView.h
// NoodleRowSpanningTableViewTest
//
// Created by Paul Kim on 10/20/09.
// Copyright 2009-2012 Noodlesoft, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#import <Cocoa/Cocoa.h>
/*
This NSTableView subclass provides a couple of neat features.
Sticky Row Headers
==================
This allows you to specify certain rows (it uses group rows by default) to "stick" to the top of the tableview
scroll area when it is scrolled out of view. This is similar to how section headers work in UITableView in the
iPhone SDK. The bulk of the implementation and delegate API are in the NSTableView-NoodleExtensions category.
To enable this feature, just set the showsStickyRowHeader property.
For more details, see the related blog post at http://www.noodlesoft.com/blog/2009/09/25/sticky-section-headers-in-nstableview/
Row Spanning Columns
====================
Row Spanning Columns are columns whose cells are allow to span across multiple rows. The span is determined by
a contiguous section of rows that have the same object value. The cells within such a span are consolidated into
a single special cell. An example of this can be seen in the Artwork column in iTunes.
For any columns where you want to have this take effect, just change the column class to NoodleTableColumn and
set the rowSpanningEnabled property on it. You can alternatively call -setRowSpanningEnabledForCapablyColumns
on the tableview in your -awakeFromNib to enable all the NoodleTableColumns in your table in one fell swoop.
For more details, see the related blog post at http://www.noodlesoft.com/blog/2009/10/20/yet-another-way-to-mimic-the-artwork-column-in-cocoa/
*/
@interface NoodleTableView : NSTableView
{
BOOL _showsStickyRowHeader;
BOOL _hasSpanningColumns;
BOOL _isDrawingStickyRow;
}
@property (readwrite, assign) BOOL showsStickyRowHeader;
#pragma mark Row Spanning methods
/*
Enables/disables row spanning for all NoodleTableColumns in the receiver. Note that row spanning is not enabled
by default so if you want row spanning, call this from -awakeFromNib is a good idea.
*/
- (void)setRowSpanningEnabledForCapableColumns:(BOOL)flag;
@end
@class NoodleRowSpanningCell;
/*
Special table column that enables row spanning functionality. Just set your columns in IB to use this class and
enable it by calling -setRowSpaningEnabled:
*/
@interface NoodleTableColumn :NSTableColumn
{
BOOL _spanningEnabled;
NoodleRowSpanningCell *_cell;
}
@property (getter=isRowSpanningEnabled, setter=setRowSpanningEnabled:) BOOL rowSpanningEnabled;
@end