소스 검색

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

Martijn Laan 6 년 전
부모
커밋
3083304f8f
7개의 변경된 파일65개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 0
      Components/ScintStylerInnoSetup.pas
  2. 6 0
      Examples/CodeClasses.iss
  3. 25 0
      Projects/Compile.pas
  4. 1 0
      Projects/Main.pas
  5. 1 0
      Projects/Struct.pas
  6. 29 7
      Projects/Wizard.pas
  7. 2 1
      whatsnew.htm

+ 1 - 0
Components/ScintStylerInnoSetup.pas

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

+ 6 - 0
Examples/CodeClasses.iss

@@ -13,6 +13,12 @@ WizardResizable=yes
 OutputDir=userdocs:Inno Setup Examples Output
 OutputDir=userdocs:Inno Setup Examples Output
 PrivilegesRequired=lowest
 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]
 [Files]
 Source: compiler:WizModernSmallImage.bmp; Flags: dontcopy
 Source: compiler:WizModernSmallImage.bmp; Flags: dontcopy
 
 

+ 25 - 0
Projects/Compile.pas

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

+ 1 - 0
Projects/Main.pas

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

+ 1 - 0
Projects/Struct.pas

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

+ 29 - 7
Projects/Wizard.pas

@@ -232,6 +232,7 @@ type
     function PageIndexFromID(const ID: Integer): Integer;
     function PageIndexFromID(const ID: Integer): Integer;
     procedure UpdateCurPageButtonVisibility;
     procedure UpdateCurPageButtonVisibility;
     procedure SetCurPage(const NewPageID: Integer);
     procedure SetCurPage(const NewPageID: Integer);
+    procedure SizeAndCenter;
     procedure UpdateRunList(const SelectedComponents, SelectedTasks: TStringList);
     procedure UpdateRunList(const SelectedComponents, SelectedTasks: TStringList);
     function ValidateDirEdit: Boolean;
     function ValidateDirEdit: Boolean;
     function ValidateGroupEdit: Boolean;
     function ValidateGroupEdit: Boolean;
@@ -720,11 +721,18 @@ begin
       WizardSmallBitmapImage.Left := WizardSmallBitmapImage.Left + (I div 2);
       WizardSmallBitmapImage.Left := WizardSmallBitmapImage.Left + (I div 2);
     end;
     end;
   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;
   InitializeFont;
-  if shWindowVisible in SetupHeader.Options then
-    CenterInsideControl(MainForm, True)
-  else
-    Center;
   SetFontNameSize(WelcomeLabel1.Font, LangOptions.WelcomeFontName,
   SetFontNameSize(WelcomeLabel1.Font, LangOptions.WelcomeFontName,
     LangOptions.WelcomeFontSize, '', 12);
     LangOptions.WelcomeFontSize, '', 12);
   WelcomeLabel1.Font.Style := [fsBold];
   WelcomeLabel1.Font.Style := [fsBold];
@@ -759,6 +767,7 @@ begin
     ClientWidth := SaveClientWidth;
     ClientWidth := SaveClientWidth;
     ClientHeight := SaveClientHeight;
     ClientHeight := SaveClientHeight;
     if shWizardResizable in SetupHeader.Options then begin
     if shWizardResizable in SetupHeader.Options then begin
+      { Do not allow user to resize it smaller than the current size. }
       Constraints.MinHeight := Height;
       Constraints.MinHeight := Height;
       Constraints.MinWidth := Width;
       Constraints.MinWidth := Width;
     end;
     end;
@@ -1156,6 +1165,21 @@ begin
     NoIconsCheck.Visible := False;
     NoIconsCheck.Visible := False;
 end;
 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;
 destructor TWizardForm.Destroy;
 begin
 begin
   FreeAndNil(PrevDeselectedComponents);
   FreeAndNil(PrevDeselectedComponents);
@@ -1232,6 +1256,7 @@ begin
 
 
   NotebookPage := TNewNotebookPage.Create(APage);
   NotebookPage := TNewNotebookPage.Create(APage);
   NotebookPage.Notebook := InnerNotebook;
   NotebookPage.Notebook := InnerNotebook;
+  NotebookPage.HandleNeeded; { See TWizardForm.Create comment }
   APage.FID := FNextPageID;
   APage.FID := FNextPageID;
   APage.FOuterNotebookPage := InnerPage;
   APage.FOuterNotebookPage := InnerPage;
   APage.FInnerNotebookPage := NotebookPage;
   APage.FInnerNotebookPage := NotebookPage;
@@ -2404,9 +2429,6 @@ begin
     this doesn't keep the aspect ratio. Calculate and set new width to restore
     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. }
     the aspect ratio and update all the other controls in the page for this. }
   AnchorOuterPage(WelcomePage, WizardBitmapImage);
   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);
   AnchorOuterPage(FinishedPage, WizardBitmapImage2);
 end;
 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>
 <p>The wizard window is now resizable:</p>
 <ul>
 <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>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>
 </ul>
 <p><span class="head2">Other changes</span></p>
 <p><span class="head2">Other changes</span></p>
 <ul>
 <ul>