On Tue, 18 Jan 2011, Max Vlasov wrote:

On Mon, Jan 17, 2011 at 2:08 PM, Michael Van Canneyt <[email protected]
wrote:



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

and

Var
 LabelDefaults : TLabelDefaults;

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



I liked the idea, but to understand it correctly... You placed it in "var",
isn't it supposed to be placed on a form like any other TComponent? So once
it added, every existing and future TLabel on the form will get new defaults
unless they're explicitly changed by the user? And if the persistent is
deleted all default will be back to objects default.

No, I actually meant a var, because I want it to be application-wide.

You could of course implement a 'form local'  variant for this as well. The
loading code could do something like

If Assigned(GlobalLabelDefaults) then
  ApplyDefaults(GlobalLabelDefaults);
LocalDefaults:=FindLocalDefaults(TLabelDefaults);
If Assigned(LocalDefaults) then
  ApplyDefaults(LocalDefaults);


There are some challenges I think, for example how to behave with
inheritance since in this case both component and default can be inherited
and changed in the form.

Not a problem with the global one ?


Also I thought that it would be useful to implement them like TField in
database components. So for example make Defaults properties in the form
that works like Fields in TDataSet descendants so on any placed component if
there is registered corresponding TComponentDefault found, it's
automatically added to Defaults designer or rather say as TField works, it
simply added to form while also supported effectively by specially created
designer. I know that it's more work to do in this case, but implementing
this way will allow more convenient usage, since starting some number of
defaults randomly placed components on the form are harder to track and use.

A good idea as well, but I would like to have an application-wide setting.

Well, with a global and a local version, it works almost like CSS :-)

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to