todolist: menu item for package editors

git-svn-id: trunk@26161 -
This commit is contained in:
mattias 2010-06-17 17:19:15 +00:00
parent 7db6376b93
commit dcedf3e519
4 changed files with 31 additions and 4 deletions

View File

@ -30,8 +30,8 @@ interface
uses
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, TodoList, ToDoListStrConsts, Buttons, ButtonPanel, MenuIntf,
SrcEditorIntf, IDECommands, LCLType, IDEWindowIntf, LazIDEIntf;
ExtCtrls, TodoList, ToDoListStrConsts, Buttons, ButtonPanel, Menus, MenuIntf,
PackageIntf, SrcEditorIntf, IDECommands, LCLType, IDEWindowIntf, LazIDEIntf;
type
@ -77,7 +77,6 @@ var
Cat: TIDECommandCategory;
begin
// mattias: move icon resource item_todo to package
// mattias: add package intf for files and main file
// mattias: add menu item to package editor
// mattias: test short cut
@ -104,6 +103,10 @@ begin
RegisterIDEMenuCommand(itmViewMainWindows, 'ViewToDoList',
lisToDoList, nil, nil, ViewToDoListCmd, 'item_todo');
// add a menu item in the package editor
RegisterIDEMenuCommand(PkgEditMenuSectionMisc, 'ViewPkgToDoList',
lisToDoList, nil, nil, ViewToDoListCmd, 'item_todo');
// register window creator
IDEWindowCreators.Add(ToDoWindowName,@CreateIDEToDoWindow,nil,'250','250','','');
end;
@ -126,8 +129,13 @@ begin
end;
procedure ViewToDoList(Sender: TObject);
var
Pkg: TIDEPackage;
begin
IDEWindowCreators.ShowForm(ToDoWindowName,true);
Pkg:=PackageEditingInterface.GetPackageOfEditorItem(Sender);
if Pkg<>nil then
IDETodoWindow.OwnerFilename:=Pkg.Filename;
end;
procedure CreateIDEToDoWindow(Sender: TObject; aFormName: string;

View File

@ -79,7 +79,8 @@
- on show again: restore a default layout
- close button for pages
}
{ TODO : RRR1
}
unit AnchorDocking;
{$mode objfpc}{$H+}

View File

@ -223,6 +223,9 @@ type
function GetPackages(Index: integer): TIDEPackage; virtual; abstract;
function FindPackageWithName(const PkgName: string): TIDEPackage; virtual; abstract;
// package editors
function GetPackageOfEditorItem(Sender: TObject): TIDEPackage; virtual; abstract;
// events
procedure RemoveAllHandlersOfObject(AnObject: TObject);
procedure AddHandlerOnGraphChanged(const OnGraphChanged: TNotifyEvent;

View File

@ -283,6 +283,7 @@ type
function WarnAboutMissingPackageFiles(APackage: TLazPackage): TModalResult;
function AddPackageDependency(APackage: TLazPackage; const ReqPackage: string;
OnlyTestIfPossible: boolean = false): TModalResult; override;
function GetPackageOfEditorItem(Sender: TObject): TIDEPackage; override;
// package compilation
@ -3671,6 +3672,20 @@ begin
end;
end;
function TPkgManager.GetPackageOfEditorItem(Sender: TObject): TIDEPackage;
begin
Result:=nil;
while (Sender is TMenuItem) and (TMenuItem(Sender).Parent<>nil) do
Sender:=TMenuItem(Sender).Parent;
if (Sender is TMenuItem) and (TMenuItem(Sender).Menu<>nil)
then
Sender:=TMenuItem(Sender).Menu;
if (Sender is TComponent) and (TComponent(Sender).Owner is TCustomForm) then
Sender:=TCustomForm(TComponent(Sender).Owner);
if Sender is TPackageEditorForm then
Result:=TPackageEditorForm(Sender).LazPackage;
end;
function TPkgManager.DoInstallPackage(APackage: TLazPackage): TModalResult;
var
PkgList: TFPList;