MG: added consistency checks and fixed selection drawing on wrong forms

git-svn-id: trunk@3466 -
This commit is contained in:
lazarus 2002-10-05 09:31:12 +00:00
parent 22bf0ac14e
commit c6990367e3
3 changed files with 45 additions and 15 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;