@@ -207,6 +207,7 @@ TUIRibbon = class(TWinControl, IUIApplication)
207207 // / <param name="pCommandId">The id of the ribbon command.</param>
208208 // / <param name="pContextAvailability">The availability state.</param>
209209 procedure SetContextTabAvailability (const pCommandId: Integer; const pContextAvailability: TUIContextAvailability);
210+ function GetContextTabAvailability (const pCommandId: Integer): TUIContextAvailability;
210211
211212 { IInterface }
212213 function _AddRef : Integer; stdcall;
@@ -403,6 +404,12 @@ TUIRibbon = class(TWinControl, IUIApplication)
403404 // / <param name="pCommandId">The ID of the context tab.</param>
404405 procedure EnableContextTab (const pCommandId: Integer);
405406
407+ // / <summary>
408+ // / Returns whether or not a ribbon context tab is enabled.
409+ // / </summary>
410+ // / <param name="pCommandId">The ID of the context tab.</param>
411+ function IsContextTabEnabled (const pCommandId: Integer): Boolean;
412+
406413 // / <summary>
407414 // / Hides a ribbon context tab.
408415 // / </summary>
@@ -1104,6 +1111,11 @@ procedure TUIRibbon.InvalidateUICommand(const Command: TUICommand;
11041111 end ;
11051112end ;
11061113
1114+ function TUIRibbon.IsContextTabEnabled (const pCommandId: Integer): Boolean;
1115+ begin
1116+ Result := GetContextTabAvailability(pCommandId) in [TUIContextAvailability.caAvailable, TUIContextAvailability.caActive];
1117+ end ;
1118+
11071119function TUIRibbon.GetRecentItems (): TUICommandRecentItems;
11081120begin
11091121 if not Assigned(fRecentItems) then
@@ -1590,6 +1602,22 @@ procedure TUIRibbon.SetContextTabAvailability(const pCommandId: Integer; const p
15901602 (lCommand as TUICommandContext).Availability := pContextAvailability;
15911603end ;
15921604
1605+ function TUIRibbon.GetContextTabAvailability (const pCommandId: Integer): TUIContextAvailability;
1606+ var
1607+ lCommand: TUICommand;
1608+ begin
1609+ Result := TUIContextAvailability.caNotAvailable;
1610+ // If Ribbons are disabled, exit here.
1611+ if (not Self.Visible) then
1612+ Exit;
1613+ // Get the command with that ID
1614+ if not Self.TryGetCommand(pCommandId, lCommand) then
1615+ Exit;
1616+ // If found, check type, cast and get Availability property.
1617+ if (lCommand.CommandType = TUICommandType.ctContext) then
1618+ Result := (lCommand as TUICommandContext).Availability;
1619+ end ;
1620+
15931621procedure TUIRibbon.SetHighlightColor (const Value : TColor);
15941622begin
15951623 SetHighlightHsbColor(ColorToHsb(Value ));
0 commit comments