require 'phi'
require 'pgrid'
Phi.debug = true
include Phi

form = Form.new :main_form

gc_btn = Button.new form, :gc_btn, "GC"
gc_btn.align = Phi::AL_TOP

def gc_btn.on_click
  GC.start
end

memo = Memo.new form, :memo
memo.align = Phi::AL_BOTTOM
memo.height = 30

pgrid = PropGrid.new form, :pgrid
pgrid.align = Phi::AL_CLIENT

pgrid.auto_update = true
pgrid.break_by_section= true

selrow = proc do |sender, index, sectionname|
p [sender.items, index]
  if index != -1
    memo.text = sender.items[index].note
  end
end

value_change = proc do |args|
  p args
end

item_ary = Array.new

pgrid.on_select_row = selrow
pgrid.items.update do
item = pgrid.items.add
item.key = "あお"
item.value = "Blue"
item.section = "いろいろ"
item.note = "そらのいろ"
item.on_value_change = value_change
#item_ary.push item
item = pgrid.items.add
item.key = "あか"
item.value = "赤"
item.section = "いろいろ"
item.note = "あぽろのいろ"
item.on_value_change = value_change
#item_ary.push item
item = pgrid.items.add
item.key = "みどり"
item.value = "green"
item.section = "いろいろ"
item.note = "まっちゃのいろ"
item.on_value_change = value_change
#item_ary.push item
end

form.show

Phi.mainloop


