From c6990367e3c6ccc427d9a016903a91ed4d039b44 Mon Sep 17 00:00:00 2001 From: lazarus Date: Sat, 5 Oct 2002 09:31:12 +0000 Subject: [PATCH] MG: added consistency checks and fixed selection drawing on wrong forms git-svn-id: trunk@3466 - --- designer/controlselection.pp | 21 ++++++++++++++++----- designer/jitforms.pp | 28 ++++++++++++++++++---------- designer/objectinspector.pp | 11 +++++++++++ 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/designer/controlselection.pp b/designer/controlselection.pp index c4ad64c19d..f3c6534559 100644 --- a/designer/controlselection.pp +++ b/designer/controlselection.pp @@ -123,6 +123,8 @@ type csaSide2SpaceEqually); TComponentSizing = (cssNone, cssShrinkToSmallest, cssGrowToLargest, cssFixed); TSelectionSortCompare = function(Index1, Index2: integer): integer of object; + TOnSelectionFormChanged = procedure(Sender: TObject; + OldForm, NewForm: TCustomForm) of object; TControlSelState = (cssOnlyNonVisualNeedsUpdate, cssOnlyVisualNeedsUpdate, @@ -144,6 +146,7 @@ type // These are the values set by the user // But due to snapping and lcl aligning the components can have other bounds FLeft: Integer; + FOnSelectionFormChanged: TOnSelectionFormChanged; FSavedHeight: integer; FSavedLeft: integer; FSavedTop: integer; @@ -306,6 +309,10 @@ type property Visible:boolean read FVisible write SetVisible; function OnlyNonVisualComponentsSelected: boolean; function OnlyVisualComponentsSelected: boolean; + + property SelectionForm: TCustomForm read FCustomForm; + property OnSelectionFormChanged: TOnSelectionFormChanged + read FOnSelectionFormChanged write FOnSelectionFormChanged; end; @@ -523,14 +530,18 @@ begin end; procedure TControlSelection.SetCustomForm; -var NewCustomForm:TCustomForm; +var + OldCustomForm, NewCustomForm: TCustomForm; begin if Count>0 then NewCustomForm:=Items[0].ParentForm else NewCustomForm:=nil; if NewCustomForm=FCustomForm then exit; + OldCustomForm:=FCustomForm; FCustomForm:=NewCustomForm; + if Assigned(FOnSelectionFormChanged) then + FOnSelectionFormChanged(Self,OldCustomForm,NewCustomForm); end; function TControlSelection.GetGrabbers(AGrabIndex:TGrabIndex): TGrabber; @@ -1260,15 +1271,15 @@ begin if gpLeft in GrabberPos then begin FLeft:=FLeft+dx; FWidth:=FWidth-dx; - end; - if gpRight in GrabberPos then begin + end + else if gpRight in GrabberPos then begin FWidth:=FWidth+dx; end; if gpTop in GrabberPos then begin FTop:=FTop+dy; FHeight:=FHeight-dy; - end; - if gpBottom in GrabberPos then begin + end + else if gpBottom in GrabberPos then begin FHeight:=FHeight+dy; end; EndResizing(true); diff --git a/designer/jitforms.pp b/designer/jitforms.pp index 420afd1aae..1370f34388 100644 --- a/designer/jitforms.pp +++ b/designer/jitforms.pp @@ -422,6 +422,8 @@ begin if IndexOf(JITForm)<0 then raise Exception.Create('TJITForms.RemoveMethod JITForm.ClassName='+ JITForm.ClassName); + if (AName='') or (not IsValidIdent(AName)) then + raise Exception.Create('TJITForms.RemoveMethod invalid name: "'+AName+'"'); OldCode:=nil; DoRemoveMethod(JITForm.ClassType,AName,OldCode); FreeMem(OldCode); @@ -434,6 +436,8 @@ begin if IndexOf(JITForm)<0 then raise Exception.Create('TJITForms.RenameMethod JITForm.ClassName='+ JITForm.ClassName); + if (NewName='') or (not IsValidIdent(NewName)) then + raise Exception.Create('TJITForms.RenameMethod invalid name: "'+NewName+'"'); DoRenameMethod(JITForm.ClassType,OldName,NewName); end; @@ -444,6 +448,8 @@ begin if IndexOf(JITForm)<0 then raise Exception.Create('TJITForms.RenameFormClass JITForm.ClassName='+ JITForm.ClassName); + if (NewName='') or (not IsValidIdent(NewName)) then + raise Exception.Create('TJITForms.RenameFormClass invalid name: "'+NewName+'"'); DoRenameClass(JITForm.ClassType,NewName); end; @@ -457,6 +463,8 @@ begin if IndexOf(JITForm)<0 then raise Exception.Create('TJITForms.CreateNewMethod JITForm.ClassName='+ JITForm.ClassName); + if (AName='') or (not IsValidIdent(AName)) then + raise Exception.Create('TJITForms.CreateNewMethod invalid name: "'+AName+'"'); OldCode:=JITForm.MethodAddress(AName); if OldCode<>nil then begin Result.Data:=JITForm; @@ -476,19 +484,19 @@ end; // adding, removing and renaming of classes and methods at runtime type - // these definitions are copied from objpas.inc + // these definitions are copied from objpas.inc - TMethodNameRec = packed record - Name : PShortString; - Addr : Pointer; - end; + TMethodNameRec = packed record + Name : PShortString; + Addr : Pointer; + end; - TMethodNameTable = packed record - Count : DWord; - Entries : packed array[0..0] of TMethodNameRec; - end; + TMethodNameTable = packed record + Count : DWord; + Entries : packed array[0..0] of TMethodNameRec; + end; - PMethodNameTable = ^TMethodNameTable; + PMethodNameTable = ^TMethodNameTable; function TJITForms.CreateVMTCopy(SourceClass:TClass; diff --git a/designer/objectinspector.pp b/designer/objectinspector.pp index 2310a8ff7d..628b5f381a 100644 --- a/designer/objectinspector.pp +++ b/designer/objectinspector.pp @@ -236,6 +236,8 @@ type read FPropertyEditorHook write SetPropertyEditorHook; procedure BuildPropertyList; procedure RefreshPropertyValues; + + procedure PropEditLookupRootChange; property RowCount:integer read GetRowCount; property Rows[Index:integer]:TOIPropertyGridRow read GetRow; @@ -1292,6 +1294,13 @@ begin DoPaint(true); end; +procedure TOIPropertyGrid.PropEditLookupRootChange; +begin + // When the LookupRoot changes, no changes can be made + // -> undo the value editor changes + RefreshValueEdit; +end; + function TOIPropertyGrid.RowRect(ARow:integer):TRect; begin Result.Left:=BorderWidth; @@ -1971,6 +1980,8 @@ end; procedure TObjectInspector.PropEditLookupRootChange; begin + PropertyGrid.PropEditLookupRootChange; + EventGrid.PropEditLookupRootChange; FillComponentComboBox; end;