&xcenter;
WPS
class. There can only be one open view per &xcenter; so
that an &xcenter; instance is identical to an &xcenter;
view when it's open, but there can be several &xcenter;
instances on the system (i.e. one for each screen border).
Even though the &xcenter; itself is obviously a Desktop object, it completely isolates the widgets from the WPS stuff internally. This is why SOM/WPS programming knowledge is not required to write a new widget class, but you can still do WPS programming if you want to.
Again, to make that clear: A widget is a separate PM window inside the &xcenter;.
XCENTERWIDGETCLASS
).
This structure holds the name of a PM window class which is used by the &xcenter;
to create the PM widget windows. Depending on the widget
class's attributes, there can be one or several
instances of a widget class. If you want a different widget in the &xcenter;,
you need to write a widget class.
Writing a widget class basically boils down to writing a PM window class (see below), with some additional rules to follow. To make things easier, several widget classes can share the same PM class though.
Some widget classes are built into the &xcenter; itself (i.e. reside in
XFLDR.DLL
), but the &xcenter; can obviously load external plug-in DLLs too.
Several of the widget classes that come with &xwp; have been created as plug-ins to
show you how it's done. If you have the
&xwp; source code,
look for the src\widgets
directory.
Basically, PM organizes windows into classes. For example, if you create
a PM button, you invoke WinCreateWindow
with the name of the
button window class (WC_BUTTON
), which is a standard window class
of every &os2; system.
It is possible to create new window classes though. The &xcenter; makes use of this feature to implement widget classes. So again, a widget class is a PM window class with a bit of extra data to give the &xcenter; more information about the widgets that can be created of that class.
The advantage of using separate PM window classes is that a widget is essentially free to do whatever it wants. It can say "Hello world", but it can also choose to start a dozen subthreads with videos playing.
The disadvantage is that writing a PM window class from scratch is a bit more difficult than using standard controls. But that's why there are plenty of samples to learn from.
When a widget is created (either because it is added to an open &xcenter;
or when an &xcenter; is opened in the first place and thus all widgets have to
be created), it does call WinCreateWindow
with the PM window class
name that was specified with the widget class. So this is really not too spectacular.
plugins\xcenter
directory of the &xwp;
installation directory. This must contain one or
several widget classes. There are three procedures that a widget plugin DLL
is required to export to make the &xcenter; see the widget classes. This is
explained in detail on the next pages.