Class: Interphase::Box

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

Overview

A simple item container. You should use VBox or HBox rather than this.

Direct Known Subclasses

HBox, VBox

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, #initialize, #method_missing, #on, #respond_to_missing?, #show, #size

Constructor Details

This class inherits a constructor from Interphase::Widget

Dynamic Method Handling

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

Instance Method Details

#add(child, expand = true, fill = true, padding = 0, ref = :start, &block) ⇒ Object

Add a widget to the box, after all others added at the same reference. Accepts a block which is executed on the child.

child

The new child widget.

expand

(Optional) Allocate extra space to this widget, default true.

fill

(Optional) Allocate to the full width/height of the box, default true.

padding

(Optional) Any padding to allocate to this widget, default 0.

ref

(Optional) The reference at which to add the widget. Either :start (default) or :end.


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/interphase/widgets/box.rb', line 17

def add(child,
        expand = true,
        fill = true,
        padding = 0,
        ref = :start,
        &block)
  super(child, false, &block)

  if ref == :start
    gtk_instance.pack_start(child.gtk_instance, expand, fill, padding)
  elsif ref == :end
    gtk_instance.pack_end(child.gtk_instance, expand, fill, padding)
  else
    raise 'ref should be either PACK_START or PACK_END'
  end
end