Re: [Lazarus] Own component - problem with default published property

2012-05-18 Thread Alexander Klenin
On Wed, May 16, 2012 at 5:13 PM, cobines cobi...@gmail.com wrote:
 2012/5/16 Krzysztof dib...@wp.pl:
 Or must I create new descendant of TMyProperty for each control and
 then change default value of SomeValue property?

 Yes, I think you have to do this. If you want to have different
 defaults for the property then you need to make different classes for
 them.

Yes, this is somewhat annoying. In TAChart I tried to reduce the
amount of extra code
by setting the default value in the ancestor class based on RTTI.
This way you need not override constructors of descendant properties.

-- 
Alexander S. Klenin

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Own component - problem with default published property

2012-05-16 Thread cobines
If you changed the default you should publish it with:

property Style default csDropDownList;

If property has default value it is not written to LFM, in that case
the value is whatever you set in constructor.

--
cobines

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Own component - problem with default published property

2012-05-16 Thread Krzysztof
But what if this is subproperty?

For example:

TMyProperty = class(TPersistent)
published
  property SomeValue: TSomeType read FSomeValue write SetSomeValue default sv1
end;

Can I do something like that:

TMyControl1 = class(TControl)
published
  MyProperty.SomeValue default sv2
end;

TMyControl2 = class(TControl)
published
  MyProperty.SomeValue default sv3
end;

Or must I create new descendant of TMyProperty for each control and
then change default value of SomeValue property?

2012/5/16 cobines cobi...@gmail.com:
 If you changed the default you should publish it with:

 property Style default csDropDownList;

 If property has default value it is not written to LFM, in that case
 the value is whatever you set in constructor.

 --
 cobines

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Own component - problem with default published property

2012-05-16 Thread cobines
2012/5/16 Krzysztof dib...@wp.pl:
 Or must I create new descendant of TMyProperty for each control and
 then change default value of SomeValue property?

Yes, I think you have to do this. If you want to have different
defaults for the property then you need to make different classes for
them.

--
cobines

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus