1 // 2 // SubviewTableViewController.h 3 // SubviewTableViewRuleEditor 4 // 5 // Created by Joar Wingfors on Sat Feb 15 2003. 6 // Copyright (c) 2003 joar.com. All rights reserved. 7 // 8 9 /***************************************************************************** 10 11 SubviewTableViewController 12 13 Files: 14 15 * SubviewTableViewController.h 16 * SubviewTableViewCell.h 17 18 Overview: 19 20 The SubviewTableViewController (STVC) is used to create a table view like the 21 one used in the rules preference pane in Mail, or the new find panel in Finder. 22 It allows you to provide views that will be displayed instead of (really: on 23 top of) the usual cells in the table view. 24 25 Usage guidelines: 26 27 The table view used to hold the contents is a standard NSTableView. The table 28 view needs to have a table column dedicated for the subviews. The table view 29 also preferably needs to have a row height matching the height of the subviews. 30 The owner of the table view should instantiate a STVC using the convenience 31 method, and providing this column: 32 33 - (void) awakeFromNib 34 { 35 tableViewController = 36 [[SubviewTableViewController controllerWithViewColumn: subviewTableColumn] 37 retain]; 38 [tableViewController setDelegate: self]; 39 } 40 41 The STVC will make itself the delegate and data source of the table view, 42 and will forward all data source and delegate methods to the original owner. 43 44 NOTE! In order for the STVC to know when the contents of the table view has 45 changed a public method is provided to trigger the reload of the table view 46 via the controller. You NEED to use this method in any case where you would 47 have otherwise used "reloadData" from NSTableView: 48 49 [tableViewController reloadTableView]; 50 51 *****************************************************************************/ 52 53 #import <AppKit/AppKit.h> 54 55 @interface SubviewTableViewController : NSObject 56 { 57 @private 58 59 NSTableView *subviewTableView; 60 NSTableColumn *subviewTableColumn; 61 62 id delegate; 63 } 64 65 // Convenience factory method 66 + (id) controllerWithViewColumn:(NSTableColumn *) vCol; 67 68 // The delegate is required to conform to the SubviewTableViewControllerDataSourceProtocol 69 - (void) setDelegate:(id) obj; 70 - (id) delegate; 71 72 // The method to call instead of the standard "reloadData" method of NSTableView. 73 // You need to call this method at any time that you would have called reloadData 74 // on a table view. 75 - (void) reloadTableView; 76 77 @end 78 79 @protocol SubviewTableViewControllerDataSourceProtocol 80 81 // The view retreived will not be retained, and will be resized to fit the 82 // cell in the table view. Please adjust the row height and column width in 83 // ib (or in code) to make sure that it is appropriate for the views used. 84 - (NSView *) tableView:(NSTableView *) tableView viewForRow:(int) row; 85 86 @end 87