paragui-users
[Top][All Lists]
Advanced

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

[paragui-users] About Factories again...


From: Guillaume Schmid
Subject: [paragui-users] About Factories again...
Date: 17 Jun 2002 18:38:28 +0200

Hello,
I thought about the factory problem and I think that it is possible.
I designed a very simple factory system compatible with paragui 1.0.x
and started to program it.

For the moment, it is VERY simple and does only support label and
buttons but it seems to work. The interface with the factory does only
takes strings as input. My sample app is looking like this:

  fact.Create("label");
  fact.SetAttribute ("name", "pipolabel");
  fact.SetAttribute ("size", "0,0,100,100");
  fact.SetAttribute ("text", "Label Wizzz!");
  fact.SetAttribute ("hide","0");
  fact.CommitWidget ();


  fact.Create("button");
  fact.SetAttribute ("name", "pipobutton");
  fact.SetAttribute ("size", "100,100,100,100");
  fact.SetAttribute ("text", "PipoButton");
  fact.SetAttribute ("hide","0");
  fact.CommitWidget ();

  app.Run ();

I removed all error detection code for clarity.
So, it should be very easy to create a simple script parser that call
those methods. It can set a parent with a name and support all
parameters that le pglayout loader support.

This factory thing implies no modification of paragui at all.
I am thinking about extensibility in two ways:
inheritance: A users could provide a class that inherit from the factory
to create his own widgets.
Registering widget factories: The factory uses specific widget factories
for each kind of widgets (they use the same inherirance tree that the
widgets). The user could register his own CustomWidgetFactory to the
PG_Factory wis a custom widget name, and parse the strings. Some special
string would trigger the use of his custom factory, such as:
  fact.Create("customwidget");
  fact.SetAttribute ("name", "HokutoWidget");
  fact.SetAttribute ("size", "100,100,100,100");
  fact.SetAttribute ("customparam", "customvalue");
  fact.CommitWidget ();

For the moment, I am developping this for my app, I will write a small
lex (and yacc if there is a need) parser to build my interfaces. But if
you think that it might be of some interest to Paragui, I will happily
provide all this stuff. For the moment, I will code all the factories to
be complete as possible.

For the moment, the code might just be interesting for review, I think
that it would greatly benefit from contructive criticism. It is not
perfectly integrated with paragui (I dont use the paragui loggin
facilities). I think that there will be a few refactoring as soon as the
interface in complete :).

a++
Guillaume.
PS: I dont have any web page. I can only send this code by email to
those interested (if any :)






reply via email to

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