Forum: wxRuby Creating custom widget

73b8fef129c4939fa606190d803855ac?d=identicon&s=25 Stanislav Chren (stanozm)
on 2011-10-01 11:49
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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2011-10-02 03:16
(Received via mailing list)
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:
> 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?

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
E7f3cbcb69beec85643d1ecc54121460?d=identicon&s=25 David Beswick (davidbeswick)
on 2011-10-02 03:34
(Received via mailing list)
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
This topic is locked and can not be replied to.