Hi,

John Labenski wrote:
> On Nov 16, 2007 8:47 AM, Hakki Dogusan <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Is it possible to extend wxArtProvider in wxLua? wx's document shows
>> following sample:
>>
>>    class MyProvider : public wxArtProvider
>>    {
>>    protected:
>>      wxBitmap CreateBitmap(const wxArtID& id,
>>                            const wxArtClient& client,
>>                            const wxSize size)
>>      { ... }
>>    };
>>    ...
>>    wxArtProvider::Push(new MyProvider);
>>
> 
> Unfortunately not, a class like wxLuaPrintout that allows overriding
> virtual functions would have to be written. I'll try to remember to do
> it.
> 
> There's a general issue about creating our own classes to allow
> overriding virtual functions however, if we continue to create more
> and more of them we'll end up with a lot of wxLuaXXX classes on top of
> the original XXX classes and that seems awkward to me since you
> shouldn't have to worry about such things in wxLua. It could be made
> transparent by calling them just XXX in Lua, but I think this could be
> a problem if you call a function that returns an XXX class, but wxLua
> only deals with our subclassed wxLuaXXX classes.
> 
> For example: We write wxLuaTreeCtrl so we can override
> OnCompareItems(...) in Lua and as above treat all wxTreeCtrls as
> wxLuaTreeCtrls. Everything is great if all wxTreeCtrls are created in
> wxLua since they'll all be wxLuaTreeCtrls. There's a problem if a user
> uses wxGlade (or whatever) to create XML files for their GUI and then
> they try to get their wxTreeCtrl, but wxLua pushes it as a
> wxLuaTreeCtrl which it's not. The wxGenericDirCtrl creates it's own
> wxTreeCtrl which you can get using wxGenericDirCtrl ::GetTreeCtrl(),
> same problem as above.
> 
> I guess I have to look at wxPython to see how they handle this since I
> know that they subclass quite a few things. Unless maybe someone else
> knows?
> 
> Regards,
>     John
> 


It seems wxPython implements wxPyArtProvider and uses it as 
wxArtProvider. Related parts from artprov.i is below:


%{  // Python aware wxArtProvider
class wxPyArtProvider : public wxArtProvider  {
public:

     virtual wxBitmap CreateBitmap(const wxArtID& id,
                                   const wxArtClient& client,
                                   const wxSize& size) {
         wxBitmap rval = wxNullBitmap;
         wxPyBlock_t blocked = wxPyBeginBlockThreads();
         if ((wxPyCBH_findCallback(m_myInst, "CreateBitmap"))) {
             PyObject* so = wxPyConstructObject((void*)&size, 
wxT("wxSize"), 0);
             PyObject* ro;
             wxBitmap* ptr;
             PyObject* s1, *s2;
             s1 = wx2PyString(id);
             s2 = wx2PyString(client);
             ro = wxPyCBH_callCallbackObj(m_myInst, 
Py_BuildValue("(OOO)", s1, s2, so));
             Py_DECREF(so);
             Py_DECREF(s1);
             Py_DECREF(s2);
             if (ro) {
                 if (wxPyConvertSwigPtr(ro, (void**)&ptr, wxT("wxBitmap")))
                     rval = *ptr;
                 Py_DECREF(ro);
             }
         }
         wxPyEndBlockThreads(blocked);
         return rval;
     }

     PYPRIVATE;
};
%}



%rename(ArtProvider) wxPyArtProvider;
class wxPyArtProvider /*: public wxObject*/
{
public:

     %pythonAppend wxPyArtProvider setCallbackInfo(ArtProvider);
     wxPyArtProvider();
     ~wxPyArtProvider();

     void _setCallbackInfo(PyObject* self, PyObject* _class);

     %disownarg( wxPyArtProvider *provider );
...

     %cleardisown( wxPyArtProvider *provider );
...

     %pythonPrepend Destroy "args[0].this.own(False)"
     %extend { void Destroy() { delete self; }}
};

%init %{
     wxPyPtrTypeMap_Add("wxArtProvider", "wxPyArtProvider");
%}



-- 
Regards,
Hakki Dogusan




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to