#! ruby -Ks
require "Phi" ; include Phi

plan = 2

case plan
when 1

form = Form.new
gb = GroupBox.new form, :group_box1, "グループボックス(plan = #{plan})"
frame = Panel.new gb
frame.align = AL_CLIENT
frame.bevel_inner = BV_NONE
frame.bevel_outer = BV_NONE
rb1 = RadioButton.new frame, :rb1 , "test1"
rb2 = RadioButton.new frame, :rb2 , "test2"
rb3 = RadioButton.new frame, :rb2 , "test3"
rb1.left = 10 ; rb1.top = 10
rb2.left = 10 ; rb2.top = 30
rb3.left = 10 ; rb3.top = 50
form.show
mainloop

when 2

form = Form.new
frame = GroupBox.new form, :group_box1, "グループボックス(plan = #{plan})"
rb1 = RadioButton.new frame, :rb1 , "test1"
rb2 = RadioButton.new frame, :rb2 , "test2"
rb3 = RadioButton.new frame, :rb2 , "test3"
rb1.left = 10 ; rb1.top = 20
rb2.left = 10 ; rb2.top = 40
rb3.left = 10 ; rb3.top = 60
form.show
mainloop

when 3

class Control
  def self.new_ex(parent,name=nil,caption=nil,*args)
    caption = name.to_s unless caption
    obj = self.new(parent,name,caption)
    args.each{|arg|
      case arg
      when Array
        obj.left   = arg[0] if arg[0]
        obj.top    = arg[1] if arg[1]
        obj.width  = arg[2] if arg[2]
        obj.height = arg[3] if arg[3]
      end
    }
    return obj
  end
end

form = Form.new
frame = GroupBox.new form, :group_box1, "グループボックス(plan = #{plan})"
rb1 = RadioButton.new_ex frame, :rb1 , "test1", [10,20]
rb2 = RadioButton.new_ex frame, :rb2 , "test2", [10,40]
rb3 = RadioButton.new_ex frame, :rb2 , "test3", [10,60]
form.show
mainloop

end
