Class: Glimmer::LibUI::TableProxy
- Inherits:
-
ControlProxy
- Object
- ControlProxy
- Glimmer::LibUI::TableProxy
- Includes:
- FiddleConsumer
- Defined in:
- lib/glimmer/libui/table_proxy.rb
Overview
Proxy for LibUI table objects
Follows the Proxy Design Pattern
Constant Summary
Constants inherited from ControlProxy
ControlProxy::BOOLEAN_PROPERTIES, ControlProxy::STRING_PROPERTIES
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#model_handler ⇒ Object
readonly
Returns the value of attribute model_handler.
-
#table_params ⇒ Object
readonly
Returns the value of attribute table_params.
Attributes inherited from ControlProxy
#args, #block, #keyword, #libui, #parent_proxy
Instance Method Summary collapse
- #cell_rows(rows = nil) ⇒ Object (also: #cell_rows=, #set_cell_rows)
- #destroy ⇒ Object
- #editable(value = nil) ⇒ Object (also: #editable=, #set_editable, #editable?)
- #expanded_cell_rows ⇒ Object
-
#initialize(keyword, parent, args, &block) ⇒ TableProxy
constructor
A new instance of TableProxy.
- #post_add_content ⇒ Object
- #post_initialize_child(child) ⇒ Object
Methods included from FiddleConsumer
Methods inherited from ControlProxy
#append_properties, #append_property, boolean_to_integer, #can_handle_listener?, #content, control_proxies, create, #default_destroy, #destroy_child, #enabled, exists?, #handle_listener, image_proxies, integer_to_boolean, #libui_api_keyword, main_window_proxy, menu_proxies, #method_missing, new_control, #respond_to?, #respond_to_libui?, #send_to_libui, #visible, widget_proxy_class, #window_proxy
Constructor Details
#initialize(keyword, parent, args, &block) ⇒ TableProxy
Returns a new instance of TableProxy.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/glimmer/libui/table_proxy.rb', line 38 def initialize(keyword, parent, args, &block) @keyword = keyword @parent_proxy = parent @args = args @block = block @enabled = true @columns = [] @cell_rows = [] window_proxy.on_destroy do # the following unless condition is an exceptional condition stumbled upon that fails freeing the table model ::LibUI.free_table_model(@model) unless @destroyed && parent_proxy.is_a?(Glimmer::LibUI::Box) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer::LibUI::ControlProxy
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
36 37 38 |
# File 'lib/glimmer/libui/table_proxy.rb', line 36 def columns @columns end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
36 37 38 |
# File 'lib/glimmer/libui/table_proxy.rb', line 36 def model @model end |
#model_handler ⇒ Object (readonly)
Returns the value of attribute model_handler.
36 37 38 |
# File 'lib/glimmer/libui/table_proxy.rb', line 36 def model_handler @model_handler end |
#table_params ⇒ Object (readonly)
Returns the value of attribute table_params.
36 37 38 |
# File 'lib/glimmer/libui/table_proxy.rb', line 36 def table_params @table_params end |
Instance Method Details
#cell_rows(rows = nil) ⇒ Object Also known as: cell_rows=, set_cell_rows
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 |
# File 'lib/glimmer/libui/table_proxy.rb', line 68 def cell_rows(rows = nil) if rows.nil? @cell_rows else @cell_rows = rows @cell_rows.tap do @last_cell_rows = @cell_rows.clone Glimmer::DataBinding::Observer.proc do if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows) @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row| ::LibUI.table_model_row_deleted(model, row) end elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows) @cell_rows.array_diff_indexes(@last_cell_rows).each do |row| ::LibUI.table_model_row_inserted(model, row) end else @cell_rows.each_with_index do |new_row_data, row| ::LibUI.table_model_row_changed(model, row) if new_row_data != @last_cell_rows[row] end end @last_cell_rows = @cell_rows.clone end.observe(self, :cell_rows) end end end |
#destroy ⇒ Object
63 64 65 66 |
# File 'lib/glimmer/libui/table_proxy.rb', line 63 def destroy super @destroyed = true end |
#editable(value = nil) ⇒ Object Also known as: editable=, set_editable, editable?
103 104 105 106 107 108 109 |
# File 'lib/glimmer/libui/table_proxy.rb', line 103 def editable(value = nil) if value.nil? @editable else @editable = !!value end end |
#expanded_cell_rows ⇒ Object
97 98 99 100 101 |
# File 'lib/glimmer/libui/table_proxy.rb', line 97 def cell_rows.map do |row| row.flatten(1) end end |
#post_add_content ⇒ Object
52 53 54 55 |
# File 'lib/glimmer/libui/table_proxy.rb', line 52 def post_add_content build_control super end |
#post_initialize_child(child) ⇒ Object
57 58 59 60 61 |
# File 'lib/glimmer/libui/table_proxy.rb', line 57 def post_initialize_child(child) @columns << child # add an extra complementary nil column if it is a dual column (i.e. ImageTextColumnProxy or CheckboxTextColumnProxy @columns << nil if child.is_a?(DualColumn) end |