table-view.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #if defined(Hiro_TableView)
  2. @class CocoaTableViewContent;
  3. @interface CocoaTableView : NSScrollView <NSTableViewDelegate, NSTableViewDataSource> {
  4. @public
  5. hiro::mTableView* tableView;
  6. CocoaTableViewContent* content;
  7. NSFont* font;
  8. }
  9. -(id) initWith:(hiro::mTableView&)tableViewReference;
  10. -(void) dealloc;
  11. -(CocoaTableViewContent*) content;
  12. -(NSFont*) font;
  13. -(void) setFont:(NSFont*)font;
  14. -(void) reloadColumns;
  15. -(NSInteger) numberOfRowsInTableView:(NSTableView*)table;
  16. -(id) tableView:(NSTableView*)table objectValueForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
  17. -(BOOL) tableView:(NSTableView*)table shouldShowCellExpansionForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
  18. -(NSString*) tableView:(NSTableView*)table toolTipForCell:(NSCell*)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation;
  19. -(void) tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row;
  20. -(void) tableViewSelectionDidChange:(NSNotification*)notification;
  21. -(IBAction) doubleAction:(id)sender;
  22. @end
  23. @interface CocoaTableViewContent : NSTableView {
  24. hiro::mTableView* tableView;
  25. }
  26. -(id) initWith:(hiro::mTableView&)tableViewReference;
  27. -(void) keyDown:(NSEvent*)event;
  28. -(NSMenu*) menuForEvent:(NSEvent*)event;
  29. -(void) reloadData;
  30. @end
  31. @interface CocoaTableViewCell : NSCell {
  32. hiro::mTableView* tableView;
  33. NSButtonCell* buttonCell;
  34. }
  35. -(id) initWith:(hiro::mTableView&)tableViewReference;
  36. -(NSString*) stringValue;
  37. -(void) drawWithFrame:(NSRect)frame inView:(NSView*)view;
  38. -(NSUInteger) hitTestForEvent:(NSEvent*)event inRect:(NSRect)frame ofView:(NSView*)view;
  39. -(BOOL) trackMouse:(NSEvent*)event inRect:(NSRect)frame ofView:(NSView*)view untilMouseUp:(BOOL)flag;
  40. +(BOOL) prefersTrackingUntilMouseUp;
  41. @end
  42. namespace hiro {
  43. struct pTableView : pWidget {
  44. Declare(TableView, Widget)
  45. auto append(sTableViewColumn column) -> void;
  46. auto append(sTableViewItem item) -> void;
  47. auto remove(sTableViewColumn column) -> void;
  48. auto remove(sTableViewItem item) -> void;
  49. auto resizeColumns() -> void;
  50. auto setAlignment(Alignment alignment) -> void;
  51. auto setBackgroundColor(Color color) -> void;
  52. auto setBatchable(bool batchable) -> void;
  53. auto setBordered(bool bordered) -> void;
  54. auto setEnabled(bool enabled) -> void override;
  55. auto setFont(const Font& font) -> void override;
  56. auto setForegroundColor(Color color) -> void;
  57. auto setHeadered(bool headered) -> void;
  58. auto setSortable(bool sortable) -> void;
  59. auto _cellWidth(uint row, uint column) -> uint;
  60. auto _columnWidth(uint column) -> uint;
  61. auto _width(uint column) -> uint;
  62. CocoaTableView* cocoaTableView = nullptr;
  63. };
  64. }
  65. #endif