IDE: indentiation

git-svn-id: trunk@45217 -
This commit is contained in:
mattias 2014-05-28 23:12:11 +00:00
parent 8844f15f3a
commit 5656db6508
8 changed files with 74 additions and 78 deletions

View File

@ -63,6 +63,12 @@ type
procedure UpdateComponentNodesValues; virtual; procedure UpdateComponentNodesValues; virtual;
function CreateNodeCaption(APersistent: TPersistent; DefaultName: string = ''): string; virtual; function CreateNodeCaption(APersistent: TPersistent; DefaultName: string = ''): string; virtual;
public public
ImgIndexForm: Integer;
ImgIndexComponent: Integer;
ImgIndexControl: Integer;
ImgIndexBox: Integer;
ImgIndexCollection: Integer;
ImgIndexItem: Integer;
property Selection: TPersistentSelectionList read GetSelection property Selection: TPersistentSelectionList read GetSelection
write SetSelection; write SetSelection;
property PropertyEditorHook: TPropertyEditorHook property PropertyEditorHook: TPropertyEditorHook
@ -535,27 +541,28 @@ function TComponentTreeView.GetImageFor(APersistent: TPersistent): integer;
begin begin
if Assigned(APersistent) then if Assigned(APersistent) then
begin begin
if (APersistent is TControl) and (csAcceptsControls in TControl(APersistent).ControlStyle) then if (APersistent is TControl)
Result := 3 and (csAcceptsControls in TControl(APersistent).ControlStyle) then
Result := ImgIndexBox
else else
if (APersistent is TControl) then if (APersistent is TControl) then
Result := 2 Result := ImgIndexControl
else else
if (APersistent is TComponent) then if (APersistent is TComponent) then
Result := 1 Result := ImgIndexComponent
else else
if (APersistent is TCollection) then if (APersistent is TCollection) then
Result := 4 Result := ImgIndexCollection
else else
if (APersistent is TCollectionItem) then if (APersistent is TCollectionItem) then
Result := 5; Result := ImgIndexItem;
end end
else else
Result := -1; Result := -1;
//finally, ask the designer such as TDesignerMediator to override it, if any // finally, ask the designer such as TDesignerMediator to override it, if any
if assigned(OnComponentGetImageIndex) then if Assigned(OnComponentGetImageIndex) then
OnComponentGetImageIndex(APersistent, Result); OnComponentGetImageIndex(APersistent, Result);
end; end;
procedure TComponentTreeView.SetPropertyEditorHook( procedure TComponentTreeView.SetPropertyEditorHook(
@ -583,17 +590,17 @@ begin
Bitmap := TPortableNetworkGraphic.Create; Bitmap := TPortableNetworkGraphic.Create;
try try
Bitmap.LoadFromResourceName(HInstance, 'oi_form'); Bitmap.LoadFromResourceName(HInstance, 'oi_form');
FImageList.Add(Bitmap, nil); ImgIndexForm:=FImageList.Add(Bitmap, nil);
Bitmap.LoadFromResourceName(HInstance, 'oi_comp'); Bitmap.LoadFromResourceName(HInstance, 'oi_comp');
FImageList.Add(Bitmap, nil); ImgIndexComponent:=FImageList.Add(Bitmap, nil);
Bitmap.LoadFromResourceName(HInstance, 'oi_control'); Bitmap.LoadFromResourceName(HInstance, 'oi_control');
FImageList.Add(Bitmap, nil); ImgIndexControl:=FImageList.Add(Bitmap, nil);
Bitmap.LoadFromResourceName(HInstance, 'oi_box'); Bitmap.LoadFromResourceName(HInstance, 'oi_box');
FImageList.Add(Bitmap, nil); ImgIndexBox:=FImageList.Add(Bitmap, nil);
Bitmap.LoadFromResourceName(HInstance, 'oi_collection'); Bitmap.LoadFromResourceName(HInstance, 'oi_collection');
FImageList.Add(Bitmap, nil); ImgIndexCollection:=FImageList.Add(Bitmap, nil);
Bitmap.LoadFromResourceName(HInstance, 'oi_item'); Bitmap.LoadFromResourceName(HInstance, 'oi_item');
FImageList.Add(Bitmap, nil); ImgIndexItem:=FImageList.Add(Bitmap, nil);
finally finally
Bitmap.Free; Bitmap.Free;
end; end;

View File

@ -78,7 +78,7 @@ type
procedure MouseDown({%H-}Button: TMouseButton; {%H-}Shift: TShiftState; {%H-}p: TPoint; var {%H-}Handled: boolean); virtual; 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 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 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 LCLForm: TForm read FLCLForm write SetLCLForm;
property Designer: TComponentEditorDesigner read FDesigner write SetDesigner; property Designer: TComponentEditorDesigner read FDesigner write SetDesigner;
@ -461,9 +461,9 @@ begin
if ComponentIsIcon(Child) then if ComponentIsIcon(Child) then
OffsetRect(ChildBounds,ScrollOffset.X, OffsetRect(ChildBounds,ScrollOffset.X,
ScrollOffset.Y) ScrollOffset.Y)
else///x2nie else
OffsetRect(ChildBounds,ClientArea.Left+ScrollOffset.X, OffsetRect(ChildBounds,ClientArea.Left+ScrollOffset.X,
ClientArea.Top+ScrollOffset.Y); ClientArea.Top+ScrollOffset.Y);
//DebugLn(['TDesignerMediator.ComponentAtPos ChildBounds=',dbgs(ChildBounds),' p=',dbgs(p)]); //DebugLn(['TDesignerMediator.ComponentAtPos ChildBounds=',dbgs(ChildBounds),' p=',dbgs(p)]);
if PtInRect(ChildBounds,p) then begin if PtInRect(ChildBounds,p) then begin
Found:=true; Found:=true;
@ -531,7 +531,7 @@ begin
end; end;
procedure TDesignerMediator.OiNodeGetImageIndex(APersistent: TPersistent; procedure TDesignerMediator.GetObjInspNodeImageIndex(APersistent: TPersistent;
var AIndex: integer); var AIndex: integer);
begin begin

View File

@ -616,6 +616,7 @@ type
StatusBar: TStatusBar; StatusBar: TStatusBar;
procedure AvailComboBoxCloseUp(Sender: TObject); procedure AvailComboBoxCloseUp(Sender: TObject);
procedure ComponentTreeDblClick(Sender: TObject); procedure ComponentTreeDblClick(Sender: TObject);
procedure ComponentTreeGetNodeImageIndex(APersistent: TPersistent; var AIndex: integer);
procedure ComponentTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ComponentTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ComponentTreeSelectionChanged(Sender: TObject); procedure ComponentTreeSelectionChanged(Sender: TObject);
procedure OnGridKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure OnGridKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
@ -637,7 +638,6 @@ type
procedure OnShowStatusBarPopupMenuItemClick(Sender: TObject); procedure OnShowStatusBarPopupMenuItemClick(Sender: TObject);
procedure OnShowOptionsPopupMenuItemClick(Sender: TObject); procedure OnShowOptionsPopupMenuItemClick(Sender: TObject);
procedure OnMainPopupMenuPopup(Sender: TObject); procedure OnMainPopupMenuPopup(Sender: TObject);
procedure OnVTNodeGetImageIndex(APersistent: TPersistent; var AIndex: integer);
procedure RestrictedPageShow(Sender: TObject); procedure RestrictedPageShow(Sender: TObject);
procedure WidgetSetRestrictedPaint(Sender: TObject); procedure WidgetSetRestrictedPaint(Sender: TObject);
procedure ComponentRestrictedPaint(Sender: TObject); procedure ComponentRestrictedPaint(Sender: TObject);
@ -4094,7 +4094,7 @@ begin
OnDblClick := @ComponentTreeDblClick; OnDblClick := @ComponentTreeDblClick;
OnKeyDown := @ComponentTreeKeyDown; OnKeyDown := @ComponentTreeKeyDown;
OnSelectionChanged := @ComponentTreeSelectionChanged; OnSelectionChanged := @ComponentTreeSelectionChanged;
OnComponentGetImageIndex := @OnVTNodeGetImageIndex; OnComponentGetImageIndex := @ComponentTreeGetNodeImageIndex;
OnModified := @DoModified; OnModified := @DoModified;
Scrollbars := ssAutoBoth; Scrollbars := ssAutoBoth;
PopupMenu := MainPopupMenu; PopupMenu := MainPopupMenu;
@ -5514,7 +5514,7 @@ begin
FavoriteGrid.Favorites:=FFavorites; FavoriteGrid.Favorites:=FFavorites;
end; end;
procedure TObjectInspectorDlg.OnVTNodeGetImageIndex( procedure TObjectInspectorDlg.ComponentTreeGetNodeImageIndex(
APersistent: TPersistent; var AIndex: integer); APersistent: TPersistent; var AIndex: integer);
begin begin
//ask TMediator //ask TMediator

View File

@ -656,17 +656,16 @@ begin
begin begin
if Owner.Mediator.ComponentIsIcon(TComponent(FPersistent)) then if Owner.Mediator.ComponentIsIcon(TComponent(FPersistent)) then
begin 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 end
else else begin
begin Owner.Mediator.GetBounds(TComponent(FPersistent),OldBounds);
ParentOffset:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent));
Owner.Mediator.GetBounds(TComponent(FPersistent),OldBounds); dec(ParentOffset.X,OldBounds.Left);
ParentOffset:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent)); dec(ParentOffset.Y,OldBounds.Top);
dec(ParentOffset.X,OldBounds.Left); Owner.Mediator.SetBounds(TComponent(FPersistent),
dec(ParentOffset.Y,OldBounds.Top); Bounds(ALeft-ParentOffset.X,ATop-ParentOffset.Y,AWidth,AHeight));
Owner.Mediator.SetBounds(TComponent(FPersistent),
Bounds(ALeft-ParentOffset.X,ATop-ParentOffset.Y,AWidth,AHeight));
end; end;
end end
else else
@ -687,17 +686,16 @@ begin
if Owner.Mediator<>nil then begin if Owner.Mediator<>nil then begin
if Owner.Mediator.ComponentIsIcon(TComponent(FPersistent)) then if Owner.Mediator.ComponentIsIcon(TComponent(FPersistent)) then
begin begin
GetComponentBounds(TComponent(FPersistent),ALeft, ATop, AWidth, AHeight);//x2nie GetComponentBounds(TComponent(FPersistent),ALeft, ATop, AWidth, AHeight);
end end
else else
begin begin
ALeftTop:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent));
ALeftTop:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent)); Owner.Mediator.GetBounds(TComponent(FPersistent),CurBounds);
Owner.Mediator.GetBounds(TComponent(FPersistent),CurBounds); ALeft:=ALeftTop.X;
ALeft:=ALeftTop.X; ATop:=ALeftTop.Y;
ATop:=ALeftTop.Y; AWidth:=CurBounds.Right-CurBounds.Left;
AWidth:=CurBounds.Right-CurBounds.Left; AHeight:=CurBounds.Bottom-CurBounds.Top;
AHeight:=CurBounds.Bottom-CurBounds.Top;
end; end;
end else begin end else begin
ALeftTop := GetParentFormRelativeTopLeft(TComponent(FPersistent)); ALeftTop := GetParentFormRelativeTopLeft(TComponent(FPersistent));
@ -735,14 +733,12 @@ begin
begin begin
GetComponentBounds(TComponent(FPersistent), GetComponentBounds(TComponent(FPersistent),
FOldLeft,FOldTop,FOldWidth,FOldHeight); FOldLeft,FOldTop,FOldWidth,FOldHeight);
end end else begin
else Owner.Mediator.GetBounds(TComponent(FPersistent),r);
begin FOldLeft:=r.Left;
Owner.Mediator.GetBounds(TComponent(FPersistent),r); FOldTop:=r.Top;
FOldLeft:=r.Left; FOldWidth:=r.Right-r.Left;
FOldTop:=r.Top; FOldHeight:=r.Bottom-r.Top;
FOldWidth:=r.Right-r.Left;
FOldHeight:=r.Bottom-r.Top;
end; end;
end else begin end else begin
GetComponentBounds(TComponent(FPersistent), GetComponentBounds(TComponent(FPersistent),
@ -1641,11 +1637,9 @@ begin
if not PersistentAlignable(AComponent) then continue; if not PersistentAlignable(AComponent) then continue;
if IsSelected(AComponent) then continue; if IsSelected(AComponent) then continue;
if FMediator <> nil then if FMediator <> nil then
begin CurLeft := FMediator.GetComponentOriginOnForm(AComponent).X
CurLeft := FMediator.GetComponentOriginOnForm(AComponent).X;
end
else else
CurLeft:=GetParentFormRelativeTopLeft(AComponent).X; CurLeft:=GetParentFormRelativeTopLeft(AComponent).X;
CurDist:=Abs(CurLeft-NearestInt.OldValue); CurDist:=Abs(CurLeft-NearestInt.OldValue);
if CurDist>MaxDist then continue; // skip components far away if CurDist>MaxDist then continue; // skip components far away
ImproveNearestInt(NearestInt,CurLeft); ImproveNearestInt(NearestInt,CurLeft);
@ -1671,8 +1665,8 @@ begin
CurRight := FMediator.GetComponentOriginOnForm(AComponent).X+ R.Right; CurRight := FMediator.GetComponentOriginOnForm(AComponent).X+ R.Right;
end end
else else
CurRight:=GetParentFormRelativeTopLeft(AComponent).X CurRight:=GetParentFormRelativeTopLeft(AComponent).X
+GetComponentWidth(AComponent); +GetComponentWidth(AComponent);
CurDist:=Abs(CurRight-NearestInt.OldValue); CurDist:=Abs(CurRight-NearestInt.OldValue);
if CurDist>MaxDist then continue; // skip components far away if CurDist>MaxDist then continue; // skip components far away
ImproveNearestInt(NearestInt,CurRight); ImproveNearestInt(NearestInt,CurRight);
@ -1691,11 +1685,9 @@ begin
if not PersistentAlignable(AComponent) then continue; if not PersistentAlignable(AComponent) then continue;
if IsSelected(AComponent) then continue; if IsSelected(AComponent) then continue;
if FMediator <> nil then if FMediator <> nil then
begin CurTop := FMediator.GetComponentOriginOnForm(AComponent).Y
CurTop := FMediator.GetComponentOriginOnForm(AComponent).Y;
end
else else
CurTop:=GetParentFormRelativeTopLeft(AComponent).Y; CurTop:=GetParentFormRelativeTopLeft(AComponent).Y;
CurDist:=Abs(CurTop-NearestInt.OldValue); CurDist:=Abs(CurTop-NearestInt.OldValue);
if CurDist>MaxDist then continue; // skip components far away if CurDist>MaxDist then continue; // skip components far away
ImproveNearestInt(NearestInt,CurTop); ImproveNearestInt(NearestInt,CurTop);
@ -1721,8 +1713,8 @@ begin
CurBottom := FMediator.GetComponentOriginOnForm(AComponent).Y+ R.Bottom; CurBottom := FMediator.GetComponentOriginOnForm(AComponent).Y+ R.Bottom;
end end
else else
CurBottom:=GetParentFormRelativeTopLeft(AComponent).Y CurBottom:=GetParentFormRelativeTopLeft(AComponent).Y
+GetComponentHeight(AComponent); +GetComponentHeight(AComponent);
CurDist:=Abs(CurBottom-NearestInt.OldValue); CurDist:=Abs(CurBottom-NearestInt.OldValue);
if CurDist>MaxDist then continue; // skip components far away if CurDist>MaxDist then continue; // skip components far away
ImproveNearestInt(NearestInt,CurBottom); ImproveNearestInt(NearestInt,CurBottom);

View File

@ -3611,9 +3611,6 @@ begin
end; end;
function TDesigner.GetParentFormRelativeClientOrigin(AComponent: TComponent): TPoint; function TDesigner.GetParentFormRelativeClientOrigin(AComponent: TComponent): TPoint;
var
CurClientArea: TRect;
ScrollOffset: TPoint;
begin begin
if Mediator<>nil then begin if Mediator<>nil then begin
Result:=Mediator.GetComponentOriginOnForm(AComponent); Result:=Mediator.GetComponentOriginOnForm(AComponent);

View File

@ -132,14 +132,14 @@ begin
with Canvas do begin with Canvas do begin
if LookupRoot is TDataModule then if LookupRoot is TDataModule then
begin begin
Brush.Color:=clWhite; Brush.Color:=clWhite;
ARect:=Rect(FrameWidth,FrameWidth, ARect:=Rect(FrameWidth,FrameWidth,
Self.ClientWidth-FrameWidth, Self.ClientWidth-FrameWidth,
Self.ClientHeight-FrameWidth); Self.ClientHeight-FrameWidth);
FillRect(ARect); FillRect(ARect);
ARect:=Rect(0,0,Self.ClientWidth+1,Self.ClientHeight+1); ARect:=Rect(0,0,Self.ClientWidth+1,Self.ClientHeight+1);
Pen.Color:=clBlack; Pen.Color:=clBlack;
Frame3d(ARect, FrameWidth, bvLowered); Frame3d(ARect, FrameWidth, bvLowered);
end; end;
if (Mediator<>nil) and (LookupRoot<>nil) then if (Mediator<>nil) and (LookupRoot<>nil) then
Mediator.Paint; Mediator.Paint;

View File

@ -65,7 +65,7 @@ type
procedure InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean); procedure InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean);
property MyForm: TMyForm read FMyForm; property MyForm: TMyForm read FMyForm;
public public
procedure OiNodeGetImageIndex(APersistent: TPersistent; var AIndex: integer); override; procedure GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); override;
end; end;
{ TFileDescPascalUnitWithMyForm } { TFileDescPascalUnitWithMyForm }
@ -140,18 +140,18 @@ begin
LCLIntf.InvalidateRect(LCLForm.Handle,@ARect,Erase); LCLIntf.InvalidateRect(LCLForm.Handle,@ARect,Erase);
end; end;
procedure TMyWidgetMediator.OiNodeGetImageIndex(APersistent: TPersistent; procedure TMyWidgetMediator.GetObjInspNodeImageIndex(APersistent: TPersistent;
var AIndex: integer); var AIndex: integer);
begin begin
if Assigned(APersistent) then if Assigned(APersistent) then
begin begin
if (APersistent is TMyWidget) and (TMyWidget(APersistent).AcceptChildrenAtDesignTime) then if (APersistent is TMyWidget) and (TMyWidget(APersistent).AcceptChildrenAtDesignTime) then
AIndex := 3 AIndex := FormEditingHook.GetCurrentObjectInspector.ComponentTree.ImgIndexBox
else else
if (APersistent is TMyWidget) then if (APersistent is TMyWidget) then
AIndex := 2 AIndex := FormEditingHook.GetCurrentObjectInspector.ComponentTree.ImgIndexControl
else else
inherited OiNodeGetImageIndex(APersistent, AIndex); inherited;
end end
end; end;

View File

@ -2423,7 +2423,7 @@ begin
//ask TMediator //ask TMediator
if DesignerForm is TNonControlDesignerForm then if DesignerForm is TNonControlDesignerForm then
TNonControlDesignerForm(DesignerForm).Mediator.OiNodeGetImageIndex(APersistent, AImageIndex); TNonControlDesignerForm(DesignerForm).Mediator.GetObjInspNodeImageIndex(APersistent, AImageIndex);
end; end;