functions are the add ons, that are only used, if there is no LCL component to handle the task. In other words: The LCL wraps the interface in an object pascal way.
For example: The user should never use the LCLCheckMenuItem. For the user this is a low lvl function. The LCL delegates and controls the interface. So, the interface base is below the LCL.
Our trick is, that the actual implementations of the interface (gtk, win32) overrides the interface base. And because the user does not use the real interface, we have the choice to put it wherever we want in the hierachy. And the easiest position for the implementation is above the whole LCL and its base. That's why we can use TMenuItem in the win32 intf. This is only because of its hideous character. If we would use a perfect OO design, the implemented interface would ly right on the interface base and would not know the LCL.
The other side:
What would happen, if we put the LCL and the interface base on the same level?
This would mean, a call of LCLCheckMenuItem and the use of AMenuItem.Checked:=true is equivalent. This would mean the LCL logic must be handled in the interface (unchecking if it is a radio item, etc.). I strongly suggest, that we do not try this way.
So, my conclusion is, that the LCL should be clearly above the interface base.
Show quoted text 10 lines
If we adhere to this order, nothing can go wrong. Things on lower level
may use things on a higher level, but only when they need to implement
functionality.
> If units are ordered hierachical, an user can start exploring the high
> lvl units and then go down, as he needs. But with unit circles, he needs
> to read the whole circle to understand what is going on.
I think not many users read interface uses and 'know' what's meant when
he reads an interface call.
That's exactly my point. Although it seems, you can draw different conclusions from it.
Back to the "unnecssary" casting:
- it is always a good idea to check the input of a function
- the interface functions can also be used by the user. Even if we say: Plz don't do. People will do.
- We can add function to TBaseMenuItem, so that te typecast is not needed.
Mattias