I do not think it is a bug: ----in case of cell1 you create a widget with a hash which specifies its dimensions to h=100 and w=100 and than you start to paint starting from 100(x) etc so de facto you are painting outside the widget display area. If you change your paint method to: def paint fill(white) rect(0, 0, @width, @height) line(0, 0, @width, 0) line(0, 0, 0, @height) line(@width, 0, @width, @height) line(0, @height, @width, @height) end everything is OK, right?
----for cell2 you do not specify any widget parameters explicitly so it is an "open" slot onto which you paint rectangle and lines and use up as much space as necessary. This is how I understand what happens. Hope it helps Krzys On Sat, Jan 24, 2009 at 4:23 PM, Szymon Wrozynski sw <[email protected]> wrote: > Hello, > > Could you point me what's wrong here? > > The code: > > class Cell1 < Shoes::Widget > def initialize(opts={}) > @x = opts[:x] > @y = opts[:y] > @width = opts[:width] > @height = opts[:height] > paint > end > > def paint > fill(white) > rect(@x, @y, @width, @height) > line(@x, @y, @x + @width, @y) > line(@x, @y, @x, @y + @height) > line(@x + @width, @y, @x + @width, @y + @height) > line(@x, @y + @height, @x + @width, @y + @height) > end > end > > class Cell2 < Shoes::Widget > def initialize(x, y, width, height) > @x = x > @y = y > @width = width > @height = height > paint > end > > def paint > fill(white) > rect(@x, @y, @width, @height) > line(@x, @y, @x + @width, @y) > line(@x, @y, @x, @y + @height) > line(@x + @width, @y, @x + @width, @y + @height) > line(@x, @y + @height, @x + @width, @y + @height) > end > end > > Shoes.app do > cell1(:x=>100, :y=>100, :width=>100, :height=>100) # doesn't work!! > cell2(100, 100, 100, 100) # works ok > end > > > The paint methods are the same. > Is it a bug? Why it doesn't work while passing a hash? The console says > nothing. > > As usually any help will be blessed. > > kind regards > > sw >
