Class: RubyMVC::Toolkit::WxRuby::GridModel
- Inherits:
-
Wx::GridTableBase
- Object
- Wx::GridTableBase
- RubyMVC::Toolkit::WxRuby::GridModel
- Defined in:
- lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb
Overview
This class provides an adapter between a RubyMVC::Models::TableModel instance and the Wx::GridTableBase API so that we can drive Wx::Grid instances using our model definitions.
Instance Method Summary collapse
- #get_attr(row, col, kind) ⇒ Object
- #get_col_label_value(col) ⇒ Object
- #get_key(col) ⇒ Object
- #get_number_cols ⇒ Object
- #get_number_rows ⇒ Object
- #get_row_label_value(row) ⇒ Object
- #get_value(row, col) ⇒ Object
-
#initialize(model) ⇒ GridModel
constructor
A new instance of GridModel.
- #is_empty_cell(row, col) ⇒ Object
Constructor Details
#initialize(model) ⇒ GridModel
Returns a new instance of GridModel.
36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 36 def initialize(model) super() @model = model @labels = model.labels @cols = {} @labels.each_with_index do |l, i| @cols[i] = l[:key] end end |
Instance Method Details
#get_attr(row, col, kind) ⇒ Object
62 63 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 62 def get_attr(row, col, kind) end |
#get_col_label_value(col) ⇒ Object
69 70 71 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 69 def get_col_label_value(col) @labels[col][:label] end |
#get_key(col) ⇒ Object
73 74 75 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 73 def get_key(col) @cols[col] end |
#get_number_cols ⇒ Object
46 47 48 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 46 def get_number_cols @model.labels.size end |
#get_number_rows ⇒ Object
50 51 52 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 50 def get_number_rows @model.size end |
#get_row_label_value(row) ⇒ Object
65 66 67 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 65 def get_row_label_value(row) (row + 1).to_s end |
#get_value(row, col) ⇒ Object
54 55 56 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 54 def get_value(row, col) @model.value_for(row, get_key(col)).to_s end |
#is_empty_cell(row, col) ⇒ Object
58 59 60 |
# File 'lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb', line 58 def is_empty_cell(row, col) get_value(row, col).nil? end |