Forum: wxRuby WxRuby Region clearing

790ce5a6fe89527a36dc1f3665107a9b?d=identicon&s=25 Francis Toth (shaz)
on 2011-01-20 05:21
Attachment: RegionTest.rb (1 KB)
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.
790ce5a6fe89527a36dc1f3665107a9b?d=identicon&s=25 Francis Toth (shaz)
on 2011-01-22 21:12
Attachment: RegionTest.rb (1 KB)
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.
This topic is locked and can not be replied to.