[Lazarus] LCL improvement idea

Michael Van Canneyt michael at freepascal.org
Mon Jan 17 12:08:51 CET 2011


Hi,

Following the RAD discussion, I thought of something.

Often, I subclass a control just to set some properties to other than their
default values. (TLabel.AutoSize and TLabel.layout jump to mind).

This can in fact be avoided by having some kind of 'Application-Wide defaults' system.

I imagine something like

TLabelDefaults = Class(TPersistent)
   // Selected properties.
end;

and

Var
   LabelDefaults : TLabelDefaults;

Which are applied as soon as a TLabel control is created.

This would eliminate the need to subclass many controls. 
Instead of subclassing TLabel, I could do

LabelDefaults.AutoSize:=False;
LabelDefaults.Layout:=tlCenter;

Once in my application (you could even create a separate designer for this in the
IDE), and all labels have a different default.

Since the .lfm file only contains properties that are actually set to
non-default values, this would work with streaming as well.

Michael.




More information about the Lazarus mailing list