From f5cb1ce5f953fa15423839dc1b7816b80c76d9c2 Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 12 Dec 2009 09:00:46 +0000 Subject: [PATCH] ideintf: free options index searching - GetFreeIDEOptionsGroupIndex - to find free group index - GetFreeIDEOptionsIndex - to find free options index inside group git-svn-id: trunk@23092 - --- ideintf/ideoptionsintf.pas | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ideintf/ideoptionsintf.pas b/ideintf/ideoptionsintf.pas index 7fe811c037..d9efecbec6 100644 --- a/ideintf/ideoptionsintf.pas +++ b/ideintf/ideoptionsintf.pas @@ -113,6 +113,8 @@ type function FindEditor(AEditor: TAbstractIDEOptionsEditorClass): TAbstractIDEOptionsEditor; virtual; abstract; end; +function GetFreeIDEOptionsGroupIndex(AStartIndex: Integer): Integer; +function GetFreeIDEOptionsIndex(AGroupIndex: Integer; AStartIndex: Integer): Integer; procedure RegisterIDEOptionsGroup(AGroupIndex: Integer; AGroupClass: TAbstractIDEOptionsClass); procedure RegisterIDEOptionsEditor(AGroupIndex: Integer; AEditorClass: TAbstractIDEOptionsEditorClass; AIndex: Integer; AParent: Integer = NoParent); @@ -178,7 +180,7 @@ begin Result := FIDEEditorGroups; end; -procedure RegisterIDEOptionsGroup(AGroupIndex: Integer; AGroupClass:TAbstractIDEOptionsClass); +procedure RegisterIDEOptionsGroup(AGroupIndex: Integer; AGroupClass: TAbstractIDEOptionsClass); begin IDEEditorGroups.Add(AGroupIndex, AGroupClass); end; @@ -202,6 +204,30 @@ begin end; end; +function GetFreeIDEOptionsGroupIndex(AStartIndex: Integer): Integer; +var + I: Integer; +begin + for I := AStartIndex to High(Integer) do + if IDEEditorGroups.GetByIndex(I) = nil then + Exit(I); +end; + +function GetFreeIDEOptionsIndex(AGroupIndex: Integer; AStartIndex: Integer): Integer; +var + Rec: PIDEOptionsGroupRec; + I: Integer; +begin + Result := -1; // -1 = error + Rec := IDEEditorGroups.GetByIndex(AGroupIndex); + if Rec = nil then + Exit; + + for I := AStartIndex to High(Integer) do + if Rec^.Items.GetByIndex(I) = nil then + Exit(I); +end; + function GroupListCompare(Item1, Item2: Pointer): Integer; var Rec1: PIDEOptionsGroupRec absolute Item1;