WxRuby Region clearing

Hi !

I’m trying to understand how regions are working in wxRuby. For now, I
tried only to draw a rectangle and to move it. In order to do that, I
use a region to tell wxRuby to refresh only the rectangle and not the
whole screen. But no matter how I try, it always refreshs only a part of
the rectangle. Can somebody tell me why ?

I’m running wxRuby 2.0.1 on OSX, and wrote a script (attached to this
post) as an example. Don’t hesitate to tell me if my code looks bad and
how to improve it, I’m a beginner in WxRuby as in Ruby.

Thanks in advance.

Francis Toth wrote in post #976161:

Hi !

I’m trying to understand how regions are working in wxRuby. For now, I
tried only to draw a rectangle and to move it. In order to do that, I
use a region to tell wxRuby to refresh only the rectangle and not the
whole screen. But no matter how I try, it always refreshs only a part of
the rectangle. Can somebody tell me why ?

I’m running wxRuby 2.0.1 on OSX, and wrote a script (attached to this
post) as an example. Don’t hesitate to tell me if my code looks bad and
how to improve it, I’m a beginner in WxRuby as in Ruby.

Thanks in advance.

Finally, I worked it out !
I can’t explain why, but it seems that wxRuby acts strangely when a
region is cleared and redrawn in the same event. I decided to proceed
with two different events :

def refreshRectangle
@frame.paint{|dc|
clearRectangle(dc)
}
yield # move the rectangle
@frame.paint{|dc|
drawRectangle(dc)
}
end

For those interested, I’ve put the new script in attachment.

++

Francis.