FIX: Bug [0001784] Lazarus 1.7: The window size greater than the size of the screen after restart DC/The width of the columns is not restored

This commit is contained in:
Alexander Koblov 2017-04-08 16:56:03 +00:00
commit 34fc0f119e
3 changed files with 47 additions and 9 deletions

View file

@ -1606,8 +1606,7 @@ end;
procedure TDrawGridEx.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
// Don't auto adjust vertical layout
inherited DoAutoAdjustLayout(AMode, AXProportion, 1.0);
// Don't auto adjust layout
end;
{$endif}

View file

@ -659,6 +659,7 @@ type
{$ENDIF}
private
{ Private declarations }
FPixelsPerInch: Integer;
FMainSplitterPos: Double;
PanelSelected: TFilePanelSelect;
DrivesList : TDrivesList;
@ -734,6 +735,12 @@ type
procedure RightDriveBarExecuteDrive(ToolItem: TKASToolItem);
procedure SetDragCursor(Shift: TShiftState);
protected
{$if lcl_fullversion >= 1070000}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$endif}
public
constructor Create(TheOwner: TComponent); override;
Function ActiveFrame: TFileView; // get Active frame
@ -3617,6 +3624,24 @@ begin
FrameRight.SetDragCursor(Shift);
end;
{$if lcl_fullversion >= 1070000}
procedure TfrmMain.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
DisableAutoSizing;
try
ScaleFontsPPI(AYProportion);
BorderSpacing.AutoAdjustLayout(AXProportion, AYProportion);
Constraints.AutoAdjustLayout(AXProportion, AYProportion);
finally
EnableAutoSizing;
end;
end;
end;
{$endif}
procedure TfrmMain.FormKeyUp( Sender: TObject; var Key: Word;
Shift: TShiftState) ;
begin
@ -5364,16 +5389,25 @@ end;
procedure TfrmMain.LoadWindowState;
var
ANode: TXmlNode;
ALeft, ATop, AWidth, AHeight: Integer;
begin
(* Load window bounds and state *)
ANode := gConfig.FindNode(gConfig.RootNode, 'MainWindow/Position');
if Assigned(ANode) then
ANode := gConfig.FindNode(gConfig.RootNode, 'MainWindow/Position', True);
begin
MainSplitterPos := gConfig.GetValue(ANode, 'Splitter', 50.0);
Left := gConfig.GetValue(ANode, 'Left', 80);
Top := gConfig.GetValue(ANode, 'Top', 48);
Width := gConfig.GetValue(ANode, 'Width', 800);
Height := gConfig.GetValue(ANode, 'Height', 480);
ALeft := gConfig.GetValue(ANode, 'Left', 80);
ATop := gConfig.GetValue(ANode, 'Top', 48);
AWidth := gConfig.GetValue(ANode, 'Width', 800);
AHeight := gConfig.GetValue(ANode, 'Height', 480);
{$if lcl_fullversion >= 1070000}
FPixelsPerInch := gConfig.GetValue(ANode, 'PixelsPerInch', DesignTimePPI);
if Scaled and (Screen.PixelsPerInch <> FPixelsPerInch) then
begin
AWidth := MulDiv(AWidth, Screen.PixelsPerInch, FPixelsPerInch);
AHeight := MulDiv(AHeight, Screen.PixelsPerInch, FPixelsPerInch);
end;
{$endif}
SetBounds(ALeft, ATop, AWidth, AHeight);
if gConfig.GetValue(ANode, 'Maximized', True) then
Self.WindowState := wsMaximized;
end;
@ -5396,6 +5430,7 @@ begin
gConfig.SetValue(ANode, 'Top', Top);
gConfig.SetValue(ANode, 'Width', Width);
gConfig.SetValue(ANode, 'Height', Height);
gConfig.SetValue(ANode, 'PixelsPerInch', Screen.PixelsPerInch);
end;
gConfig.SetValue(ANode, 'Maximized', (WindowState = wsMaximized));
gConfig.SetValue(ANode, 'Splitter', FMainSplitterPos);

View file

@ -235,7 +235,7 @@ type
implementation
uses
crc, uDebug, uLng, uGlobs;
LCLType, Forms, crc, uDebug, uLng, uGlobs;
var
DefaultTitleHash: LongWord = 0;
@ -773,8 +773,10 @@ var
SubNode: TXmlNode;
Quality: Integer = 0;
AColumn: TPanelColumn;
APixelsPerInch: Integer;
begin
FCustomView := AConfig.GetValue(ANode, 'CustomView', False);
APixelsPerInch:= AConfig.GetValue(ANode, 'PixelsPerInch', Screen.PixelsPerInch);
FCursorBorder := AConfig.GetAttr(ANode, 'CursorBorder/Enabled', gUseCursorBorder);
FCursorBorderColor := TColor(AConfig.GetValue(ANode, 'CursorBorder/Color', gCursorBorderColor));
FUseFrameCursor := AConfig.GetAttr(ANode, 'UseFrameCursor', gUseFrameCursor);
@ -795,6 +797,7 @@ begin
AColumn.Title := AConfig.GetValue(SubNode, 'Title', '');
AColumn.FuncString := AConfig.GetValue(SubNode, 'FuncString', '');
AColumn.Width := AConfig.GetValue(SubNode, 'Width', 50);
AColumn.Width := MulDiv(AColumn.Width, Screen.PixelsPerInch, APixelsPerInch);
AColumn.Align := TAlignment(AConfig.GetValue(SubNode, 'Align', Integer(0)));
AConfig.GetFont(SubNode, 'Font', AColumn.FontName, AColumn.FontSize, Integer(AColumn.FontStyle), Quality,
gFonts[dcfMain].Name, gFonts[dcfMain].Size, Integer(gFonts[dcfMain].Style), Quality);
@ -844,6 +847,7 @@ var
AColumn: TPanelColumn;
begin
AConfig.SetValue(ANode, 'CustomView', FCustomView);
AConfig.SetValue(ANode, 'PixelsPerInch', Screen.PixelsPerInch);
AConfig.SetAttr(ANode, 'CursorBorder/Enabled', FCursorBorder);
if FCursorBorderColor <> clNone then
AConfig.SetValue(ANode, 'CursorBorder/Color', FCursorBorderColor);