From 1913e8198e1d7a80cc393f58eb0a013966091a7b Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 22 Nov 2009 12:31:34 +0000 Subject: [PATCH] IDEIntf: added TComponentEditorDesigner.ChangeStamp and OnModified handler list git-svn-id: trunk@22703 - --- designer/designer.pp | 1 + ideintf/componenteditors.pas | 81 +++++++++++++++++++++++++++++++++++- ideintf/propedits.pp | 4 +- 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/designer/designer.pp b/designer/designer.pp index d1402d2321..01089a4ed0 100644 --- a/designer/designer.pp +++ b/designer/designer.pp @@ -2455,6 +2455,7 @@ procedure TDesigner.Modified; Begin ControlSelection.SaveBounds; DoModified; + inherited Modified; end; Procedure TDesigner.RemovePersistentAndChilds(APersistent: TPersistent); diff --git a/ideintf/componenteditors.pas b/ideintf/componenteditors.pas index 3c6113298c..0784846da9 100644 --- a/ideintf/componenteditors.pas +++ b/ideintf/componenteditors.pas @@ -38,13 +38,23 @@ type cpsfFindUniquePositions ); TComponentPasteSelectionFlags = set of TComponentPasteSelectionFlag; - + TComponentEditorDesignerHookType = ( + cedhtModified + ); TComponentEditorDesigner = class(TIDesigner) + private + FChangeStamp: int64; protected FForm: TCustomForm; + FHandlers: array[TComponentEditorDesignerHookType] of TMethodList; function GetPropertyEditorHook: TPropertyEditorHook; virtual; abstract; + function GetHandlerCount(HookType: TComponentEditorDesignerHookType): integer; + procedure AddHandler(HookType: TComponentEditorDesignerHookType; const Handler: TMethod); + procedure RemoveHandler(HookType: TComponentEditorDesignerHookType; const Handler: TMethod); public + destructor Destroy; override; + procedure Modified; override; function CopySelection: boolean; virtual; abstract; function CutSelection: boolean; virtual; abstract; function CanPaste: boolean; virtual; abstract; @@ -62,6 +72,12 @@ type ): string; virtual; abstract; property PropertyEditorHook: TPropertyEditorHook read GetPropertyEditorHook; property Form: TCustomForm read FForm; + property ChangeStamp: int64 read FChangeStamp;// increased on calling Modified + public + // Handlers + procedure RemoveAllHandlersForObject(const HandlerObject: TObject); + procedure AddHandlerModified(const OnModified: TNotifyEvent); + procedure RemoveHandlerModified(const OnModified: TNotifyEvent); end; @@ -1199,6 +1215,69 @@ begin BestEditEvent := 'ONTIMER'; end; +{ TComponentEditorDesigner } + +function TComponentEditorDesigner.GetHandlerCount( + HookType: TComponentEditorDesignerHookType): integer; +begin + Result:=FHandlers[HookType].Count; +end; + +procedure TComponentEditorDesigner.AddHandler( + HookType: TComponentEditorDesignerHookType; const Handler: TMethod); +begin + if Handler.Code=nil then RaiseGDBException('TComponentEditorDesigner.AddHandler'); + if FHandlers[HookType]=nil then + FHandlers[HookType]:=TMethodList.Create; + FHandlers[HookType].Add(Handler); +end; + +procedure TComponentEditorDesigner.RemoveHandler( + HookType: TComponentEditorDesignerHookType; const Handler: TMethod); +begin + FHandlers[HookType].Remove(Handler); +end; + +destructor TComponentEditorDesigner.Destroy; +var + HookType: TComponentEditorDesignerHookType; +begin + for HookType:=Low(FHandlers) to High(FHandlers) do + FreeThenNil(FHandlers[HookType]); + inherited Destroy; +end; + +procedure TComponentEditorDesigner.Modified; +begin + if FChangeStampnil then + FHandlers[HookType].RemoveAllMethodsOfObject(HandlerObject); +end; + +procedure TComponentEditorDesigner.AddHandlerModified( + const OnModified: TNotifyEvent); +begin + AddHandler(cedhtModified,TMethod(OnModified)); +end; + +procedure TComponentEditorDesigner.RemoveHandlerModified( + const OnModified: TNotifyEvent); +begin + RemoveHandler(cedhtModified,TMethod(OnModified)); +end; + initialization RegisterComponentEditorProc := @DefaultRegisterComponentEditorProc; RegisterComponentEditor(TCustomNotebook, TNotebookComponentEditor); diff --git a/ideintf/propedits.pp b/ideintf/propedits.pp index dc28248074..1282ff95d2 100644 --- a/ideintf/propedits.pp +++ b/ideintf/propedits.pp @@ -5959,7 +5959,7 @@ procedure TPropertyEditorHook.RemoveAllHandlersForObject(const HandlerObject: TO var HookType: TPropHookType; begin - for HookType:=Low(TPropHookType) to High(TPropHookType) do + for HookType:=Low(FHandlers) to High(FHandlers) do if FHandlers[HookType]<>nil then FHandlers[HookType].RemoveAllMethodsOfObject(HandlerObject); end; @@ -6344,7 +6344,7 @@ destructor TPropertyEditorHook.Destroy; var HookType: TPropHookType; begin - for HookType:=Low(TPropHookType) to high(TPropHookType) do + for HookType:=Low(FHandlers) to high(FHandlers) do FreeThenNil(FHandlers[HookType]); inherited Destroy; end;