IDE Coolbar: New class TIDECoolBarOptions for environment options data. No LCL components created there any more. Refactoring.

git-svn-id: trunk@48579 -
This commit is contained in:
juha 2015-04-01 15:34:18 +00:00
parent bd5e44ad93
commit c12cc20d48
6 changed files with 400 additions and 333 deletions

View File

@ -291,25 +291,8 @@ type
FCompletionWindowWidth: Integer;
FCompletionWindowHeight: Integer;
//toolbars
FToolbarVisible: Boolean;
FToolBarStandardVisible: Boolean;
FToolBarStandardLeft: Integer;
FToolBarStandardTop: Integer;
FToolBarViewDebugVisible: Boolean;
FToolBarViewDebugLeft: Integer;
FToolBarViewDebugTop: Integer;
FToolBarHighlight: Boolean;
FToolBarRaised: Boolean;
//coolbar
FIDEToolBarList: TIDEToolBarList;
FIDECoolBarVisible: Boolean;
FIDECoolBarWidth: Integer;
FIDECoolBarGrabStyle: Integer;
FIDECoolBarGrabWidth: Integer;
FIDECoolBarBorderStyle: Integer;
// IDE Coolbar
FIDECoolBarOptions: TIDECoolBarOptions;
// component palette
FComponentPaletteOptions: TCompPaletteOptions;
@ -540,18 +523,8 @@ type
property IDENameForDesignedFormList: boolean read FIDENameForDesignedFormList
write FIDENameForDesignedFormList;
//coolbar
property IDEToolBarList: TIDEToolBarList read FIDEToolBarList;
property IDECoolBarVisible: Boolean read FIDECoolBarVisible
write FIDECoolBarVisible;
property IDECoolBarWidth: Integer read FIDECoolBarWidth
write FIDECoolBarWidth;
property IDECoolBarGrabStyle: Integer read FIDECoolBarGrabStyle
write FIDECoolBarGrabStyle;
property IDECoolBarGrabWidth: Integer read FIDECoolBarGrabWidth
write FIDECoolBarGrabWidth;
property IDECoolBarBorderStyle: Integer read FIDECoolBarBorderStyle
write FIDECoolBarBorderStyle;
// IDE Coolbar
property IDECoolBarOptions: TIDECoolBarOptions read FIDECoolBarOptions;
// component palette
property ComponentPaletteOptions: TCompPaletteOptions read FComponentPaletteOptions;
@ -866,7 +839,6 @@ constructor TEnvironmentOptions.Create;
var
o: TEnvOptParseType;
c: TMsgWndColor;
IDEToolBar: TIDEToolBar;
begin
inherited Create;
for o:=low(FParseValues) to high(FParseValues) do
@ -927,50 +899,8 @@ begin
FCompletionWindowWidth := 320;
FCompletionWindowHeight := 6;
FToolbarVisible := False;
FToolBarStandardVisible := False;
FToolBarStandardLeft := 0;
FToolBarStandardTop := 0;
FToolBarViewDebugVisible := False;
FToolBarViewDebugLeft := 0;
FToolBarViewDebugTop := 26;
FToolBarHighlight := False;
FToolBarRaised := False;
//coolbar
FIDEToolBarList := TIDEToolBarList.Create;
FIDECoolBarVisible := True;
FIDECoolBarWidth := 230;
FIDECoolBarGrabStyle := 1;
FIDECoolBarGrabWidth := 5;
FIDECoolBarBorderStyle := 1;
//standard toolbar defaults
IDEToolBar := FIDEToolBarList.Add;
IDEToolBar.Position := 0;
IDEToolBar.Break := False;
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileNew/itmFileNewForm');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileNew/itmFileNewUnit');
IDEToolBar.ButtonNames.Add('---------------');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileOpenSave/itmFileOpen');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileOpenSave/itmFileSave');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileOpenSave/itmFileSaveAll');
IDEToolBar.ButtonNames.Add('---------------');
IDEToolBar.ButtonNames.Add('IDEMainMenu/View/itmViewMainWindows/itmViewToggleFormUnit');
//debug toolbar defaults
IDEToolBar := FIDEToolBarList.Add;
IDEToolBar.Position := 1;
IDEToolBar.Break := True;
IDEToolBar.ButtonNames.Add('IDEMainMenu/Project/itmProjectAddRemoveSection/itmProjectViewUnits');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Project/itmProjectAddRemoveSection/itmProjectViewForms');
IDEToolBar.ButtonNames.Add('---------------');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Project/itmProjectAddRemoveSection/itmProjectBuildMode');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuRun');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuPause');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStop');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStepOver');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStepInto');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStepOut');
// IDE Coolbar
FIDECoolBarOptions:=TIDECoolBarOptions.Create;
// component palette
FComponentPaletteOptions:=TCompPaletteOptions.Create;
@ -1079,7 +1009,7 @@ begin
FreeAndNil(FRecentPackageFiles);
FreeAndNil(FObjectInspectorOptions);
FreeAndNil(FComponentPaletteOptions);
FreeAndNil(FIDEToolBarList);
FreeAndNil(FIDECoolBarOptions);
FreeAndNil(FLazarusDirHistory);
FreeAndNil(FCompilerFileHistory);
FreeAndNil(FFPCSourceDirHistory);
@ -1205,10 +1135,6 @@ var
EventType: TDBGEventType;
NodeName: String;
mwc: TMsgWndColor;
IDEToolBar: TIDEToolBar;
IDEToolBarCount: Integer;
IDEToolBarButtonsCount: Integer;
IDEToolBarButtonsName: string;
begin
Cfg:=nil;
try
@ -1274,58 +1200,6 @@ begin
FIDENameForDesignedFormList:=XMLConfig.GetValue(
Path+'Desktop/IDENameForDesignedFormList/Value',false);
//Coolbar
SubPath := Path + 'Desktop/IDECoolBar/';
FIDECoolBarVisible := XMLConfig.GetValue(SubPath + 'Visible/Value', True);
FIDECoolBarWidth := XMLConfig.GetValue(SubPath + 'Width/Value', 230);
FIDECoolBarGrabStyle := XMLConfig.GetValue(SubPath + 'GrabStyle/Value', 1);
FIDECoolBarGrabWidth := XMLConfig.GetValue(SubPath + 'GrabWidth/Value', 5);
FIDECoolBarBorderStyle := XMLConfig.GetValue(SubPath + 'BorderStyle/Value', 5);
IDEToolbarCount := XMLConfig.GetValue(SubPath + 'ToolBarCount/Value', 0);
if IDEToolBarCount > 0 then
begin
FIDEToolBarList.Clear;
SubPath := SubPath + 'ToolBar';
for I := 0 to IDEToolbarCount - 1 do
begin
IDEToolBar := FIDEToolBarList.Add;
IDEToolBar.Position := I;
IDEToolBar.Break := XMLConfig.GetValue(
SubPath + IntToStr(I) + '/Break/Value', False);
IDEToolBarButtonsCount := XMLConfig.GetValue(
SubPath + IntToStr(I) + '/ButtonCount/Value', 0);
for J := 0 to IDEToolBarButtonsCount - 1 do
begin
IDEToolBarButtonsName := XMLConfig.GetValue(
SubPath + IntToStr(I) + '/Buttons/Name' + IntToStr(J) + '/Value', '');
if Trim(IDEToolBarButtonsName) <> '' then
IDEToolBar.ButtonNames.Add(IDEToolBarButtonsName);
end;
end;
end;
// Toolbar
FToolBarStandardVisible := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Standarad/ToolBarStandardVisible/Value', True);
FToolBarStandardLeft := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Standarad/ToolBarStandardLeft/Value', 0);
FToolBarStandardTop := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Standarad/ToolBarStandardTop/Value', 0);
FToolBarViewDebugVisible :=XMLConfig.GetValue(
Path+'Desktop/Toolbars/ViewDebug/ToolBarViewDebugVisible/Value', True);
FToolBarViewDebugLeft := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Standarad/ToolBarViewDebugLeft/Value', 0);
FToolBarViewDebugTop := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Standarad/ToolBarViewDebugTop/Value', 26);
FToolbarVisible := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Common/ToolbarVisible/Value', True);
FToolBarHighlight := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Common/ToolBarHighlight/Value', False);
FToolBarRaised := XMLConfig.GetValue(
Path+'Desktop/Toolbars/Common/ToolBarRaised/Value', False);
// form editor
FShowGrid:=XMLConfig.GetValue(
Path+'FormEditor/ShowGrid',true);
@ -1581,6 +1455,8 @@ begin
FLowercaseDefaultFilename:=XMLConfig.GetValue(
Path+'LowercaseDefaultFilename/Value',true);
// IDE Coolbar
FIDECoolBarOptions.Load(XMLConfig);
// component palette
FComponentPaletteOptions.Load(XMLConfig);
@ -1710,61 +1586,6 @@ begin
XMLConfig.SetDeleteValue(Path+'Desktop/IDENameForDesignedFormList/Value',
FIDENameForDesignedFormList,false);
// toolbar
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Standarad/ToolBarStandardVisible/Value',
FToolBarStandardVisible, True);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Standarad/ToolBarStandardLeft/Value',
FToolBarStandardLeft, 0);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Standarad/ToolBarStandardTop/Value',
FToolBarStandardTop, 0);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/ViewDebug/ToolBarViewDebugVisible/Value',
FToolBarViewDebugVisible, True);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Standarad/ToolBarViewDebugLeft/Value',
FToolBarViewDebugLeft, 0);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Standarad/ToolBarViewDebugTop/Value',
FToolBarViewDebugTop, 26);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Common/ToolbarVisible/Value',
FToolbarVisible, True);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Common/ToolBarHighlight/Value',
FToolBarHighlight, False);
XMLConfig.SetDeleteValue(Path+'Desktop/Toolbars/Common/ToolBarRaised/Value',
FToolBarRaised, False);
//coolbar
SubPath := Path + 'Desktop/IDECoolBar/';
XMLConfig.DeletePath(SubPath);
XMLConfig.SetDeleteValue(SubPath + 'Visible/Value',
FIDECoolBarVisible, True);
XMLConfig.SetDeleteValue(SubPath + 'Width/Value',
FIDECoolBarWidth, 0);
XMLConfig.SetDeleteValue(SubPath + 'GrabStyle/Value',
FIDECoolBarGrabStyle, 1);
XMLConfig.SetDeleteValue(SubPath + 'GrabWidth/Value',
FIDECoolBarGrabWidth, 5);
XMLConfig.SetDeleteValue(SubPath + 'BorderStyle/Value',
FIDECoolBarBorderStyle, 5);
if FIDEToolBarList.Count > 0 then
begin
XMLConfig.SetDeleteValue(SubPath + 'ToolBarCount/Value',
FIDEToolbarList.Count, 0);
SubPath := SubPath + 'ToolBar';
for I := 0 to FIDEToolbarList.Count - 1 do
begin
XMLConfig.SetDeleteValue(SubPath + IntToStr(I) + '/Break/Value',
FIDEToolbarList.Items[I].Break, False);
XMLConfig.SetDeleteValue(SubPath + IntToStr(I) + '/ButtonCount/Value',
FIDEToolbarList.Items[I].ButtonNames.Count, 0);
for J := 0 to FIDEToolbarList.Items[I].ButtonNames.Count - 1 do
begin
XMLConfig.SetDeleteValue(SubPath + IntToStr(I) + '/Buttons/Name' + IntToStr(J) + '/Value',
FIDEToolbarList.Items[I].ButtonNames.Strings[J], '');
end;
end;
end;
// form editor
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowBorderSpacing',
FShowBorderSpacing,false);
@ -1998,6 +1819,8 @@ begin
XMLConfig.SetDeleteValue(Path+'LowercaseDefaultFilename/Value',
FLowercaseDefaultFilename,true);
// IDE Coolbar
FIDECoolBarOptions.Save(XMLConfig);
// component palette
FComponentPaletteOptions.Save(XMLConfig);

View File

@ -72,7 +72,7 @@ type
procedure spGrabWidthChange(Sender: TObject);
procedure tmWaitTimer(Sender: TObject);
private
FTempList: TIDEToolBarList;
FTempCoolBar: TIDECoolBar;
procedure SelectBand(const ID: integer);
function GetSelectedBand: Integer;
procedure ToolBarClick(Sender: TObject);
@ -130,7 +130,7 @@ var
I, J: integer;
IDEToolBar: TIDEToolBar;
begin
with AOptions as TEnvironmentOptions do
with (AOptions as TEnvironmentOptions).IDECoolBarOptions do
begin
//read toolbar settings
cbToolBarVisible.Checked := IDECoolBarVisible;
@ -152,16 +152,16 @@ begin
EnableDisableButtons(0);
//read toolbars
FTempList.Clear;
for I := 0 to IDEToolbarList.Count - 1 do
FTempCoolBar.ToolBars.Clear;
for I := 0 to IDECoolBar.ToolBars.Count - 1 do
begin
IDEToolBar := FTempList.Add;
IDEToolBar.Position := IDEToolbarList.Items[I].Position;
IDEToolBar.Break := IDEToolbarList.Items[I].Break;
for J := 0 to IDEToolbarList.Items[I].ButtonNames.Count - 1 do
IDEToolBar.ButtonNames.Add(IDEToolbarList.Items[I].ButtonNames.Strings[J]);
IDEToolBar := FTempCoolBar.Add;
IDEToolBar.Position := IDECoolBar.ToolBars[I].Position;
IDEToolBar.Break := IDECoolBar.ToolBars[I].Break;
for J := 0 to IDECoolBar.ToolBars[I].ButtonNames.Count - 1 do
IDEToolBar.ButtonNames.Add(IDECoolBar.ToolBars[I].ButtonNames.Strings[J]);
end;
FTempList.Sort;
FTempCoolBar.Sort;
PopulateToolBar;
end;
@ -173,7 +173,7 @@ var
IDEToolBar: TIDEToolBar;
ToolBar: TToolBar;
begin
with AOptions as TEnvironmentOptions do
with (AOptions as TEnvironmentOptions).IDECoolBarOptions do
begin
//write toolbar settings
IDECoolBarVisible := cbToolBarVisible.Checked;
@ -187,23 +187,23 @@ begin
if Coolbar.Bands[I].Control = nil then
Continue;
ToolBar := (Coolbar.Bands[I].Control as TToolBar);
J := FTempList.FindByToolBar(ToolBar);
J := FTempCoolBar.FindByToolBar(ToolBar);
if J <> -1 then
begin
FTempList.Items[J].Position := Coolbar.Bands[I].Index;
FTempList.Items[J].Break := Coolbar.Bands[I].Break;
FTempCoolBar.ToolBars[J].Position := Coolbar.Bands[I].Index;
FTempCoolBar.ToolBars[J].Break := Coolbar.Bands[I].Break;
end;
end;
FTempList.Sort;
FTempCoolBar.Sort;
IDEToolbarList.Clear;
for I := 0 to FTempList.Count - 1 do
IDECoolBar.ToolBars.Clear;
for I := 0 to FTempCoolBar.ToolBars.Count - 1 do
begin
IDEToolBar := IDEToolbarList.Add;
IDEToolBar.Position := FTempList.Items[I].Position;
IDEToolBar.Break := FTempList.Items[I].Break;
for J := 0 to FTempList.Items[I].ButtonNames.Count - 1 do
IDEToolBar.ButtonNames.Add(FTempList.Items[I].ButtonNames.Strings[J]);
IDEToolBar := IDECoolBar.Add;
IDEToolBar.Position := FTempCoolBar.ToolBars[I].Position;
IDEToolBar.Break := FTempCoolBar.ToolBars[I].Break;
for J := 0 to FTempCoolBar.ToolBars[I].ButtonNames.Count - 1 do
IDEToolBar.ButtonNames.Add(FTempCoolBar.ToolBars[I].ButtonNames.Strings[J]);
end;
end;
MainIDEBar.RefreshCoolbar;
@ -325,12 +325,12 @@ procedure TToolbarOptionsFrame.EnableDisableButtons(const bType: Integer);
IDEToolBar1: TIDEToolBar;
begin
Result := True;
if FTempList.Count <> 2 then
if FTempCoolBar.ToolBars.Count <> 2 then
Exit;
if (FTempList.Items[0].ButtonNames.Count <> 8) or (FTempList.Items[1].ButtonNames.Count <> 10) then
if (FTempCoolBar.ToolBars[0].ButtonNames.Count <> 8) or (FTempCoolBar.ToolBars[1].ButtonNames.Count <> 10) then
Exit;
IDEToolBar0 := FTempList.Items[0];
IDEToolBar1 := FTempList.Items[1];
IDEToolBar0 := FTempCoolBar.ToolBars[0];
IDEToolBar1 := FTempCoolBar.ToolBars[1];
Result := (IDEToolBar0.ButtonNames[0] <> 'IDEMainMenu/File/itmFileNew/itmFileNewForm') or
(IDEToolBar0.ButtonNames[1] <> 'IDEMainMenu/File/itmFileNew/itmFileNewUnit') or
(IDEToolBar0.ButtonNames[2] <> '---------------') or
@ -383,19 +383,19 @@ var
I, J: Integer;
begin
CoolBar.Bands.Clear;
for I := 0 to FTempList.Count - 1 do
for I := 0 to FTempCoolBar.ToolBars.Count - 1 do
begin
CoolBand := CoolBar.Bands.Add;
CoolBand.Break := FTempList.Items[I].Break;
CoolBand.Control := FTempList.Items[I].Toolbar;
FTempList.Items[I].Toolbar.Enabled := False;
CoolBand.Break := FTempCoolBar.ToolBars[I].Break;
CoolBand.Control := FTempCoolBar.ToolBars[I].Toolbar;
FTempCoolBar.ToolBars[I].Toolbar.Enabled := False;
CoolBand.Visible := True;
CoolBand.MinWidth := 25;
CoolBand.MinHeight := 22;
CoolBand.FixedSize := True;
FTempList.Items[I].ClearToolbar;
for J := 0 to FTempList.Items[I].ButtonNames.Count - 1 do
FTempList.Items[I].AddCustomItems(J);
FTempCoolBar.ToolBars[I].ClearToolbar;
for J := 0 to FTempCoolBar.ToolBars[I].ButtonNames.Count - 1 do
FTempCoolBar.ToolBars[I].AddCustomItems(J);
end;
if CoolBar.Bands.Count > 0 then
SelectBand(0);
@ -406,12 +406,12 @@ end;
constructor TToolbarOptionsFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FTempList := TIDEToolBarList.Create;
FTempCoolBar := TIDEcoolBar.Create(Nil);
end;
destructor TToolbarOptionsFrame.Destroy;
begin
FreeAndNil(FTempList);
FreeAndNil(FTempCoolBar);
inherited Destroy;
end;
@ -420,7 +420,7 @@ var
CoolBand: TCoolBand;
IDEToolbar: TIDEToolBar;
begin
IDEToolbar := FTempList.Add;
IDEToolbar := FTempCoolBar.Add;
IDEToolbar.Break := False;
IDEToolbar.OnToolBarClick := @ToolBarClick;
@ -453,16 +453,16 @@ begin
ToolBar := (Coolbar.Bands.Items[ToConfig].Control as TToolBar);
if ToolBar <> nil then
begin
ToConfig := FTempList.FindByToolBar(ToolBar);
ToConfig := FTempCoolBar.FindByToolBar(ToolBar);
if ToConfig <> -1 then
begin
fToolBarConfig.LoadSettings(FTempList.Items[ToConfig].ButtonNames);
fToolBarConfig.LoadSettings(FTempCoolBar.ToolBars[ToConfig].ButtonNames);
if fToolBarConfig.ShowModal = mrOK then
begin
FTempList.Items[ToConfig].ClearToolbar;
fToolBarConfig.SaveSettings(FTempList.Items[ToConfig].ButtonNames);
for I := 0 to FTempList.Items[ToConfig].ButtonNames.Count - 1 do
FTempList.Items[ToConfig].AddCustomItems(I);
FTempCoolBar.ToolBars[ToConfig].ClearToolbar;
fToolBarConfig.SaveSettings(FTempCoolBar.ToolBars[ToConfig].ButtonNames);
for I := 0 to FTempCoolBar.ToolBars[ToConfig].ButtonNames.Count - 1 do
FTempCoolBar.ToolBars[ToConfig].AddCustomItems(I);
end;
end;
end;
@ -492,9 +492,9 @@ begin
SelectBand(ToDelete + 1)
else if ToDelete - 1 >= 0 then
SelectBand(ToDelete - 1);
I := FTempList.FindByToolBar((CoolBar.Bands.Items[ToDelete].Control as TToolBar));
I := FTempCoolBar.FindByToolBar((CoolBar.Bands.Items[ToDelete].Control as TToolBar));
if I <> -1 then
FTempList.Delete(I);
FTempCoolBar.ToolBars.Delete(I);
CoolBar.Bands.Delete(ToDelete);
end;
end;
@ -517,9 +517,9 @@ procedure TToolbarOptionsFrame.bDefaultToolbarClick(Sender: TObject);
var
IDEToolBar: TIDEToolBar;
begin
FTempList.Clear;
FTempCoolBar.ToolBars.Clear;
//standard
IDEToolBar := FTempList.Add;
IDEToolBar := FTempCoolBar.Add;
IDEToolBar.Position := 0;
IDEToolBar.Break := False;
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileNew/itmFileNewForm');
@ -532,7 +532,7 @@ begin
IDEToolBar.ButtonNames.Add('IDEMainMenu/View/itmViewMainWindows/itmViewToggleFormUnit');
//debug
IDEToolBar := FTempList.Add;
IDEToolBar := FTempCoolBar.Add;
IDEToolBar.Position := 1;
IDEToolBar.Break := True;
IDEToolBar.ButtonNames.Add('IDEMainMenu/Project/itmProjectAddRemoveSection/itmProjectViewUnits');

View File

@ -94,7 +94,7 @@ uses
// help manager
IDEContextHelpEdit, IDEHelpIntf, IDEHelpManager, CodeHelp, HelpOptions,
// designer
JITForms, ComponentPalette, ComponentList, CompPagesPopup,
JITForms, ComponentPalette, ComponentList, CompPagesPopup, ToolbarData,
ObjInspExt, Designer, FormEditor, CustomFormEditor, lfmUnitResource,
ControlSelection, AnchorEditor, TabOrderDlg, MenuEditorForm,
// LRT stuff
@ -1631,6 +1631,7 @@ begin
TComponentPalette(IDEComponentPalette).PageControl:=nil;
FreeThenNil(PkgBoss);
FreeThenNil(IDEComponentPalette);
FreeThenNil(IDECoolBar);
FreeThenNil(HelpBoss);
FreeThenNil(DebugBoss);
FreeThenNil(TheCompiler);
@ -2025,18 +2026,15 @@ begin
if EnvironmentOptions.ComponentPaletteVisible then
begin
MainIDEBar.CoolBar.Align := alLeft;
MainIDEBar.CoolBar.Width := EnvironmentOptions.IDECoolBarWidth;
MainIDEBar.CoolBar.Width := EnvironmentOptions.IDECoolBarOptions.IDECoolBarWidth;
end
else
MainIDEBar.CoolBar.Align := alClient;
MainIDEBar.CoolBar.Vertical := False;
MainIDEBar.CoolBar.HorizontalSpacing := 1;
MainIDEBar.CoolBar.VerticalSpacing := 3;
MainIDEBar.CoolBar.FixedSize := True;
MainIDEBar.CoolBar.DoubleBuffered := True;
MainIDEBar.CoolBar.EdgeInner := esNone;
MainIDEBar.CoolBar.EdgeOuter := esNone;
MainIDEBar.CoolBar.Visible := EnvironmentOptions.IDECoolBarVisible;
// IDE Coolbar object wraps MainIDEBar.CoolBar.
IDECoolBar:=TIDECoolBar.Create(MainIDEBar.CoolBar);
IDECoolBar.SetCoolBarDefaults;
IDECoolBar.CreateDefaultToolbars;
MainIDEBar.CoolBar.Visible := EnvironmentOptions.IDECoolBarOptions.IDECoolBarVisible;
MainIDEBar.CoolBar.OnChange := @MainIDEBar.CoolBarOnChange;
MainIDEBar.CreatePopupMenus(OwningComponent);
@ -3715,7 +3713,7 @@ begin
if MainIDEBar.CoolBar.Align = alClient then
begin
MainIDEBar.CoolBar.Width := 230;
EnvironmentOptions.IDECoolBarWidth := 230;
EnvironmentOptions.IDECoolBarOptions.IDECoolBarWidth := 230;
end;
MainIDEBar.CoolBar.Align := alLeft;
MainIDEBar.CoolBar.Vertical := False;
@ -3735,7 +3733,7 @@ begin
MainIDEBar.itmViewIDESpeedButtons.Checked := SpeedButtonsVisible;
MainIDEBar.CoolBar.Visible := SpeedButtonsVisible;
MainIDEBar.MainSplitter.Visible := SpeedButtonsVisible;
EnvironmentOptions.IDECoolBarVisible := SpeedButtonsVisible;
EnvironmentOptions.IDECoolBarOptions.IDECoolBarVisible := SpeedButtonsVisible;
MainIDEBar.MainSplitter.Visible := MainIDEBar.Coolbar.Visible and
MainIDEBar.ComponentPageControl.Visible;
end;

View File

@ -42,7 +42,7 @@ uses
ComCtrls, ExtCtrls, LMessages,
// IDEIntf
ProjectIntf, NewItemIntf, MenuIntf, LazIDEIntf, LazFileCache,
EnvironmentOpts, LazarusIDEStrConsts, IDEImagesIntf;
EnvironmentOpts, LazarusIDEStrConsts, IDEImagesIntf, ToolbarData;
type
{ TMainIDEBar }
@ -540,33 +540,35 @@ procedure TMainIDEBar.RefreshCoolbar;
var
I, J: Integer;
CoolBand: TCoolBand;
CoolBarOpts: TIDECoolBarOptions;
begin
EnvironmentOptions.IDEToolBarList.Sort;
CoolBarOpts := EnvironmentOptions.IDECoolBarOptions;
IDECoolBar.Sort;
//read general settings
if not (EnvironmentOptions.IDECoolBarGrabStyle in [0..5]) then
EnvironmentOptions.IDECoolBarGrabStyle := 4;
Coolbar.GrabStyle := TGrabStyle(EnvironmentOptions.IDECoolBarGrabStyle);
if not (EnvironmentOptions.IDECoolBarGrabWidth in [1..50]) then
EnvironmentOptions.IDECoolBarGrabWidth := 5;
Coolbar.GrabWidth := EnvironmentOptions.IDECoolBarGrabWidth;
Coolbar.BandBorderStyle := TBorderStyle(EnvironmentOptions.IDECoolBarBorderStyle);
if not (CoolBarOpts.IDECoolBarGrabStyle in [0..5]) then
CoolBarOpts.IDECoolBarGrabStyle := 4;
Coolbar.GrabStyle := TGrabStyle(CoolBarOpts.IDECoolBarGrabStyle);
if not (CoolBarOpts.IDECoolBarGrabWidth in [1..50]) then
CoolBarOpts.IDECoolBarGrabWidth := 5;
Coolbar.GrabWidth := CoolBarOpts.IDECoolBarGrabWidth;
Coolbar.BandBorderStyle := TBorderStyle(CoolBarOpts.IDECoolBarBorderStyle);
//read toolbars
CoolBar.Bands.Clear;
for I := 0 to EnvironmentOptions.IDEToolBarList.Count - 1 do
for I := 0 to IDECoolBar.ToolBars.Count - 1 do
begin
CoolBand := CoolBar.Bands.Add;
CoolBand.Break := EnvironmentOptions.IDEToolBarList.Items[I].Break;
CoolBand.Control := EnvironmentOptions.IDEToolBarList.Items[I].Toolbar;
CoolBand.Break := IDECoolBar.ToolBars[I].Break;
CoolBand.Control := IDECoolBar.ToolBars[I].Toolbar;
CoolBand.MinWidth := 25;
CoolBand.MinHeight := 22;
CoolBand.FixedSize := True;
EnvironmentOptions.IDEToolBarList.Items[I].ClearToolbar;
for J := 0 to EnvironmentOptions.IDEToolBarList.Items[I].ButtonNames.Count - 1 do
EnvironmentOptions.IDEToolBarList.Items[I].AddCustomItems(J);
IDECoolBar.ToolBars[I].ClearToolbar;
for J := 0 to IDECoolBar.ToolBars[I].ButtonNames.Count - 1 do
IDECoolBar.ToolBars[I].AddCustomItems(J);
end;
CoolBar.AutosizeBands;
CoolBar.Visible := EnvironmentOptions.IDECoolBarVisible;
CoolBar.Visible := CoolBarOpts.IDECoolBarVisible;
itmViewIDESpeedButtons.Checked := CoolBar.Visible;
MainSplitter.Align := alLeft;
MainSplitter.Visible := MainIDEBar.Coolbar.Visible and
@ -576,7 +578,7 @@ end;
procedure TMainIDEBar.MainSplitterMoved(Sender: TObject);
begin
EnvironmentOptions.IDECoolBarWidth := CoolBar.Width;
EnvironmentOptions.IDECoolBarOptions.IDECoolBarWidth := CoolBar.Width;
end;
procedure TMainIDEBar.CoolBarOnChange(Sender: TObject);
@ -589,14 +591,14 @@ begin
if Coolbar.Bands[I].Control = nil then
Continue;
ToolBar := (Coolbar.Bands[I].Control as TToolBar);
J := EnvironmentOptions.IDEToolBarList.FindByToolBar(ToolBar);
J := IDECoolBar.FindByToolBar(ToolBar);
if J <> -1 then
begin
EnvironmentOptions.IDEToolBarList.Items[J].Position := Coolbar.Bands[I].Index;
EnvironmentOptions.IDEToolBarList.Items[J].Break := Coolbar.Bands[I].Break;
IDECoolBar.ToolBars[J].Position := Coolbar.Bands[I].Index;
IDECoolBar.ToolBars[J].Break := Coolbar.Bands[I].Break;
end
end;
EnvironmentOptions.IDEToolBarList.Sort;
IDECoolBar.Sort;
end;

View File

@ -770,7 +770,7 @@ begin
CreateMenuItem(ParentMI,itmViewComponentPalette,'itmViewComponentPalette',lisMenuViewComponentPalette, '',
true, EnvironmentOptions.ComponentPaletteVisible);
CreateMenuItem(ParentMI,itmViewIDESpeedButtons,'itmViewIDESpeedButtons',lisMenuViewIDESpeedButtons, '',
true, EnvironmentOptions.IDECoolBarVisible);
true, EnvironmentOptions.IDECoolBarOptions.IDECoolBarVisible);
end;
end;

View File

@ -21,6 +21,8 @@
Author: Balázs Székely
Abstract:
The implementation of IDE Coolbar.
ToDo:
Extract an interface from here and put it to IdeIntf package.
}
unit ToolbarData;
@ -32,9 +34,61 @@ interface
uses
Classes, SysUtils, LCLProc, ComCtrls, ExtCtrls, ToolWin,
MenuIntf, IDEImagesIntf, IDECommands;
MenuIntf, IDEImagesIntf, IDECommands, Laz2_XMLCfg, fgl;
type
// Option classes take care of saving / loading environment options data.
// They don't contain LCL components.
{ TIDEToolBarOptions }
TIDEToolBarOptions = class
private
Break: Boolean;
ButtonNames: TStringList;
end;
TIDEToolBarOptionList = specialize TFPGObjectList<TIDEToolBarOptions>;
{ TIDECoolBarOptions }
TIDECoolBarOptions = class
private
//toolbars
FToolbarVisible: Boolean;
FToolBarStandardVisible: Boolean;
FToolBarStandardLeft: Integer;
FToolBarStandardTop: Integer;
FToolBarViewDebugVisible: Boolean;
FToolBarViewDebugLeft: Integer;
FToolBarViewDebugTop: Integer;
FToolBarHighlight: Boolean;
FToolBarRaised: Boolean;
FToolBars: TIDEToolBarOptionList;
//coolbar
FIDECoolBarVisible: Boolean;
FIDECoolBarWidth: Integer;
FIDECoolBarGrabStyle: Integer;
FIDECoolBarGrabWidth: Integer;
FIDECoolBarBorderStyle: Integer;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
//procedure Assign(Source: TIDECoolBarOptions);
function IsDefault: Boolean;
function Load(XMLConfig: TXMLConfig): boolean;
function Save(XMLConfig: TXMLConfig): boolean;
public
property ToolBars: TIDEToolBarOptionList read FToolBars;
property IDECoolBarVisible: Boolean read FIDECoolBarVisible write FIDECoolBarVisible;
property IDECoolBarWidth: Integer read FIDECoolBarWidth write FIDECoolBarWidth;
property IDECoolBarGrabStyle: Integer read FIDECoolBarGrabStyle write FIDECoolBarGrabStyle;
property IDECoolBarGrabWidth: Integer read FIDECoolBarGrabWidth write FIDECoolBarGrabWidth;
property IDECoolBarBorderStyle: Integer read FIDECoolBarBorderStyle write FIDECoolBarBorderStyle;
end;
// Actual Coolbar and its member Toolbars
TOnToolBarClick = procedure(Sender: TObject) of object;
{ TIDEToolBar }
@ -63,29 +117,12 @@ type
public
property Position: Integer read FPosition write FPosition;
property Break: Boolean read FBreak write FBreak;
property ButtonNames: TStringList read FButtonNames write FButtonNames;
property ButtonNames: TStringList read FButtonNames;
property Toolbar: TToolBar read FToolBar;
property OnToolBarClick: TOnToolbarClick read FOnToolbarClick write FOnToolbarClick;
end;
{ TIDEToolBarList }
TIDEToolBarList = class
private
FToolBarList: TFPList;
function GetItems(Index: integer): TIDEToolBar;
function GetCount: Integer;
public
constructor Create;
destructor Destroy; override;
function Add: TIDEToolBar;
function FindByToolBar(const ToolBar: TToolBar): Integer;
procedure Delete(const Index: Integer);
procedure Clear;
procedure Sort;
public
property Items[Index: Integer]: TIDEToolBar read GetItems;
property Count: Integer read GetCount;
end;
TIDEToolBarList = specialize TFPGObjectList<TIDEToolBar>;
{ TIDEToolBarToolButton }
TIDEToolBarToolButton = class(TToolButton)
@ -96,18 +133,172 @@ type
property IdeMenuItem: TIDEMenuItem read FMenuItem write FMenuItem;
end;
{ TIDECoolBar }
TIDECoolBar = class
private
FCoolBar: TCoolBar; // The actual CoolBar, not owned by this class.
FToolBars: TIDEToolBarList;
public
constructor Create(ACoolBar: TCoolBar);
destructor Destroy; override;
procedure SetCoolBarDefaults;
procedure CreateDefaultToolbars;
procedure CopyFromOptions(Options: TIDECoolBarOptions);
procedure CopyToOptions(Options: TIDECoolBarOptions);
function Add: TIDEToolBar;
function FindByToolBar(const ToolBar: TToolBar): Integer;
procedure Sort;
public
property ToolBars: TIDEToolBarList read FToolBars;
property CoolBar: TCoolBar read FCoolBar;
end;
function GetShortcut(AMenuItem: TIDEMenuItem): string;
var
IDECoolBar: TIDECoolBar;
implementation
uses MainBar;
{ TEditToolBarToolButton }
procedure TIDEToolBarToolButton.Click;
const
BasePath = 'IDECoolBarOptions/';
{ TIDECoolBarOptions }
constructor TIDECoolBarOptions.Create;
begin
inherited Click;
if assigned(FMenuItem) then
FMenuItem.TriggerClick;
inherited Create;
FToolBars := TIDEToolBarOptionList.Create;
FToolbarVisible := False;
FToolBarStandardVisible := False;
FToolBarStandardLeft := 0;
FToolBarStandardTop := 0;
FToolBarViewDebugVisible := False;
FToolBarViewDebugLeft := 0;
FToolBarViewDebugTop := 26;
FToolBarHighlight := False;
FToolBarRaised := False;
//coolbar
FIDECoolBarVisible := True;
FIDECoolBarWidth := 230;
FIDECoolBarGrabStyle := 1;
FIDECoolBarGrabWidth := 5;
FIDECoolBarBorderStyle := 1;
end;
destructor TIDECoolBarOptions.Destroy;
begin
FToolBars.Free;
inherited Destroy;
end;
procedure TIDECoolBarOptions.Clear;
begin
FToolBars.Clear;
end;
{
procedure TIDECoolBarOptions.Assign(Source: TIDECoolBarOptions);
begin
end;
}
function TIDECoolBarOptions.IsDefault: Boolean;
begin
// ToDo: Implement
Result := False;
end;
function TIDECoolBarOptions.Load(XMLConfig: TXMLConfig): boolean;
var
ToolBarOpt: TIDEToolBarOptions;
ToolBarCount: Integer;
ButtonCount: Integer;
ButtonName: string;
SubPath: String;
I, J: Integer;
begin
//Coolbar
FIDECoolBarVisible := XMLConfig.GetValue(BasePath + 'Visible/Value', True);
FIDECoolBarWidth := XMLConfig.GetValue(BasePath + 'Width/Value', 230);
FIDECoolBarGrabStyle := XMLConfig.GetValue(BasePath + 'GrabStyle/Value', 1);
FIDECoolBarGrabWidth := XMLConfig.GetValue(BasePath + 'GrabWidth/Value', 5);
FIDECoolBarBorderStyle := XMLConfig.GetValue(BasePath + 'BorderStyle/Value', 5);
ToolbarCount := XMLConfig.GetValue(BasePath + 'ToolBarCount/Value', 0);
if ToolBarCount > 0 then
begin
FToolBars.Clear;
SubPath := BasePath + 'ToolBar';
for I := 0 to ToolbarCount - 1 do
begin
ToolBarOpt := TIDEToolBarOptions.Create;
FToolBars.Add(ToolBarOpt);
ToolBarOpt.Break := XMLConfig.GetValue(SubPath + IntToStr(I) + '/Break/Value', False);
ButtonCount := XMLConfig.GetValue(SubPath + IntToStr(I) + '/ButtonCount/Value', 0);
for J := 0 to ButtonCount - 1 do
begin
ButtonName := Trim(XMLConfig.GetValue(
SubPath + IntToStr(I) + '/Buttons/Name' + IntToStr(J) + '/Value', ''));
if ButtonName <> '' then
ToolBarOpt.ButtonNames.Add(ButtonName);
end;
end;
end;
// Toolbar
FToolBarStandardVisible := XMLConfig.GetValue(BasePath+'Toolbars/Standard/Visible/Value', True);
FToolBarStandardLeft := XMLConfig.GetValue(BasePath+'Toolbars/Standard/Left/Value', 0);
FToolBarStandardTop := XMLConfig.GetValue(BasePath+'Toolbars/Standard/Top/Value', 0);
FToolBarViewDebugVisible :=XMLConfig.GetValue(BasePath+'Toolbars/ViewDebug/Visible/Value', True);
FToolBarViewDebugLeft := XMLConfig.GetValue(BasePath+'Toolbars/ViewDebug/Left/Value', 0);
FToolBarViewDebugTop := XMLConfig.GetValue(BasePath+'Toolbars/ViewDebug/Top/Value', 26);
FToolbarVisible := XMLConfig.GetValue(BasePath+'Toolbars/Common/Visible/Value', True);
FToolBarHighlight := XMLConfig.GetValue(BasePath+'Toolbars/Common/Highlight/Value', False);
FToolBarRaised := XMLConfig.GetValue(BasePath+'Toolbars/Common/Raised/Value', False);
end;
function TIDECoolBarOptions.Save(XMLConfig: TXMLConfig): boolean;
var
ToolBarOpt: TIDEToolBarOptions;
SubPath: String;
I, J: Integer;
begin
// toolbar
XMLConfig.SetDeleteValue(BasePath+'Toolbars/Standard/Visible/Value',FToolBarStandardVisible, True);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/Standard/Left/Value',FToolBarStandardLeft, 0);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/Standard/Top/Value',FToolBarStandardTop, 0);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/ViewDebug/Visible/Value',FToolBarViewDebugVisible, True);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/ViewDebug/Left/Value',FToolBarViewDebugLeft, 0);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/ViewDebug/Top/Value',FToolBarViewDebugTop, 26);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/Common/Visible/Value',FToolbarVisible, True);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/Common/Highlight/Value',FToolBarHighlight, False);
XMLConfig.SetDeleteValue(BasePath+'Toolbars/Common/Raised/Value',FToolBarRaised, False);
//coolbar
XMLConfig.DeletePath(BasePath);
XMLConfig.SetDeleteValue(BasePath + 'Visible/Value', FIDECoolBarVisible, True);
XMLConfig.SetDeleteValue(BasePath + 'Width/Value', FIDECoolBarWidth, 0);
XMLConfig.SetDeleteValue(BasePath + 'GrabStyle/Value', FIDECoolBarGrabStyle, 1);
XMLConfig.SetDeleteValue(BasePath + 'GrabWidth/Value', FIDECoolBarGrabWidth, 5);
XMLConfig.SetDeleteValue(BasePath + 'BorderStyle/Value', FIDECoolBarBorderStyle, 5);
if FToolBars.Count > 0 then
begin
XMLConfig.SetDeleteValue(BasePath + 'ToolBarCount/Value', FToolBars.Count, 0);
SubPath := BasePath + 'ToolBar';
for I := 0 to FToolBars.Count - 1 do
begin
XMLConfig.SetDeleteValue(SubPath + IntToStr(I) + '/Break/Value',
FToolBars[I].Break, False);
XMLConfig.SetDeleteValue(SubPath + IntToStr(I) + '/ButtonCount/Value',
FToolBars[I].ButtonNames.Count, 0);
for J := 0 to FToolBars[I].ButtonNames.Count - 1 do
XMLConfig.SetDeleteValue(SubPath + IntToStr(I) + '/Buttons/Name' + IntToStr(J) + '/Value',
FToolBars[I].ButtonNames[J], '');
end;
end;
end;
{ TIDEToolBar }
@ -295,43 +486,116 @@ begin
end;
{ TIDEToolBarList }
function TIDEToolBarList.GetItems(Index: integer): TIDEToolBar;
{ TEditToolBarToolButton }
procedure TIDEToolBarToolButton.Click;
begin
Result := TIDEToolBar(FToolBarList[Index]);
inherited Click;
if assigned(FMenuItem) then
FMenuItem.TriggerClick;
end;
constructor TIDEToolBarList.Create;
{ TIDECoolBar }
constructor TIDECoolBar.Create(ACoolBar: TCoolBar);
begin
inherited Create;
FToolBarList := TFPList.Create;
FCoolBar := ACoolBar;
FToolBars := TIDEToolBarList.Create;
end;
destructor TIDEToolBarList.Destroy;
destructor TIDECoolBar.Destroy;
begin
Clear;
FreeAndNil(FToolBarList);
FreeAndNil(FToolBars);
inherited Destroy;
end;
function TIDEToolBarList.Add: TIDEToolBar;
procedure TIDECoolBar.SetCoolBarDefaults;
begin
FCoolBar.Vertical := False;
FCoolBar.HorizontalSpacing := 1;
FCoolBar.VerticalSpacing := 3;
FCoolBar.FixedSize := True;
FCoolBar.DoubleBuffered := True;
FCoolBar.EdgeInner := esNone;
FCoolBar.EdgeOuter := esNone;
end;
procedure TIDECoolBar.CreateDefaultToolbars;
var
IDEToolBar: TIDEToolBar;
begin
//standard toolbar defaults
IDEToolBar := Add;
IDEToolBar.Position := 0;
IDEToolBar.Break := False;
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileNew/itmFileNewForm');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileNew/itmFileNewUnit');
IDEToolBar.ButtonNames.Add('---------------');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileOpenSave/itmFileOpen');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileOpenSave/itmFileSave');
IDEToolBar.ButtonNames.Add('IDEMainMenu/File/itmFileOpenSave/itmFileSaveAll');
IDEToolBar.ButtonNames.Add('---------------');
IDEToolBar.ButtonNames.Add('IDEMainMenu/View/itmViewMainWindows/itmViewToggleFormUnit');
//debug toolbar defaults
IDEToolBar := Add;
IDEToolBar.Position := 1;
IDEToolBar.Break := True;
IDEToolBar.ButtonNames.Add('IDEMainMenu/Project/itmProjectAddRemoveSection/itmProjectViewUnits');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Project/itmProjectAddRemoveSection/itmProjectViewForms');
IDEToolBar.ButtonNames.Add('---------------');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Project/itmProjectAddRemoveSection/itmProjectBuildMode');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuRun');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuPause');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStop');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStepOver');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStepInto');
IDEToolBar.ButtonNames.Add('IDEMainMenu/Run/itmRunnning/itmRunMenuStepOut');
end;
procedure TIDECoolBar.CopyFromOptions(Options: TIDECoolBarOptions);
var
I: Integer;
IDEToolBar: TIDEToolBar;
begin
IDEToolBar := TIDEToolBar.Create;
I := FToolBarList.Add(IDEToolBar);
Result := Items[I];
FToolBars.Clear;
for I := 0 to Options.FToolBars.Count-1 do
begin
IDEToolBar := Add;
IDEToolBar.Position := I;
IDEToolBar.Break := Options.FToolBars[I].Break;
IDEToolBar.ButtonNames.Assign(Options.FToolBars[I].ButtonNames);
end;
end;
function TIDEToolBarList.FindByToolBar(const ToolBar: TToolBar): Integer;
procedure TIDECoolBar.CopyToOptions(Options: TIDECoolBarOptions);
var
I: Integer;
Opt: TIDEToolBarOptions;
begin
Options.FToolBars.Clear;
for I := 0 to FToolBars.Count - 1 do
begin
Opt := TIDEToolBarOptions.Create;
Options.FToolBars.Add(Opt);
Opt.Break := FToolBars[I].Break;
Opt.ButtonNames.Assign(FToolBars[I].ButtonNames);
end;
end;
function TIDECoolBar.Add: TIDEToolBar;
begin
Result := TIDEToolBar.Create;
FToolBars.Add(Result);
end;
function TIDECoolBar.FindByToolBar(const ToolBar: TToolBar): Integer;
var
I: Integer;
begin
Result := -1;
for I := 0 to FToolBarList.Count - 1 do
for I := 0 to FToolBars.Count - 1 do
begin
if Items[I].Toolbar = Toolbar then
if ToolBars[I].Toolbar = Toolbar then
begin
Result := I;
Break;
@ -339,34 +603,14 @@ begin
end;
end;
procedure TIDEToolBarList.Delete(const Index: Integer);
function Compare(const Item1, Item2: TIDEToolBar): Integer;
begin
Items[Index].Free;
FToolBarList.Delete(Index);
Result := Item1.Position - Item2.Position;
end;
procedure TIDEToolBarList.Clear;
var
I: Integer;
procedure TIDECoolBar.Sort;
begin
for I := 0 to FToolBarList.Count - 1 do
Items[I].Free;
FToolBarList.Clear;
end;
function Compare(Item1, Item2: Pointer): Integer;
begin
Result := TIDEToolBar(Item1).Position - TIDEToolBar(Item2).Position;
end;
procedure TIDEToolBarList.Sort;
begin
FToolBarList.Sort(@Compare);
end;
function TIDEToolBarList.GetCount: Integer;
begin
Result := FToolBarList.Count;
FToolBars.Sort(@Compare);
end;
function GetShortcut(AMenuItem: TIDEMenuItem): string;