#!/usr/local/bin/ruby
# by YOSHIDA Kazuhiro (moriq@moriq.com)
# modified by KUMAGAI Hidetake (ggb03124@nifty.ne.jp)
# modified by NISHIO Mizuho (mzh@portnet.ne.jp)

module RGUI
  class Form < Phi::Form
    include RGUI

    def layout
      stop_align do
        orig_auto_scroll = self.auto_scroll
        self.auto_scroll = false
        begin
          fix_height = 0
          status_bar = controls.find{|i| i.is_a? Phi::StatusBar }
          fix_height+= status_bar.height if status_bar

          @children.each do |c|
            c.left = 0
            c.top = 0
            c.width  = client_width
            c.height = client_height-fix_height
            c.layout if defined? c.layout
          end
        ensure
          self.auto_scroll = orig_auto_scroll
        end
      end
    end

  end
end
