mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 20:59:17 +02:00
IDEIntf: added TComponentEditorDesigner.ChangeStamp and OnModified handler list
git-svn-id: trunk@22703 -
This commit is contained in:
parent
64c97e551d
commit
1913e8198e
@ -2455,6 +2455,7 @@ procedure TDesigner.Modified;
|
|||||||
Begin
|
Begin
|
||||||
ControlSelection.SaveBounds;
|
ControlSelection.SaveBounds;
|
||||||
DoModified;
|
DoModified;
|
||||||
|
inherited Modified;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TDesigner.RemovePersistentAndChilds(APersistent: TPersistent);
|
Procedure TDesigner.RemovePersistentAndChilds(APersistent: TPersistent);
|
||||||
|
@ -38,13 +38,23 @@ type
|
|||||||
cpsfFindUniquePositions
|
cpsfFindUniquePositions
|
||||||
);
|
);
|
||||||
TComponentPasteSelectionFlags = set of TComponentPasteSelectionFlag;
|
TComponentPasteSelectionFlags = set of TComponentPasteSelectionFlag;
|
||||||
|
TComponentEditorDesignerHookType = (
|
||||||
|
cedhtModified
|
||||||
|
);
|
||||||
|
|
||||||
TComponentEditorDesigner = class(TIDesigner)
|
TComponentEditorDesigner = class(TIDesigner)
|
||||||
|
private
|
||||||
|
FChangeStamp: int64;
|
||||||
protected
|
protected
|
||||||
FForm: TCustomForm;
|
FForm: TCustomForm;
|
||||||
|
FHandlers: array[TComponentEditorDesignerHookType] of TMethodList;
|
||||||
function GetPropertyEditorHook: TPropertyEditorHook; virtual; abstract;
|
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
|
public
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure Modified; override;
|
||||||
function CopySelection: boolean; virtual; abstract;
|
function CopySelection: boolean; virtual; abstract;
|
||||||
function CutSelection: boolean; virtual; abstract;
|
function CutSelection: boolean; virtual; abstract;
|
||||||
function CanPaste: boolean; virtual; abstract;
|
function CanPaste: boolean; virtual; abstract;
|
||||||
@ -62,6 +72,12 @@ type
|
|||||||
): string; virtual; abstract;
|
): string; virtual; abstract;
|
||||||
property PropertyEditorHook: TPropertyEditorHook read GetPropertyEditorHook;
|
property PropertyEditorHook: TPropertyEditorHook read GetPropertyEditorHook;
|
||||||
property Form: TCustomForm read FForm;
|
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;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1199,6 +1215,69 @@ begin
|
|||||||
BestEditEvent := 'ONTIMER';
|
BestEditEvent := 'ONTIMER';
|
||||||
end;
|
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 FChangeStamp<High(FChangeStamp) then
|
||||||
|
inc(FChangeStamp)
|
||||||
|
else
|
||||||
|
FChangeStamp:=Low(FChangeStamp);
|
||||||
|
FHandlers[cedhtModified].CallNotifyEvents(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TComponentEditorDesigner.RemoveAllHandlersForObject(
|
||||||
|
const HandlerObject: TObject);
|
||||||
|
var
|
||||||
|
HookType: TComponentEditorDesignerHookType;
|
||||||
|
begin
|
||||||
|
for HookType:=Low(FHandlers) to High(FHandlers) do
|
||||||
|
if FHandlers[HookType]<>nil 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
|
initialization
|
||||||
RegisterComponentEditorProc := @DefaultRegisterComponentEditorProc;
|
RegisterComponentEditorProc := @DefaultRegisterComponentEditorProc;
|
||||||
RegisterComponentEditor(TCustomNotebook, TNotebookComponentEditor);
|
RegisterComponentEditor(TCustomNotebook, TNotebookComponentEditor);
|
||||||
|
@ -5959,7 +5959,7 @@ procedure TPropertyEditorHook.RemoveAllHandlersForObject(const HandlerObject: TO
|
|||||||
var
|
var
|
||||||
HookType: TPropHookType;
|
HookType: TPropHookType;
|
||||||
begin
|
begin
|
||||||
for HookType:=Low(TPropHookType) to High(TPropHookType) do
|
for HookType:=Low(FHandlers) to High(FHandlers) do
|
||||||
if FHandlers[HookType]<>nil then
|
if FHandlers[HookType]<>nil then
|
||||||
FHandlers[HookType].RemoveAllMethodsOfObject(HandlerObject);
|
FHandlers[HookType].RemoveAllMethodsOfObject(HandlerObject);
|
||||||
end;
|
end;
|
||||||
@ -6344,7 +6344,7 @@ destructor TPropertyEditorHook.Destroy;
|
|||||||
var
|
var
|
||||||
HookType: TPropHookType;
|
HookType: TPropHookType;
|
||||||
begin
|
begin
|
||||||
for HookType:=Low(TPropHookType) to high(TPropHookType) do
|
for HookType:=Low(FHandlers) to high(FHandlers) do
|
||||||
FreeThenNil(FHandlers[HookType]);
|
FreeThenNil(FHandlers[HookType]);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user