lib/shoes/basic.rb in green_shoes-0.176.0 vs lib/shoes/basic.rb in green_shoes-0.179.0

- old
+ new

@@ -79,10 +79,11 @@ @app.mccs.delete(self); @app.mrcs.delete(self); @app.mmcs.delete(self) case self when Button, EditLine, EditBox, ListBox @app.cslot.contents.delete self remove + @real = nil else @real.clear end end def positioning x, y, max @@ -123,26 +124,10 @@ end end end class Image < Basic; end - class Button < Basic - def click &blk - real.signal_connect "clicked", &blk if blk - end - end - class ToggleButton < Button - def checked? - real.active? - end - - def checked=(tof) - real.active = tof - end - end - class Check < ToggleButton; end - class Radio < ToggleButton; end class Pattern < Basic def move2 x, y return if @hided clear if @real @@ -200,11 +185,33 @@ class Tagline < TextBlock; end class Caption < TextBlock; end class Para < TextBlock; end class Inscription < TextBlock; end - class EditLine < Basic + class Native < Basic + def change obj, &blk + obj.signal_connect "changed", &proc{parent.append{blk[self]}} if blk + end + end + class Button < Native + def click &blk + real.signal_connect "clicked", &proc{parent.append{blk[self]}} if blk + end + end + class ToggleButton < Button + def checked? + real.active? + end + + def checked=(tof) + real.active = tof + end + end + class Check < ToggleButton; end + class Radio < ToggleButton; end + + class EditLine < Native def text @real.text end def text=(s) @@ -213,13 +220,17 @@ def move2 x, y @app.canvas.move @real, x, y move3 x, y end + + def change &blk + super @real, &blk + end end - class EditBox < Basic + class EditBox < Native def text @textview.buffer.text end def text=(s) @@ -228,18 +239,35 @@ def move2 x, y @app.canvas.move @real, x, y move3 x, y end + + def change &blk + super @textview.buffer, &blk + end end - class ListBox < Basic + class ListBox < Native def text @items[@real.active] end + + def choose item + @real.active = @items.index item + end + + def change &blk + super @real, &blk + end + + def items= items + @items = items + items.each{|item| real.append_text item.to_s} + end end - class Progress < Basic + class Progress < Native def fraction real.fraction end def fraction= n