From: klaas.holwerda <kho...@xs...> - 2006-02-03 21:42:37
|
Hi Guys, Thanks for makes the wxluacan corrections, it indeed works nice. But to bad, there is a problem. I used wx as namespace to start with, and this works correctly. But now i changed wxluacan.rule to wxlucan as namespace in lua. Running the script incircles.lua from the script directory, it becomes clear that there is still a problem. When enabling the wxPrintf in wxLuaBinding::RegisterGeneratedClasses() it show that different classes end up with the same itag. And is a problem. Hope you can solve this one John, i tried before but don't understand how to do it. Tsjau, Klaas |
From: John L. <jla...@gm...> - 2006-02-03 22:03:29
|
On 2/3/06, klaas.holwerda <kho...@xs...> wrote: > Hi Guys, > > Thanks for makes the wxluacan corrections, it indeed works nice. > But to bad, there is a problem. > I used wx as namespace to start with, and this works correctly. heh. I can't get the wxLua app to work in MSW using VC Express 2005. It doesn't want to run the wxModule that loads the bindings. > But now i changed wxluacan.rule to wxlucan as namespace in lua. > > Running the script incircles.lua from the script directory, it becomes > clear that there is still a problem. > > When enabling the wxPrintf in wxLuaBinding::RegisterGeneratedClasses() > it show that different classes end up with the same itag. And is a proble= m. > > Hope you can solve this one John, i tried before but don't understand > how to do it. I'll take a look at it. Regards, John Labenski |
From: klaas.holwerda <kho...@xs...> - 2006-02-03 22:24:37
|
John Labenski wrote: >On 2/3/06, klaas.holwerda <kho...@xs...> wrote: > > >>Hi Guys, >> >>Thanks for makes the wxluacan corrections, it indeed works nice. >>But to bad, there is a problem. >>I used wx as namespace to start with, and this works correctly. >> >> > >heh. I can't get the wxLua app to work in MSW using VC Express 2005. >It doesn't want to run the wxModule that loads the bindings. > > Maybe that is the same problem i had first with all those bindings, it is not linked in i think. For some reason, if a module with bindings is not used somehow directly in the application, it is not linked in. I put a breakpoint on that wxModule binding and it did not arrive there. > > >I'll take a look at it. > > Thanks. Allow me to ask a question. I think it would be cool to wxCanObjScript working. I am thinking of deriving the wxCanvasObj from wxEvtHandler, and that way sent and event to wxLua to draw the object and another to Hittest the object. But maybe that is way to complex. And how to intercept those two functions in wxlua m_script of the object. In principle m_script in the C++ object, should contain two functions. On with input parameter a wxDC* etc. and this one is used for drawing. The other Is IsHit( x, y etc. ) and is used for hit testing, and return true to C++ if hit. Now do you have any idea on how to best call those function in m_script from the coresponding C++ functions? The next step is of course to have the whole derived wxCanObj defined in a lua script. But one step first ;-) Thanks, Klaas |
From: John L. <jla...@gm...> - 2006-02-03 22:54:44
|
> Allow me to ask a question. > I think it would be cool to wxCanObjScript working. > I am thinking of deriving the wxCanvasObj from wxEvtHandler, and that > way sent and event to wxLua to draw the object and another to Hittest > the object. > But maybe that is way to complex. And how to intercept those two > functions in wxlua m_script of the object. > In principle m_script in the C++ object, should contain two functions. > On with input parameter a wxDC* etc. and this one is used for drawing. > The other Is IsHit( x, y etc. ) and is used for hit testing, and return > true to C++ if hit. > Now do you have any idea on how to best call those function in m_script > from the coresponding C++ functions? You can have your C function just call lua code directly. m_wxlState.RunString(wxString::Format(wxT("hittest(%f, %f)"), x, y))); in the lua code you can then set variables back to C++ through the binding. Maybe I don't understand fully though. > The next step is of course to have the whole derived wxCanObj defined in > a lua script. > But one step first ;-) Whatever would be easier. -John |
From: k. h. <kla...@nl...> - 2006-02-06 09:00:22
|
Hi John, John Labenski wrote: >You can have your C function just call lua code directly. >m_wxlState.RunString(wxString::Format(wxT("hittest(%f, %f)"), x, y))); >in the lua code you can then set variables back to C++ through the binding. > > But i need to call a function in Lua which gets as a parameter a wxDC pointer from C++. So i think i need to push things on the lua stack, and call a function next? Also the functions to call are part of the m_script string stored inside each luacanvas object. And for each such object that script would be different in general, but the function is called the same ( Draw and HitTest ). Just reporting the functions to lua (using runstring() ) is not enough, as i think they must be unique. But on the other hand wrapping the luacanvas object to lua does not help too, since the instance of the object is in the C++ canvas. So i do not want to create the instance inside lua code. Eventually i think i need to push the current (to draw/hit ) luacanvas object as a (this) pointer on the stack, and next the parameters to the member function to call on that object. And when that is ready call the function. How complex :-( If you have any idea, i be glad to hear them, regards, Klaas -- Unclassified |
From: John L. <jla...@gm...> - 2006-02-06 20:50:51
|
On 2/6/06, k. holwerda <kla...@nl...> wrote: > Hi John, > > John Labenski wrote: > > >You can have your C function just call lua code directly. > >m_wxlState.RunString(wxString::Format(wxT("hittest(%f, %f)"), x, y))); > >in the lua code you can then set variables back to C++ through the bindi= ng. > > > > > But i need to call a function in Lua which gets as a parameter a wxDC > pointer from C++. > So i think i need to push things on the lua stack, and call a function ne= xt? Take a look at this, it tells you how to call lua functions from C. http://www.lua.org/pil/25.2.html > Also the functions to call are part of the m_script string stored inside > each luacanvas object. > And for each such object that script would be different in general, but > the function is called the same ( Draw and HitTest ). > Just reporting the functions to lua (using runstring() ) is not enough, > as i think they must be unique. So you'll have a wxLuaState for every object? Maybe you can just create a table in lua to store each object (as a sub table). In each object's table you can put the functions to call. > But on the other hand wrapping the luacanvas object to lua does not help > too, since the instance of the object is in the C++ canvas. > So i do not want to create the instance inside lua code. > Eventually i think i need to push the current (to draw/hit ) luacanvas > object as a (this) pointer on the stack, and next the parameters to the > member function to call on that object. And when that is ready call the > function. Humm, I don't think I understand. I haven't looked at the code for wxluacan yet however. -John |
From: klaas.holwerda <kho...@xs...> - 2006-02-06 22:44:28
|
John Labenski wrote: >Humm, I don't think I understand. I haven't looked at the code for >wxluacan yet however. > > Let me try to explain what i want to do without going into detail. First canvasobjects are placed on a canvas and the are drawn and hittested by a member function of that cavasobject. So for each derived canvasobject there is a different draw and hittest functions. This how there is a rectangle and circle object already. The idea is to implement a special canvasobject which has its draw and hittest function implemented as a lua function. This lua function can be edited runtime if wanted, and the functions (draw and hittest ) are stored in a string inside the canvasobject. So as soon as the object needs to be drawn on the canvas, it needs to call the function stored inside the script. And as input parameter it will get the wxDC* that is used to draw. The lua canvas object is created in C++ and stored in the canvas. Let's assume the default script string is drawing a rectangle. When drawing the canvas and arriving at this specific lua canvas object stored in that canvas, i already have the object pointer ( the c++ object), and only need to call a (draw/hittest) function, which is stored in its script string. For each luacanvasobject instance added to the canvas, the script string may have its own implementation. One draws a single rectangle, and another draws a whole set of whatever. Easy to say, but i realize it is not so simple ;-) Maybe i should begin with making all drawing and hittets functions unique. Like: MYOBJ_1_Draw( ) MYOBJ_1_Hittest( ) MYOBJ_2_Draw( ) MYOBJ_2_Hittest( ) etc. That would reduce it to loading those function at the start, and call the right one from C++. First read some more about calling lua functions, Thanks, Klaas |