Forum: wxRuby Creating custom widget

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9fbc199aff813e81e012888a6c8629b3?d=identicon&s=25 Stanislav C. (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
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
Bf1119b5b34d9916c65a4b571d9c34c0?d=identicon&s=25 David B. (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.