mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 02:59:15 +02:00
Designer: Disable ViewLFM menu item for virtual units
git-svn-id: trunk@38817 -
This commit is contained in:
parent
9a487a2e50
commit
6b90fc2348
@ -43,7 +43,7 @@ uses
|
|||||||
ClipBrd, TypInfo, contnrs,
|
ClipBrd, TypInfo, contnrs,
|
||||||
// IDEIntf
|
// IDEIntf
|
||||||
IDEDialogs, PropEdits, PropEditUtils, ComponentEditors, MenuIntf, IDEImagesIntf,
|
IDEDialogs, PropEdits, PropEditUtils, ComponentEditors, MenuIntf, IDEImagesIntf,
|
||||||
FormEditingIntf, ComponentReg, //MainBase,
|
FormEditingIntf, ComponentReg,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, EnvironmentOpts, IDECommands,
|
LazarusIDEStrConsts, EnvironmentOpts, IDECommands,
|
||||||
NonControlDesigner, FrameDesigner, AlignCompsDlg, SizeCompsDlg, ScaleCompsDlg,
|
NonControlDesigner, FrameDesigner, AlignCompsDlg, SizeCompsDlg, ScaleCompsDlg,
|
||||||
@ -399,6 +399,8 @@ procedure RegisterStandardDesignerMenuItems;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses SourceFileManager;
|
||||||
|
|
||||||
type
|
type
|
||||||
TCustomFormAccess = class(TCustomForm);
|
TCustomFormAccess = class(TCustomForm);
|
||||||
TControlAccess = class(TControl);
|
TControlAccess = class(TControl);
|
||||||
@ -3469,8 +3471,6 @@ var
|
|||||||
MultiCompsAreSelected: boolean;
|
MultiCompsAreSelected: boolean;
|
||||||
OneControlSelected: Boolean;
|
OneControlSelected: Boolean;
|
||||||
SelectionVisible: Boolean;
|
SelectionVisible: Boolean;
|
||||||
//ActiveSourceEditor: TSourceEditor;
|
|
||||||
//ActiveUnitInfo: TUnitInfo;
|
|
||||||
|
|
||||||
procedure UpdateChangeParentMenu;
|
procedure UpdateChangeParentMenu;
|
||||||
var
|
var
|
||||||
@ -3555,11 +3555,10 @@ begin
|
|||||||
DesignerMenuCopy.Enabled := CanCopy;
|
DesignerMenuCopy.Enabled := CanCopy;
|
||||||
DesignerMenuPaste.Enabled := CanPaste;
|
DesignerMenuPaste.Enabled := CanPaste;
|
||||||
DesignerMenuDeleteSelection.Enabled := CompsAreSelected;
|
DesignerMenuDeleteSelection.Enabled := CompsAreSelected;
|
||||||
|
|
||||||
DesignerMenuChangeClass.Enabled := CompsAreSelected and (ControlSelection.Count = 1);
|
DesignerMenuChangeClass.Enabled := CompsAreSelected and (ControlSelection.Count = 1);
|
||||||
// ToDo: Disable ViewLFM menu item for virtual units. There is no form file yet.
|
// Disable ViewLFM menu item for virtual units. There is no form file yet.
|
||||||
//MainIDE.GetUnitWithPersistent(FLookupRoot, ActiveSourceEditor, ActiveUnitInfo);
|
DesignerMenuViewLFM.Enabled := not SourceFileMgr.DesignerUnitIsVirtual(FLookupRoot);
|
||||||
//DesignerMenuViewLFM.Enabled := not ActiveUnitInfo.IsVirtual;
|
|
||||||
UpdateChangeParentMenu;
|
UpdateChangeParentMenu;
|
||||||
|
|
||||||
DesignerMenuSnapToGridOption.Checked := EnvironmentOptions.SnapToGrid;
|
DesignerMenuSnapToGridOption.Checked := EnvironmentOptions.SnapToGrid;
|
||||||
|
@ -149,8 +149,6 @@ type
|
|||||||
CloseFlags: TCloseFlags; out Component: TComponent): TModalResult;
|
CloseFlags: TCloseFlags; out Component: TComponent): TModalResult;
|
||||||
|
|
||||||
// methods for 'close unit'
|
// methods for 'close unit'
|
||||||
procedure FreeDesigner(AnUnitInfo: TUnitInfo; ADesigner: TDesigner;
|
|
||||||
AFreeComponent: boolean);
|
|
||||||
function CloseUnitComponent(AnUnitInfo: TUnitInfo; Flags: TCloseFlags): TModalResult;
|
function CloseUnitComponent(AnUnitInfo: TUnitInfo; Flags: TCloseFlags): TModalResult;
|
||||||
function CloseDependingUnitComponents(AnUnitInfo: TUnitInfo;
|
function CloseDependingUnitComponents(AnUnitInfo: TUnitInfo;
|
||||||
Flags: TCloseFlags): TModalResult;
|
Flags: TCloseFlags): TModalResult;
|
||||||
@ -177,6 +175,8 @@ type
|
|||||||
function ReplaceUnitUse(OldFilename, OldUnitName,
|
function ReplaceUnitUse(OldFilename, OldUnitName,
|
||||||
NewFilename, NewUnitName: string;
|
NewFilename, NewUnitName: string;
|
||||||
IgnoreErrors, Quiet, Confirm: boolean): TModalResult;
|
IgnoreErrors, Quiet, Confirm: boolean): TModalResult;
|
||||||
|
// related to Designer
|
||||||
|
function DesignerUnitIsVirtual(aLookupRoot: TComponent): Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -4642,16 +4642,17 @@ begin
|
|||||||
Result:=LoadCodeBuffer(ACodeBuffer,AFilename,Flags,ShowAbort);
|
Result:=LoadCodeBuffer(ACodeBuffer,AFilename,Flags,ShowAbort);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazSourceFileManager.FreeDesigner(AnUnitInfo: TUnitInfo;
|
|
||||||
ADesigner: TDesigner; AFreeComponent: boolean);
|
|
||||||
begin
|
|
||||||
AnUnitInfo.LoadedDesigner:=false;
|
|
||||||
ADesigner.PrepareFreeDesigner(AFreeComponent);
|
|
||||||
ADesigner.FinalizeFreeDesigner;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TLazSourceFileManager.CloseUnitComponent(AnUnitInfo: TUnitInfo;
|
function TLazSourceFileManager.CloseUnitComponent(AnUnitInfo: TUnitInfo;
|
||||||
Flags: TCloseFlags): TModalResult;
|
Flags: TCloseFlags): TModalResult;
|
||||||
|
var
|
||||||
|
OldDesigner: TDesigner;
|
||||||
|
|
||||||
|
procedure FreeDesigner(AFreeComponent: boolean);
|
||||||
|
begin
|
||||||
|
AnUnitInfo.LoadedDesigner:=false;
|
||||||
|
OldDesigner.PrepareFreeDesigner(AFreeComponent);
|
||||||
|
OldDesigner.FinalizeFreeDesigner;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure FreeUnusedComponents;
|
procedure FreeUnusedComponents;
|
||||||
var
|
var
|
||||||
@ -4673,7 +4674,6 @@ function TLazSourceFileManager.CloseUnitComponent(AnUnitInfo: TUnitInfo;
|
|||||||
|
|
||||||
var
|
var
|
||||||
AForm: TCustomForm;
|
AForm: TCustomForm;
|
||||||
OldDesigner: TDesigner;
|
|
||||||
LookupRoot: TComponent;
|
LookupRoot: TComponent;
|
||||||
ComponentStillUsed: Boolean;
|
ComponentStillUsed: Boolean;
|
||||||
begin
|
begin
|
||||||
@ -4746,14 +4746,14 @@ begin
|
|||||||
{$IFDEF VerboseIDEMultiForm}
|
{$IFDEF VerboseIDEMultiForm}
|
||||||
DebugLn(['TLazSourceFileManager.CloseUnitComponent hiding component and freeing designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
DebugLn(['TLazSourceFileManager.CloseUnitComponent hiding component and freeing designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FreeDesigner(AnUnitInfo, OldDesigner, false);
|
FreeDesigner(false);
|
||||||
end else begin
|
end else begin
|
||||||
// free designer and design form
|
// free designer and design form
|
||||||
{$IFDEF VerboseIDEMultiForm}
|
{$IFDEF VerboseIDEMultiForm}
|
||||||
DebugLn(['TLazSourceFileManager.CloseUnitComponent freeing component and designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
DebugLn(['TLazSourceFileManager.CloseUnitComponent freeing component and designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
try
|
try
|
||||||
FreeDesigner(AnUnitInfo, OldDesigner, true);
|
FreeDesigner(true);
|
||||||
finally
|
finally
|
||||||
AnUnitInfo.Component:=nil;
|
AnUnitInfo.Component:=nil;
|
||||||
end;
|
end;
|
||||||
@ -5702,6 +5702,15 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazSourceFileManager.DesignerUnitIsVirtual(aLookupRoot: TComponent): Boolean;
|
||||||
|
var
|
||||||
|
ActiveSourceEditor: TSourceEditor;
|
||||||
|
ActiveUnitInfo: TUnitInfo;
|
||||||
|
begin
|
||||||
|
Assert(Assigned(aLookupRoot),'SourceFileMgr.DesignerUnitIsVirtual: aLookupRoot is not assigned');
|
||||||
|
MainIDE.GetUnitWithPersistent(aLookupRoot, ActiveSourceEditor, ActiveUnitInfo);
|
||||||
|
Result := ActiveUnitInfo.IsVirtual;
|
||||||
|
end;
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
SourceFileMgrSingleton.Free;
|
SourceFileMgrSingleton.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user