@@ -33,6 +33,7 @@ interface
3333 UIRibbonCommands;
3434
3535type
36+ // / This record stores information about a single ellemt in a ribbon UI
3637 TRibbonMarkupElement = record
3738 public
3839 Name : string;
@@ -41,19 +42,24 @@ TRibbonMarkupElement = record
4142 LabelDescriptionResourceID: integer;
4243 TooltipTitleResourceID: integer;
4344 TooltipDescriptionResourceID: integer;
44- constructor Create(pActionName: string; pActionID: integer;
45- pLabelTitleResourceID: integer = -1 ;
46- pLabelDescriptionResourceID: integer = -1 ;
47- pTooltipTitleResourceID: integer = -1 ;
48- pTooltipDescriptionResourceID: integer = -1 );
45+ // / Returns an initializes record of this type
46+ constructor Create(pActionName: string; pActionID: integer; pLabelTitleResourceID: integer = -1 ; pLabelDescriptionResourceID: integer = -1 ; pTooltipTitleResourceID: integer = -1 ; pTooltipDescriptionResourceID: integer = -1 );
4947 end ;
5048
49+ // / This class stores elements of the type <see cref="TRibbonMarkupElement>
5150 TRibbonMarkupElementList = class (TList<TRibbonMarkupElement>)
52- private
51+ strict private
5352 fResourceName: string;
53+ class var fContainer: TList<TRibbonMarkupElementList>;
54+ class constructor Create;
55+ class destructor Destroy;
5456 public
57+ class function LookupListByResourceName (const pResourceName: string): TRibbonMarkupElementList;
5558 function TryGetItem (pID: integer; out pItem: TRibbonMarkupElement): boolean;
59+ // / Creates an instance of this class
60+ // / <param name="pResourceName">The name of the resource of the ribbon to which this list of ribbon elements belongs</param>
5661 constructor Create(pResourceName: string);
62+ // / The name of the resource of the ribbon to which this list of ribbon elements belongs
5763 property ResourceName: string read fResourceName write fResourceName;
5864 end ;
5965
@@ -491,6 +497,30 @@ constructor TRibbonMarkupElementList.Create(pResourceName: string);
491497begin
492498 inherited Create();
493499 fResourceName := pResourceName;
500+ if not Assigned(fContainer) then
501+ fContainer := TList<TRibbonMarkupElementList>.Create();
502+ fContainer.Add(Self);
503+ end ;
504+
505+ class constructor TRibbonMarkupElementList.Create;
506+ begin
507+ fContainer := nil ;
508+ end ;
509+
510+ class destructor TRibbonMarkupElementList.Destroy;
511+ begin
512+ FreeAndNil(fContainer);
513+ end ;
514+
515+ class function TRibbonMarkupElementList.LookupListByResourceName (const pResourceName: string): TRibbonMarkupElementList;
516+ var
517+ lElement: TRibbonMarkupElementList;
518+ begin
519+ for lElement in fContainer do begin
520+ if SameText(pResourceName, lElement.ResourceName) then
521+ Exit(lElement);
522+ end ;
523+ Exit(nil ); // No match found
494524end ;
495525
496526function TRibbonMarkupElementList.TryGetItem (pID: integer; out pItem: TRibbonMarkupElement): boolean;
@@ -926,7 +956,7 @@ procedure TUIRibbon.Load();
926956 except
927957 on E: EOleException do begin
928958 E.Message := Format(sErrorLoadingRibbonRessource, [Self.ResourceName, e.Message]);
929- raise e ;
959+ raise;
930960 end ;
931961 end ;// try..except
932962
0 commit comments