Forum: wxRuby draw in C++ with wxRuby

223712a7bca2b1d054421aa7ada329fe?d=identicon&s=25 Emmanuel Emmanuel (emmanuel)
on 2010-05-17 17:09
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
7e3a56ff8a090fc9ffbd1909dea94904?d=identicon&s=25 Sergey Chernov (sergeych)
on 2010-05-17 18:41
(Received via mailing list)
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 Emmanuel <lists@ruby-forum.com> ÎÁÐÉÓÁÌ
(Á):
223712a7bca2b1d054421aa7ada329fe?d=identicon&s=25 Emmanuel Emmanuel (emmanuel)
on 2010-05-17 19:09
Sergey Chernov 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 Emmanuel <lists@ruby-forum.com> �������
> (�):

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

Emmanuel
7e3a56ff8a090fc9ffbd1909dea94904?d=identicon&s=25 Sergey Chernov (sergeych)
on 2010-05-17 22:37
(Received via mailing list)
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 Emmanuel <lists@ruby-forum.com>
написал(а):
223712a7bca2b1d054421aa7ada329fe?d=identicon&s=25 Emmanuel Emmanuel (emmanuel)
on 2010-05-17 23:44
Sergey Chernov 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 Emmanuel <lists@ruby-forum.com>
> написал(а):

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 ?
7e3a56ff8a090fc9ffbd1909dea94904?d=identicon&s=25 Sergey Chernov (sergeych)
on 2010-05-18 00:40
(Received via mailing list)
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 Emmanuel ÎÁÐÉÓÁÌ(Á):

> 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
> wxruby-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users

Sergey Chernov
real.sergeych@gmail.com
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2010-05-19 01:42
(Received via mailing list)
On 17/05/2010 16:09, Emmanuel Emmanuel 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
223712a7bca2b1d054421aa7ada329fe?d=identicon&s=25 Emmanuel Emmanuel (emmanuel)
on 2010-05-19 08:01
Alex Fenton wrote:
> On 17/05/2010 16:09, Emmanuel Emmanuel 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....:-)
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
This topic is locked and can not be replied to.