forked from mikecsh/mbtablegrid
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMBTableGrid.h
More file actions
1715 lines (1489 loc) · 50.3 KB
/
MBTableGrid.h
File metadata and controls
1715 lines (1489 loc) · 50.3 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2008 Matthew Ball - http://www.mattballdesign.com
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>
#import <QuartzCore/QuartzCore.h>
typedef enum : NSUInteger {
MBSortNone,
MBSortAscending,
MBSortDescending,
MBSortUndetermined
} MBSortDirection;
@class MBTableGridHeaderView, MBTableGridFooterView, MBTableGridHeaderCell, MBTableGridContentView, MBTableGridShadowView;
@protocol MBTableGridDelegate, MBTableGridDataSource;
/* Notifications */
/**
* @brief Posted after an MBTableGrid object's selection changes.
* The notification object is the table grid whose selection
* changed. This notification does not contain a userInfo
* dictionary.
*
* @details This notification will often be posted twice for a single
* selection change (once for the column selection and once
* for the row selection). As such, any methods called in
* response to this notification should be especially efficient.
*/
APPKIT_EXTERN NSString *MBTableGridDidChangeSelectionNotification;
APPKIT_EXTERN NSString *MBTableGridDidChangeColumnSelectionNotification;
APPKIT_EXTERN NSString *MBTableGridDidChangeRowSelectionNotification;
/**
* @brief Posted after one or more columns are moved by user action
* in an MBTableGrid object. The notification object is
* the table grid in which the column(s) moved. The \c userInfo
* dictionary contains the following information:
* - \c @"OldColumns": An NSIndexSet containing the columns'
* original indices.
* - \c @"NewColumns": An NSIndexSet containing the columns'
* new indices.
*/
APPKIT_EXTERN NSString *MBTableGridDidMoveColumnsNotification;
/**
* @brief Posted after one or more rows are moved by user action
* in an MBTableGrid object. The notification object is
* the table grid in which the row(s) moved. The userInfo
* dictionary contains the following information:
* - \c @"OldRows": An NSIndexSet containing the rows'
* original indices.
* - \c @"NewRows": An NSIndexSet containing the rows'
* new indices.
*/
APPKIT_EXTERN NSString *MBTableGridDidMoveRowsNotification;
APPKIT_EXTERN NSString *MBTableGridDidResizeColumnNotification;
APPKIT_EXTERN NSString *MBTableGridColumnDataType;
APPKIT_EXTERN NSString *MBTableGridRowDataType;
/**
* @brief Just a little bit of padding to make resizing the last column easier.
*/
APPKIT_EXTERN CGFloat MBTableGridContentViewPadding;
typedef NS_ENUM(NSInteger, MBTableGridEdge) {
MBTableGridLeftEdge = 0,
MBTableGridRightEdge = 1,
MBTableGridTopEdge = 3,
MBTableGridBottomEdge = 4
};
typedef NS_ENUM(NSUInteger, MBHorizontalEdge) {
MBHorizontalEdgeLeft,
MBHorizontalEdgeRight
};
typedef NS_ENUM(NSUInteger, MBVerticalEdge) {
MBVerticalEdgeTop,
MBVerticalEdgeBottom
};
/**
* @brief MBTableGrid (sometimes referred to as a table grid)
* is a means of displaying tabular data in a spreadsheet
* format.
*
* @details An MBTableGrid object must have an object that acts
* as a data source and may optionally have an object which
* acts as a delegate. The data source must adopt the
* MBTableGridDataSource protocol, and the delegate must
* adopt the MBTableGridDelegate protocol. The data source
* provides information that MBTableGrid needs to construct
* the table grid and facillitates the insertion, deletion, and
* reordering of data within it. The delegate optionally provides
* formatting and validation information. For more information
* on these, see the MBTableGridDataSource and MBTableGridDelegate
* protocols.
*
* MBTableGrid and its methods actually encompass
* several subviews, including MBTableGridContentView
* (which handles the display, selection, and editing of
* cells) and MBTableGridHeaderView (which handles
* the display, selection, and dragging of column and
* row headers). In general, however, it is not necessary
* to interact with these views directly.
*
* @author Matthew Ball
*/
@interface MBTableGrid : NSControl <NSDraggingSource, NSDraggingDestination> {
/* Headers */
MBTableGridHeaderCell *headerCell;
/* Headers */
NSScrollView *columnHeaderScrollView;
MBTableGridHeaderView *columnHeaderView;
MBTableGridHeaderView *frozenColumnHeaderView;
NSScrollView *rowHeaderScrollView;
MBTableGridHeaderView *rowHeaderView;
/* Shadows */
MBTableGridShadowView *columnShadowView;
MBTableGridShadowView *rowShadowView;
/* Footer */
NSScrollView *columnFooterScrollView;
MBTableGridFooterView *columnFooterView;
MBTableGridFooterView *frozenColumnFooterView;
/* Content */
NSScrollView *contentScrollView;
MBTableGridContentView *contentView;
/* Frozen Content */
NSScrollView *frozenContentScrollView;
MBTableGridContentView *frozenContentView;
/* Behavior */
BOOL shouldOverrideModifiers;
/* Sticky Edges (for Shift+Arrow expansions) */
MBTableGridEdge stickyColumnEdge;
MBTableGridEdge stickyRowEdge;
NSMutableDictionary *columnWidths;
NSMutableArray *columnIndexNames;
NSUInteger firstSelectedRow;
}
#pragma mark -
#pragma mark Reloading the Grid
/**
* @name Reloading the Grid
*/
/**
* @{
*/
/**
* @brief Marks the receiver as needing redisplay, so
* it will reload the data for visible cells and
* draw the new values.
*
* @details This method forces redraw of all the visible
* cells in the receiver. If you want to update
* the value in a single cell, column, or row,
* it is more efficient to use \c frameOfCellAtColumn:row:,
* \c rectOfColumn:, or \c rectOfRow: in conjunction with
* \c setNeedsDisplayInRect:.
*
* @see frameOfCellAtColumn:row:
* @see rectOfColumn:
* @see rectOfRow:
*/
- (void)reloadData;
#pragma mark -
#pragma mark Selecting Rows and Columns
/**
* @brief Scrolls the grid to the specified row
*
* @param rowIndex The row to scroll to
* @param shouldAnimate Whether the grid should animate the scrolling to the row.
*
*/
- (void)scrollToRow:(NSUInteger)rowIndex animate:(BOOL)shouldAnimate;
/**
* @brief Selects the specified rows
*
* @param rowIndexes The rows to select
*
*/
- (void)selectRowIndexes:(NSIndexSet *)rowIndexes;
/**
* @brief Selects the specified row
*
* @param rowIndex The row to select
*
*/
- (void)selectRow:(NSUInteger)rowIndex;
/**
* @brief Selects the specified row and column
*
* @param rowIndex The row to select
* @param columnIndex The column to select
*
*/
- (void)selectRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex;
/**
* @brief Double-clicks the specified row or column
*
* @param rowIndex The row to select
* @param columnIndex The column to select
*
*/
- (void)doubleClickRow:(NSUInteger)rowIndex;
- (void)doubleClickColumn:(NSUInteger)columnIndex;
/**
* @brief Moves the selection down one row
*
*/
- (void)moveDown:(id)sender;
/**
* @brief Moves the selection up one row
*
*/
- (void)moveUp:(id)sender;
/**
* @brief Initiates the fill down operation
*
*/
- (void)fillDown:(id)sender;
/**
* @brief Initiates the fill up operation
*
*/
- (void)fillUp:(id)sender;
/**
* @}
*/
#pragma mark -
#pragma mark Resize column
/**
* @name Resize column
*/
/**
* @{
*/
/**
* @brief Live resizes column
*
* @details This method resizes the column and updates the views
*
* @return The amount that the distance is beyond the minimum size
*
*/
- (CGFloat)resizeColumnWithIndex:(NSUInteger)columnIndex withDistance:(float)distance location:(NSPoint)location;
/**
* @brief Cache of column rects
*
* @return A mutable dictionary containing the records for all the rows keyed by column index number
*
*/
@property (nonatomic, strong) NSMutableDictionary *columnRects;
/**
* @}
*/
#pragma mark -
#pragma mark Selecting Columns and Rows
/**
* @name Selecting Columns and Rows
*/
/**
* @{
*/
/**
* @brief Returns an index set containing the indexes of
* the selected columns.
*
* @return An index set containing the indexes of the
* selected columns.
*
* @see selectedRowIndexes
* @see selectCellsInColumns:rows:
*/
@property(nonatomic, strong) NSIndexSet *selectedColumnIndexes;
/**
* @brief Returns an index set containing the indexes of
* the selected rows.
*
* @return An index set containing the indexes of the
* selected rows.
*
* @see selectedColumnIndexes
* @see selectCellsInColumns:rows:
*/
@property(nonatomic, strong) NSMutableIndexSet *selectedRowIndexes;
/**
* @}
*/
#pragma mark -
#pragma mark Dimensions
/**
* @name Dimensions
*/
/**
* @{
*/
/**
* @brief Returns the number of rows in the receiver.
*
* @return The number of rows in the receiver.
*
* @see numberOfColumns
*/
@property (nonatomic, assign) NSUInteger numberOfRows;
/**
* @brief Returns the number of columns in the receiver.
*
* @return The number of rows in the receiver.
*
* @see numberOfRows
*/
@property (nonatomic, assign) NSUInteger numberOfColumns;
#pragma mar -
#pragma mark Sort Indicators
/**
* @brief Sets the indicator image for the specified column.
* This is used for indicating which direction the
* column is being sorted by.
*
* @param anImage The sort indicator image.
* @param reverseImage The reversed sort indicator image.
* @param inColumns Array of columns.
*
* @return The header value for the row.
*/
- (void)setSortAscendingImage:(NSImage *)ascendingImage sortDescendingImage:(NSImage*)descendingImage sortUndeterminedImage:(NSImage *)undeterminedImage;
/**
* @brief Returns the sort indicator image
* for the specified column.
*
* @param columnIndex The index of the column.
*
* @return The sort indicator image for the column.
*/
- (NSImage *)indicatorImageInColumn:(NSUInteger)columnIndex;
/**
* @}
*/
#pragma mark -
#pragma mark Configuring Behavior
/**
* @name Configuring Behavior
*/
/**
* @{
*/
/**
* @brief Indicates whether the receiver allows
* the user to select more than one cell at
* a time.
*
* @details The default is \c YES. You can select multiple
* cells programmatically regardless of this setting.
*
* @return \c YES if the receiver allows the user
* to select more than one cell at a time.
* Otherwise, \c NO.
*/
@property(assign) BOOL allowsMultipleSelection;
/**
* @brief Indicates whether the receiver is enabled
*
* @details The default is \c YES.
*
* @return \c YES if the receiver allows the user
* to select any rows.
* Otherwise, \c NO.
*/
@property(assign, nonatomic) BOOL isEditable;
/**
* @brief Sets the default font to use for content cells
*
*/
@property(nonatomic, strong) NSFont *defaultCellFont;
/**
* @brief The autosave name for this grid
*/
@property (nonatomic) NSString *autosaveName;
- (void)copy:(id)sender;
/**
* @brief Indicates whether the footer is hidden or visible
*
* @details The default is \c YES.
*
* @return \c YES if the footer is hidden.
*/
@property (nonatomic) BOOL footerHidden;
/**
* @brief Returns the number of frozen columns in the receiver.
*
* @return The number of frozen columns in the receiver.
*
* @see freezeColumns
*/
@property (nonatomic) NSUInteger numberOfFrozenColumns;
/**
* @brief Returns whether or not some columns are frozen.
*
* @return Whether or not some columns are frozen.
*
* @see numberOfFrozenColumns
*/
@property (nonatomic) BOOL freezeColumns;
/**
* @brief Whether or not summary rows should be displayed for groups, providing subtotals of the groups.
*
* @return Whether or not summary rows should be displayed for groups.
*/
@property (nonatomic) BOOL includeGroupSummaryRows;
/**
* @brief Whether or not ONLY summary rows should be displayed for groups, providing subtotals of the groups.
*
* @return Whether or not summary rows should be displayed for groups.
*/
@property (nonatomic) BOOL includeOnlyGroupSummaryRows;
/**
* @}
*/
#pragma mark -
#pragma mark Managing the Delegate and the Data Source
/**
* @name Managing the Delegate and the Data Source
*/
/**
* @{
*/
/**
* @brief The object that provides the data displayed by
* the grid.
*
* @details The data source must adopt the \c MBTableGridDataSource
* protocol. The data source is not retained.
*
* @see delegate
*/
@property(nonatomic, weak) IBOutlet id <MBTableGridDataSource> dataSource;
/**
* @brief The object that acts as the delegate of the
* receiving table grid.
*
* @details The delegate must adopt the \c MBTableGridDelegate
* protocol. The delegate is not retained.
*
* @see dataSource
*/
@property(nonatomic, weak) IBOutlet id <MBTableGridDelegate> delegate;
/**
* @}
*/
#pragma mark -
#pragma mark Layout Support
/**
* @name Layout Support
*/
/**
* @{
*/
/**
* @brief Returns the rectangle containing the column at
* a given index.
*
* @param columnIndex The index of a column in the receiver.
*
* @return The rectangle containing the column at \c columnIndex.
* Returns \c NSZeroRect if \c columnIndex lies outside
* the range of valid column indices for the receiver.
*
* @see frameOfCellAtColumn:row:
* @see rectOfRow:
* @see headerRectOfColumn:
*/
- (NSRect)rectOfColumn:(NSUInteger)columnIndex;
/**
* @brief Returns the rectangle containing the row at a
* given index.
*
* @param rowIndex The index of a row in the receiver.
*
* @return The rectangle containing the row at \c rowIndex.
* Returns \c NSZeroRect if \c rowIndex lies outside
* the range of valid column indices for the receiver.
*
* @see frameOfCellAtColumn:row:
* @see rectOfColumn:
* @see headerRectOfRow:
*/
- (NSRect)rectOfRow:(NSUInteger)rowIndex;
/**
* @brief Returns a rectangle locating the cell that lies at
* the intersection of \c columnIndex and \c rowIndex.
*
* @param columnIndex The index of the column containing the cell
* whose rectangle you want.
* @param rowIndex The index of the row containing the cell
* whose rectangle you want.
*
* @return A rectangle locating the cell that lies at the intersection
* of \c columnIndex and \c rowIndex. Returns \c NSZeroRect if
* \c columnIndex or \c rowIndex is greater than the number of
* columns or rows in the receiver.
*
* @see rectOfColumn:
* @see rectOfRow:
* @see headerRectOfColumn:
* @see headerRectOfRow:
*/
- (NSRect)frameOfCellAtColumn:(NSUInteger)columnIndex row:(NSUInteger)rowIndex;
/**
* @brief Returns the rectangle containing the header tile for
* the column at \c columnIndex.
*
* @param columnIndex The index of the column containing the
* header whose rectangle you want.
*
* @return A rectangle locating the header for the column at
* \c columnIndex. Returns \c NSZeroRect if \c columnIndex
* lies outside the range of valid column indices for the
* receiver.
*
* @see headerRectOfRow:
* @see headerRectOfCorner
*/
- (NSRect)headerRectOfColumn:(NSUInteger)columnIndex;
/**
* @brief Returns the rectangle containing the header tile for
* the row at \c rowIndex.
*
* @param rowIndex The index of the row containing the
* header whose rectangle you want.
*
* @return A rectangle locating the header for the row at
* \c rowIndex. Returns \c NSZeroRect if \c rowIndex
* lies outside the range of valid column indices for the
* receiver.
*
* @see headerRectOfColumn:
* @see headerRectOfCorner
*/
- (NSRect)headerRectOfRow:(NSUInteger)rowIndex;
/**
* @brief Returns the rectangle containing the corner which
* divides the row headers from the column headers.
*
* @return A rectangle locating the corner separating rows
* from columns.
*
* @see headerRectOfColumn:
* @see headerRectOfRow:
*/
- (NSRect)headerRectOfCorner;
/**
* @brief Returns the index of the column a given point lies in.
*
* @param aPoint A point in the coordinate system of the receiver.
*
* @return The index of the column \c aPoint lies in, or \c NSNotFound if \c aPoint
* lies outside the receiver's bounds.
*
* @see rowAtPoint:
*/
- (NSInteger)columnAtPoint:(NSPoint)aPoint;
/**
* @brief Returns the index of the row a given point lies in.
*
* @param aPoint A point in the coordinate system of the receiver.
*
* @return The index of the row \c aPoint lies in, or \c NSNotFound if \c aPoint
* lies outside the receiver's bounds.
*
* @see columnAtPoint:
*/
- (NSInteger)rowAtPoint:(NSPoint)aPoint;
/**
* @brief Returns the index of the group heading row for a given row.
*
* @param rowIndex The index of a row.
*
* @return The index of the group heading that contains the row, or \c NSNotFound if there are no group headings before this row.
*/
- (NSInteger)groupHeadingRowForRow:(NSInteger)rowIndex;
/**
* @}
*/
#pragma mark -
#pragma mark Auxiliary Views
/**
* @name Auxiliary Views
*/
/**
* @{
*/
/**
* @brief Returns the \c MBTableGridHeaderView object used
* to draw headers over columns.
*
* @return The \c MBTableGridHeaderView object used to draw
* column headers.
*
* @see rowHeaderView
*/
- (MBTableGridHeaderView *)columnHeaderView;
/**
* @brief Returns the \c MBTableGridHeaderView object used
* to draw headers over frozen columns.
*
* @return The \c MBTableGridHeaderView object used to draw
* frozen column headers.
*
* @see rowHeaderView
*/
- (MBTableGridHeaderView *)frozenColumnHeaderView;
/**
* @brief Returns the \c MBTableGridFooterView object used
* to draw footers below frozen columns.
*
* @return The \c MBTableGridFooterView object used to draw
* frozen column footers.
*
* @see frozenColumnHeaderView
*/
- (MBTableGridFooterView *)frozenColumnFooterView;
/**
* @brief Returns the \c MBTableGridHeaderView object used
* to draw headers beside rows.
*
* @return The \c MBTableGridHeaderView object used to draw
* column headers.
*
* @see columnHeaderView
*/
- (MBTableGridHeaderView *)rowHeaderView;
/**
* @brief Returns the \c MBTableGridShadowView object used
* to draw a shadow next to the column header or frozen columns.
*
* @return The \c MBTableGridShadowView object used to draw
* a shadow.
*
* @see rowShadowView
*/
- (MBTableGridShadowView *)columnShadowView;
/**
* @brief Returns the \c MBTableGridShadowView object used
* to draw a shadow below the row header.
*
* @return The \c MBTableGridShadowView object used to draw
* a shadow.
*
* @see columnShadowView
*/
- (MBTableGridShadowView *)rowShadowView;
/**
* @brief Returns the receiver's content view.
*
* @details An \c MBTableGrid object uses its content view to
* draw the individual cells. It is enclosed in a
* scroll view to allow for scrolling.
*
* @return The receiver's content view.
*/
- (MBTableGridContentView *)contentView;
/**
* @brief Returns the receiver's frozen content view.
*
* @details An \c MBTableGrid object uses its content view to
* draw the individual cells. It is enclosed in a
* scroll view to allow for scrolling. This one
* is used for any frozen columns.
*
* @return The receiver's frozen content view.
*/
- (MBTableGridContentView *)frozenContentView;
/**
* @brief Returns whether or not a column is frozen.
*
* @details A column is frozen if frozen columns are enabled via
* the freezeColumns property, and the column is within
* the numberOfFrozenColumns.
*
* @return YES if the column is frozen, NO if not.
*/
- (BOOL)isFrozenColumn:(NSUInteger)column;
/**
* @brief Scrolls between frozen and unfrozen columns, if needed.
*
* @details If moving between a frozen column and an unfrozen one,
* this will scroll to reveal the adjacent column, as needed.
*
* @return YES if scrolling was appropriate.
*/
- (BOOL)scrollForFrozenColumnsFromColumn:(NSUInteger)fromColumn right:(BOOL)right;
/**
* @}
*/
@end
#pragma mark -
@protocol MBTableGridPopupMenu <NSObject>
- (void)cellPopupMenuItemSelected:(NSMenuItem *)menuItem;
@end
#pragma mark -
/**
* @brief The \c MBTableGridDataSource protocol is adopted
* by an object that mediates the data model for an
* \c MBTableGrid object.
*
* @details As a representative of the data model, the data
* source supplies no information about the grid's
* appearance or behavior. Rather, the grid's
* delegate (adopting the \c MBTableGridDelegate
* protocol) can provide that information.
*/
@protocol MBTableGridDataSource <NSObject>
@required
#pragma mark -
#pragma mark Dimensions
/**
* @name Dimensions
*/
/**
* @{
*/
@required
/**
* @brief Returns the number of rows managed for \c aTableGrid
* by the data source object.
*
* @param aTableGrid The table grid that sent the message.
*
* @return The number of rows in \c aTableGrid.
*
* @see numberOfColumnsInTableGrid:
*/
- (NSUInteger)numberOfRowsInTableGrid:(MBTableGrid *)aTableGrid;
/**
* @brief Returns the number of rows managed for \c aTableGrid
* by the data source object.
*
* @param aTableGrid The table grid that sent the message.
*
* @return The number of rows in \c aTableGrid.
*
* @see numberOfRowsInTableGrid:
*/
- (NSUInteger)numberOfColumnsInTableGrid:(MBTableGrid *)aTableGrid;
/**
* @}
*/
/**
* @name Accessing Cell Values
*/
/**
* @{
*/
@required
/**
* @brief Returns the data object associated with the specified column and row.
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
* @param rowIndex A row in \c aTableGrid.
*
* @return The object for the specified cell of the view.
*
* @see tableGrid:setObjectValue:forColumn:row:
*/
- (id)tableGrid:(MBTableGrid *)aTableGrid objectValueForColumn:(NSUInteger)columnIndex row:(NSUInteger)rowIndex;
@optional
/**
* @brief Returns the formatter associated with the specified column.
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
*
* @return The formatter for the specified column to use when displaying cell values
*/
- (NSFormatter *)tableGrid:(MBTableGrid *)aTableGrid formatterForColumn:(NSUInteger)columnIndex;
@optional
/**
* @brief Returns the cell associated with the specified column.
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
*
* @return The cell for the specified column
*/
- (NSCell *)tableGrid:(MBTableGrid *)aTableGrid cellForColumn:(NSUInteger)columnIndex;
@optional
/**
* @brief Returns the cell's accessory button with the specified column and row
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
* @
*
* @return The cell for the specified column
*/
- (NSImage *)tableGrid:(MBTableGrid *)aTableGrid accessoryButtonImageForColumn:(NSUInteger)columnIndex row:(NSUInteger)row;
@optional
/**
* @brief
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
*
* @return An array of possible object values to represent in a popup button for a given column. Return nil if the cells in the column should not be edited with a popup button of available values, but should instead allow freeform string input. The count of the returned array should match that returned in tableGrid:availableUserStringsForColumn:.
*/
- (NSArray *)tableGrid:(MBTableGrid *)aTableGrid availableObjectValuesForColumn:(NSUInteger)columnIndex;
@optional
/**
* @brief Offer auto-completion strings based on the user input.
*
* @param aTableGrid The table grid that sent the message.
* @param value The text the user entered in the cell editor.
* @param columnIndex A column in \c aTableGrid.
* @param rowIndex A row in \c aTableGrid.
*
* @return An array of strings to offer as auto-completion matches for the user-entered text for a given column and row. The returned strings should generally be based on the other values in the column that have the same prefix as the given text. Return nil or an empty array if no auto-completion strings should be offered.
*/
- (NSArray *)tableGrid:(MBTableGrid *)aTableGrid autocompleteValuesForEditString:(NSString *)editString column:(NSUInteger)columnIndex row:(NSUInteger)rowIndex;
@optional
/**
* @brief Returns the background color for the specified column and row.
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
* @param rowIndex A row in \c aTableGrid.
*
* @return The background color for the specified cell of the view.
*/
- (NSColor *)tableGrid:(MBTableGrid *)aTableGrid backgroundColorForColumn:(NSUInteger)columnIndex row:(NSUInteger)rowIndex;
/**
* @brief Returns the frozen background color for the specified column and row.
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
* @param rowIndex A row in \c aTableGrid.
*
* @return The frozen background color for the specified cell of the view.
*/
- (NSColor *)tableGrid:(MBTableGrid *)aTableGrid frozenBackgroundColorForColumn:(NSUInteger)columnIndex row:(NSUInteger)rowIndex;
/**
* @brief Returns the group summary background color for the specified column and row.
*
* @param aTableGrid The table grid that sent the message.
* @param columnIndex A column in \c aTableGrid.
* @param rowIndex A row in \c aTableGrid.
*
* @return The group summary background color for the specified cell of the view.
*/
- (NSColor *)tableGrid:(MBTableGrid *)aTableGrid groupSummaryBackgroundColorForColumn:(NSUInteger)columnIndex row:(NSUInteger)rowIndex;
@optional
/**