class Rgw::Pile
Public Class Methods
new()
click to toggle source
Initialize a new Rgw::Pile
object
Calls superclass method
# File lib/rgw/pile.rb, line 37 def initialize super(:vertical) @child1 = nil @child2 = nil @x = 0 @y = 0 end
Public Instance Methods
set_child(child)
click to toggle source
Adds the bottom child to the widget.
@param child [Gtk::Widget] The widget to add.
# File lib/rgw/pile.rb, line 48 def set_child child raise RuntimeError, 'Rgw::Pile can only contain one child' unless @child1.nil? @child1 = child self.pack_start @child1, :expand => true, :fill => true @child1.signal_connect_after(:size_allocate) {|widget, allo| on_allocate1 widget, allo} end
set_pile_child(child, x=0, y=0)
click to toggle source
Adds the stacked child to the widget.
@param child [Gtk::Widget] The widget to add. It has to be added after the child. @param x [Integer] Horizontal position of the child. @param y [Integer] Vertical position of the child.
Both positions are in pixels. If the value is positive it goes from the left respective top border of the container, if it is negative it goes from the right respective bottom border.
# File lib/rgw/pile.rb, line 63 def set_pile_child child, x=0, y=0 raise RuntimeError, 'child has to be set before pile_child' if @child1.nil? raise RuntimeError, 'Rgw::Pile can only contain one pile_child' unless @child2.nil? raise ArgumentError, "unsuported class %s, expect Gtk::Widget for child" % child.class.to_s unless child.is_a? Gtk::Widget raise ArgumentError, "unsuported class %s, expect Integer for x" % x.class.to_s unless x.is_a? Integer raise ArgumentError, "unsuported class %s, expect Integer for y" % y.class.to_s unless y.is_a? Integer @pileBox = Gtk::Box.new :horizontal self.pack_start @pileBox, :expand => false, :fill => false @child2 = child @x = x @y = y @child2.has_window = false @pileBox.pack_start @child2, :expand => false, :fill => false @child2.set_parent_window self.window @pileBox.signal_connect_after(:size_allocate) {|widget, allo| on_allocate2 widget, allo} end
Private Instance Methods
on_allocate1(widget, allocation)
click to toggle source
Expands the child, so that it also consumes the place the pile child used.
# File lib/rgw/pile.rb, line 87 def on_allocate1 widget, allocation allocation.height = self.allocation.height widget.size_allocate allocation end
on_allocate2(widget, allocation)
click to toggle source
Moves the pile child to it’s destination.
# File lib/rgw/pile.rb, line 94 def on_allocate2 widget, allocation sAllocation = self.allocation if @x >= 0 allocation.x = @x elsif @x < 0 allocation.x = sAllocation.width - @child2.allocation.width - -@x end if @y >= 0 allocation.y = @y elsif @y < 0 allocation.y = sAllocation.height - @child2.allocation.height - -@y end widget.size_allocate allocation end