diff --git a/Contrib/Modern UI 2/Deprecated.nsh b/Contrib/Modern UI 2/Deprecated.nsh index 754fd4d5..85339f2b 100644 --- a/Contrib/Modern UI 2/Deprecated.nsh +++ b/Contrib/Modern UI 2/Deprecated.nsh @@ -5,6 +5,21 @@ Deprecated code - display warnings */ + +!macro MUI_LEGACY_MAP_NOSTRETCH NAME R + !if "${R}" != "" + !ifdef ${NAME}NOSTRETCH + !define /IfNDef ${NAME}STRETCH NoStretchNoCropNoAlign + !endif + !else + !insertmacro ${__MACRO__} ${NAME}BITMAP_ 1 + !insertmacro ${__MACRO__} ${NAME}BITMAP_RTL_ 1 + !insertmacro ${__MACRO__} ${NAME}UNBITMAP_ 1 + !insertmacro ${__MACRO__} ${NAME}UNBITMAP_RTL_ 1 + !endif +!macroend + + ;-------------------------------- ;InstallOptions @@ -66,7 +81,6 @@ Deprecated code - display warnings !macro MUI_RESERVEFILE_INSTALLOPTIONS - !define MUI_DOLLAR "$" - !error "MUI_RESERVEFILE_INSTALLOPTIONS is no longer supported as InstallOptions is no longer used by MUI2. Instead, use ReserveFile '${MUI_DOLLAR}{NSISDIR}\Plugins\InstallOptions.dll'. It is also recommended to upgrade to nsDialogs." + !error `MUI_RESERVEFILE_INSTALLOPTIONS is no longer supported as InstallOptions is no longer used by MUI2. Instead, use "ReserveFile /plugin InstallOptions.dll". It is also recommended to upgrade to nsDialogs.` !macroend diff --git a/Contrib/Modern UI 2/Interface.nsh b/Contrib/Modern UI 2/Interface.nsh index e7f89d6f..24f1eeca 100644 --- a/Contrib/Modern UI 2/Interface.nsh +++ b/Contrib/Modern UI 2/Interface.nsh @@ -50,24 +50,27 @@ Var mui.Button.Back !insertmacro MUI_DEFAULT MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" !insertmacro MUI_DEFAULT MUI_BGCOLOR "FFFFFF" + ;Map *_NOSTRETCH legacy define to the correct *_STRETCH value + !insertmacro MUI_LEGACY_MAP_NOSTRETCH MUI_HEADERIMAGE_ "" + !insertmacro MUI_LEGACY_MAP_NOSTRETCH MUI_WELCOMEFINISHPAGE_ "" + !insertmacro MUI_LEGACY_MAP_NOSTRETCH MUI_UNWELCOMEFINISHPAGE_ "" + ;Default header images !ifdef MUI_HEADERIMAGE !insertmacro MUI_DEFAULT MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp" + !insertmacro MUI_DEFAULT MUI_HEADERIMAGE_BITMAP_STRETCH "FitControl" + !insertmacro MUI_DEFAULT MUI_HEADERIMAGE_BITMAP_RTL_STRETCH ${MUI_HEADERIMAGE_BITMAP_STRETCH} !ifndef MUI_HEADERIMAGE_UNBITMAP !define MUI_HEADERIMAGE_UNBITMAP "${MUI_HEADERIMAGE_BITMAP}" - !ifdef MUI_HEADERIMAGE_BITMAP_NOSTRETCH - !insertmacro MUI_SET MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH "" - !endif + !insertmacro MUI_SET MUI_HEADERIMAGE_UNBITMAP_STRETCH ${MUI_HEADERIMAGE_BITMAP_STRETCH} !endif !ifdef MUI_HEADERIMAGE_BITMAP_RTL !ifndef MUI_HEADERIMAGE_UNBITMAP_RTL !define MUI_HEADERIMAGE_UNBITMAP_RTL "${MUI_HEADERIMAGE_BITMAP_RTL}" - !ifdef MUI_HEADERIMAGE_BITMAP_RTL_NOSTRETCH - !insertmacro MUI_SET MUI_HEADERIMAGE_UNBITMAP_RTL_NOSTRETCH "" - !endif + !insertmacro MUI_SET MUI_HEADERIMAGE_UNBITMAP_RTL_STRETCH ${MUI_HEADERIMAGE_BITMAP_RTL_STRETCH} !endif !endif @@ -133,7 +136,53 @@ Var mui.Button.Back ;-------------------------------- ;Initialization of GUI -!macro MUI_HEADERIMAGE_INIT UNINSTALLER +!macro MUI_HEADERIMAGE_INITHELPER_LOADIMAGEWITHMACRO MACRO + + !ifdef MUI_HEADERIMAGE_RIGHT + !ifndef MUI_OPTIMIZE_ALWAYSLTR ; Undocumented + ${if} $(^RTL) == 1 + !insertmacro ${MACRO} $mui.Header.Image "${PATH}" Left Leak + ${Else} + !insertmacro ${MACRO} $mui.Header.Image "${PATH}" Right Leak + ${EndIf} + !else + !insertmacro ${MACRO} $mui.Header.Image "${PATH}" Right Leak + !endif + !else + !insertmacro ${MACRO} $mui.Header.Image "${PATH}" Auto Leak + !endif + +!macroend +!macro MUI_HEADERIMAGE_INITHELPER_LOADIMAGE UN RTL IMGRESID PATH + + GetDlgItem $mui.Header.Image $HWNDPARENT ${IMGRESID} ; Every mode doesn't use this variable but we have to reference it to avoid a compiler warning. + + !if "${MUI_HEADERIMAGE_${UN}BITMAP${RTL}_STRETCH}" == "NoStretchNoCropNoAlign" + + SetBrandingImage /IMGID=${IMGRESID} "${PATH}" + + !else if "${MUI_HEADERIMAGE_${UN}BITMAP${RTL}_STRETCH}" == "NoStretchNoCrop" + + !insertmacro MUI_HEADERIMAGE_INITHELPER_LOADIMAGEWITHMACRO \ + MUI_LOADANDXALIGNIMAGE + + !else if "${MUI_HEADERIMAGE_${UN}BITMAP${RTL}_STRETCH}" == "AspectFitHeight" + + !insertmacro MUI_HEADERIMAGE_INITHELPER_LOADIMAGEWITHMACRO \ + MUI_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT + + !else + + !if "${MUI_HEADERIMAGE_${UN}BITMAP${RTL}_STRETCH}" != "FitControl" + !warning 'MUI_HEADERIMAGE_${UN}BITMAP${RTL}_STRETCH set to unknown value, defaulting to FitControl' + !endif + SetBrandingImage /IMGID=${IMGRESID} /RESIZETOFIT "${PATH}" + + !endif + +!macroend + +!macro MUI_HEADERIMAGE_INIT UN IMGRESID ;Load and display header image @@ -141,34 +190,20 @@ Var mui.Button.Back InitPluginsDir - !ifdef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL - + !ifdef MUI_HEADERIMAGE_${UN}BITMAP_RTL ${if} $(^RTL) == 1 - File "/oname=$PLUGINSDIR\modern-header.bmp" "${MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL}" - - !ifndef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL_NOSTRETCH - SetBrandingImage /IMGID=1046 /RESIZETOFIT "$PLUGINSDIR\modern-header.bmp" - !else - SetBrandingImage /IMGID=1046 "$PLUGINSDIR\modern-header.bmp" - !endif + File "/oname=$PLUGINSDIR\modern-header.bmp" "${MUI_HEADERIMAGE_${UN}BITMAP_RTL}" + !insertmacro MUI_HEADERIMAGE_INITHELPER_LOADIMAGE "${UN}" "_RTL" ${IMGRESID} "$PLUGINSDIR\modern-header.bmp" ${else} - !endif - File "/oname=$PLUGINSDIR\modern-header.bmp" "${MUI_HEADERIMAGE_${UNINSTALLER}BITMAP}" - - !ifndef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_NOSTRETCH - SetBrandingImage /IMGID=1046 /RESIZETOFIT "$PLUGINSDIR\modern-header.bmp" - !else - SetBrandingImage /IMGID=1046 "$PLUGINSDIR\modern-header.bmp" - !endif - - !ifdef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL + File "/oname=$PLUGINSDIR\modern-header.bmp" "${MUI_HEADERIMAGE_${UN}BITMAP}" + !insertmacro MUI_HEADERIMAGE_INITHELPER_LOADIMAGE "${UN}" "" ${IMGRESID} "$PLUGINSDIR\modern-header.bmp" + !ifdef MUI_HEADERIMAGE_${UN}BITMAP_RTL ${endif} - !endif !endif @@ -195,15 +230,17 @@ Var mui.Button.Back !endif ;Header image - !insertmacro MUI_HEADERIMAGE_INIT "${UNINSTALLER}" + !insertmacro MUI_HEADERIMAGE_INIT "${UNINSTALLER}" 1046 ;Header background GetDlgItem $mui.Header.Background $HWNDPARENT 1034 SetCtlColors $mui.Header.Background "" "${MUI_BGCOLOR}" - ;Header image background - GetDlgItem $mui.Header.Image $HWNDPARENT 1039 - SetCtlColors $mui.Header.Image "" "${MUI_BGCOLOR}" + ;Header icon image background + !ifndef MUI_HEADERIMAGE + GetDlgItem $mui.Header.Image $HWNDPARENT 1039 + SetCtlColors $mui.Header.Image "" "${MUI_BGCOLOR}" + !endif ;Branding text GetDlgItem $mui.Branding.Background $HWNDPARENT 1028 diff --git a/Contrib/Modern UI 2/MUI2.nsh b/Contrib/Modern UI 2/MUI2.nsh index b90d8105..96f4d18f 100644 --- a/Contrib/Modern UI 2/MUI2.nsh +++ b/Contrib/Modern UI 2/MUI2.nsh @@ -2,6 +2,7 @@ NSIS Modern User Interface - Version 2.0 Copyright 2002-2014 Joost Verburg +Contributors: Amir Szekely, Anders Kjersem */ diff --git a/Contrib/Modern UI 2/Pages.nsh b/Contrib/Modern UI 2/Pages.nsh index 2c8e2e42..58ee96d9 100644 --- a/Contrib/Modern UI 2/Pages.nsh +++ b/Contrib/Modern UI 2/Pages.nsh @@ -166,3 +166,159 @@ Support code for all pages !endif !macroend + +!macro MUI_INTERNAL_FULLWINDOW_LOADWIZARDIMAGE _un _hwndImg _ImgPath _RetImgHandle + + !ifdef MUI_${_un}WELCOMEFINISHPAGE_BITMAP_NOSTRETCH + !insertmacro MUI_DEFAULT MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH NoStretchNoCropNoAlign ; Legacy compatibility + !endif + !insertmacro MUI_DEFAULT MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH FitControl + + !if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" == "NoStretchNoCropNoAlign" + + ${NSD_SetImage} ${_hwndImg} "${_ImgPath}" "${_RetImgHandle}" + + !else if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" == "NoStretchNoCrop" + + !insertmacro MUI_LOADANDXALIGNIMAGE ${_hwndImg} "${_ImgPath}" Auto "${_RetImgHandle}" + + !else if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" == "AspectFitHeight" + + !insertmacro MUI_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT ${_hwndImg} "${_ImgPath}" Auto "${_RetImgHandle}" + + !else + + !if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" != "FitControl" + !warning 'MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH set to unknown value, defaulting to FitControl' + !endif + ${NSD_SetStretchedImage} ${_hwndImg} "${_ImgPath}" "${_RetImgHandle}" + + !endif + +!macroend + + +;-------------------------------- +;Helper macros + +!include Util.nsh + +!macro MUI_INTERNAL_LOADANDSIZEIMAGE _macro _hwndImg _ImgPath _XAlign _RetImgHandle + !if "${_XAlign}" == "Auto" + ${if} $(^RTL) == 1 + Push "*${_ImgPath}" + ${Else} + Push "${_ImgPath}" + ${EndIf} + !else if "${_XAlign}" == "Right" + Push "*${_ImgPath}" + !else + Push "${_ImgPath}" + !endif + Push "${_hwndImg}" + ${CallArtificialFunction} ${_macro} + !if "${_RetImgHandle}" == "Leak" + !insertmacro _LOGICLIB_TEMP + Pop $_LOGICLIB_TEMP + !else if "${_RetImgHandle}" != "Stack" + Pop ${_RetImgHandle} + !endif +!macroend + +!macro MUI_LOADANDXALIGNIMAGE _hwndImg _ImgPath _XAlign _RetImgHandle +!insertmacro MUI_INTERNAL_LOADANDSIZEIMAGE \ + MUI_INTERNAL_LOADANDXALIGNIMAGE "${_hwndImg}" "${_ImgPath}" "${_XAlign}" "${_RetImgHandle}" +!macroend +!macro MUI_INTERNAL_LOADANDXALIGNIMAGE + System::Store "S" + System::Call 'USER32::GetWindowRect(psr0,@r1)' + System::Call 'USER32::MapWindowPoints(p0,p$hwndparent,pr1,i2)' ; Note: Assuming control is not in inner dialog + System::Call '*$1(i.r5,i.r6,i.r7,i.r8)' + IntOp $7 $7 - $5 + IntOp $8 $8 - $6 + + Pop $1 + StrCpy $3 $1 1 + ${If} $3 == "*" ; Move control to the right? + StrCpy $1 $1 "" 1 + ${Endif} + System::Call 'USER32::LoadImage(p0,tr1,i${IMAGE_BITMAP},i0,i0,i${LR_LOADFROMFILE})p.r2' + SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $2 $1 + Push $2 ; Return value + System::Call 'GDI32::DeleteObject(pr1)' ; Note: Assuming the previous image (if any) was a bitmap + System::Call 'USER32::GetClientRect(pr0,@r1)' + System::Call '*$1(i,i,i.r1,i.r2)' + + ${If} $3 == "*" + ${AndIf} $1 < $7 ; ImgW < CtlW + IntOp $3 $7 - $1 + IntOp $5 $5 + $3 + System::Call 'USER32::SetWindowPos(pr0,p0,ir5,ir6,i,i,i0x15)' + ${EndIf} + + System::Store "L" +!macroend + +!macro MUI_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT _hwndImg _ImgPath _XAlign _RetImgHandle +!insertmacro MUI_INTERNAL_LOADANDSIZEIMAGE \ + MUI_INTERNAL_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT "${_hwndImg}" "${_ImgPath}" "${_XAlign}" "${_RetImgHandle}" +!macroend +!macro MUI_INTERNAL_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT + System::Store "S" + System::Call 'USER32::GetWindowRect(psr0,@r1)' + System::Call 'USER32::MapWindowPoints(p0,p$hwndparent,pr1,i2)' ; Note: Assuming control is not in inner dialog + System::Call '*$1(i.r5,i.r6,i.r7,i.r8)' + IntOp $7 $7 - $5 + IntOp $8 $8 - $6 + + Pop $1 + StrCpy $3 $1 1 + ${If} $3 == "*" ; Move control to the right? + StrCpy $1 $1 "" 1 + ${Endif} + System::Call 'USER32::LoadImage(p0,tr1,i${IMAGE_BITMAP},i0,i0,i${LR_LOADFROMFILE})p.r2' + SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $2 $1 + Push $2 ; Return value + System::Call 'GDI32::DeleteObject(pr1)' ; Note: Assuming the previous image (if any) was a bitmap + System::Call 'USER32::GetClientRect(pr0,@r1)' + System::Call '*$1(i,i,i.r1,i.r2)' + + IntOp $R7 $7 * 10000 + IntOp $R8 $8 * 10000 + IntOp $R1 $1 * 10000 + IntOp $R2 $2 * 10000 + IntOp $R3 $R1 / $2 + StrCpy $R4 10000 + ${If} $R1 > $R2 + StrCpy $R3 10000 + IntOp $R4 $R2 / $1 + ${EndIf} + + ${DoWhile} $R2 > $R8 ; ImgH > CtlH + IntOp $R1 $R1 - $R3 + IntOp $R2 $R2 - $R4 + ${Loop} + ${DoWhile} $R2 < $R8 ; ImgH < CtlH + IntOp $R1 $R1 + $R3 + IntOp $R2 $R2 + $R4 + ${Loop} + IntOp $1 $R1 / 10000 + IntOp $2 $R2 / 10000 + + ${If} $1 < $7 + ${AndIf} $3 == "*" + IntOp $R3 $7 - $1 + IntOp $5 $5 + $R3 + ${EndIf} + + ${DoWhile} $2 > $8 ; Non-aspect-maintained stretch to make it a pixel perfect match + IntOp $2 $2 - 1 + IntOp $1 $1 - 1 + ${IfThen} $3 == "*" ${|} IntOp $5 $5 + 1 ${|} + ${Loop} + + System::Call 'USER32::SetWindowPos(pr0,p0,ir5,ir6,ir1,ir2,i0x14)' + System::Store "L" +!macroend + + diff --git a/Contrib/Modern UI 2/Pages/Finish.nsh b/Contrib/Modern UI 2/Pages/Finish.nsh index d58aacb4..2df261fc 100644 --- a/Contrib/Modern UI 2/Pages/Finish.nsh +++ b/Contrib/Modern UI 2/Pages/Finish.nsh @@ -264,11 +264,7 @@ Finish page (implemented using nsDialogs) ;Image control ${NSD_CreateBitmap} 0u 0u 109u 193u "" Pop $mui.FinishPage.Image - !ifndef MUI_${MUI_PAGE_UNINSTALLER_PREFIX}WELCOMEFINISHPAGE_BITMAP_NOSTRETCH - ${NSD_SetStretchedImage} $mui.FinishPage.Image $PLUGINSDIR\modern-wizard.bmp $mui.FinishPage.Image.Bitmap - !else - ${NSD_SetImage} $mui.FinishPage.Image $PLUGINSDIR\modern-wizard.bmp $mui.FinishPage.Image.Bitmap - !endif + !insertmacro MUI_INTERNAL_FULLWINDOW_LOADWIZARDIMAGE "${MUI_PAGE_UNINSTALLER_PREFIX}" $mui.FinishPage.Image $PLUGINSDIR\modern-wizard.bmp $mui.FinishPage.Image.Bitmap ;Positiong of controls diff --git a/Contrib/Modern UI 2/Pages/Welcome.nsh b/Contrib/Modern UI 2/Pages/Welcome.nsh index 5e7ebdd8..f50d4261 100644 --- a/Contrib/Modern UI 2/Pages/Welcome.nsh +++ b/Contrib/Modern UI 2/Pages/Welcome.nsh @@ -126,11 +126,7 @@ Welcome page (implemented using nsDialogs) ;Image control ${NSD_CreateBitmap} 0u 0u 109u 193u "" Pop $mui.WelcomePage.Image - !ifndef MUI_${MUI_PAGE_UNINSTALLER_PREFIX}WELCOMEFINISHPAGE_BITMAP_NOSTRETCH - ${NSD_SetStretchedImage} $mui.WelcomePage.Image $PLUGINSDIR\modern-wizard.bmp $mui.WelcomePage.Image.Bitmap - !else - ${NSD_SetImage} $mui.WelcomePage.Image $PLUGINSDIR\modern-wizard.bmp $mui.WelcomePage.Image.Bitmap - !endif + !insertmacro MUI_INTERNAL_FULLWINDOW_LOADWIZARDIMAGE "${MUI_PAGE_UNINSTALLER_PREFIX}" $mui.WelcomePage.Image $PLUGINSDIR\modern-wizard.bmp $mui.WelcomePage.Image.Bitmap ;Positiong of controls diff --git a/Contrib/Modern UI 2/Readme.html b/Contrib/Modern UI 2/Readme.html index 04db6611..446e00da 100644 --- a/Contrib/Modern UI 2/Readme.html +++ b/Contrib/Modern UI 2/Readme.html @@ -282,11 +282,23 @@ Default: ${NSISDIR}\Contrib\Graphics\Header\nsis.bmp
- MUI_HEADERIMAGE_BITMAP_NOSTRETCH
- Do not stretch the installer header bitmap to fit the size of the field. Use this
- option only if you have an image that does not use the whole space. If you have
- a full size bitmap that fits exactly, you should not use this option because the
- size of the field will be different if the user has a custom DPI setting.
FitControl (Default)
+ Stretch the image to fit the image control.
NoStretchNoCropNoAlign
+ Do not stretch the image to fit the size of the image control.
+ You should not use this option if you have a full size bitmap that fits exactly because
+ the size of the field will be different if the user has a custom DPI setting or
+ if the installer is using a CJK language.
NoStretchNoCrop
+ This is similar to NoStretchNoCropNoAlign but will align the image to the right edge when
+ using a RTL language or if MUI_HEADERIMAGE_RIGHT is defined.
AspectFitHeight
+ Scale the image up or down until it is the same height as the image control while
+ maintaining the image aspect ratio.
MUI_HEADERIMAGE_BITMAP_RTL bmp_file
Bitmap image to display on the header of installers pages when using a RTL language
@@ -294,12 +306,8 @@
Default: Non-RTL bitmap
- MUI_HEADERIMAGE_BITMAP_RTL_NOSTRETCH
- Do not stretch the installer header bitmap when using a RTL language to fit the
- size of the field. Use this option only if you have an image that does not use the
- whole space. If you have a full size bitmap that fits exactly, you should not use
- this option because the size of the field will be different if the user has a custom
- DPI setting.
@@ -309,11 +317,8 @@ Default: Installer header bitmap
- MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH
- Do not stretch the uninstaller header bitmap to fit the size of the field. Use this
- option only if you have an image that does not use the whole space. If you have
- a full size bitmap that fits exactly, you should not use this option because the
- size of the field will be different if the user has a custom DPI setting.
MUI_HEADERIMAGE_UNBITMAP_RTL bmp_file
Bitmap image to display on the header of uninstallers pages when using a RTL language
@@ -321,12 +326,8 @@
Default: Installer RTL header bitmap
- MUI_HEADERIMAGE_UNBITMAP_RTL_NOSTRETCH
- Do not stretch the uninstaller header bitmap when using a RTL language to fit the
- size of the field. Use this option only if you have an image that does not use the
- whole space. If you have a full size bitmap that fits exactly, you should not use
- this option because the size of the field will be different if the user has a custom
- DPI setting.
@@ -385,11 +386,8 @@ Default: ${NSISDIR}\Contrib\Graphics\Wizard\win.bmp
- MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH
- Do not stretch the bitmap for the Welcome and Finish page to fit the size of the
- field. Use this option only if you have an image that does not use the whole space.
- If you have a full size bitmap that fits exactly, you should not use this option
- because the size of the field will be different if the user has a custom DPI setting.
- MUI_UNWELCOMEFINISHPAGE_BITMAP_NOSTRETCH
- Do not stretch the bitmap for the Welcome and Finish page to fit the size of the
- field. Use this option only if you have an image that does not use the whole space.
- If you have a full size bitmap that fits exactly, you should not use this option
- because the size of the field will be different if the user has a custom DPI setting.