From 5656db6508961addde13a68c4bb47e6fb3fc3df3 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 28 May 2014 23:12:11 +0000 Subject: [PATCH] IDE: indentiation git-svn-id: trunk@45217 - --- components/ideintf/componenttreeview.pas | 37 +++++++----- components/ideintf/formeditingintf.pas | 10 ++-- components/ideintf/objectinspector.pp | 6 +- designer/controlselection.pp | 68 ++++++++++------------ designer/designer.pp | 3 - designer/noncontroldesigner.pas | 16 ++--- examples/designnonlcl/mywidgetdesigner.pas | 10 ++-- ide/customformeditor.pp | 2 +- 8 files changed, 74 insertions(+), 78 deletions(-) diff --git a/components/ideintf/componenttreeview.pas b/components/ideintf/componenttreeview.pas index e768079d4b..9967d8851b 100644 --- a/components/ideintf/componenttreeview.pas +++ b/components/ideintf/componenttreeview.pas @@ -63,6 +63,12 @@ type procedure UpdateComponentNodesValues; virtual; function CreateNodeCaption(APersistent: TPersistent; DefaultName: string = ''): string; virtual; public + ImgIndexForm: Integer; + ImgIndexComponent: Integer; + ImgIndexControl: Integer; + ImgIndexBox: Integer; + ImgIndexCollection: Integer; + ImgIndexItem: Integer; property Selection: TPersistentSelectionList read GetSelection write SetSelection; property PropertyEditorHook: TPropertyEditorHook @@ -535,27 +541,28 @@ function TComponentTreeView.GetImageFor(APersistent: TPersistent): integer; begin if Assigned(APersistent) then begin - if (APersistent is TControl) and (csAcceptsControls in TControl(APersistent).ControlStyle) then - Result := 3 + if (APersistent is TControl) + and (csAcceptsControls in TControl(APersistent).ControlStyle) then + Result := ImgIndexBox else if (APersistent is TControl) then - Result := 2 + Result := ImgIndexControl else if (APersistent is TComponent) then - Result := 1 + Result := ImgIndexComponent else if (APersistent is TCollection) then - Result := 4 + Result := ImgIndexCollection else if (APersistent is TCollectionItem) then - Result := 5; + Result := ImgIndexItem; end else Result := -1; - //finally, ask the designer such as TDesignerMediator to override it, if any - if assigned(OnComponentGetImageIndex) then - OnComponentGetImageIndex(APersistent, Result); + // finally, ask the designer such as TDesignerMediator to override it, if any + if Assigned(OnComponentGetImageIndex) then + OnComponentGetImageIndex(APersistent, Result); end; procedure TComponentTreeView.SetPropertyEditorHook( @@ -583,17 +590,17 @@ begin Bitmap := TPortableNetworkGraphic.Create; try Bitmap.LoadFromResourceName(HInstance, 'oi_form'); - FImageList.Add(Bitmap, nil); + ImgIndexForm:=FImageList.Add(Bitmap, nil); Bitmap.LoadFromResourceName(HInstance, 'oi_comp'); - FImageList.Add(Bitmap, nil); + ImgIndexComponent:=FImageList.Add(Bitmap, nil); Bitmap.LoadFromResourceName(HInstance, 'oi_control'); - FImageList.Add(Bitmap, nil); + ImgIndexControl:=FImageList.Add(Bitmap, nil); Bitmap.LoadFromResourceName(HInstance, 'oi_box'); - FImageList.Add(Bitmap, nil); + ImgIndexBox:=FImageList.Add(Bitmap, nil); Bitmap.LoadFromResourceName(HInstance, 'oi_collection'); - FImageList.Add(Bitmap, nil); + ImgIndexCollection:=FImageList.Add(Bitmap, nil); Bitmap.LoadFromResourceName(HInstance, 'oi_item'); - FImageList.Add(Bitmap, nil); + ImgIndexItem:=FImageList.Add(Bitmap, nil); finally Bitmap.Free; end; diff --git a/components/ideintf/formeditingintf.pas b/components/ideintf/formeditingintf.pas index 77946c5503..04f17c29e8 100644 --- a/components/ideintf/formeditingintf.pas +++ b/components/ideintf/formeditingintf.pas @@ -78,7 +78,7 @@ type procedure MouseDown({%H-}Button: TMouseButton; {%H-}Shift: TShiftState; {%H-}p: TPoint; var {%H-}Handled: boolean); virtual; procedure MouseMove({%H-}Shift: TShiftState; {%H-}p: TPoint; var {%H-}Handled: boolean); virtual; procedure MouseUp({%H-}Button: TMouseButton; {%H-}Shift: TShiftState; {%H-}p: TPoint; var {%H-}Handled: boolean); virtual; - procedure OiNodeGetImageIndex(APersistent: TPersistent; var AIndex: integer); virtual; + procedure GetObjInspNodeImageIndex({%H-}APersistent: TPersistent; var {%H-}AIndex: integer); virtual; property LCLForm: TForm read FLCLForm write SetLCLForm; property Designer: TComponentEditorDesigner read FDesigner write SetDesigner; @@ -461,9 +461,9 @@ begin if ComponentIsIcon(Child) then OffsetRect(ChildBounds,ScrollOffset.X, ScrollOffset.Y) - else///x2nie - OffsetRect(ChildBounds,ClientArea.Left+ScrollOffset.X, - ClientArea.Top+ScrollOffset.Y); + else + OffsetRect(ChildBounds,ClientArea.Left+ScrollOffset.X, + ClientArea.Top+ScrollOffset.Y); //DebugLn(['TDesignerMediator.ComponentAtPos ChildBounds=',dbgs(ChildBounds),' p=',dbgs(p)]); if PtInRect(ChildBounds,p) then begin Found:=true; @@ -531,7 +531,7 @@ begin end; -procedure TDesignerMediator.OiNodeGetImageIndex(APersistent: TPersistent; +procedure TDesignerMediator.GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); begin diff --git a/components/ideintf/objectinspector.pp b/components/ideintf/objectinspector.pp index 9da3f8c5b9..d1c361dac8 100644 --- a/components/ideintf/objectinspector.pp +++ b/components/ideintf/objectinspector.pp @@ -616,6 +616,7 @@ type StatusBar: TStatusBar; procedure AvailComboBoxCloseUp(Sender: TObject); procedure ComponentTreeDblClick(Sender: TObject); + procedure ComponentTreeGetNodeImageIndex(APersistent: TPersistent; var AIndex: integer); procedure ComponentTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ComponentTreeSelectionChanged(Sender: TObject); procedure OnGridKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); @@ -637,7 +638,6 @@ type procedure OnShowStatusBarPopupMenuItemClick(Sender: TObject); procedure OnShowOptionsPopupMenuItemClick(Sender: TObject); procedure OnMainPopupMenuPopup(Sender: TObject); - procedure OnVTNodeGetImageIndex(APersistent: TPersistent; var AIndex: integer); procedure RestrictedPageShow(Sender: TObject); procedure WidgetSetRestrictedPaint(Sender: TObject); procedure ComponentRestrictedPaint(Sender: TObject); @@ -4094,7 +4094,7 @@ begin OnDblClick := @ComponentTreeDblClick; OnKeyDown := @ComponentTreeKeyDown; OnSelectionChanged := @ComponentTreeSelectionChanged; - OnComponentGetImageIndex := @OnVTNodeGetImageIndex; + OnComponentGetImageIndex := @ComponentTreeGetNodeImageIndex; OnModified := @DoModified; Scrollbars := ssAutoBoth; PopupMenu := MainPopupMenu; @@ -5514,7 +5514,7 @@ begin FavoriteGrid.Favorites:=FFavorites; end; -procedure TObjectInspectorDlg.OnVTNodeGetImageIndex( +procedure TObjectInspectorDlg.ComponentTreeGetNodeImageIndex( APersistent: TPersistent; var AIndex: integer); begin //ask TMediator diff --git a/designer/controlselection.pp b/designer/controlselection.pp index 20ea3065b1..46c14734cb 100644 --- a/designer/controlselection.pp +++ b/designer/controlselection.pp @@ -656,17 +656,16 @@ begin begin if Owner.Mediator.ComponentIsIcon(TComponent(FPersistent)) then begin - Owner.Mediator.SetBounds(TComponent(FPersistent),Rect( ALeft, ATop, ALeft+AWidth, ATop+AHeight));//x2nie + Owner.Mediator.SetBounds(TComponent(FPersistent), + Bounds(ALeft, ATop, AWidth, AHeight)); end - else - begin - - Owner.Mediator.GetBounds(TComponent(FPersistent),OldBounds); - ParentOffset:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent)); - dec(ParentOffset.X,OldBounds.Left); - dec(ParentOffset.Y,OldBounds.Top); - Owner.Mediator.SetBounds(TComponent(FPersistent), - Bounds(ALeft-ParentOffset.X,ATop-ParentOffset.Y,AWidth,AHeight)); + else begin + Owner.Mediator.GetBounds(TComponent(FPersistent),OldBounds); + ParentOffset:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent)); + dec(ParentOffset.X,OldBounds.Left); + dec(ParentOffset.Y,OldBounds.Top); + Owner.Mediator.SetBounds(TComponent(FPersistent), + Bounds(ALeft-ParentOffset.X,ATop-ParentOffset.Y,AWidth,AHeight)); end; end else @@ -687,17 +686,16 @@ begin if Owner.Mediator<>nil then begin if Owner.Mediator.ComponentIsIcon(TComponent(FPersistent)) then begin - GetComponentBounds(TComponent(FPersistent),ALeft, ATop, AWidth, AHeight);//x2nie + GetComponentBounds(TComponent(FPersistent),ALeft, ATop, AWidth, AHeight); end else begin - - ALeftTop:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent)); - Owner.Mediator.GetBounds(TComponent(FPersistent),CurBounds); - ALeft:=ALeftTop.X; - ATop:=ALeftTop.Y; - AWidth:=CurBounds.Right-CurBounds.Left; - AHeight:=CurBounds.Bottom-CurBounds.Top; + ALeftTop:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent)); + Owner.Mediator.GetBounds(TComponent(FPersistent),CurBounds); + ALeft:=ALeftTop.X; + ATop:=ALeftTop.Y; + AWidth:=CurBounds.Right-CurBounds.Left; + AHeight:=CurBounds.Bottom-CurBounds.Top; end; end else begin ALeftTop := GetParentFormRelativeTopLeft(TComponent(FPersistent)); @@ -735,14 +733,12 @@ begin begin GetComponentBounds(TComponent(FPersistent), FOldLeft,FOldTop,FOldWidth,FOldHeight); - end - else - begin - Owner.Mediator.GetBounds(TComponent(FPersistent),r); - FOldLeft:=r.Left; - FOldTop:=r.Top; - FOldWidth:=r.Right-r.Left; - FOldHeight:=r.Bottom-r.Top; + end else begin + Owner.Mediator.GetBounds(TComponent(FPersistent),r); + FOldLeft:=r.Left; + FOldTop:=r.Top; + FOldWidth:=r.Right-r.Left; + FOldHeight:=r.Bottom-r.Top; end; end else begin GetComponentBounds(TComponent(FPersistent), @@ -1641,11 +1637,9 @@ begin if not PersistentAlignable(AComponent) then continue; if IsSelected(AComponent) then continue; if FMediator <> nil then - begin - CurLeft := FMediator.GetComponentOriginOnForm(AComponent).X; - end + CurLeft := FMediator.GetComponentOriginOnForm(AComponent).X else - CurLeft:=GetParentFormRelativeTopLeft(AComponent).X; + CurLeft:=GetParentFormRelativeTopLeft(AComponent).X; CurDist:=Abs(CurLeft-NearestInt.OldValue); if CurDist>MaxDist then continue; // skip components far away ImproveNearestInt(NearestInt,CurLeft); @@ -1671,8 +1665,8 @@ begin CurRight := FMediator.GetComponentOriginOnForm(AComponent).X+ R.Right; end else - CurRight:=GetParentFormRelativeTopLeft(AComponent).X - +GetComponentWidth(AComponent); + CurRight:=GetParentFormRelativeTopLeft(AComponent).X + +GetComponentWidth(AComponent); CurDist:=Abs(CurRight-NearestInt.OldValue); if CurDist>MaxDist then continue; // skip components far away ImproveNearestInt(NearestInt,CurRight); @@ -1691,11 +1685,9 @@ begin if not PersistentAlignable(AComponent) then continue; if IsSelected(AComponent) then continue; if FMediator <> nil then - begin - CurTop := FMediator.GetComponentOriginOnForm(AComponent).Y; - end + CurTop := FMediator.GetComponentOriginOnForm(AComponent).Y else - CurTop:=GetParentFormRelativeTopLeft(AComponent).Y; + CurTop:=GetParentFormRelativeTopLeft(AComponent).Y; CurDist:=Abs(CurTop-NearestInt.OldValue); if CurDist>MaxDist then continue; // skip components far away ImproveNearestInt(NearestInt,CurTop); @@ -1721,8 +1713,8 @@ begin CurBottom := FMediator.GetComponentOriginOnForm(AComponent).Y+ R.Bottom; end else - CurBottom:=GetParentFormRelativeTopLeft(AComponent).Y - +GetComponentHeight(AComponent); + CurBottom:=GetParentFormRelativeTopLeft(AComponent).Y + +GetComponentHeight(AComponent); CurDist:=Abs(CurBottom-NearestInt.OldValue); if CurDist>MaxDist then continue; // skip components far away ImproveNearestInt(NearestInt,CurBottom); diff --git a/designer/designer.pp b/designer/designer.pp index c34d37d140..d375085e9a 100644 --- a/designer/designer.pp +++ b/designer/designer.pp @@ -3611,9 +3611,6 @@ begin end; function TDesigner.GetParentFormRelativeClientOrigin(AComponent: TComponent): TPoint; -var - CurClientArea: TRect; - ScrollOffset: TPoint; begin if Mediator<>nil then begin Result:=Mediator.GetComponentOriginOnForm(AComponent); diff --git a/designer/noncontroldesigner.pas b/designer/noncontroldesigner.pas index 7b1c9fcc5b..64134d681c 100644 --- a/designer/noncontroldesigner.pas +++ b/designer/noncontroldesigner.pas @@ -132,14 +132,14 @@ begin with Canvas do begin if LookupRoot is TDataModule then begin - Brush.Color:=clWhite; - ARect:=Rect(FrameWidth,FrameWidth, - Self.ClientWidth-FrameWidth, - Self.ClientHeight-FrameWidth); - FillRect(ARect); - ARect:=Rect(0,0,Self.ClientWidth+1,Self.ClientHeight+1); - Pen.Color:=clBlack; - Frame3d(ARect, FrameWidth, bvLowered); + Brush.Color:=clWhite; + ARect:=Rect(FrameWidth,FrameWidth, + Self.ClientWidth-FrameWidth, + Self.ClientHeight-FrameWidth); + FillRect(ARect); + ARect:=Rect(0,0,Self.ClientWidth+1,Self.ClientHeight+1); + Pen.Color:=clBlack; + Frame3d(ARect, FrameWidth, bvLowered); end; if (Mediator<>nil) and (LookupRoot<>nil) then Mediator.Paint; diff --git a/examples/designnonlcl/mywidgetdesigner.pas b/examples/designnonlcl/mywidgetdesigner.pas index f16dbb4e4b..ef8327f02c 100644 --- a/examples/designnonlcl/mywidgetdesigner.pas +++ b/examples/designnonlcl/mywidgetdesigner.pas @@ -65,7 +65,7 @@ type procedure InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean); property MyForm: TMyForm read FMyForm; public - procedure OiNodeGetImageIndex(APersistent: TPersistent; var AIndex: integer); override; + procedure GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); override; end; { TFileDescPascalUnitWithMyForm } @@ -140,18 +140,18 @@ begin LCLIntf.InvalidateRect(LCLForm.Handle,@ARect,Erase); end; -procedure TMyWidgetMediator.OiNodeGetImageIndex(APersistent: TPersistent; +procedure TMyWidgetMediator.GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); begin if Assigned(APersistent) then begin if (APersistent is TMyWidget) and (TMyWidget(APersistent).AcceptChildrenAtDesignTime) then - AIndex := 3 + AIndex := FormEditingHook.GetCurrentObjectInspector.ComponentTree.ImgIndexBox else if (APersistent is TMyWidget) then - AIndex := 2 + AIndex := FormEditingHook.GetCurrentObjectInspector.ComponentTree.ImgIndexControl else - inherited OiNodeGetImageIndex(APersistent, AIndex); + inherited; end end; diff --git a/ide/customformeditor.pp b/ide/customformeditor.pp index e65f2728ee..4175fccbae 100644 --- a/ide/customformeditor.pp +++ b/ide/customformeditor.pp @@ -2423,7 +2423,7 @@ begin //ask TMediator if DesignerForm is TNonControlDesignerForm then - TNonControlDesignerForm(DesignerForm).Mediator.OiNodeGetImageIndex(APersistent, AImageIndex); + TNonControlDesignerForm(DesignerForm).Mediator.GetObjInspNodeImageIndex(APersistent, AImageIndex); end;