Defines a TFont descendant class for defining a font which is a derivative of another thing. For example, say you wanted to have a Title Font which is based on the normal Font for your component except it is bold. You can use this class to define that derivative font and set it up to automatically update its characteristics as the normal Font changes. The TRSDeltaFont class provides a font class which tracks what characteristics of the font have changed from an original font. When the original font changes, you call the UpdateNonDelta method of the TRSCustomDeltaFont and pass in the original font.
The TRSDeltaFont class is a descendant of the RSDeltaFont.TRSCustomDeltaFont class and publishes the Deltas property. The TRSCustomDeltaFont class does not publish any new properties so it can be used interchangeably with the TFont class.
To use the TRSDeltaFont class, you need to perform three steps:
• Create the Delta Font class for your component
• Hook up the DeltaFont to your original font using the OnGetOriginalFont event.
• Call the UpdateNonDelta method when the original font changes.
Namespace: RSDeltaFont
TFont |
Delphi |
type |
|
|
Create the Delta Font class for your component: Delphi |
constructor TMyControl.Create(AOwner: TComponent); |
Hook up the DeltaFont to your original font using the OnGetOriginalFont event:
Delphi
procedure TMyControl.GetOriginalFont(Sender: TObject;
var Font: TFont);
begin
Font := Self.Font;
end;
Call the UpdateNonDelta method when the original font changes:
Delphi
procedure TMyControl.FontChanged;
begin
inherited FontChanged;
if FTitleFont <> nil then
(FTitleFont as TRSCustomDeltaFont).UpdateNonDelta(Font);
end;
Reference•UpdateNonDelta |