Class: Glimmer::LibUI::ControlProxy::TableProxy
- Inherits:
-
Glimmer::LibUI::ControlProxy
- Object
- Glimmer::LibUI::ControlProxy
- Glimmer::LibUI::ControlProxy::TableProxy
- Includes:
- FiddleConsumer
- Defined in:
- lib/glimmer/libui/control_proxy/table_proxy.rb
Overview
Proxy for LibUI table objects
Follows the Proxy Design Pattern
Constant Summary
Constants inherited from Glimmer::LibUI::ControlProxy
BOOLEAN_PROPERTIES, STRING_PROPERTIES, TransformProxy
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 Glimmer::LibUI::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 Glimmer::LibUI::ControlProxy
#append_properties, #append_property, #can_handle_listener?, constant_symbol, #content, control_proxies, create, #custom_listener_aliases, #custom_listeners, #default_destroy, descendant_keyword_constant_map, #destroy_child, #enabled, exists?, #handle_custom_listener, #handle_listener, #has_custom_listener?, image_proxies, keyword, #libui_api_keyword, main_window_proxy, map_descendant_keyword_constants_for, menu_proxies, #method_missing, new_control, reset_descendant_keyword_constant_map, #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.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 40 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?(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.
38 39 40 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 38 def columns @columns end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
38 39 40 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 38 def model @model end |
#model_handler ⇒ Object (readonly)
Returns the value of attribute model_handler.
38 39 40 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 38 def model_handler @model_handler end |
#table_params ⇒ Object (readonly)
Returns the value of attribute table_params.
38 39 40 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 38 def table_params @table_params end |
Instance Method Details
#cell_rows(rows = nil) ⇒ Object Also known as: cell_rows=, set_cell_rows
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 70 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
65 66 67 68 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 65 def destroy super @destroyed = true end |
#editable(value = nil) ⇒ Object Also known as: editable=, set_editable, editable?
105 106 107 108 109 110 111 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 105 def editable(value = nil) if value.nil? @editable else @editable = !!value end end |
#expanded_cell_rows ⇒ Object
99 100 101 102 103 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 99 def cell_rows.map do |row| row.flatten(1) end end |
#post_add_content ⇒ Object
54 55 56 57 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 54 def post_add_content build_control super end |
#post_initialize_child(child) ⇒ Object
59 60 61 62 63 |
# File 'lib/glimmer/libui/control_proxy/table_proxy.rb', line 59 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 |