.SetChecked for TAdvGlowButton in D5
I'm building a toolbar with buttons like bold, italic, etc from AdvGlowButtons in Delphi 5.
In D5, the AdvGlowButtons don't have a SetChecked-function, so the AdvGlowButtons don't go down when a action want to set them down.
Changing in advglowbutton.pas
after
{$IFDEF DELPHI6_LVL}
TAdvGlowButtonActionLink = class(TControlActionLink)
[...]
{$ENDIF}
insert
{$IFDEF VER130}
TAdvGlowButtonActionLink = class(TControlActionLink)
protected
FImageIndex: Integer;
FClient: TAdvCustomGlowButton; //TAdvGlowButton;
procedure AssignClient(AClient: TObject); override;
function IsCheckedLinked: Boolean; override;
procedure SetChecked(Value: Boolean); override;
function IsImageIndexLinked: Boolean; override;
end;
{$ENDIF}
After
{$IFDEF DELPHI6_LVL}
function ActionHasImages: boolean;
{$ENDIF}
insert
{$IFDEF VER130}
function ActionHasImages: boolean;
{$ENDIF}
After
{$IFDEF DELPHI6_LVL}
function GetActionLinkClass: TControlActionLinkClass; override;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
{$ENDIF}
insert
{$IFDEF VER130}
function GetActionLinkClass: TControlActionLinkClass; override;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
{$ENDIF}
After
{$IFDEF DELPHI6_LVL}
function TAdvCustomGlowButton.ActionHasImages: boolean;
begin
[...]
end;
{$ENDIF}
insert
{$IFDEF VER130}
function TAdvCustomGlowButton.ActionHasImages: boolean;
begin
Result := false;
if Assigned(Action) then
begin
if (Action.Owner is TActionList) then
Result := Assigned((Action.Owner as TActionList).Images);
end;
end;
{$ENDIF}
After
{$IFDEF DELPHI6_LVL}
procedure TAdvCustomGlowButton.ActionChange(Sender: TObject; CheckDefaults: Boolean);
begin
[...]
end;
//------------------------------------------------------------------------------
function TAdvCustomGlowButton.GetActionLinkClass: TControlActionLinkClass;
begin
[...]
end;
{$ENDIF}
insert
{$IFDEF VER130}
procedure TAdvCustomGlowButton.ActionChange(Sender: TObject; CheckDefaults: Boolean);
begin
inherited ActionChange(Sender, CheckDefaults);
if Sender is TCustomAction then
with TCustomAction(Sender) do
begin
if CheckDefaults or (Self.GroupIndex = 0) then
Self.GroupIndex := GroupIndex;
if (csDesigning in ComponentState)
then
begin
if ActionHasImages then
Self.ImageIndex := ImageIndex;
Self.Down := Checked;
end;
end;
if AutoSize and Assigned(Parent) and HandleAllocated then
begin
DoAutoSize := true;
paint;
DoAutoSize := false;
end;
end;
//------------------------------------------------------------------------------
function TAdvCustomGlowButton.GetActionLinkClass: TControlActionLinkClass;
begin
Result := TAdvGlowButtonActionLink;
end;
{$ENDIF}
After
{$IFDEF DELPHI6_LVL}
{ TAdvGlowButtonActionLink }
procedure TAdvGlowButtonActionLink.AssignClient(AClient: TObject);
begin
[...]
end;
//------------------------------------------------------------------------------
function TAdvGlowButtonActionLink.IsCheckedLinked: Boolean;
begin
[...]
end;
//------------------------------------------------------------------------------
function TAdvGlowButtonActionLink.IsGroupIndexLinked: Boolean;
begin
[...]
end;
//------------------------------------------------------------------------------
procedure TAdvGlowButtonActionLink.SetImageIndex(Value: Integer);
begin
[...]
end;
//------------------------------------------------------------------------------
function TAdvGlowButtonActionLink.IsImageIndexLinked: boolean;
begin
[...]
end;
//------------------------------------------------------------------------------
function TAdvGlowButtonActionLink.IsHelpLinked: Boolean;
begin
[...]
end;
//------------------------------------------------------------------------------
procedure TAdvGlowButtonActionLink.SetHelpContext(Value: THelpContext);
begin
[...]
end;
//------------------------------------------------------------------------------
procedure TAdvGlowButtonActionLink.SetHelpKeyword(const Value: string);
begin
[...]
end;
//------------------------------------------------------------------------------
procedure TAdvGlowButtonActionLink.SetHelpType(Value: THelpType);
begin
[...]
end;
//------------------------------------------------------------------------------
procedure TAdvGlowButtonActionLink.SetChecked(Value: Boolean);
begin
[...]
end;
//------------------------------------------------------------------------------
procedure TAdvGlowButtonActionLink.SetGroupIndex(Value: Integer);
begin
[...]
end;
{$ENDIF}
insert
{$IFDEF VER130}
{ TAdvGlowButtonActionLink }
procedure TAdvGlowButtonActionLink.AssignClient(AClient: TObject);
begin
inherited AssignClient(AClient);
FClient := AClient as TAdvCustomGlowButton;
end;
//------------------------------------------------------------------------------
function TAdvGlowButtonActionLink.IsCheckedLinked: Boolean;
begin
Result := inherited IsCheckedLinked {and (FClient.GroupIndex <> 0) and
FClient.AllowAllUp} and (FClient.Down = (Action as TCustomAction).Checked);
FClient.CheckLinked := Result;
end;
//------------------------------------------------------------------------------
function TAdvGlowButtonActionLink.IsImageIndexLinked: boolean;
begin
Result := inherited IsImageIndexLinked and
(FImageIndex = (Action as TCustomAction).ImageIndex);
end;
//------------------------------------------------------------------------------
procedure TAdvGlowButtonActionLink.SetChecked(Value: Boolean);
begin
if IsCheckedLinked then
TAdvCustomGlowButton(FClient).Down := Value;
end;
{$ENDIF}
and it works like in the versions > D5.
Maybe interesting for other D5-users.