From fa97a5e9e9345fc1e716e0bd3a4d4d44681737a9 Mon Sep 17 00:00:00 2001 From: lazarus Date: Thu, 13 Jun 2002 06:34:18 +0000 Subject: [PATCH] MG: added build all button to configure build lazarus git-svn-id: trunk@1751 - --- designer/controlselection.pp | 194 ++++++++++++++++++++--------------- ide/buildlazdialog.pas | 72 +++++++++---- 2 files changed, 165 insertions(+), 101 deletions(-) diff --git a/designer/controlselection.pp b/designer/controlselection.pp index 962ef439bd..4b67804fbd 100644 --- a/designer/controlselection.pp +++ b/designer/controlselection.pp @@ -169,6 +169,7 @@ type function CompareVertCenter(Index1, Index2: integer): integer; protected procedure AdjustGrabber; + procedure DoApplyBounds; public constructor Create; destructor Destroy; override; @@ -182,20 +183,25 @@ type procedure Delete(Index:integer); procedure Clear; procedure Assign(AControlSelection:TControlSelection); - procedure AdjustSize; - property IsResizing: boolean read FIsResizing; function IsSelected(AComponent: TComponent): Boolean; procedure SaveBounds; + + property IsResizing: boolean read FIsResizing; + procedure BeginResizing; + procedure EndResizing; + procedure AdjustSize; procedure MoveSelection(dx, dy: integer); procedure SizeSelection(dx, dy: integer); + procedure SetBounds(NewLeft,NewTop,NewWidth,NewHeight: integer); // size all controls depending on ActiveGrabber. // if ActiveGrabber=nil then Right,Bottom - procedure AlignComponents(HorizAlignment, VertAlignment: TComponentAlignment); + procedure AlignComponents(HorizAlignment,VertAlignment:TComponentAlignment); procedure MirrorHorizontal; procedure MirrorVertical; procedure SizeComponents(HorizSizing: TComponentSizing; AWidth: integer; VertSizing: TComponentSizing; AHeight: integer); procedure ScaleComponents(Percent: integer); + property GrabberSize:integer read FGrabberSize write SetGrabberSize; property GrabberColor: TColor read FGrabberColor write FGrabberColor; procedure DrawGrabbers(DC: HDC); @@ -207,17 +213,20 @@ type procedure DrawMarker(AComponent:TComponent; DC:HDC); procedure DrawMarkerAt(ACanvas: TCanvas; ALeft, ATop, AWidth, AHeight: integer); property ActiveGrabber:TGrabber read FActiveGrabber write SetActiveGrabber; + property Left:integer read FLeft; property Top:integer read FTop; property Width:integer read FWidth; property Height:integer read FHeight; + property RubberbandBounds:TRect read FRubberbandBounds write SetRubberbandBounds; property RubberbandActive: boolean read FRubberbandActive write FRubberbandActive; procedure DrawRubberband(DC: HDC); - function OnlyNonVisualComponentsSelected: boolean; procedure SelectWithRubberBand(ACustomForm:TCustomForm; ExclusiveOr: boolean); + procedure Sort(SortProc: TSelectionSortCompare); property Visible:boolean read FVisible write SetVisible; + function OnlyNonVisualComponentsSelected: boolean; end; @@ -449,18 +458,31 @@ end; procedure TControlSelection.EndUpdate; begin - if FUpdateLock<=0 then exit; + if FUpdateLock<=0 then exit; + dec(FUpdateLock); + if FUpdateLock=0 then begin + try + if FChangedDuringLock then DoChange; + except + on E: Exception do + raise EGenException.Create( + 'Exception Occured in ControlSelection EndUpdate '+E.Message); + end; + end; +end; - dec(FUpdateLock); +procedure TControlSelection.BeginResizing; +begin + BeginUpdate; + FIsResizing:=true; +end; - if FUpdateLock=0 then - begin - try - if FChangedDuringLock then DoChange; - except - raise EGenException.Create('Exception Occured in ControlSelection EndUpdate'); - end; - end; +procedure TControlSelection.EndResizing; +begin + AdjustGrabber; + DoApplyBounds; + EndUpdate; + FIsResizing:=false; end; procedure TControlSelection.SetCustomForm; @@ -543,19 +565,64 @@ begin end; end; +procedure TControlSelection.DoApplyBounds; +var + i, NewLeft, NewTop, NewRight, NewBottom, NewWidth, NewHeight: integer; +begin + BeginUpdate; + if Count=1 then begin + // single selection + NewLeft:=FLeft; + NewTop:=FTop; + NewRight:=FLeft+FWidth; + NewBottom:=FTop+FHeight; + Items[0].SetBounds( + Min(NewLeft,NewRight), + Min(NewTop,NewBottom), + Abs(FWidth), + Abs(FHeight) + ); + end else if Count>1 then begin + // multi selection + if (FOldWidth<>0) and (FOldHeight<>0) then begin + for i:=0 to Count-1 do begin + NewLeft:=FLeft + (((Items[i].OldLeft-FOldLeft) * FWidth) div FOldWidth); + NewTop:=FTop + (((Items[i].OldTop-FOldTop) * FHeight) div FOldHeight); + NewWidth:=(Items[i].OldWidth*FWidth) div FOldWidth; + NewHeight:=(Items[i].OldHeight*FHeight) div FOldHeight; + if NewWidth<0 then begin + NewWidth:=-NewWidth; + dec(NewLeft,NewWidth); + end; + if NewWidth<1 then NewWidth:=1; + if NewHeight<0 then begin + NewHeight:=-NewHeight; + dec(NewTop,NewHeight); + end; + if NewHeight<1 then NewHeight:=1; + Items[i].SetBounds(NewLeft,NewTop,NewWidth,NewHeight); +writeln('[TControlSelection.SizeSelection] i=',i,' ',Items[i].Width,' ',Items[i].Height); + end; + end; + end; + EndUpdate; +end; + procedure TControlSelection.DoChange; begin -try - if (FUpdateLock>0) then - FChangedDuringLock:=true - else - begin - if Assigned(fOnChange) then fOnChange(Self); - FChangedDuringLock:=false; + try + if (FUpdateLock>0) then + FChangedDuringLock:=true + else + begin + if Assigned(fOnChange) then fOnChange(Self); + FChangedDuringLock:=false; + end; + except + on E: Exception do + raise EGenException.Create( + 'Exception Occured in ControlSelection DoChange '+E.Message); end; -except - raise EGenException.Create('Exception Occured in ControlSelection DoChange'); -end; end; procedure TControlSelection.SetVisible(const Value: Boolean); @@ -626,6 +693,7 @@ begin if i>=0 then Delete(i); end; +// remove a component from the selection procedure TControlSelection.Delete(Index:integer); begin if Index<0 then exit; @@ -672,38 +740,23 @@ begin end; procedure TControlSelection.MoveSelection(dx, dy: integer); -var i: integer; - g: TGrabIndex; begin if (dx=0) and (dy=0) then exit; - BeginUpdate; - FIsResizing:=true; - for i:=0 to FControls.Count-1 do begin - with Items[i] do begin -//writeln('TControlSelection.MoveSelection ',i,' ',OldLeft,',',OldTop,' d=',dx,',',dy); - SetBounds(OldLeft+dx,OldTop+dy,Width,Height) - end; - end; - for g:=Low(TGrabIndex) to High(TGrabIndex) do begin - FGrabbers[g].Left:=FGrabbers[g].OldLeft+dx; - FGrabbers[g].Top:=FGrabbers[g].OldTop+dy; - end; - FIsResizing:=false; - SaveBounds; - EndUpdate; + BeginResizing; + inc(FLeft,dx); + inc(FTop,dy); + EndResizing; end; procedure TControlSelection.SizeSelection(dx, dy: integer); // size all controls depending on ActiveGrabber. // if ActiveGrabber=nil then Left,Top -var i:integer; +var GrabberPos:TGrabPositions; - NewLeft, NewTop, NewRight, NewBottom: integer; begin if (Count=0) or (FIsResizing) then exit; -writeln('[TControlSelection.SizeSelection] A ',dx,',',dy); - BeginUpdate; - FIsResizing:=true; + writeln('[TControlSelection.SizeSelection] A ',dx,',',dy); + BeginResizing; if FActiveGrabber<>nil then GrabberPos:=FActiveGrabber.Positions else @@ -725,46 +778,27 @@ writeln('[TControlSelection.SizeSelection] A ',dx,',',dy); if gpBottom in GrabberPos then begin FHeight:=FHeight+dy; end; - AdjustGrabber; - if Count=1 then begin - // single selection - NewLeft:=FLeft; - NewTop:=FTop; - NewRight:=FLeft+FWidth; - NewBottom:=FTop+FHeight; - Items[0].SetBounds( - Min(NewLeft,NewRight), - Min(NewTop,NewBottom), - Abs(FWidth), - Abs(FHeight) - ); - end else if Count>1 then begin - // multi selection - if (FOldWidth<>0) and (FOldHeight<>0) then begin - for i:=0 to Count-1 do begin - NewLeft:=FOldLeft + (((Items[i].OldLeft-FOldLeft) * FWidth) div FOldWidth); - NewTop:=FOldTop + (((Items[i].OldTop-FOldTop) * FHeight) div FOldHeight); - NewRight:=Max(1,Abs(FOldLeft + - (((Items[i].OldLeft+Items[i].OldWidth-FOldLeft) * FWidth) - div FOldWidth))); - NewBottom:=Max(1,Abs(FOldTop + - (((Items[i].OldTop+Items[i].OldHeight-FOldTop) * FHeight) - div FOldHeight))); - Items[i].SetBounds(NewLeft,NewTop,NewRight-NewLeft,NewBottom-NewTop); -writeln('[TControlSelection.SizeSelection] i=',i,' ',Items[i].Width,' ',Items[i].Height); - end; - end; - end; - EndUpdate; - FIsResizing:=false; + EndResizing; +end; + +procedure TControlSelection.SetBounds(NewLeft, NewTop, + NewWidth, NewHeight: integer); +begin + if (Count=0) or (FIsResizing) then exit; + BeginResizing; + FLeft:=NewLeft; + FTop:=NewTop; + FWidth:=NewWidth; + FHeight:=NewHeight; + EndResizing; end; function TControlSelection.GrabberAtPos(X,Y:integer):TGrabber; var g:TGrabIndex; begin if FControls.Count>0 then begin -writeln('[TControlSelection.GrabberAtPos] ',x,',',y,' ' -,FGrabbers[4].Left,',',FGrabbers[4].Top); + writeln('[TControlSelection.GrabberAtPos] ',x,',',y,' ' + ,FGrabbers[4].Left,',',FGrabbers[4].Top); for g:=Low(TGrabIndex) to High(TGrabIndex) do if (FGrabbers[g].Left<=x) and (FGrabbers[g].Top<=y) and (FGrabbers[g].Left+FGrabbers[g].Width>x) diff --git a/ide/buildlazdialog.pas b/ide/buildlazdialog.pas index 7b4f29b2cc..8a82087ca7 100644 --- a/ide/buildlazdialog.pas +++ b/ide/buildlazdialog.pas @@ -69,6 +69,7 @@ type TConfigureBuildLazarusDlg = class(TForm) CleanAllCheckBox: TCheckBox; + BuildAllButton: TButton; BuildLCLRadioGroup: TRadioGroup; BuildComponentsRadioGroup: TRadioGroup; BuildSynEditRadioGroup: TRadioGroup; @@ -79,6 +80,7 @@ type OptionsEdit: TEdit; OkButton: TButton; CancelButton: TButton; + procedure BuildAllButtonClick(Sender: TObject); procedure ConfigureBuildLazarusDlgResize(Sender: TObject); procedure OkButtonClick(Sender: TObject); procedure CancelButtonClick(Sender: TObject); @@ -175,22 +177,23 @@ begin SetMakeParams(Options.BuildComponents,Options.ExtraOptions); Result:=ExternalTools.Run(Tool,Macros); if Result<>mrOk then exit; - end; - if Options.BuildSynEdit<>mmNone then begin - // build SynEdit - Tool.Title:='Build SynEdit'; - Tool.WorkingDirectory:='$(LazarusDir)/components/synedit'; - SetMakeParams(Options.BuildSynEdit,Options.ExtraOptions); - Result:=ExternalTools.Run(Tool,Macros); - if Result<>mrOk then exit; - end; - if Options.BuildCodeTools<>mmNone then begin - // build CodeTools - Tool.Title:='Build CodeTools'; - Tool.WorkingDirectory:='$(LazarusDir)/components/codetools'; - SetMakeParams(Options.BuildCodeTools,Options.ExtraOptions); - Result:=ExternalTools.Run(Tool,Macros); - if Result<>mrOk then exit; + end else begin + if Options.BuildSynEdit<>mmNone then begin + // build SynEdit + Tool.Title:='Build SynEdit'; + Tool.WorkingDirectory:='$(LazarusDir)/components/synedit'; + SetMakeParams(Options.BuildSynEdit,Options.ExtraOptions); + Result:=ExternalTools.Run(Tool,Macros); + if Result<>mrOk then exit; + end; + if Options.BuildCodeTools<>mmNone then begin + // build CodeTools + Tool.Title:='Build CodeTools'; + Tool.WorkingDirectory:='$(LazarusDir)/components/codetools'; + SetMakeParams(Options.BuildCodeTools,Options.ExtraOptions); + Result:=ExternalTools.Run(Tool,Macros); + if Result<>mrOk then exit; + end; end; if Options.BuildIDE<>mmNone then begin // build IDE @@ -229,7 +232,7 @@ begin inherited Create(AnOwner); if LazarusResources.Find(Classname)=nil then begin Width:=350; - Height:=385; + Height:=415; Position:=poScreenCenter; Caption:='Configure "Build Lazarus"'; OnResize:=@ConfigureBuildLazarusDlgResize; @@ -238,16 +241,28 @@ begin with CleanAllCheckBox do begin Parent:=Self; Name:='CleanAllCheckBox'; - SetBounds(10,10,Self.ClientWidth-24,20); + SetBounds(10,10,Self.ClientWidth-20,20); Caption:='Clean all'; Visible:=true; end; + BuildAllButton:=TButton.Create(Self); + with BuildAllButton do begin + Name:='BuildAllButton'; + Parent:=Self; + Left:=CleanAllCheckBox.Left; + Top:=CleanAllCheckBox.Top+CleanAllCheckBox.Height+5; + Width:=200; + Caption:='Set to "Build All"'; + OnClick:=@BuildAllButtonClick; + Visible:=true; + end; + BuildLCLRadioGroup:=TRadioGroup.Create(Self); with BuildLCLRadioGroup do begin Parent:=Self; Name:='BuildLCLRadioGroup'; - SetBounds(10,CleanAllCheckBox.Top+CleanAllCheckBox.Height+5, + SetBounds(10,BuildAllButton.Top+BuildAllButton.Height+5, CleanAllCheckBox.Width,40); Caption:='Build LCL'; for MakeMode:=Low(TMakeMode) to High(TMakeMode) do @@ -262,7 +277,7 @@ begin Name:='BuildComponentsRadioGroup'; SetBounds(10,BuildLCLRadioGroup.Top+BuildLCLRadioGroup.Height+5, BuildLCLRadioGroup.Width,BuildLCLRadioGroup.Height); - Caption:='Build Components'; + Caption:='Build Components (SynEdit, CodeTools)'; for MakeMode:=Low(TMakeMode) to High(TMakeMode) do Items.Add(MakeModeNames[MakeMode]); Columns:=3; @@ -369,12 +384,27 @@ begin ConfigureBuildLazarusDlgResize(nil); end; +procedure TConfigureBuildLazarusDlg.BuildAllButtonClick(Sender: TObject); +begin + CleanAllCheckBox.Checked:=true; + BuildLCLRadioGroup.ItemIndex:=1; + BuildComponentsRadioGroup.ItemIndex:=1; + BuildSynEditRadioGroup.ItemIndex:=0; + BuildCodeToolsRadioGroup.ItemIndex:=0; + BuildIDERadioGroup.ItemIndex:=1; + BuildExamplesRadioGroup.ItemIndex:=1; + OptionsEdit.Text:=''; +end; + procedure TConfigureBuildLazarusDlg.ConfigureBuildLazarusDlgResize( Sender: TObject); begin CleanAllCheckBox.SetBounds(10,10,Self.ClientWidth-24,20); + BuildAllButton.SetBounds(CleanAllCheckBox.Left, + CleanAllCheckBox.Top+CleanAllCheckBox.Height+5, + 200,BuildAllButton.Height); BuildLCLRadioGroup.SetBounds(10, - CleanAllCheckBox.Top+CleanAllCheckBox.Height+5, + BuildAllButton.Top+BuildAllButton.Height+5, CleanAllCheckBox.Width,40); BuildComponentsRadioGroup.SetBounds(10, BuildLCLRadioGroup.Top+BuildLCLRadioGroup.Height+5,