Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-07

new widget implementation - class hierarchy help required

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

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.

I hope my question makes sense.... :-)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Marc Weustink
to Graeme Geldenhuys
Graeme Geldenhuys wrote 19 lines
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

Reply by email

Graeme Geldenhuys
to Marc Weustink

2008/7/7 Marc Weustink :

Show quoted text 9 lines
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.

Ah, now it makes sense. Some class trickery is at play! :) Thanks for explaining it, Marc.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email