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; FCompletionWindowWidth: Integer;
FCompletionWindowHeight: Integer; FCompletionWindowHeight: Integer;
//toolbars // IDE Coolbar
FToolbarVisible: Boolean; FIDECoolBarOptions: TIDECoolBarOptions;
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;
// component palette // component palette
FComponentPaletteOptions: TCompPaletteOptions; FComponentPaletteOptions: TCompPaletteOptions;
@ -540,18 +523,8 @@ type
property IDENameForDesignedFormList: boolean read FIDENameForDesignedFormList property IDENameForDesignedFormList: boolean read FIDENameForDesignedFormList
write FIDENameForDesignedFormList; write FIDENameForDesignedFormList;
//coolbar // IDE Coolbar
property IDEToolBarList: TIDEToolBarList read FIDEToolBarList; property IDECoolBarOptions: TIDECoolBarOptions read FIDECoolBarOptions;
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;
// component palette // component palette
property ComponentPaletteOptions: TCompPaletteOptions read FComponentPaletteOptions; property ComponentPaletteOptions: TCompPaletteOptions read FComponentPaletteOptions;
@ -866,7 +839,6 @@ constructor TEnvironmentOptions.Create;
var var
o: TEnvOptParseType; o: TEnvOptParseType;
c: TMsgWndColor; c: TMsgWndColor;
IDEToolBar: TIDEToolBar;
begin begin
inherited Create; inherited Create;
for o:=low(FParseValues) to high(FParseValues) do for o:=low(FParseValues) to high(FParseValues) do
@ -927,50 +899,8 @@ begin
FCompletionWindowWidth := 320; FCompletionWindowWidth := 320;
FCompletionWindowHeight := 6; FCompletionWindowHeight := 6;
FToolbarVisible := False; // IDE Coolbar
FToolBarStandardVisible := False; FIDECoolBarOptions:=TIDECoolBarOptions.Create;
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');
// component palette // component palette
FComponentPaletteOptions:=TCompPaletteOptions.Create; FComponentPaletteOptions:=TCompPaletteOptions.Create;
@ -1079,7 +1009,7 @@ begin
FreeAndNil(FRecentPackageFiles); FreeAndNil(FRecentPackageFiles);
FreeAndNil(FObjectInspectorOptions); FreeAndNil(FObjectInspectorOptions);
FreeAndNil(FComponentPaletteOptions); FreeAndNil(FComponentPaletteOptions);
FreeAndNil(FIDEToolBarList); FreeAndNil(FIDECoolBarOptions);
FreeAndNil(FLazarusDirHistory); FreeAndNil(FLazarusDirHistory);
FreeAndNil(FCompilerFileHistory); FreeAndNil(FCompilerFileHistory);
FreeAndNil(FFPCSourceDirHistory); FreeAndNil(FFPCSourceDirHistory);
@ -1205,10 +1135,6 @@ var
EventType: TDBGEventType; EventType: TDBGEventType;
NodeName: String; NodeName: String;
mwc: TMsgWndColor; mwc: TMsgWndColor;
IDEToolBar: TIDEToolBar;
IDEToolBarCount: Integer;
IDEToolBarButtonsCount: Integer;
IDEToolBarButtonsName: string;
begin begin
Cfg:=nil; Cfg:=nil;
try try
@ -1274,58 +1200,6 @@ begin
FIDENameForDesignedFormList:=XMLConfig.GetValue( FIDENameForDesignedFormList:=XMLConfig.GetValue(
Path+'Desktop/IDENameForDesignedFormList/Value',false); 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 // form editor
FShowGrid:=XMLConfig.GetValue( FShowGrid:=XMLConfig.GetValue(
Path+'FormEditor/ShowGrid',true); Path+'FormEditor/ShowGrid',true);
@ -1581,6 +1455,8 @@ begin
FLowercaseDefaultFilename:=XMLConfig.GetValue( FLowercaseDefaultFilename:=XMLConfig.GetValue(
Path+'LowercaseDefaultFilename/Value',true); Path+'LowercaseDefaultFilename/Value',true);
// IDE Coolbar
FIDECoolBarOptions.Load(XMLConfig);
// component palette // component palette
FComponentPaletteOptions.Load(XMLConfig); FComponentPaletteOptions.Load(XMLConfig);
@ -1710,61 +1586,6 @@ begin
XMLConfig.SetDeleteValue(Path+'Desktop/IDENameForDesignedFormList/Value', XMLConfig.SetDeleteValue(Path+'Desktop/IDENameForDesignedFormList/Value',
FIDENameForDesignedFormList,false); 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 // form editor
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowBorderSpacing', XMLConfig.SetDeleteValue(Path+'FormEditor/ShowBorderSpacing',
FShowBorderSpacing,false); FShowBorderSpacing,false);
@ -1998,6 +1819,8 @@ begin
XMLConfig.SetDeleteValue(Path+'LowercaseDefaultFilename/Value', XMLConfig.SetDeleteValue(Path+'LowercaseDefaultFilename/Value',
FLowercaseDefaultFilename,true); FLowercaseDefaultFilename,true);
// IDE Coolbar
FIDECoolBarOptions.Save(XMLConfig);
// component palette // component palette
FComponentPaletteOptions.Save(XMLConfig); FComponentPaletteOptions.Save(XMLConfig);

View File

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

View File

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

View File

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

View File

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

View File

@ -21,6 +21,8 @@
Author: Balázs Székely Author: Balázs Székely
Abstract: Abstract:
The implementation of IDE Coolbar. The implementation of IDE Coolbar.
ToDo:
Extract an interface from here and put it to IdeIntf package.
} }
unit ToolbarData; unit ToolbarData;
@ -32,9 +34,61 @@ interface
uses uses
Classes, SysUtils, LCLProc, ComCtrls, ExtCtrls, ToolWin, Classes, SysUtils, LCLProc, ComCtrls, ExtCtrls, ToolWin,
MenuIntf, IDEImagesIntf, IDECommands; MenuIntf, IDEImagesIntf, IDECommands, Laz2_XMLCfg, fgl;
type 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; TOnToolBarClick = procedure(Sender: TObject) of object;
{ TIDEToolBar } { TIDEToolBar }
@ -63,29 +117,12 @@ type
public public
property Position: Integer read FPosition write FPosition; property Position: Integer read FPosition write FPosition;
property Break: Boolean read FBreak write FBreak; 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 Toolbar: TToolBar read FToolBar;
property OnToolBarClick: TOnToolbarClick read FOnToolbarClick write FOnToolbarClick; property OnToolBarClick: TOnToolbarClick read FOnToolbarClick write FOnToolbarClick;
end; end;
{ TIDEToolBarList } TIDEToolBarList = specialize TFPGObjectList<TIDEToolBar>;
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;
{ TIDEToolBarToolButton } { TIDEToolBarToolButton }
TIDEToolBarToolButton = class(TToolButton) TIDEToolBarToolButton = class(TToolButton)
@ -96,18 +133,172 @@ type
property IdeMenuItem: TIDEMenuItem read FMenuItem write FMenuItem; property IdeMenuItem: TIDEMenuItem read FMenuItem write FMenuItem;
end; 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; function GetShortcut(AMenuItem: TIDEMenuItem): string;
var
IDECoolBar: TIDECoolBar;
implementation implementation
uses MainBar; uses MainBar;
{ TEditToolBarToolButton } const
procedure TIDEToolBarToolButton.Click; BasePath = 'IDECoolBarOptions/';
{ TIDECoolBarOptions }
constructor TIDECoolBarOptions.Create;
begin begin
inherited Click; inherited Create;
if assigned(FMenuItem) then FToolBars := TIDEToolBarOptionList.Create;
FMenuItem.TriggerClick; 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; end;
{ TIDEToolBar } { TIDEToolBar }
@ -295,43 +486,116 @@ begin
end; end;
{ TIDEToolBarList } { TEditToolBarToolButton }
function TIDEToolBarList.GetItems(Index: integer): TIDEToolBar; procedure TIDEToolBarToolButton.Click;
begin begin
Result := TIDEToolBar(FToolBarList[Index]); inherited Click;
if assigned(FMenuItem) then
FMenuItem.TriggerClick;
end; end;
constructor TIDEToolBarList.Create;
{ TIDECoolBar }
constructor TIDECoolBar.Create(ACoolBar: TCoolBar);
begin begin
inherited Create; inherited Create;
FToolBarList := TFPList.Create; FCoolBar := ACoolBar;
FToolBars := TIDEToolBarList.Create;
end; end;
destructor TIDEToolBarList.Destroy; destructor TIDECoolBar.Destroy;
begin begin
Clear; FreeAndNil(FToolBars);
FreeAndNil(FToolBarList);
inherited Destroy; inherited Destroy;
end; 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 var
I: Integer; I: Integer;
IDEToolBar: TIDEToolBar; IDEToolBar: TIDEToolBar;
begin begin
IDEToolBar := TIDEToolBar.Create; FToolBars.Clear;
I := FToolBarList.Add(IDEToolBar); for I := 0 to Options.FToolBars.Count-1 do
Result := Items[I]; begin
IDEToolBar := Add;
IDEToolBar.Position := I;
IDEToolBar.Break := Options.FToolBars[I].Break;
IDEToolBar.ButtonNames.Assign(Options.FToolBars[I].ButtonNames);
end;
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 var
I: Integer; I: Integer;
begin begin
Result := -1; Result := -1;
for I := 0 to FToolBarList.Count - 1 do for I := 0 to FToolBars.Count - 1 do
begin begin
if Items[I].Toolbar = Toolbar then if ToolBars[I].Toolbar = Toolbar then
begin begin
Result := I; Result := I;
Break; Break;
@ -339,34 +603,14 @@ begin
end; end;
end; end;
procedure TIDEToolBarList.Delete(const Index: Integer); function Compare(const Item1, Item2: TIDEToolBar): Integer;
begin begin
Items[Index].Free; Result := Item1.Position - Item2.Position;
FToolBarList.Delete(Index);
end; end;
procedure TIDEToolBarList.Clear; procedure TIDECoolBar.Sort;
var
I: Integer;
begin begin
for I := 0 to FToolBarList.Count - 1 do FToolBars.Sort(@Compare);
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;
end; end;
function GetShortcut(AMenuItem: TIDEMenuItem): string; function GetShortcut(AMenuItem: TIDEMenuItem): string;