IDE: added flag to disable autosizing on create

git-svn-id: trunk@26002 -
This commit is contained in:
mattias 2010-06-09 07:06:52 +00:00
parent 44cf8aac3a
commit 9b2dc8742c
9 changed files with 76 additions and 34 deletions

View File

@ -40,8 +40,6 @@ uses
Classes, Forms, Controls, IDEProcs, Debugger, EnvironmentOpts, IDEOptionDefs; Classes, Forms, Controls, IDEProcs, Debugger, EnvironmentOpts, IDEOptionDefs;
type type
TDebuggerDlgClass = class of TDebuggerDlg;
TDebuggerDlg = class(TForm) TDebuggerDlg = class(TForm)
private private
FUpdateCount: integer; FUpdateCount: integer;
@ -54,6 +52,7 @@ type
procedure EndUpdate; procedure EndUpdate;
function UpdateCount: integer; function UpdateCount: integer;
end; end;
TDebuggerDlgClass = class of TDebuggerDlg;
implementation implementation

View File

@ -55,10 +55,10 @@
- header auto, left, top, right, bottom - header auto, left, top, right, bottom
- undock (needed if no place to undock on screen) - undock (needed if no place to undock on screen)
- merge (for example after moving a dock page into a layout) - merge (for example after moving a dock page into a layout)
- enlarge side to left, top, right, bottom
ToDo: ToDo:
- popup menu - popup menu
- enlarge side to left, top, right, bottom
- shrink side left, top, right, bottom - shrink side left, top, right, bottom
- options - options
- close (for pages) - close (for pages)
@ -353,6 +353,7 @@ type
AddDockHeader: boolean = true); AddDockHeader: boolean = true);
function ShowControl(ControlName: string; BringToFront: boolean = false function ShowControl(ControlName: string; BringToFront: boolean = false
): TControl; ): TControl;
procedure CloseAll;
// save/restore layouts // save/restore layouts
procedure SaveMainLayoutToTree(LayoutTree: TAnchorDockLayoutTree); procedure SaveMainLayoutToTree(LayoutTree: TAnchorDockLayoutTree);
@ -1033,6 +1034,29 @@ begin
MakeDockable(Result,true,BringToFront); MakeDockable(Result,true,BringToFront);
end; end;
procedure TAnchorDockMaster.CloseAll;
var
AForm: TCustomForm;
i: Integer;
begin
// first hide all to reduce flicker
i:=Screen.CustomFormCount-1;
while i>=0 do begin
AForm:=GetParentForm(Screen.CustomForms[i]);
if AForm<>nil then
AForm.Hide;
i:=Min(i,Screen.CustomFormCount);
end;
// then close all, but the MainForm
i:=Screen.CustomFormCount-1;
while i>=0 do begin
AForm:=Screen.CustomForms[i];
if AForm<>Application.MainForm then
AForm.Close;
i:=Min(i,Screen.CustomFormCount);
end;
end;
procedure TAnchorDockMaster.SaveMainLayoutToTree(LayoutTree: TAnchorDockLayoutTree procedure TAnchorDockMaster.SaveMainLayoutToTree(LayoutTree: TAnchorDockLayoutTree
); );
var var
@ -2345,7 +2369,7 @@ begin
OnlyCheckIfPossible) then exit(true); OnlyCheckIfPossible) then exit(true);
if EnlargeSideResizeTwoSplitters(Side,OppositeAnchor[ClockwiseAnchor[Side]], if EnlargeSideResizeTwoSplitters(Side,OppositeAnchor[ClockwiseAnchor[Side]],
OnlyCheckIfPossible) then exit(true); OnlyCheckIfPossible) then exit(true);
// ToDo: // ToDo: EnlargeBetween
end; end;
function TAnchorDockHostSite.EnlargeSideResizeTwoSplitters(ShrinkSplitterSide, function TAnchorDockHostSite.EnlargeSideResizeTwoSplitters(ShrinkSplitterSide,

View File

@ -46,10 +46,10 @@ type
{ TIDEEasyDockMaster } { TIDEEasyDockMaster }
TIDEEasyDockMaster = class(TIDEDockMaster) TIDEEasyDockMaster = class(TIDEDockMaster)
private
function DockMasterRestore(const CtrlName: string; ASite: TWinControl function DockMasterRestore(const CtrlName: string; ASite: TWinControl
): TControl; ): TControl;
function DockMasterSave(ACtrl: TControl): string; function DockMasterSave(ACtrl: TControl): string;
private
procedure GetDefaultBounds(AForm: TCustomForm; out Creator: TIDEWindowCreator; procedure GetDefaultBounds(AForm: TCustomForm; out Creator: TIDEWindowCreator;
out NewBounds: TRect; out DockSiblingName: string; out DockAlign: TAlign); out NewBounds: TRect; out DockSiblingName: string; out DockAlign: TAlign);
public public
@ -283,7 +283,7 @@ begin
end; end;
initialization initialization
// create the dockmaster in the initialization section, so that is ready // create the dockmaster in the initialization section, so that it is ready
// when the Register procedures of the packages are called. // when the Register procedures of the packages are called.
TDockMaster.Create(nil); TDockMaster.Create(nil);
IDEDockMaster:=TIDEEasyDockMaster.Create; IDEDockMaster:=TIDEEasyDockMaster.Create;

View File

@ -146,7 +146,8 @@ type
function ShowWatchProperties(const AWatch: TIDEWatch; AWatchExpression: String = ''): TModalresult; virtual; abstract; function ShowWatchProperties(const AWatch: TIDEWatch; AWatchExpression: String = ''): TModalresult; virtual; abstract;
procedure ViewDebugDialog(const ADialogType: TDebugDialogType; procedure ViewDebugDialog(const ADialogType: TDebugDialogType;
BringToFront: Boolean = True; Show: Boolean = true); virtual; abstract; BringToFront: Boolean = True; Show: Boolean = true;
DoDisableAutoSizing: boolean = false); virtual; abstract;
public public
property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger
property Debuggers[const AIndex: Integer]: TDebuggerClass read GetDebuggerClass; property Debuggers[const AIndex: Integer]: TDebuggerClass read GetDebuggerClass;

View File

@ -116,7 +116,7 @@ type
// Dialog routines // Dialog routines
procedure CreateDebugDialog(Sender: TObject; aFormName: string; procedure CreateDebugDialog(Sender: TObject; aFormName: string;
var AForm: TCustomForm); var AForm: TCustomForm; DoDisableAutoSizing: boolean);
procedure DestroyDebugDialog(const ADialogType: TDebugDialogType); procedure DestroyDebugDialog(const ADialogType: TDebugDialogType);
procedure InitDebugOutputDlg; procedure InitDebugOutputDlg;
procedure InitDebugEventsDlg; procedure InitDebugEventsDlg;
@ -187,7 +187,7 @@ type
function ShowBreakPointProperties(const ABreakpoint: TIDEBreakPoint): TModalresult; override; function ShowBreakPointProperties(const ABreakpoint: TIDEBreakPoint): TModalresult; override;
function ShowWatchProperties(const AWatch: TIDEWatch; AWatchExpression: String = ''): TModalresult; override; function ShowWatchProperties(const AWatch: TIDEWatch; AWatchExpression: String = ''): TModalresult; override;
procedure ViewDebugDialog(const ADialogType: TDebugDialogType; BringToFront: Boolean = true; Show: Boolean = true); override; procedure ViewDebugDialog(const ADialogType: TDebugDialogType; BringToFront: Boolean = true; Show: Boolean = true; DoDisableAutoSizing: boolean = false); override;
end; end;
@ -1741,7 +1741,7 @@ begin
end; end;
procedure TDebugManager.ViewDebugDialog(const ADialogType: TDebugDialogType; procedure TDebugManager.ViewDebugDialog(const ADialogType: TDebugDialogType;
BringToFront: Boolean; Show: Boolean); BringToFront: Boolean; Show: Boolean; DoDisableAutoSizing: boolean);
const const
DEBUGDIALOGCLASS: array[TDebugDialogType] of TDebuggerDlgClass = ( DEBUGDIALOGCLASS: array[TDebugDialogType] of TDebuggerDlgClass = (
TDbgOutputForm, TDbgEventsForm, TBreakPointsDlg, TWatchesDlg, TLocalsDlg, TDbgOutputForm, TDbgEventsForm, TBreakPointsDlg, TWatchesDlg, TLocalsDlg,
@ -1753,8 +1753,10 @@ begin
if Destroying then exit; if Destroying then exit;
if FDialogs[ADialogType] = nil if FDialogs[ADialogType] = nil
then begin then begin
FDialogs[ADialogType] := DEBUGDIALOGCLASS[ADialogType].Create(Self); CurDialog := TDebuggerDlg(DEBUGDIALOGCLASS[ADialogType].NewInstance);
CurDialog:=FDialogs[ADialogType]; CurDialog.DisableAutoSizing;
CurDialog.Create(Self);
FDialogs[ADialogType]:=CurDialog;
CurDialog.Name:=NonModalIDEWindowNames[DebugDlgIDEWindow[ADialogType]]; CurDialog.Name:=NonModalIDEWindowNames[DebugDlgIDEWindow[ADialogType]];
CurDialog.Tag := Integer(ADialogType); CurDialog.Tag := Integer(ADialogType);
CurDialog.OnDestroy := @DebugDialogDestroy; CurDialog.OnDestroy := @DebugDialogDestroy;
@ -1773,12 +1775,16 @@ begin
end end
else begin else begin
CurDialog:=FDialogs[ADialogType]; CurDialog:=FDialogs[ADialogType];
if DoDisableAutoSizing then
CurDialog.DisableAutoSizing;
if (CurDialog is TBreakPointsDlg) if (CurDialog is TBreakPointsDlg)
then begin then begin
if (Project1<>nil) then if (Project1<>nil) then
TBreakPointsDlg(CurDialog).BaseDirectory:=Project1.ProjectDirectory; TBreakPointsDlg(CurDialog).BaseDirectory:=Project1.ProjectDirectory;
end; end;
end; end;
if not DoDisableAutoSizing then
CurDialog.EnableAutoSizing;
if Show then if Show then
begin begin
IDEWindowCreators.ShowForm(CurDialog,BringToFront); IDEWindowCreators.ShowForm(CurDialog,BringToFront);
@ -2195,7 +2201,7 @@ begin
end; end;
procedure TDebugManager.CreateDebugDialog(Sender: TObject; aFormName: string; procedure TDebugManager.CreateDebugDialog(Sender: TObject; aFormName: string;
var AForm: TCustomForm); var AForm: TCustomForm; DoDisableAutoSizing: boolean);
function ItIs(Prefix: string): boolean; function ItIs(Prefix: string): boolean;
begin begin
@ -2208,7 +2214,7 @@ begin
for DlgType:=Low(TDebugDialogType) to High(TDebugDialogType) do for DlgType:=Low(TDebugDialogType) to High(TDebugDialogType) do
if ItIs(NonModalIDEWindowNames[DebugDlgIDEWindow[DlgType]]) then if ItIs(NonModalIDEWindowNames[DebugDlgIDEWindow[DlgType]]) then
begin begin
ViewDebugDialog(DlgType,false,false); ViewDebugDialog(DlgType,false,false,DoDisableAutoSizing);
AForm:=FDialogs[DlgType]; AForm:=FDialogs[DlgType];
exit; exit;
end; end;

View File

@ -807,7 +807,7 @@ type
procedure DoShowRestrictionBrowser(Show: boolean; const RestrictedName: String = ''); procedure DoShowRestrictionBrowser(Show: boolean; const RestrictedName: String = '');
procedure DoShowComponentList(Show: boolean); procedure DoShowComponentList(Show: boolean);
procedure CreateIDEWindow(Sender: TObject; aFormName: string; procedure CreateIDEWindow(Sender: TObject; aFormName: string;
var AForm: TCustomForm); var AForm: TCustomForm; DoDisableAutoSizing: boolean);
function CreateNewUniqueFilename(const Prefix, Ext: string; function CreateNewUniqueFilename(const Prefix, Ext: string;
NewOwner: TObject; Flags: TSearchIDEFileFlags; TryWithoutNumber: boolean NewOwner: TObject; Flags: TSearchIDEFileFlags; TryWithoutNumber: boolean
): string; override; ): string; override;
@ -9013,7 +9013,7 @@ begin
end; end;
procedure TMainIDE.CreateIDEWindow(Sender: TObject; aFormName: string; var procedure TMainIDE.CreateIDEWindow(Sender: TObject; aFormName: string; var
AForm: TCustomForm); AForm: TCustomForm; DoDisableAutoSizing: boolean);
function ItIs(Prefix: string): boolean; function ItIs(Prefix: string): boolean;
begin begin
@ -9073,9 +9073,9 @@ begin
begin begin
DoShowComponentList(false); DoShowComponentList(false);
AForm:=ComponentListForm; AForm:=ComponentListForm;
end end;
else if (AForm<>nil) and DoDisableAutoSizing then
raise Exception.Create('TMainIDE.CreateIDEWindow invalid formname: '+aFormName); AForm.DisableAutoSizing;
end; end;
function TMainIDE.CreateNewUniqueFilename(const Prefix, Ext: string; function TMainIDE.CreateNewUniqueFilename(const Prefix, Ext: string;

View File

@ -951,7 +951,7 @@ type
function ActiveOrNewSourceWindow: TSourceNotebook; function ActiveOrNewSourceWindow: TSourceNotebook;
function NewSourceWindow: TSourceNotebook; function NewSourceWindow: TSourceNotebook;
procedure CreateSourceWindow(Sender: TObject; aFormName: string; procedure CreateSourceWindow(Sender: TObject; aFormName: string;
var AForm: TCustomForm); var AForm: TCustomForm; DoDisableAutoSizing: boolean);
procedure GetDefaultLayout(Sender: TObject; aFormName: string; procedure GetDefaultLayout(Sender: TObject; aFormName: string;
out aBounds: TRect; out DockSibling: string; out DockAlign: TAlign); out aBounds: TRect; out DockSibling: string; out DockAlign: TAlign);
function SourceWindowWithPage(const APage: TPage): TSourceNotebook; function SourceWindowWithPage(const APage: TPage): TSourceNotebook;
@ -1045,7 +1045,8 @@ type
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
function CreateNewWindow(Activate: Boolean= False): TSourceNotebook; function CreateNewWindow(Activate: Boolean= False;
DoDisableAutoSizing: boolean = False): TSourceNotebook;
private private
FOnAddJumpPoint: TOnAddJumpPoint; FOnAddJumpPoint: TOnAddJumpPoint;
FOnClearBookmark: TPlaceBookMarkEvent; FOnClearBookmark: TPlaceBookMarkEvent;
@ -8406,12 +8407,12 @@ begin
end; end;
procedure TSourceEditorManager.CreateSourceWindow(Sender: TObject; procedure TSourceEditorManager.CreateSourceWindow(Sender: TObject;
aFormName: string; var AForm: TCustomForm); aFormName: string; var AForm: TCustomForm; DoDisableAutoSizing: boolean);
begin begin
{$IFDEF VerboseIDEDocking} {$IFDEF VerboseIDEDocking}
debugln(['TSourceEditorManager.CreateSourceWindow Sender=',DbgSName(Sender),' FormName="',aFormName,'"']); debugln(['TSourceEditorManager.CreateSourceWindow Sender=',DbgSName(Sender),' FormName="',aFormName,'"']);
{$ENDIF} {$ENDIF}
AForm := CreateNewWindow(false); AForm := CreateNewWindow(false,DoDisableAutoSizing);
AForm.Name:=aFormName; AForm.Name:=aFormName;
end; end;
@ -9107,12 +9108,14 @@ begin
Result := AnsiStrComp(PChar(SrcWin1.Caption), PChar(SrcWin2.Caption)); Result := AnsiStrComp(PChar(SrcWin1.Caption), PChar(SrcWin2.Caption));
end; end;
function TSourceEditorManager.CreateNewWindow(Activate: Boolean= False): TSourceNotebook; function TSourceEditorManager.CreateNewWindow(Activate: Boolean= False;
DoDisableAutoSizing: boolean = false): TSourceNotebook;
var var
i: Integer; i: Integer;
begin begin
Result := TSourceNotebook.Create(Self); Result := TSourceNotebook(TSourceNotebook.NewInstance);
Result.FreeNotification(self); Result.DisableAutoSizing;
Result.Create(Self);
Result.OnDropFiles := @OnFilesDroping; Result.OnDropFiles := @OnFilesDroping;
for i := 1 to FUpdateLock do for i := 1 to FUpdateLock do
@ -9125,6 +9128,8 @@ begin
ShowActiveWindowOnTop(False); ShowActiveWindowOnTop(False);
end; end;
FChangeNotifyLists[semWindowCreate].CallNotifyEvents(Result); FChangeNotifyLists[semWindowCreate].CallNotifyEvents(Result);
if not DoDisableAutoSizing then
Result.EnableAutoSizing;
end; end;
procedure TSourceEditorManager.RemoveWindow(AWindow: TSourceNotebook); procedure TSourceEditorManager.RemoveWindow(AWindow: TSourceNotebook);

View File

@ -113,7 +113,7 @@ type
); );
TCreateIDEWindowEvent = procedure(Sender: TObject; aFormName: string; TCreateIDEWindowEvent = procedure(Sender: TObject; aFormName: string;
var AForm: TCustomForm) of object; var AForm: TCustomForm; DoDisableAutoSizing: boolean) of object;
TGetDefaultIDEWindowLayoutEvent = procedure(Sender: TObject; aFormName: string; TGetDefaultIDEWindowLayoutEvent = procedure(Sender: TObject; aFormName: string;
out aBounds: TRect; out DockSibling: string; out DockAlign: TAlign) of object; out aBounds: TRect; out DockSibling: string; out DockAlign: TAlign) of object;
TShowIDEWindowEvent = procedure(Sender: TObject; AForm: TCustomForm; TShowIDEWindowEvent = procedure(Sender: TObject; AForm: TCustomForm;
@ -190,7 +190,8 @@ type
procedure Delete(Index: integer); procedure Delete(Index: integer);
function IndexOfName(FormName: string): integer; function IndexOfName(FormName: string): integer;
function FindWithName(FormName: string): TIDEWindowCreator; function FindWithName(FormName: string): TIDEWindowCreator;
function GetForm(aFormName: string; AutoCreate: boolean): TCustomForm; function GetForm(aFormName: string; AutoCreate: boolean;
DisableAutoSizing: boolean = false): TCustomForm;
procedure ShowForm(AForm: TCustomForm; BringToFront: boolean); procedure ShowForm(AForm: TCustomForm; BringToFront: boolean);
property OnShowForm: TShowIDEWindowEvent read FOnShowForm write FOnShowForm; property OnShowForm: TShowIDEWindowEvent read FOnShowForm write FOnShowForm;
end; end;
@ -675,13 +676,17 @@ begin
Result:=nil; Result:=nil;
end; end;
function TIDEWindowCreatorList.GetForm(aFormName: string; AutoCreate: boolean function TIDEWindowCreatorList.GetForm(aFormName: string; AutoCreate: boolean;
): TCustomForm; DisableAutoSizing: boolean): TCustomForm;
var var
Item: TIDEWindowCreator; Item: TIDEWindowCreator;
begin begin
Result:=Screen.FindForm(aFormName); Result:=Screen.FindForm(aFormName);
if Result<>nil then exit; if Result<>nil then begin
if DisableAutoSizing then
Result.DisableAutoSizing;
exit;
end;
if AutoCreate then begin if AutoCreate then begin
Item:=FindWithName(aFormName); Item:=FindWithName(aFormName);
if Item=nil then begin if Item=nil then begin
@ -692,7 +697,7 @@ begin
debugln(['TIDEWindowCreatorList.GetForm no OnCreateForm for ',aFormName]); debugln(['TIDEWindowCreatorList.GetForm no OnCreateForm for ',aFormName]);
exit; exit;
end; end;
Item.OnCreateForm(Self,aFormName,Result); Item.OnCreateForm(Self,aFormName,Result,DisableAutoSizing);
if Result=nil then begin if Result=nil then begin
debugln(['TIDEWindowCreatorList.GetForm create failed for ',aFormName]); debugln(['TIDEWindowCreatorList.GetForm create failed for ',aFormName]);
exit; exit;

View File

@ -159,7 +159,7 @@ type
function LoadDependencyList(FirstDependency: TPkgDependency): TModalResult; function LoadDependencyList(FirstDependency: TPkgDependency): TModalResult;
procedure OnOpenPackageForCurrentSrcEditFile(Sender: TObject); procedure OnOpenPackageForCurrentSrcEditFile(Sender: TObject);
procedure CreateIDEWindow(Sender: TObject; aFormName: string; procedure CreateIDEWindow(Sender: TObject; aFormName: string;
var AForm: TCustomForm); var AForm: TCustomForm; DoDisableAutoSizing: boolean);
private private
// helper functions // helper functions
FLastLazarusSrcDir: string; FLastLazarusSrcDir: string;
@ -717,12 +717,14 @@ begin
end; end;
procedure TPkgManager.CreateIDEWindow(Sender: TObject; aFormName: string; var procedure TPkgManager.CreateIDEWindow(Sender: TObject; aFormName: string; var
AForm: TCustomForm); AForm: TCustomForm; DoDisableAutoSizing: boolean);
begin begin
if SysUtils.CompareText(aFormName,NonModalIDEWindowNames[nmiwPkgGraphExplorer])=0 if SysUtils.CompareText(aFormName,NonModalIDEWindowNames[nmiwPkgGraphExplorer])=0
then begin then begin
DoShowPackageGraph(false); DoShowPackageGraph(false);
AForm:=PackageGraphExplorer; AForm:=PackageGraphExplorer;
if DoDisableAutoSizing then
AForm.DisableAutoSizing;
end; end;
end; end;