Draw in C++ with wxRuby

Hello,

I want to draw using C++ wxWdiget in some windows created using wxRuby.

Does anybody know if it is possible ?

I tried one thing which is maybe very naive … but it does not work :

1- I created a Frame using wxRuby
2- i got the field wx_id of this instance of Frame
3- I tried to get the wxWindow in C++ using this id (using
FindWindowById of the C++ api of wxWidget)

Any help will be very appreciated !

Emmanuel

Does this work with, say, Canvas properly fitted into the frame?
Actually drawing on the frame may not be as good as it looks.

Yours,
Sergey

17.05.2010, × 19:09, Emmanuel E. [email protected] ÎÁÐÉÓÁÌ
(Á):

Sergey C. wrote:

Does this work with, say, Canvas properly fitted into the frame?
Actually drawing on the frame may not be as good as it looks.

Yours,
Sergey

17.05.2010, � 19:09, Emmanuel E. [email protected] �������
(�):

Nô i don t think you understood.
In thé example i give,
FindWindowById retiens NULL!

Emmanuel

I’d checked whether it happens with non-frame windows. Can’t check
after migrating on snow leopard it just don’t work

Yours,
Sergey

17.05.2010, в 21:09, Emmanuel E. [email protected]
написал(а):

Sergey C. wrote:

I’d checked whether it happens with non-frame windows. Can’t check
after migrating on snow leopard it just don’t work

Yours,
Sergey

17.05.2010, в 21:09, Emmanuel E. [email protected]
написал(а):

YOU DID NOT UNDERSTAND !?!

Whatever object is created using wxRuby, I want to be able to manipulate
the corresponding wxWidget object in C++, how do I do that ?

it was clear since the beginning.

try get_id() on your window, and if it fails

try to do it with the regular window - not frame - unless you have to.
I’m used to get strange effects with frames sometimes.

good luck

18.05.2010, × 1:44, Emmanuel E. ÎÁÐÉÓÁÌ(Á):

YOU DID NOT UNDERSTAND !?!

Whatever object is created using wxRuby, I want to be able to manipulate
the corresponding wxWidget object in C++, how do I do that ?

Posted via http://www.ruby-forum.com/.


wxruby-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wxruby-users

Sergey C.
[email protected]

On 17/05/2010 16:09, Emmanuel E. wrote:

I tried one thing which is maybe very naive … but it does not work :

1- I created a Frame using wxRuby
2- i got the field wx_id of this instance of Frame
3- I tried to get the wxWindow in C++ using this id (using
FindWindowById of the C++ api of wxWidget)

I don’t think this is naive - it looks like the right way to do this.
The return value of wx_id should simply be a ruby Fixnum representation
of the C++ int.

You don’t say exactly what is going wrong here, but in your later
messages you suggest that you’re getting NULL back in C++ when you try
wxWindow::FindWindowById. Can you provide some more detail about how
you’re passing the value from Ruby to your C++ library, and how you call
FindWindowById in C++?

One test might be to find the object in C++ by GetChildren, inspecting
its pointer address and comparing to what you have in Ruby - for
debugging, you can access the C++ pointer address of a Wx::Window with
the method ptr_addr.

The advice to draw upon a Panel, rather than directly on a Frame, is
sound and in line with standard Wx techniques.

PS - don’t SHOUT on this list. The support offered here works wholly on
the basis of good-will.

alex

Alex F. wrote:

On 17/05/2010 16:09, Emmanuel E. wrote:

I tried one thing which is maybe very naive … but it does not work :

1- I created a Frame using wxRuby
2- i got the field wx_id of this instance of Frame
3- I tried to get the wxWindow in C++ using this id (using
FindWindowById of the C++ api of wxWidget)

I don’t think this is naive - it looks like the right way to do this.
The return value of wx_id should simply be a ruby Fixnum representation
of the C++ int.

You don’t say exactly what is going wrong here, but in your later
messages you suggest that you’re getting NULL back in C++ when you try
wxWindow::FindWindowById. Can you provide some more detail about how
you’re passing the value from Ruby to your C++ library, and how you call
FindWindowById in C++?

One test might be to find the object in C++ by GetChildren, inspecting
its pointer address and comparing to what you have in Ruby - for
debugging, you can access the C++ pointer address of a Wx::Window with
the method ptr_addr.

The advice to draw upon a Panel, rather than directly on a Frame, is
sound and in line with standard Wx techniques.

PS - don’t SHOUT on this list. The support offered here works wholly on
the basis of good-will.

alex

Hello,

first… sorry for “shouting” … I should not have…:slight_smile:
And it is indeed very nice of both of you to take time trying to help
me.
I really appreciate!

Yes, The problem was not that I could not draw in the window but that
FindWindowById returned NULL.
… now I just solved it (yes!) … I was not properly linking my C++
code to build the dynamic library…

It is all working now …

Thank you very much (and sorry!) again

Emmanuel