Creating custom widget

Hi,

I’m trying to learn and experiment with Ruby a bit so I decided to make
a simple diagram editor using wxruby.

The problem is, I will need to create a custom widget for the diagram
components (e.g. rectangles, connections) and implement some custom
events. I found these examples of how it’s done in generic wxWidgets:
http://wiki.wxwidgets.org/Painting_your_custom_control
http://docs.wxwidgets.org/2.9.2/overview_customwidgets.html

Is something like this possible in wxRuby or is there any sample ruby
code which I could look at?

Thank you for any suggestions.

Stano

hi

On 01/10/11 10:49, Stanislav Chren wrote:

The problem is, I will need to create a custom widget for the diagram
components (e.g. rectangles, connections) and implement some custom
events. I found these examples of how it’s done in generic wxWidgets:
Painting your custom control - WxWiki
http://docs.wxwidgets.org/2.9.2/overview_customwidgets.html

Is something like this possible in wxRuby or is there any sample ruby
code which I could look at?

Have a look at samples/events/events.rb - it uses a custom class derived
from Wx::Window that implements an on_paint method and event handling.

cheers
alex

Hello Stanislav, I’m sure that this is possible. Most of the methods in
that
code should have direct wxruby equivalents, you can derive from the
native
wxruby classes, but the event-handling syntax is quite different. Check
out
the wxRuby samples. Where they’re installed depends on what operating
system
you’re on and how you installed wxruby, but if you can’t find it then
download the source and you can see them all in the “samples” folder. In
particular, maybe check out samples/drawing/graphics_drawing.rb