Class: Interphase::Grid

Inherits:
Container show all
Defined in:
lib/interphase/widgets/grid.rb

Overview

A grid which contains rows and columns containing other widgets. Note that grid cells will be as large as they can be; if you create a 4x4 grid but only insert one item into it, then that item will fill the entire grid's allocated space.

Direct Known Subclasses

Layout

Instance Attribute Summary

Attributes inherited from Container

#children

Attributes inherited from Widget

#gtk_instance, #name, #parent

Instance Method Summary collapse

Methods inherited from Container

#method_missing, #respond_to_missing?, #show_all

Methods inherited from Widget

#destroy, #method_missing, #on, #respond_to_missing?, #show, #size

Constructor Details

#initialize(rows, columns, **options, &block) ⇒ Grid

Create a new grid.


12
13
14
# File 'lib/interphase/widgets/grid.rb', line 12

def initialize(rows, columns, **options, &block)
  super(Gtk::Table.new(rows, columns), **options, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Interphase::Container

Instance Method Details

#add(child, left, right, top, bottom, &block) ⇒ Object

Add a child to the grid.

child

The new child widget.

left

The column number to attach the left side of the widget to.

right

The column number to attach the right side of the widget to.

top

The row number to attach the top of the widget to.

bottom

The row number to attach the bottom of the widget to.


22
23
24
25
26
# File 'lib/interphase/widgets/grid.rb', line 22

def add(child, left, right, top, bottom, &block)
  super(child, false, &block)

  gtk_instance.attach(child.gtk_instance, left, right, top, bottom)
end

#columnsObject

Retrieve the number of columns this grid has.


29
30
31
# File 'lib/interphase/widgets/grid.rb', line 29

def columns
  gtk_instance.columns
end

#rowsObject

Retrieve the number of rows this grid has.


34
35
36
# File 'lib/interphase/widgets/grid.rb', line 34

def rows
  gtk_instance.rows
end