[Lazarus] new widget implementation - class hierarchy help required
Marc Weustink
marc at dommelstein.net
Mon Jul 7 22:44:56 CEST 2008
Graeme Geldenhuys wrote:
> Hi,
>
> I'm working on the LCL-fpGUI widget set. I'm mainly working on two
> units. FpGuiWSControls.pas and FpGuiWSStdCtrls.pas.
>
> All components in FpGuiWSStdCtrls seem to descend from TWSxxx classes
> defined in the generic wsstdctrls.pas unit (not the fpGUI specific one
> FpGUIWSStdCtrls.pas).
>
> So implementing something like the Invalidate() method, it seems I
> need to implement the same thing in FpGUIWSControls and
> FpGuiWSStdCtrls. Surely if the standard controls (eg: Button)
> descends from the TFpGuiWSWinControl in FpGuiWSControls.pas, then I
> would only need to implement Invalidate() once.
>
> How does the class hierarchy tie together in the FpGUIWSControls and
> FpGuiWSStdCtrls units? All the widget set specific standard controls
> seem to descend from the generic TWSxxx classes, and not the widgetset
> specific TfpGUIWSxxx classes.
Thats where the VClasses come in :)
When you register TFpGUIxxx it gets hooked into the tws hierarchy.
Example:
TWSControl - TWSWincontrol - TWSButton
You register TFpGUIWSWincontrol(TWSWincontrol), then the virtual class
tree will become
TWSControl - TWSWincontrol - TFpGUIWSWincontrol - TWSButton
So when you derive and register TFpGUIWSButton(TWSButton) it will
"inherit" from TFpGUIWSWincontrol. The only thing not possible is using
the "inherited" keyword to call an ancestor method. You can work around
this by using TWSWincontrolClass(ClassParent).SomeMethod.
Marc
More information about the Lazarus
mailing list