Class: JLDrill::Gtk::StatisticsTable
- Inherits:
-
Gtk::Table
- Object
- Gtk::Table
- JLDrill::Gtk::StatisticsTable
- Defined in:
- lib/jldrill/views/gtk/widgets/StatisticsWindow.rb
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #addEntries(rows, columns) ⇒ Object
- #addValue(value, row, column) ⇒ Object
- #column(colNum, text) ⇒ Object
-
#initialize(rows, columns) ⇒ StatisticsTable
constructor
A new instance of StatisticsTable.
- #makeValues(height, width) ⇒ Object
- #row(rowNum, text) ⇒ Object
Constructor Details
#initialize(rows, columns) ⇒ StatisticsTable
Returns a new instance of StatisticsTable.
11 12 13 14 |
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 11 def initialize(rows, columns) super(rows.size + 1, columns.size + 1, false) @values = addEntries(rows, columns) end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
9 10 11 |
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 9 def values @values end |
Instance Method Details
#addEntries(rows, columns) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 16 def addEntries(rows, columns) values = makeValues(rows.size, columns.size) columns.each_index do |i| column(i + 1, columns[i]) end rows.each_index do |i| row(i + 1, rows[i]) 0.upto(columns.size - 1) do |j| addValue(values[i][j], i + 1, j + 1) end end values end |
#addValue(value, row, column) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 64 def addValue(value, row, column) # Add 1 to row to make up for the headers attach(value, # X direction # Y direction column + 1, column + 2, row + 1, row + 2, Gtk::EXPAND | Gtk::FILL, 0, 0, 0) end |
#column(colNum, text) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 53 def column(colNum, text) label = Gtk::Label.new(text) # Add 1 to row to make up for the headers attach(label, # X direction # Y direction colNum + 1, colNum + 2, 0, 1, Gtk::EXPAND | Gtk::FILL, 0, 0, 0) end |
#makeValues(height, width) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 30 def makeValues(height, width) retVal = [] 0.upto(height - 1) do retVal.push([]) end 0.upto(height - 1) do |i| 0.upto(width - 1) do |j| retVal[i][j] = Gtk::Label.new("0") end end retVal end |
#row(rowNum, text) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/jldrill/views/gtk/widgets/StatisticsWindow.rb', line 43 def row(rowNum, text) label = Gtk::Label.new(text) # Add 1 to row to make up for the headers attach(label, # X direction # Y direction 0, 1, rowNum + 1, rowNum + 2, Gtk::EXPAND | Gtk::FILL, 0, 0, 0) end |