started add new unit page for package editor

git-svn-id: trunk@7296 -
This commit is contained in:
mattias 2005-06-29 22:52:39 +00:00
parent 6e0a9931e1
commit 8feeeb020d
4 changed files with 172 additions and 23 deletions

View File

@ -43,7 +43,7 @@ const
These values can change from version to version, so DO NOT save them to file!
To add one static key do the following:
1. Add a constant with a unique value in the list below.
1. Add a constant with a unique value in the list below.
2. Add it to GetDefaultKeyForCommand to define the default keys+shiftstates
3. Add it to EditorCommandToDescriptionString to define the description
4. Add it to TKeyCommandRelationList.CreateDefaultMapping to define the
@ -738,7 +738,7 @@ procedure GetDefaultKeyForClassicScheme(Command: word;
end;
begin
SetResult(VK_UNKNOWN,[]);
GetDefaultKeyForCommand(Command,TheKeyA,TheKeyB);
case Command of
// moving

View File

@ -646,6 +646,7 @@ resourcestring
dlgEnvBckup = 'Backup';
dlgNaming = 'Naming';
dlgCancel = 'Cancel';
lisA2PCreateNewFile = 'Create new file';
dlgEnvLanguage = 'Language';
dlgAutoSave = 'Auto save';
dlgEdFiles = 'Editor files';
@ -2369,6 +2370,7 @@ resourcestring
+'Version %s%s%s is invalid.%sPlease use the format major.minor.release.'
+'build%sFor exmaple: 1.0.20.10';
lisA2PAddUnit = 'Add Unit';
lisA2PNewFile = 'New File';
lisA2PNewComponent = 'New Component';
lisA2PAddFile = 'Add File';
lisA2PAddFiles = 'Add Files';

View File

@ -133,6 +133,7 @@ var
AnchorSideCacheValid: array[TAnchorKind] of boolean;
AnchorSideCache: array[TAnchorKind] of integer;
CurAnchors: TAnchors;
CurAlignAnchors: TAnchors;
function ConstraintWidth(NewWidth: integer): integer;
begin
@ -205,7 +206,13 @@ var
NewTop:=Top;
NewWidth:=ConstraintWidth(Width);
NewHeight:=ConstraintHeight(Height);
// get anchors set by Align
CurAlignAnchors:=[];
if Align in [alLeft,alRight,alBottom,alTop,alClient] then
CurAlignAnchors:=AnchorAlign[Align];
end;
InitAnchorSideCache;
@ -231,9 +238,8 @@ var
2. If AnchorSide[].Control is set, the BorderSpace properties defines the
distance to another sibling (i.e. AnchorSide[].Control).
}
if (AAlign = alNone) or (Control.Anchors <> AnchorAlign[AAlign]) then
begin
// at least one side is anchored
if (AAlign = alNone) or (Control.Anchors <> CurAlignAnchors) then begin
// at least one side is anchored without align
// Get the base bounds. The base bounds are the user defined bounds
// without automatic aligning and/or anchoring
@ -263,7 +269,7 @@ var
'');
{$ENDIF}
CurAnchors:=Control.Anchors+AnchorAlign[AAlign];
CurAnchors:=Control.Anchors+CurAlignAnchors;
if akLeft in CurAnchors then begin
// keep distance to left side of parent or another sibling
NewLeft:=GetAnchorSidePosition(akLeft,CurBaseBounds.Left);
@ -272,7 +278,7 @@ var
// -> change the width
NewRight:=Control.Parent.ClientWidth
-(ParentBaseClientSize.X-CurBaseBounds.Right);
if (not (akRight in AnchorAlign[AAlign]))
if (not (akRight in CurAlignAnchors))
and (akRight in Anchors) then
NewRight:=GetAnchorSidePosition(akRight,NewRight);
NewWidth:=ConstraintWidth(NewRight-NewLeft);
@ -287,7 +293,7 @@ var
// and keep new width
NewRight:=Control.Parent.ClientWidth
-(ParentBaseClientSize.X-CurBaseBounds.Right);
if (not (akRight in AnchorAlign[AAlign]))
if (not (akRight in CurAlignAnchors))
and (akRight in Anchors) then
NewRight:=GetAnchorSidePosition(akRight,NewRight);
NewLeft:=NewRight-NewWidth;
@ -306,7 +312,7 @@ var
// -> change the height
NewBottom:=Control.Parent.ClientHeight
-(ParentBaseClientSize.Y-CurBaseBounds.Bottom);
if (not (akBottom in AnchorAlign[AAlign]))
if (not (akBottom in CurAlignAnchors))
and (akBottom in Anchors) then
NewBottom:=GetAnchorSidePosition(akBottom,NewBottom);
NewHeight:=ConstraintHeight(NewBottom-NewTop);
@ -321,7 +327,7 @@ var
// and keep new height
NewBottom:=Control.Parent.ClientHeight
-(ParentBaseClientSize.Y-CurBaseBounds.Bottom);
if (not (akBottom in AnchorAlign[AAlign]))
if (not (akBottom in CurAlignAnchors))
and (akBottom in Anchors) then
NewBottom:=GetAnchorSidePosition(akBottom,NewBottom);
NewTop:=NewBottom-NewHeight;
@ -333,7 +339,7 @@ var
end;
{$IFDEF CHECK_POSITION}
//if csDesigning in ComponentState then
if AnsiCompareText(Control.ClassName,'TScrollBar')=0 then
if CompareText(Control.ClassName,'TScrollBar')=0 then
with Control do
DebugLn('[TWinControl.AlignControls.DoPosition] After Anchoring',
' ',Name,':',ClassName,
@ -442,7 +448,7 @@ var
{$IFDEF CHECK_POSITION}
//if csDesigning in Control.ComponentState then
if AnsiCompareText(Control.ClassName,'TScrollBar')=0 then
if CompareText(Control.ClassName,'TScrollBar')=0 then
with Control do
DebugLn('[TWinControl.AlignControls.DoPosition] After Aligning',
' ',Name,':',ClassName,
@ -527,7 +533,7 @@ var
end;
{$IFDEF CHECK_POSITION}
if AnsiCompareText(Control.ClassName,'TScrollBar')=0 then
if CompareText(Control.ClassName,'TScrollBar')=0 then
with Control do
DebugLn('[TWinControl.AlignControls.DoPosition] END Control=',
Name,':',ClassName,
@ -681,7 +687,8 @@ begin
AutoSizing := True;
try
// test if resizing is possible
CurAnchors:=Anchors+AnchorAlign[Align];
CurAnchors:=Anchors;
if Align<>alNone then CurAnchors:=CurAnchors+AnchorAlign[Align];
WidthIsFixed:=(CurAnchors*[akLeft,akRight]=[akLeft,akRight]);
HeightIsFixed:=(CurAnchors*[akTop,akBottom]=[akTop,akBottom]);
@ -722,7 +729,8 @@ begin
dec(NewLeft,PreferredWidth-Width);
if akBottom in CurAnchors then
dec(NewTop,PreferredHeight-Height);
//debugln('DoAutoSize Resize ',DbgSName(Self),' W=',dbgs(PreferredWidth),' H=',dbgs(PreferredHeight));
//if CompareText(Name,'NewUnitOkButton')=0 then
// debugln('DoAutoSize Resize ',DbgSName(Self),' W=',dbgs(PreferredWidth),' H=',dbgs(PreferredHeight),' WidthIsFixed=',dbgs(WidthIsFixed),' HeightIsFixed=',dbgs(HeightIsFixed));
SetBoundsKeepBase(NewLeft,NewTop,PreferredWidth,PreferredHeight,true);
end;
finally
@ -4535,6 +4543,9 @@ end;
{ =============================================================================
$Log$
Revision 1.331 2005/06/29 22:52:39 mattias
started add new unit page for package editor
Revision 1.330 2005/06/28 22:56:32 mattias
improved lcl autosizing: reduced overhead by preconsidering anchors

View File

@ -39,8 +39,8 @@ interface
uses
Classes, SysUtils, LResources, Forms, Controls, Buttons, StdCtrls, ExtCtrls,
Dialogs, FileUtil, ComCtrls, LazarusIDEStrConsts, IDEOptionDefs, InputHistory,
{$IFNDEF VER1_0}AVL_Tree{$ELSE}OldAvLTree{$ENDIF}, CodeToolManager, IDEDefs,
Dialogs, FileUtil, ComCtrls, AVL_Tree, LCLProc, NewItemIntf, ProjectIntf,
LazarusIDEStrConsts, IDEOptionDefs, InputHistory, CodeToolManager, IDEDefs,
IDEProcs, EnvironmentOpts, PackageSystem, PackageDefs, ComponentReg;
type
@ -74,6 +74,8 @@ type
TOnGetUnitRegisterInfo = procedure(Sender: TObject; const AFilename: string;
var TheUnitName: string; var HasRegisterProc: boolean) of object;
{ TAddToPackageDlg }
TAddToPackageDlg = class(TForm)
// notebook
NoteBook: TNoteBook;
@ -82,6 +84,7 @@ type
AddFilesPage: TPage;
NewComponentPage: TPage;
NewDependPage: TPage;
NewUnitPage: TPage;
// add unit page
AddUnitFilenameLabel: TLabel;
AddUnitFilenameEdit: TEdit;
@ -95,6 +98,12 @@ type
AddUnitUpdateButton: TButton;
AddUnitButton: TButton;
CancelAddUnitButton: TButton;
// new unit page
NewUnitTreeView: TTreeView;
NewUnitDescriptionGroupBox: TGroupBox;
NewUnitHelpLabel: TLabel;
NewUnitOkButton: TButton;
NewUnitCancelButton: TButton;
// new component page
AncestorTypeLabel: TLabel;
AncestorComboBox: TComboBox;
@ -163,6 +172,11 @@ type
procedure NewComponentPageResize(Sender: TObject);
procedure NewDependButtonClick(Sender: TObject);
procedure NewDependPageResize(Sender: TObject);
procedure NewUnitOkButtonClick(Sender: TObject);
procedure NewUnitPageResize(Sender: TObject);
procedure NewUnitTreeViewClick(Sender: TObject);
procedure NewUnitTreeViewDblClick(Sender: TObject);
procedure NewUnitTreeViewSelectionChanged(Sender: TObject);
private
fLastNewComponentAncestorType: string;
fLastNewComponentClassName: string;
@ -174,6 +188,7 @@ type
procedure SetLazPackage(const AValue: TLazPackage);
procedure SetupComponents;
procedure SetupAddUnitPage;
procedure SetupNewUnitPage;
procedure SetupNewComponentPage;
procedure SetupAddDependencyPage;
procedure SetupAddFilePage;
@ -185,6 +200,7 @@ type
procedure UpdateAddUnitInfo;
procedure UpdateAddFileInfo;
function SwitchRelativeAbsoluteFilename(const Filename: string): string;
procedure FillNewUnitTreeView;
public
Params: TAddToPkgResult;
constructor Create(TheOwner: TComponent); override;
@ -1209,6 +1225,42 @@ begin
SetBounds(x+NewDependButton.Width+10,y,80,Height);
end;
procedure TAddToPackageDlg.NewUnitOkButtonClick(Sender: TObject);
begin
// TODO
end;
procedure TAddToPackageDlg.NewUnitPageResize(Sender: TObject);
begin
NewUnitTreeView.Width:=NewUnitPage.ClientWidth div 2;
end;
procedure TAddToPackageDlg.NewUnitTreeViewClick(Sender: TObject);
var
Desc: String;
ANode: TTreeNode;
begin
ANode:=NewUnitTreeView.Selected;
Desc:='';
if (ANode<>nil) and (ANode.Data<>nil) then begin
if TObject(ANode.Data) is TNewIDEItemTemplate then
Desc:=TNewIDEItemTemplate(ANode.Data).Description;
end;
NewUnitHelpLabel.Caption:=Desc;
end;
procedure TAddToPackageDlg.NewUnitTreeViewDblClick(Sender: TObject);
begin
NewUnitOkButtonClick(Self);
end;
procedure TAddToPackageDlg.NewUnitTreeViewSelectionChanged(Sender: TObject);
begin
NewUnitOkButton.Enabled:=false;
// TODO and (NewUnitTreeView.Selected<>nil)
// and (TObject(NewUnitTreeView.Selected.Data) is TNewIDEItemTemplate);
end;
procedure TAddToPackageDlg.SetLazPackage(const AValue: TLazPackage);
begin
if FLazPackage=AValue then exit;
@ -1225,15 +1277,17 @@ begin
Name:='NoteBook';
Parent:=Self;
Pages.Add(lisA2PAddUnit);
AddUnitPage:=Page[0];
AddUnitPage:=Page[Pages.Count-1];
Pages.Add(lisA2PNewFile);
NewUnitPage:=Page[Pages.Count-1];
Pages.Add(lisA2PNewComponent);
NewComponentPage:=Page[1];
NewComponentPage:=Page[Pages.Count-1];
Pages.Add(lisProjAddNewRequirement);
NewDependPage:=Page[2];
NewDependPage:=Page[Pages.Count-1];
Pages.Add(lisA2PAddFile);
AddFilePage:=Page[3];
AddFilePage:=Page[Pages.Count-1];
Pages.Add(lisA2PAddFiles);
AddFilesPage:=Page[4];
AddFilesPage:=Page[Pages.Count-1];
PageIndex:=0;
Align:=alClient;
end;
@ -1245,6 +1299,7 @@ begin
AddFilesPage.OnResize:=@AddFilesPageResize;
SetupAddUnitPage;
SetupNewUnitPage;
SetupNewComponentPage;
SetupAddDependencyPage;
SetupAddFilePage;
@ -1332,7 +1387,7 @@ begin
with AddUnitButton do begin
Name:='AddUnitButton';
Parent:=AddUnitPage;
Caption:=lisLazBuildOk;
Caption:=lisA2PAddUnit;
OnClick:=@AddUnitButtonClick;
end;
@ -1345,6 +1400,68 @@ begin
end;
end;
procedure TAddToPackageDlg.SetupNewUnitPage;
begin
NewUnitPage.OnResize:=@NewUnitPageResize;
NewUnitTreeView:=TTreeView.Create(Self);
with NewUnitTreeView do begin
Name:='NewUnitTreeView';
Parent:=NewUnitPage;
OnClick:=@NewUnitTreeViewClick;
OnDblClick:=@NewUnitTreeViewDblClick;
OnSelectionChanged:=@NewUnitTreeViewSelectionChanged;
end;
NewUnitDescriptionGroupBox:=TGroupBox.Create(Self);
with NewUnitDescriptionGroupBox do begin
Name:='NewUnitDescriptionGroupBox';
Caption:=lisToDoLDescription;
Parent:=NewUnitPage;
AnchorToNeighbour(akLeft,0,NewUnitTreeView);
AnchorParallel(akTop,0,NewUnitPage);
AnchorParallel(akRight,0,NewUnitPage);
end;
NewUnitHelpLabel:=TLabel.Create(Self);
with NewUnitHelpLabel do begin
Name:='NewUnitHelpLabel';
Caption:='';
Align:=alClient;
WordWrap:=true;
Parent:=NewUnitDescriptionGroupBox;
end;
NewUnitOkButton:=TButton.Create(Self);
with NewUnitOkButton do begin
Name:='NewUnitOkButton';
Caption:=lisA2PCreateNewFile;
Anchors:=[akLeft,akBottom];
Left:=5;
AutoSize:=true;
Parent:=NewUnitPage;
AnchorParallel(akBottom,5,NewUnitPage);
OnClick:=@NewUnitOkButtonClick;
Enabled:=false;
end;
NewUnitTreeView.AnchorToNeighbour(akBottom,5,NewUnitOkButton);
NewUnitDescriptionGroupBox.AnchorToNeighbour(akBottom,5,NewUnitOkButton);
NewUnitCancelButton:=TButton.Create(Self);
with NewUnitCancelButton do begin
Name:='NewUnitCancelButton';
Caption:=dlgCancel;
AutoSize:=true;
Parent:=NewUnitPage;
AnchorParallel(akTop,0,NewUnitOkButton);
AnchorToNeighbour(akLeft,10,NewUnitOkButton);
ModalResult:=mrCancel;
end;
FillNewUnitTreeView;
end;
procedure TAddToPackageDlg.SetupNewComponentPage;
begin
AncestorTypeLabel:=TLabel.Create(Self);
@ -1758,6 +1875,25 @@ begin
Result:=TrimFilename(CreateAbsolutePath(Filename,LazPackage.Directory));
end;
procedure TAddToPackageDlg.FillNewUnitTreeView;
var
NewParentNode: TTreeNode;
Category: TNewIDEItemCategory;
TemplateID: Integer;
Template: TNewIDEItemTemplate;
begin
NewUnitTreeView.BeginUpdate;
NewUnitTreeView.Items.Clear;
Category:=NewIDEItems.FindByName(FileDescGroupName);
NewParentNode:=NewUnitTreeView.Items.AddObject(nil,Category.Name,Category);
for TemplateID:=0 to Category.Count-1 do begin
Template:=Category[TemplateID];
NewUnitTreeView.Items.AddChildObject(NewParentNode,Template.Name,Template);
end;
NewParentNode.Expand(true);
NewUnitTreeView.EndUpdate;
end;
constructor TAddToPackageDlg.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);