LCL controls very hard to extend, many hidden properties
Original Reporter info from Mantis: zex2011
-
Reporter name: Zex Atilla
Original Reporter info from Mantis: zex2011
- Reporter name: Zex Atilla
Description:
LCL controls are very hard to customize. For example, why the TCustomButton component doesn't have FCanvas and OnPaint event, so it can be further customized?
One has to rewrite entire component just to add a simple property. Especially because some necessary fields in the inherited control are Private, so one has to reinvent (duplicate) them too.
Additional information:
You know the TColorButton control found on the Misc tab of the Lazarus control palette? That control is an good example of a VICTIM of the LCL customization problems.
When using TColorButton one can't stop asking himself two questions:
-
Why TColorButton wasn't inherited from TButton? So it can accept focus like any other button.
-
Why it expands the color area to fill entire button, instead of having fixed size rectangle that is always say 32x24 pixels?
It very soon became clear why the author of TColorButton did what he did. Because he had the same problems that I had, when I tried to make my own TColorButton (to overcome the above problems).
It's nearly impossible to make that kind of a button by inheriting TButton, unless you're the author of LCL yourself. One has to combine TCustomButton and TCustomControl to create an extendable base button, from which it becomes possible to make TColorButton or any other custom button.
Please, make the controls more extendable. Think twice before making any field Private. If in doubt, make it Protected. One of the best things about Delphi and Lazarus is that everything is customizable. Or at least it should be.
Mantis conversion info:
- Mantis ID: 20399
- Version: 0.9.30