Skip to content

Commit 5d0639f

Browse files
author
joachim.marder
committed
Each TRibbonMarkupElementList is now registered in a static list. The property RibbonMapper is now protected. The ribbon mapper is now assigned automatically based on the resource name. Renamed GetElements() to RegisterRibbonElements() and removed it from the interface section, as there is no need to call this function explicitly.
1 parent 357e095 commit 5d0639f

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

Designer/Bin/RibbonDesigner.exe

1.45 MB
Binary file not shown.

Lib/UIRibbon.pas

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ TRibbonMarkupElement = record
5050
TRibbonMarkupElementList = class(TList<TRibbonMarkupElement>)
5151
strict private
5252
fResourceName: string;
53-
class var fContainer: TList<TRibbonMarkupElementList>;
53+
class var fContainer: TObjectList<TRibbonMarkupElementList>;
5454
class constructor Create;
5555
class destructor Destroy;
5656
public
@@ -224,6 +224,18 @@ TUIRibbon = class(TWinControl, IUIApplication)
224224
/// Localize the given Ribbon command using the resource identifiers of the given markup item.
225225
/// </summary>
226226
procedure LocalizeRibbonElement(const pCommand: TUICommand; const pMarkupItem: TRibbonMarkupElement);
227+
228+
/// <summary>
229+
/// Gets or sets the mapping dictionary, which is automatically created by
230+
/// the "Ribbon Designer" of the "Windows Ribbon Framework".
231+
/// </summary>
232+
/// <remarks>
233+
/// The mapping dictionary is contained in the pascal file, created by the
234+
/// the "Ribbon Designer" of the "Windows Ribbon Framework". It contains
235+
/// the required mapping between Ribbon command identifier and the
236+
/// corresponding Action of the assigned ActionManager.
237+
/// </remarks>
238+
property RibbonMapper: TRibbonMarkupElementList read fRibbonMapper write fRibbonMapper;
227239
{$ENDREGION 'Internal Declarations'}
228240
public
229241

@@ -406,18 +418,6 @@ TUIRibbon = class(TWinControl, IUIApplication)
406418
/// <seealso>TRibbonApplicationModes</seealso>
407419
property ApplicationModes: TRibbonApplicationModes read fApplicationModes write Set_ApplicationModes;
408420

409-
/// <summary>
410-
/// Gets or sets the mapping dictionary, which is automatically created by
411-
/// the "Ribbon Designer" of the "Windows Ribbon Framework".
412-
/// </summary>
413-
/// <remarks>
414-
/// The mapping dictionary is contained in the pascal file, created by the
415-
/// the "Ribbon Designer" of the "Windows Ribbon Framework". It contains
416-
/// the required mapping between Ribbon command identifier and the
417-
/// corresponding Action of the assigned ActionManager.
418-
/// </remarks>
419-
property RibbonMapper: TRibbonMarkupElementList read fRibbonMapper write fRibbonMapper;
420-
421421
published
422422

423423
{ The name of the Ribbon resource as it is stored in the resource file. }
@@ -498,7 +498,7 @@ constructor TRibbonMarkupElementList.Create(pResourceName: string);
498498
inherited Create();
499499
fResourceName := pResourceName;
500500
if not Assigned(fContainer) then
501-
fContainer := TList<TRibbonMarkupElementList>.Create();
501+
fContainer := TObjectList<TRibbonMarkupElementList>.Create(True);
502502
fContainer.Add(Self);
503503
end;
504504

@@ -617,7 +617,6 @@ destructor TUIRibbon.Destroy;
617617
begin
618618
SaveRibbonSettings(); // Save quick toolbar, etc.
619619
FFramework := nil;
620-
FreeAndNil(fRibbonMapper);
621620
FreeAndNil(FCommands);
622621
inherited;
623622
end;
@@ -943,6 +942,8 @@ procedure TUIRibbon.Load();
943942
begin
944943
if (Available) and (inherited Visible) and not (FLoaded) then
945944
begin
945+
// Load mapper for mapping between commands and VCL actions
946+
fRibbonMapper := TRibbonMarkupElementList.LookupListByResourceName(FResourceName);
946947
if (FResourceInstance = 0) then
947948
Inst := HInstance
948949
else

0 commit comments

Comments
 (0)