Class: Opine::Native::Table::OSXTable
- Inherits:
-
Cocoa::NSObject
- Object
- Cocoa::NSObject
- Opine::Native::Table::OSXTable
- Defined in:
- lib/opine/widgets/table_osx.rb
Instance Attribute Summary collapse
-
#hooks ⇒ Object
Returns the value of attribute hooks.
-
#table_view ⇒ Object
Returns the value of attribute table_view.
Instance Method Summary collapse
-
#initialize(parent, resources, options, &block) ⇒ OSXTable
constructor
A new instance of OSXTable.
- #reload ⇒ Object
Constructor Details
#initialize(parent, resources, options, &block) ⇒ OSXTable
Returns a new instance of OSXTable.
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 |
# File 'lib/opine/widgets/table_osx.rb', line 6 def initialize parent,resources,,&block super() @parent = parent @resources = resources @columns = [:columns] || @resources.columns.map{ |col| col.name } @hooks = {} table_container = Cocoa::NSScrollView.alloc.initWithFrame parent.frame.native @table_view = Cocoa::NSTableView.alloc.initWithFrame parent.frame.native columns = @columns.map do |name| col = Cocoa::NSTableColumn.alloc.initWithIdentifier name.to_s col.headerCell.setTitle name.to_s.humanize col.setWidth parent.frame.width / @columns.size table_view.addTableColumn col col end table_view.setDelegate self table_view.setDataSource self table_view.reloadData table_container.setDocumentView table_view table_container.setHasVerticalScroller true if parent.is_a? Opine::Window parent.content_view << table_container end table_container.setAutoresizingMask NSViewWidthSizable | NSViewHeightSizable table_container.release table_view.release columns.each do |col| col.release end end |
Instance Attribute Details
#hooks ⇒ Object
Returns the value of attribute hooks.
5 6 7 |
# File 'lib/opine/widgets/table_osx.rb', line 5 def hooks @hooks end |
#table_view ⇒ Object
Returns the value of attribute table_view.
5 6 7 |
# File 'lib/opine/widgets/table_osx.rb', line 5 def table_view @table_view end |
Instance Method Details
#reload ⇒ Object
45 46 47 48 |
# File 'lib/opine/widgets/table_osx.rb', line 45 def reload @cache = @resources.to_a table_view.reloadData end |