paragui-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [paragui-users] Paragui redesign


From: Andrew Ford
Subject: Re: [paragui-users] Paragui redesign
Date: Mon, 6 May 2002 09:47:57 -0700 (PDT)

It would be nice if the loader could send the commands
from the XML layout directly to the widget when it
loads, i.e. size, and gradient, and position, etc... 
But I guess every widget needs its own tags and
therefore its own handling like you said.  Using this
arrangement, can user widgets hand XML attributes back
to their base-classes for processing, i.e. whatever
attributes have nothing to do with this widget in
particular get sent processed by a superclass.  Do we
even need to derive from factory-object instead of
adding a virtual parseXMLarguments function to
PG_Widget?  The factory doesn't need it.
  From my perspective, forcing use of a factory via
protected constructors means that we can force the use
of reference counters so that the user can't
conveniently get pointers to widgets to subvert the
counting mechanism.  They can, of course, but it makes
it illegal by default and they'll have to work around
it or specifically request it.  I forgot to mention
the unsafe thing about reference counting.  If you
have a cyclic reference, say parent and child both
holding a reference to the other, then you're in a
situation where neither can be deleted.  Since the
creator is going to get a reference, that means that
the children will have to get temporary smrtptrs or
use pointers to their parents.  If smrtptrs are used,
can we deadlock getting temporary references like
this?  Or for that matter, do we just send messages to
our parents and not reference them directly at all?
  Now that I'm thinking about it, isn't parsing the
XML attributes like sending events to the widgets, and
if treated like that, events not handled right now are
sent up to the super-class for handling until we get
to PG_Widget...

Andrew.

--- Alexander Pipelka <address@hidden> wrote:

> The problem with the current implementation is that
> it's static. There
> are functions for parsing XML attributes for every
> widget of the lib.
> It's impossible to extend the functionality for user
> defined widgets.
> 
> My idea was to provide a basic framework for XML
> layout loading and
> passing parsing of widget attributes back to the
> widget.
> 
> To acomplish that there is need for dynamically
> created widgets
> (depending on the XML layout).
> 
> One way to do this could be:
> 
> PG_FactoryBaseClass {
>       virtual ~PG_FactoryBaseClass();
>       virtual bool ParseXMLAttributes(..);
> }
> 
> template <class T> PG_FactoryObject : virtual public
> {
>       static T* CreateObject(PG_Widget* parent) {
>               return new T(parent);
>       }
> }
> 
> template<class T> PG_Factory::RegisterClass(const
> char* classname) {
>       register the static CreateObject function pointer
>       map[classname]=createfuntion;
> }
> 
> PG_Widget* PG_Factory::CreateObject(const char*
> classname) {
> }
> 
> A widget would subclass PG_FactoryObject:
> 
> PG_Widget : public PG_MessageObject, public
> PG_FactoryObject<PG_Widget>
> {
>       ...
>       bool ParseXMLAttributes(..);
> }
> 
> The layout loader would do the following:
> 
> - Read XML file, get objecttype
> - Create the object
> - Pass parsing of XML attributes to the created
> object
> 
> Does this make sense ?
> 
> Alex


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]