Ver Fonte

Merge branch 'main' into excludelightcontrols

# Conflicts:
#	Components/NewCtrls.pas
#	Projects/Src/Setup.MainFunc.pas
#	Projects/Src/Setup.Uninstall.pas
Martijn Laan há 2 meses atrás
pai
commit
8403334040

+ 1 - 1
Components/Components.dpk

@@ -38,12 +38,12 @@ requires
   xmlrtl;
 
 contains
-  BidiCtrls in 'BidiCtrls.pas',
   BitmapButton in 'BitmapButton.pas',
   BitmapImage in 'BitmapImage.pas',
   DropListBox in 'DropListBox.pas',
   FolderTreeView in 'FolderTreeView.pas',
   NewCheckListBox in 'NewCheckListBox.pas',
+  NewCtrls in 'NewCtrls.pas',
   NewNotebookReg in 'NewNotebookReg.pas',
   NewProgressBar in 'NewProgressBar.pas',
   NewStaticText in 'NewStaticText.pas',

+ 7 - 30
Components/BidiCtrls.pas → Components/NewCtrls.pas

@@ -1,4 +1,4 @@
-unit BidiCtrls;
+unit NewCtrls;
 
 {
   Inno Setup
@@ -8,8 +8,10 @@ unit BidiCtrls;
 
   Previously this unit had RTL-capable versions of standard controls
   
-  But now standard controls are RTL-capable already, and the code left is mostly related
-  to VCL Styles, activated fully when VCLSTYLES is defined
+  But now standard controls are RTL-capable already, and there's not much code left here
+
+  Define VCLSTYLES to include an improved version TButtonStyleHook.DrawButton for command
+  link buttons
 }
 
 interface
@@ -20,10 +22,7 @@ uses
   StdCtrls, ExtCtrls;
 
 type
-  TNewEdit = class(TEdit)
-  public
-    constructor Create(AOwner: TComponent); override;
-  end;
+  TNewEdit = class(TEdit);
 
   TNewMemo = class(TMemo);
 
@@ -33,15 +32,12 @@ type
 
   TNewButton = class(TButton)
   private
-    class var FDontStyle: Boolean;
     class constructor Create;
     class destructor Destroy;
   protected
     procedure CreateParams(var Params: TCreateParams); override;
   public
-    constructor Create(AOwner: TComponent); override;
     function AdjustHeightIfCommandLink: Integer;
-    class property DontStyle: Boolean write FDontStyle;
   end;
 
   TNewButtonStyleHook = class(TButtonStyleHook)
@@ -65,11 +61,8 @@ type
     function AdjustHeight: Integer;
   end;
 
-var
-  DontStyleBidiCtrls: Boolean;
-
 procedure Register;
-
+  
 implementation
 
 uses
@@ -82,15 +75,6 @@ begin
     TNewButton, TNewCheckBox, TNewRadioButton]);
 end;
 
-{ TNewEdit }
-
-constructor TNewEdit.Create(AOwner: TComponent);
-begin
-  inherited;
-  if DontStyleBidiCtrls then
-    StyleName := TStyleManager.SystemStyleName;
-end;
-
 { TNewButton }
 
 class constructor TNewButton.Create;
@@ -98,13 +82,6 @@ begin
   TCustomStyleEngine.RegisterStyleHook(TNewButton, TNewButtonStyleHook);
 end;
 
-constructor TNewButton.Create(AOwner: TComponent);
-begin
-  inherited;
-  if DontStyleBidiCtrls or FDontStyle then
-    StyleName := TStyleManager.SystemStyleName;
-end;
-
 procedure TNewButton.CreateParams(var Params: TCreateParams);
 begin
   inherited;

+ 1 - 1
Projects/Setup.dpr

@@ -77,7 +77,7 @@ uses
   Shared.TaskDialogFunc in 'Src\Shared.TaskDialogFunc.pas',
   BidiUtils in '..\Components\BidiUtils.pas',
   PathFunc in '..\Components\PathFunc.pas',
-  BidiCtrls in '..\Components\BidiCtrls.pas',
+  NewCtrls in '..\Components\NewCtrls.pas',
   BitmapButton in '..\Components\BitmapButton.pas',
   BitmapImage in '..\Components\BitmapImage.pas',
   FolderTreeView in '..\Components\FolderTreeView.pas',

+ 1 - 1
Projects/Setup.dproj

@@ -146,7 +146,7 @@
         <DCCReference Include="Src\Shared.TaskDialogFunc.pas"/>
         <DCCReference Include="..\Components\BidiUtils.pas"/>
         <DCCReference Include="..\Components\PathFunc.pas"/>
-        <DCCReference Include="..\Components\BidiCtrls.pas"/>
+        <DCCReference Include="..\Components\NewCtrls.pas"/>
         <DCCReference Include="..\Components\BitmapButton.pas"/>
         <DCCReference Include="..\Components\BitmapImage.pas"/>
         <DCCReference Include="..\Components\FolderTreeView.pas"/>

+ 1 - 1
Projects/SetupCustomStyle.dpr

@@ -77,7 +77,7 @@ uses
   Shared.TaskDialogFunc in 'Src\Shared.TaskDialogFunc.pas',
   BidiUtils in '..\Components\BidiUtils.pas',
   PathFunc in '..\Components\PathFunc.pas',
-  BidiCtrls in '..\Components\BidiCtrls.pas',
+  NewCtrls in '..\Components\NewCtrls.pas',
   BitmapButton in '..\Components\BitmapButton.pas',
   BitmapImage in '..\Components\BitmapImage.pas',
   FolderTreeView in '..\Components\FolderTreeView.pas',

+ 1 - 1
Projects/SetupCustomStyle.dproj

@@ -147,7 +147,7 @@
         <DCCReference Include="Src\Shared.TaskDialogFunc.pas"/>
         <DCCReference Include="..\Components\BidiUtils.pas"/>
         <DCCReference Include="..\Components\PathFunc.pas"/>
-        <DCCReference Include="..\Components\BidiCtrls.pas"/>
+        <DCCReference Include="..\Components\NewCtrls.pas"/>
         <DCCReference Include="..\Components\BitmapButton.pas"/>
         <DCCReference Include="..\Components\BitmapImage.pas"/>
         <DCCReference Include="..\Components\FolderTreeView.pas"/>

+ 2 - 2
Projects/Src/Compiler.ScriptClasses.pas

@@ -281,7 +281,7 @@ begin
   end;
 end;
 
-procedure RegisterBidiCtrls_C(Cl: TPSPascalCompiler);
+procedure RegisterNewCtrls_C(Cl: TPSPascalCompiler);
 begin
   Cl.AddClassN(Cl.FindClass('TEdit'), 'TNewEdit');
   Cl.AddClassN(Cl.FindClass('TMemo'), 'TNewMemo');
@@ -705,7 +705,7 @@ begin
   RegisterStartMenuFolderTreeView_C(Cl);
   RegisterBitmapButton_C(Cl);
   RegisterBitmapImage_C(Cl);
-  RegisterBidiCtrls_C(Cl);
+  RegisterNewCtrls_C(Cl);
 
   RegisterNewNotebook_C(Cl);
   RegisterNewNotebookPage_C(Cl);

+ 1 - 7
Projects/Src/Setup.MainFunc.pas

@@ -247,7 +247,7 @@ implementation
 
 uses
   ShellAPI, ShlObj, StrUtils, ActiveX, RegStr, Imaging.pngimage, Themes,
-  ChaCha20, ECDSA, ISSigFunc, BidiCtrls, PathFunc, UnsignedFunc, FormBackgroundStyleHook, RichEditViewer,
+  ChaCha20, ECDSA, ISSigFunc, NewCtrls, PathFunc, UnsignedFunc, FormBackgroundStyleHook, RichEditViewer,
   SetupLdrAndSetup.Messages, Shared.SetupMessageIDs, Setup.DownloadFileFunc, Setup.ExtractFileFunc,
   SetupLdrAndSetup.InstFunc, Setup.InstFunc, Setup.RedirFunc,
   Compression.Base, Compression.Zlib, Compression.bzlib, Compression.LZMADecompressor,
@@ -3457,12 +3457,6 @@ begin
           {$ENDIF}
           then begin
             TStyleManager.SetStyle(Handle);
-            if not IsDarkInstallMode then begin
-              if SetupHeader.WizardControlStyling = wcsOnlyRequired then begin
-                DontStyleBidiCtrls := True;
-              end else if SetupHeader.WizardControlStyling = wcsAllButButtons then
-                TNewButton.DontStyle := True;
-            end;
             CustomWizardBackground := SetupHeader.WizardBackColor <> clNone;
             if CustomWizardBackground then begin
               TCustomStyleEngine.RegisterStyleHook(TSetupForm, TFormBackgroundStyleHook);

+ 1 - 1
Projects/Src/Setup.NewDiskForm.pas

@@ -13,7 +13,7 @@ interface
 
 uses
   Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs,
-  Setup.SetupForm, StdCtrls, ExtCtrls, NewStaticText, BitmapImage, BidiCtrls;
+  Setup.SetupForm, StdCtrls, ExtCtrls, NewStaticText, BitmapImage, NewCtrls;
 
 type
   TNewDiskForm = class(TSetupForm)

+ 3 - 3
Projects/Src/Setup.ScriptClasses.pas

@@ -24,7 +24,7 @@ uses
   uPSR_std, uPSR_classes, uPSR_graphics, uPSR_controls, uPSR_forms,
   uPSR_stdctrls, uPSR_extctrls, uPSR_comobj,
   NewStaticText, NewCheckListBox, NewProgressBar, RichEditViewer,
-  UIStateForm, PasswordEdit, FolderTreeView, BitmapButton, BitmapImage, NewNotebook, BidiCtrls,
+  UIStateForm, PasswordEdit, FolderTreeView, BitmapButton, BitmapImage, NewNotebook, NewCtrls,
   Shared.SetupTypes, Shared.CommonFunc.Vcl,
   Setup.SetupForm, Setup.MainForm, Setup.WizardForm, Setup.ScriptDlg, Setup.UninstallProgressForm;
 
@@ -198,7 +198,7 @@ begin
   end;
 end;
 
-procedure RegisterBidiCtrls_R(Cl: TPSRuntimeClassImporter);
+procedure RegisterNewCtrls_R(Cl: TPSRuntimeClassImporter);
 begin
   Cl.Add(TNewEdit);
   Cl.Add(TNewMemo);
@@ -496,7 +496,7 @@ begin
     RegisterStartMenuFolderTreeView_R(Cl);
     RegisterBitmapButton_R(Cl);
     RegisterBitmapImage_R(Cl);
-    RegisterBidiCtrls_R(Cl);
+    RegisterNewCtrls_R(Cl);
 
     RegisterNewNotebook_R(Cl);
     RegisterNewNotebookPage_R(Cl);

+ 1 - 1
Projects/Src/Setup.ScriptDlg.pas

@@ -16,7 +16,7 @@ uses
   Shared.Struct, Setup.WizardForm, Setup.DownloadFileFunc, Setup.ISSigVerifyFunc,
   Setup.ScriptFunc.HelperFunc, Compression.SevenZipDecoder,
   NewCheckListBox, NewStaticText, NewProgressBar, PasswordEdit, RichEditViewer,
-  BidiCtrls, TaskbarProgressFunc;
+  NewCtrls, TaskbarProgressFunc;
 
 type
   TInputQueryWizardPage = class(TWizardPage)

+ 1 - 1
Projects/Src/Setup.SelectFolderForm.pas

@@ -13,7 +13,7 @@ interface
 
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-  Setup.SetupForm, StdCtrls, FolderTreeView, NewStaticText, BidiCtrls;
+  Setup.SetupForm, StdCtrls, FolderTreeView, NewStaticText, NewCtrls;
 
 type
   TSelectFolderForm = class(TSetupForm)

+ 1 - 1
Projects/Src/Setup.SelectLanguageForm.pas

@@ -13,7 +13,7 @@ interface
 
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-  Setup.SetupForm, StdCtrls, ExtCtrls, NewStaticText, BitmapImage, BidiCtrls;
+  Setup.SetupForm, StdCtrls, ExtCtrls, NewStaticText, BitmapImage, NewCtrls;
 
 type
   TSelectLanguageForm = class(TSetupForm)

+ 32 - 3
Projects/Src/Setup.SetupForm.pas

@@ -11,11 +11,13 @@ unit Setup.SetupForm;
   Also used by UninstallProgressForm and UninstallSharedFileForm!
 
   Requires following globals to be set:
+  -IsDarkInstallMode
   -LangOptions.RightToLeft
   -LangOptions.DialogFontName
   -LangOptions.DialogFontSize
   -LangOptions.DialogFontBaseScaleWidth
   -LangOptions.DialogFontBaseScaleHeight
+  -shWizardLightButtonsUnstyled in SetupHeader.Options
   -shWizardBorderStyled in SetupHeader.Options
   -shWizardKeepAspectRatio in SetupHeader.Options
   Also requires following globals to be set, but 0 is allowed:
@@ -94,9 +96,10 @@ function SetFontNameSize(const AFont: TFont; const AName: String;
 implementation
 
 uses
-  Generics.Collections, UITypes, WinXPanels,
-  BidiUtils, NewNotebook,
-  Shared.Struct, Shared.CommonFunc, Shared.CommonFunc.Vcl, Setup.MainFunc;
+  Generics.Collections, UITypes, WinXPanels, Themes,
+  BidiUtils, NewCtrls, NewNotebook,
+  Shared.Struct, Shared.CommonFunc, Shared.CommonFunc.Vcl,
+  Setup.MainFunc, Setup.InstFunc;
 
 var
   WM_QueryCancelAutoPlay: UINT;
@@ -196,6 +199,28 @@ begin
     Result := Screen.PixelsPerInch;
 end;
 
+procedure DisableChildControlsStylesAsNeeded(const ParentCtl: TWinControl; const SystemStyleName: String);
+begin
+  for var I := 0 to ParentCtl.ControlCount-1 do begin
+    const Ctl = ParentCtl.Controls[I];
+
+    if Ctl is TWinControl then begin
+      const WinCtl = Ctl as TWinControl;
+      { Sanity check that the control's handle isn't already allocated,
+        because otherwise it would run TWinControl.UpdateStyleElements
+        which does a RecreateWnd. Might work but isn't efficient. }
+      if WinCtl.HandleAllocated then
+        InternalError('Unexpected HandleAllocated');
+      { Update children }
+      DisableChildControlsStylesAsNeeded(WinCtl, SystemStyleName);
+    end;
+
+    { Update self }
+    if Ctl is TNewButton then
+      Ctl.StyleName := SystemStyleName;
+  end;
+end;
+
 { TSetupForm }
 
 constructor TSetupForm.Create(AOwner: TComponent);
@@ -211,6 +236,8 @@ begin
      CreateParams below. }
   if FRightToLeft then
     BiDiMode := bdRightToLeft;
+  if not IsDarkInstallMode and (shWizardLightButtonsUnstyled in SetupHeader.Options) then
+    DisableChildControlsStylesAsNeeded(Self, TStyleManager.SystemStyleName);
   { In Delphi 2005 and later, Position defaults to poDefaultPosOnly, but we
     don't want the form to be changing positions whenever its handle is
     recreated, so change it to the D7 and earlier default of poDesigned. }
@@ -228,6 +255,8 @@ begin
   inherited;
   if FRightToLeft then
     BiDiMode := bdRightToLeft;
+  if not IsDarkInstallMode and (shWizardLightButtonsUnstyled in SetupHeader.Options) then
+    DisableChildControlsStylesAsNeeded(Self, TStyleManager.SystemStyleName);
 end;
 
 function TSetupForm.CalculateButtonWidth(const ButtonCaptions: array of String): Integer;

+ 1 - 1
Projects/Src/Setup.TaskDialogForm.pas

@@ -16,7 +16,7 @@ interface
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics,
   Controls, Forms, Dialogs, WinXPanels, ExtCtrls, StdCtrls,
-  BidiCtrls, BitmapImage, NewStaticText,
+  NewCtrls, BitmapImage, NewStaticText,
   Setup.SetupForm;
 
 const

+ 3 - 7
Projects/Src/Setup.Uninstall.pas

@@ -18,7 +18,7 @@ implementation
 
 uses
   Windows, SysUtils, Messages, Forms, Themes, Graphics,
-  PathFunc, BidiCtrls, UnsignedFunc, FormBackgroundStyleHook,
+  PathFunc, NewCtrls, UnsignedFunc, FormBackgroundStyleHook,
   Shared.CommonFunc, Shared.CommonFunc.Vcl, Setup.UninstallLog, SetupLdrAndSetup.Messages,
   Shared.SetupMessageIDs, SetupLdrAndSetup.InstFunc, Setup.InstFunc, Shared.Struct,
   Shared.SetupEntFunc, Setup.UninstallProgressForm, Setup.UninstallSharedFileForm,
@@ -574,12 +574,6 @@ begin
       var Handle: TStyleManager.TStyleServicesHandle;
       if TStyleManager.TryLoadFromResource(HInstance, StyleName, 'VCLSTYLE', Handle) then begin
         TStyleManager.SetStyle(Handle);
-        if not IsDarkInstallMode then begin
-          if SetupHeader.WizardControlStyling = wcsOnlyRequired then begin
-            DontStyleBidiCtrls := True;
-          end else if SetupHeader.WizardControlStyling = wcsAllButButtons then
-            TNewButton.DontStyle := True;
-        end;
         CustomWizardBackground := (SetupHeader.WizardBackColor <> clNone) and
           (SetupHeader.WizardBackColor <> clWindow); { Unlike Setup, Uninstall doesn't support background images which is why this extra check is here }
         if CustomWizardBackground then begin
@@ -859,6 +853,8 @@ begin
     LangOptions.DialogFontBaseScaleWidth := MessagesLangOptions.DialogFontBaseScaleWidth;
     LangOptions.DialogFontBaseScaleHeight := MessagesLangOptions.DialogFontBaseScaleHeight;
     LangOptions.RightToLeft := lfRightToLeft in MessagesLangOptions.Flags;
+    if lfWizardLightButtonsUnstyled in MessagesLangOptions.Flags then
+      Include(SetupHeader.Options, shWizardLightButtonsUnstyled);
     if lfWizardBorderStyled in MessagesLangOptions.Flags then
       Include(SetupHeader.Options, shWizardBorderStyled);
     if lfWizardKeepAspectRatio in MessagesLangOptions.Flags then

+ 1 - 1
Projects/Src/Setup.UninstallProgressForm.pas

@@ -14,7 +14,7 @@ interface
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   Setup.SetupForm, StdCtrls, ExtCtrls, BitmapImage, NewProgressBar, NewStaticText,
-  NewNotebook, BidiCtrls;
+  NewNotebook, NewCtrls;
 
 type
   TUninstallProgressForm = class(TSetupForm)

+ 1 - 1
Projects/Src/Setup.UninstallSharedFileForm.pas

@@ -13,7 +13,7 @@ interface
 
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-  Setup.SetupForm, StdCtrls, NewStaticText, BidiCtrls;
+  Setup.SetupForm, StdCtrls, NewStaticText, NewCtrls;
 
 type
   TUninstallSharedFileForm = class(TSetupForm)

+ 1 - 1
Projects/Src/Setup.WizardForm.pas

@@ -15,7 +15,7 @@ uses
   Windows, SysUtils, Messages, Classes, Graphics, Controls,
   Forms, Dialogs, StdCtrls, ExtCtrls,
   NewProgressBar, NewCheckListBox, RichEditViewer, NewStaticText,
-  PasswordEdit, FolderTreeView, BitmapImage, NewNotebook, BidiCtrls,
+  PasswordEdit, FolderTreeView, BitmapImage, NewNotebook, NewCtrls,
   Shared.Struct, Shared.SetupMessageIDs,
   Setup.SetupForm, Setup.MainFunc;
 

+ 1 - 1
README.md

@@ -86,11 +86,11 @@ If you intend to view or modify the Setup project's forms, you must install
 the following component units, which can be found in the [Components]
 directory.
 
-- BidiCtrls
 - BitmapButton
 - BitmapImage
 - FolderTreeView
 - NewCheckListBox
+- NewCtrls
 - NewNotebookReg
 - NewProgressBar
 - NewStaticText