IdeIntf: Add / remove ActionListEditor handlers for GlobalDesignHook when form is shown / hidden.

git-svn-id: trunk@53095 -
This commit is contained in:
juha 2016-10-11 21:28:51 +00:00
parent 41ea2e0f9e
commit 2ce7ea53c5

View File

@ -125,6 +125,8 @@ type
{%H-}Shift: TShiftState); {%H-}Shift: TShiftState);
procedure ActionListEditorKeyPress(Sender: TObject; var Key: char); procedure ActionListEditorKeyPress(Sender: TObject; var Key: char);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure lstActionNameDrawItem(Control: TWinControl; Index: Integer; procedure lstActionNameDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState); ARect: TRect; State: TOwnerDrawState);
procedure SplitterCanResize(Sender: TObject; var {%H-}NewSize: Integer; procedure SplitterCanResize(Sender: TObject; var {%H-}NewSize: Integer;
@ -374,6 +376,71 @@ end;
{ TActionListEditor } { TActionListEditor }
constructor TActionListEditor.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Caption := oisActionListEditor;
lblCategory.Caption := oisCategory;
lblName.Caption := oisAction;
Splitter.MinSize := lblCategory.Left + lblCategory.Width;
ActNew.Hint := cActionListEditorNewAction;
ActNewStd.Hint := cActionListEditorNewStdAction;
ActDelete.Hint := cActionListEditorDeleteActionHint;
ActMoveUp.Hint := cActionListEditorMoveUpAction;
ActMoveDown.Hint := cActionListEditorMoveDownAction;
ActPanelDescr.Caption := cActionListEditorPanelDescrriptions;
ActPanelToolBar.Caption := cActionListEditorPanelToolBar;
btnAddMore.Hint := cActionListEditorNewAction;
mItemToolBarNewAction.Caption := cActionListEditorNewAction;
mItemToolBarNewStdAction.Caption := cActionListEditorNewStdAction;
mItemActListNewAction.Caption := cActionListEditorNewAction;
mItemActListNewStdAction.Caption := cActionListEditorNewStdAction;
mItemActListMoveDownAction.Caption := cActionListEditorMoveDownAction;
mItemActListMoveUpAction.Caption := cActionListEditorMoveUpAction;
mItemActListDelAction.Caption := cActionListEditorDeleteAction;
AddActionEditor(Self);
end;
destructor TActionListEditor.Destroy;
begin
if Assigned(GlobalDesignHook) then
GlobalDesignHook.RemoveAllHandlersForObject(Self);
ReleaseActionEditor(Self);
inherited Destroy;
end;
procedure TActionListEditor.FormCreate(Sender: TObject);
begin
//imageindex 0 exists
ImageList1.AddResourceName(HInstance, 'laz_add'); //imageindex 1
ImageList1.AddResourceName(HInstance, 'laz_delete'); //imageindex 2
ImageList1.AddResourceName(HInstance, 'arrow_up'); //imadeindex 3
ImageList1.AddResourceName(HInstance, 'arrow_down'); //imageindex 4
btnAddMore.ImageIndex := 0;
// These must be set in code because OI does not work with non-existent values.
btnAdd.ImageIndex := 1;
btnDelete.ImageIndex := 2;
btnUp.ImageIndex := 3;
btnDown.ImageIndex := 4;
end;
procedure TActionListEditor.FormShow(Sender: TObject);
begin
Assert(Assigned(GlobalDesignHook), 'TActionListEditor.FormShow: GlobalDesignHook not assigned.');
GlobalDesignHook.AddHandlerComponentRenamed(@OnComponentRenamed);
GlobalDesignHook.AddHandlerSetSelection(@OnComponentSelection);
GlobalDesignHook.AddHandlerRefreshPropertyValues(@OnRefreshPropertyValues);
GlobalDesignHook.AddHandlerPersistentDeleting(@OnComponentDelete);
end;
procedure TActionListEditor.FormHide(Sender: TObject);
begin
GlobalDesignHook.RemoveHandlerComponentRenamed(@OnComponentRenamed);
GlobalDesignHook.RemoveHandlerSetSelection(@OnComponentSelection);
GlobalDesignHook.RemoveHandlerRefreshPropertyValues(@OnRefreshPropertyValues);
GlobalDesignHook.RemoveHandlerPersistentDeleting(@OnComponentDelete);
end;
function TActionListEditor.CategoryIndexOf(Category: String): Integer; function TActionListEditor.CategoryIndexOf(Category: String): Integer;
begin begin
Assert((Category <> cActionListEditorUnknownCategory) Assert((Category <> cActionListEditorUnknownCategory)
@ -401,7 +468,7 @@ end;
procedure TActionListEditor.OnComponentRenamed(AComponent: TComponent); procedure TActionListEditor.OnComponentRenamed(AComponent: TComponent);
begin begin
if Visible and Assigned(FActionList) if Assigned(FActionList)
and (AComponent is TAction) and (TAction(AComponent).ActionList = FActionList) and (AComponent is TAction) and (TAction(AComponent).ActionList = FActionList)
and Assigned(FActionList.ActionByName(AComponent.Name)) then and Assigned(FActionList.ActionByName(AComponent.Name)) then
lstActionName.Items[lstActionName.ItemIndex] := AComponent.Name; lstActionName.Items[lstActionName.ItemIndex] := AComponent.Name;
@ -414,11 +481,9 @@ var
tmpCategory: String; tmpCategory: String;
begin begin
// TODO: multiselect // TODO: multiselect
if Self.Visible if Assigned(NewSelection) and (NewSelection.Count > 0)
and Assigned(NewSelection) and (NewSelection.Items[0] is TContainedAction)
and (NewSelection.Count > 0) and (TContainedAction(NewSelection.Items[0]).ActionList = FActionList) then
and (NewSelection.Items[0] is TContainedAction)
and (TContainedAction(NewSelection.Items[0]).ActionList = FActionList) then
begin begin
if GetSelectedAction = NewSelection.Items[0] then Exit; if GetSelectedAction = NewSelection.Items[0] then Exit;
CurAct := TContainedAction(NewSelection.Items[0]); CurAct := TContainedAction(NewSelection.Items[0]);
@ -438,7 +503,8 @@ begin
lstActionName.ItemIndex := lstActionName.Items.IndexOf(CurAct.Name); lstActionName.ItemIndex := lstActionName.Items.IndexOf(CurAct.Name);
lstActionName.Click; lstActionName.Click;
end end
else lstActionName.ItemIndex := -1; else
lstActionName.ItemIndex := -1;
end; end;
procedure TActionListEditor.OnRefreshPropertyValues; procedure TActionListEditor.OnRefreshPropertyValues;
@ -450,11 +516,10 @@ var
tmpIndex, OldIndex: Integer; tmpIndex, OldIndex: Integer;
tmpValidAllCategories, tmpIsActCategory: Boolean; tmpValidAllCategories, tmpIsActCategory: Boolean;
begin begin
if not Visible then Exit;
if GlobalDesignHook = nil then Exit;
ASelections := TPersistentSelectionList.Create; ASelections := TPersistentSelectionList.Create;
GlobalDesignHook.GetSelection(ASelections);
try try
Assert(Assigned(GlobalDesignHook));
GlobalDesignHook.GetSelection(ASelections);
if ASelections.Count = 0 then Exit; if ASelections.Count = 0 then Exit;
curSel := ASelections.Items[0]; curSel := ASelections.Items[0];
if not (curSel is TContainedAction) then Exit; if not (curSel is TContainedAction) then Exit;
@ -691,21 +756,6 @@ begin
if Ord(Key) = VK_ESCAPE then Self.Close; if Ord(Key) = VK_ESCAPE then Self.Close;
end; end;
procedure TActionListEditor.FormCreate(Sender: TObject);
begin
//imageindex 0 exists
ImageList1.AddResourceName(HInstance, 'laz_add'); //imageindex 1
ImageList1.AddResourceName(HInstance, 'laz_delete'); //imageindex 2
ImageList1.AddResourceName(HInstance, 'arrow_up'); //imadeindex 3
ImageList1.AddResourceName(HInstance, 'arrow_down'); //imageindex 4
btnAddMore.ImageIndex := 0;
// These must be set in code because OI does not work with non-existent values.
btnAdd.ImageIndex := 1;
btnDelete.ImageIndex := 2;
btnUp.ImageIndex := 3;
btnDown.ImageIndex := 4;
end;
procedure TActionListEditor.lstActionNameDrawItem(Control: TWinControl; procedure TActionListEditor.lstActionNameDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState); Index: Integer; ARect: TRect; State: TOwnerDrawState);
var var
@ -854,50 +904,6 @@ begin
CreateComponentEvent(CurAction,'OnExecute'); CreateComponentEvent(CurAction,'OnExecute');
end; end;
constructor TActionListEditor.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Caption := oisActionListEditor;
lblCategory.Caption := oisCategory;
lblName.Caption := oisAction;
Splitter.MinSize := lblCategory.Left + lblCategory.Width;
ActNew.Hint := cActionListEditorNewAction;
ActNewStd.Hint := cActionListEditorNewStdAction;
ActDelete.Hint := cActionListEditorDeleteActionHint;
ActMoveUp.Hint := cActionListEditorMoveUpAction;
ActMoveDown.Hint := cActionListEditorMoveDownAction;
ActPanelDescr.Caption := cActionListEditorPanelDescrriptions;
ActPanelToolBar.Caption := cActionListEditorPanelToolBar;
btnAddMore.Hint := cActionListEditorNewAction;
mItemToolBarNewAction.Caption := cActionListEditorNewAction;
mItemToolBarNewStdAction.Caption := cActionListEditorNewStdAction;
mItemActListNewAction.Caption := cActionListEditorNewAction;
mItemActListNewStdAction.Caption := cActionListEditorNewStdAction;
mItemActListMoveDownAction.Caption := cActionListEditorMoveDownAction;
mItemActListMoveUpAction.Caption := cActionListEditorMoveUpAction;
mItemActListDelAction.Caption := cActionListEditorDeleteAction;
if Assigned(GlobalDesignHook) then
begin
GlobalDesignHook.AddHandlerComponentRenamed(@OnComponentRenamed);
GlobalDesignHook.AddHandlerSetSelection(@OnComponentSelection);
GlobalDesignHook.AddHandlerRefreshPropertyValues(@OnRefreshPropertyValues);
GlobalDesignHook.AddHandlerPersistentDeleting(@OnComponentDelete);
end;
AddActionEditor(Self);
end;
destructor TActionListEditor.Destroy;
begin
if Assigned(GlobalDesignHook) then
GlobalDesignHook.RemoveAllHandlersForObject(Self);
ReleaseActionEditor(Self);
inherited Destroy;
end;
procedure TActionListEditor.SetActionList(AActionList: TActionList); procedure TActionListEditor.SetActionList(AActionList: TActionList);
begin begin
if FActionList = AActionList then exit; if FActionList = AActionList then exit;