Class: ListSum
- Inherits:
-
Gtk::HBox
- Object
- Gtk::HBox
- ListSum
- Defined in:
- lib/ListHolder/ListPanel/ListSum.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#list_holder ⇒ Object
Returns the value of attribute list_holder.
-
#renderers ⇒ Object
Returns the value of attribute renderers.
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(list_holder) ⇒ ListSum
constructor
A new instance of ListSum.
- #inspect ⇒ Object
- #set_visible(visible) ⇒ Object
- #to_s ⇒ Object
- #update(notifier) ⇒ Object
- #zero ⇒ Object
Constructor Details
#initialize(list_holder) ⇒ ListSum
Returns a new instance of ListSum.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 6 def initialize(list_holder) @list_holder=list_holder super() @columns=Hash.new @renderers=Hash.new @values=Hash.new set_no_show_all(true) set_border_width(0) set_resize_mode(Gtk::ResizeMode::PARENT) signal_connect('destroy'){|me| renderers.each_value{|r| r.destroy if r} } end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
20 21 22 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 20 def columns @columns end |
#list_holder ⇒ Object
Returns the value of attribute list_holder.
19 20 21 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 19 def list_holder @list_holder end |
#renderers ⇒ Object
Returns the value of attribute renderers.
21 22 23 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 21 def renderers @renderers end |
Instance Method Details
#calculate ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 55 def calculate zero if list_holder.list.model list_holder.list.model.each{|model,path,iter| @columns.each_pair{|col_data,col| @values[col_data]+=iter[col.header["model_col"]].to_f} } end columns.each_key{|col_data| renderers[col_data].update(@values[col_data])} end |
#inspect ⇒ Object
65 66 67 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 65 def inspect "ListSum of #{list_holder.list}" end |
#set_visible(visible) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 39 def set_visible(visible) each{|child| if visible child.show else child.hide end # p child.inspect + child.visible?.to_s } super end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 68 def to_s inspect end |
#update(notifier) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 23 def update(notifier) @renderers.each_value{|renderer| renderer.destroy} @columns.clear @renderers.clear @values.clear list_holder.list.columns.each {|column| renderers[column.data]=SumRendererText.new(column) pack_start(renderers[column.data]) if column.summable? @values[column.data]=0.0 @columns[column.data]=column end } return self end |
#zero ⇒ Object
51 52 53 |
# File 'lib/ListHolder/ListPanel/ListSum.rb', line 51 def zero @values.each_key{|key| @values[key]=0.0} end |