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 -- Posted via http://www.ruby-forum.com/.
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 at ruby-forum.com> ??????? (?):> 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 > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users
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 at ruby-forum.com> ??????? > (?):N? i don t think you understood. In th? example i give, FindWindowById retiens NULL! Emmanuel -- Posted via http://www.ruby-forum.com/.
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 at ruby-forum.com> ???????(?):> 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 at ruby-forum.com> >> ??????? >> (?): > > N? i don t think you understood. > In th? example i give, > FindWindowById retiens NULL! > > Emmanuel > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users
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 at 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 ? -- Posted via http://www.ruby-forum.com/.
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 ???????(?):> 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 at 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 ? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-usersSergey Chernov real.sergeych at gmail.com
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
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. > > alexHello, 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 -- Posted via http://www.ruby-forum.com/.