Browse Source

Added new [Setup] section directive: WizardSizePercent. Still need to add to help file.

Martijn Laan 6 years ago
parent
commit
3083304f8f

+ 1 - 0
Components/ScintStylerInnoSetup.pas

@@ -261,6 +261,7 @@ type
     ssWizardResizable,
     ssWizardSmallImageBackColor,
     ssWizardSmallImageFile,
+    ssWizardSizePercent,
     ssWizardStyle);
 
   TLangOptionsSectionDirective = (

+ 6 - 0
Examples/CodeClasses.iss

@@ -13,6 +13,12 @@ WizardResizable=yes
 OutputDir=userdocs:Inno Setup Examples Output
 PrivilegesRequired=lowest
 
+; Uncomment the following four lines to test the layout when resizing, scaling and rtl are active
+;WizardSizePercent=120
+;[LangOptions]
+;RightToLeft=yes
+;DialogFontName=12
+
 [Files]
 Source: compiler:WizModernSmallImage.bmp; Flags: dontcopy
 

+ 25 - 0
Projects/Compile.pas

@@ -208,6 +208,7 @@ type
     ssWizardResizable,
     ssWizardSmallImageBackColor,
     ssWizardSmallImageFile,
+    ssWizardSizePercent,
     ssWizardStyle);
   TLangOptionsSectionDirectives = (
     lsCopyrightFontName,
@@ -3718,6 +3719,24 @@ var
         1: Result := Result + [proCommandLine, proDialog];
       end;
   end;
+
+  procedure StrToPercentages(const S: String; var X, Y: Integer; const Min: Integer);
+  var
+    I: Integer;
+  begin
+    I := Pos(',', S);
+    if I = Length(S) then Invalid;
+    if I <> 0 then begin
+      X := StrToIntDef(Copy(S, 1, I-1), -1);
+      Y := StrToIntDef(Copy(S, I+1, Maxint), -1);
+    end else begin
+      X := StrToIntDef(S, -1);
+      Y := X;
+    end;
+    if (X < Min) or (Y < Min) then
+      Invalid;
+  end;
+
 var
   P: Integer;
   AIncludes: TStringList;
@@ -4432,6 +4451,10 @@ begin
           Invalid;
         WizardSmallImageFile := Value;
       end;
+    ssWizardSizePercent: begin
+        StrToPercentages(Value, SetupHeader.WizardSizePercentX,
+          SetupHeader.WizardSizePercentY, 100)
+      end;
     ssWizardStyle: begin
         if CompareText(Value, 'modern') = 0 then begin
           { no-op }
@@ -8629,6 +8652,8 @@ begin
     SetupHeader.CloseApplicationsFilter := '*.exe,*.dll,*.chm';
     SetupHeader.WizardImageAlphaFormat := afIgnored;
     UsedUserAreasWarning := True;
+    SetupHeader.WizardSizePercentX := 100;
+    SetupHeader.WizardSizePercentY := 100;
 
     { Read [Setup] section }
     EnumIniSection(EnumSetup, 'Setup', 0, 0, True, True, '', False, False);

+ 1 - 0
Projects/Main.pas

@@ -3831,6 +3831,7 @@ begin
       raise;
     end;
   end;
+  WizardForm.SizeAndCenter;
   WizardForm.FlipControlsIfNeeded;
   WizardForm.SetCurPage(wpWelcome);
   if InstallMode = imNormal then begin

+ 1 - 0
Projects/Struct.pas

@@ -104,6 +104,7 @@ type
     MinVersion, OnlyBelowVersion: TSetupVersionData;
     BackColor, BackColor2: Longint;
     WizardImageAlphaFormat: (afIgnored, afDefined, afPremultiplied); // Must be same as Graphics.TAlphaFormat
+    WizardSizePercentX, WizardSizePercentY: Integer;
     PasswordHash: TSHA1Digest;
     PasswordSalt: TSetupSalt;
     ExtraDiskSpaceRequired: Integer64;

+ 29 - 7
Projects/Wizard.pas

@@ -232,6 +232,7 @@ type
     function PageIndexFromID(const ID: Integer): Integer;
     procedure UpdateCurPageButtonVisibility;
     procedure SetCurPage(const NewPageID: Integer);
+    procedure SizeAndCenter;
     procedure UpdateRunList(const SelectedComponents, SelectedTasks: TStringList);
     function ValidateDirEdit: Boolean;
     function ValidateGroupEdit: Boolean;
@@ -720,11 +721,18 @@ begin
       WizardSmallBitmapImage.Left := WizardSmallBitmapImage.Left + (I div 2);
     end;
   end;
+
+  { Not sure why the following is needed but various things related to
+    positioning and anchoring don't work without this (you get positions of
+    page controls back as if there was no anchoring until the page handle
+    is automatically created. Cause might be related to the comment in
+    TNewNotebook.AlignControls. }
+  for I := 0 to OuterNotebook.PageCount-1 do
+    OuterNotebook.Pages[I].HandleNeeded;
+  for I := 0 to InnerNotebook.PageCount-1 do
+    InnerNotebook.Pages[I].HandleNeeded;
+
   InitializeFont;
-  if shWindowVisible in SetupHeader.Options then
-    CenterInsideControl(MainForm, True)
-  else
-    Center;
   SetFontNameSize(WelcomeLabel1.Font, LangOptions.WelcomeFontName,
     LangOptions.WelcomeFontSize, '', 12);
   WelcomeLabel1.Font.Style := [fsBold];
@@ -759,6 +767,7 @@ begin
     ClientWidth := SaveClientWidth;
     ClientHeight := SaveClientHeight;
     if shWizardResizable in SetupHeader.Options then begin
+      { Do not allow user to resize it smaller than the current size. }
       Constraints.MinHeight := Height;
       Constraints.MinWidth := Width;
     end;
@@ -1156,6 +1165,21 @@ begin
     NoIconsCheck.Visible := False;
 end;
 
+procedure TWizardForm.SizeAndCenter;
+begin
+  { Apply custom initial size from script }
+  if SetupHeader.WizardSizePercentX > 100 then
+    ClientWidth := MulDiv(ClientWidth, SetupHeader.WizardSizePercentX, 100);
+  if SetupHeader.WizardSizePercentY > 100 then
+    ClientHeight := MulDiv(ClientHeight, SetupHeader.WizardSizePercentY, 100);
+
+  { Center }
+  if shWindowVisible in SetupHeader.Options then
+    CenterInsideControl(MainForm, True)
+  else
+    Center;
+end;
+
 destructor TWizardForm.Destroy;
 begin
   FreeAndNil(PrevDeselectedComponents);
@@ -1232,6 +1256,7 @@ begin
 
   NotebookPage := TNewNotebookPage.Create(APage);
   NotebookPage.Notebook := InnerNotebook;
+  NotebookPage.HandleNeeded; { See TWizardForm.Create comment }
   APage.FID := FNextPageID;
   APage.FOuterNotebookPage := InnerPage;
   APage.FInnerNotebookPage := NotebookPage;
@@ -2404,9 +2429,6 @@ begin
     this doesn't keep the aspect ratio. Calculate and set new width to restore
     the aspect ratio and update all the other controls in the page for this. }
   AnchorOuterPage(WelcomePage, WizardBitmapImage);
-  { Not sure why the following is needed but without this FinishedPage does not
-    initally return updated control positions. }
-  FinishedPage.HandleNeeded;
   AnchorOuterPage(FinishedPage, WizardBitmapImage2);
 end;
 

+ 2 - 1
whatsnew.htm

@@ -78,7 +78,8 @@ For conditions of distribution and use, see <a href="http://www.jrsoftware.org/f
 <p>The wizard window is now resizable:</p>
 <ul>
   <li>Added new [Setup] section directive: <tt>WizardResizable</tt>. If this directive is set to <tt>yes</tt>, the user will be able to resize and maximize the wizard window.</li>
-  <li>Pascal Scripting change: Added new <tt>Anchors</tt> property to all controls which allows you to support resizing for all your custom controls and wizard pages. See the <i>CodeClasses.iss</i> example script for an example.</li>
+  <li>Added new [Setup] section directive: <tt>WizardSizePercent</tt>, which can be used to increase the default size of the wizard window without changing the font size.</li>
+  <li>Pascal Scripting change: Added new <tt>Anchors</tt> property to all controls which allows you to add full support for <tt>WizardResizable</tt> and <tt>WizardSizePercent</tt> to all your custom controls and wizard pages. See the <i>CodeClasses.iss</i> example script for an example.</li>
 </ul>
 <p><span class="head2">Other changes</span></p>
 <ul>