| 1 |
/* |
| 2 |
|
| 3 |
NSIS Modern User Interface |
| 4 |
Support code for all pages |
| 5 |
|
| 6 |
*/ |
| 7 |
|
| 8 |
;-------------------------------- |
| 9 |
;Page initialization |
| 10 |
|
| 11 |
!macro MUI_PAGE_INIT |
| 12 |
|
| 13 |
!ifdef MUI_INSERT |
| 14 |
!warning "MUI_PAGE_* inserted after MUI_LANGUAGE" |
| 15 |
!endif |
| 16 |
|
| 17 |
;Include interface settings if necessary |
| 18 |
!insertmacro MUI_INTERFACE |
| 19 |
|
| 20 |
;Define settings for installer page |
| 21 |
!insertmacro MUI_UNSET MUI_PAGE_UNINSTALLER |
| 22 |
!insertmacro MUI_UNSET MUI_PAGE_UNINSTALLER_PREFIX |
| 23 |
!insertmacro MUI_UNSET MUI_PAGE_UNINSTALLER_FUNCPREFIX |
| 24 |
|
| 25 |
!insertmacro MUI_SET MUI_PAGE_UNINSTALLER_PREFIX "" |
| 26 |
!insertmacro MUI_SET MUI_PAGE_UNINSTALLER_FUNCPREFIX "" |
| 27 |
|
| 28 |
;Generate unique ID |
| 29 |
!insertmacro MUI_UNSET MUI_UNIQUEID |
| 30 |
!define MUI_UNIQUEID ${__LINE__} |
| 31 |
|
| 32 |
!macroend |
| 33 |
|
| 34 |
!macro MUI_UNPAGE_INIT |
| 35 |
|
| 36 |
!ifdef MUI_INSERT |
| 37 |
!warning "MUI_UNPAGE_* inserted after MUI_LANGUAGE" |
| 38 |
!endif |
| 39 |
|
| 40 |
;Include interface settings |
| 41 |
!insertmacro MUI_INTERFACE |
| 42 |
|
| 43 |
;Define prefixes for uninstaller page |
| 44 |
!insertmacro MUI_SET MUI_UNINSTALLER "" |
| 45 |
|
| 46 |
!insertmacro MUI_SET MUI_PAGE_UNINSTALLER "" |
| 47 |
!insertmacro MUI_SET MUI_PAGE_UNINSTALLER_PREFIX "UN" |
| 48 |
!insertmacro MUI_SET MUI_PAGE_UNINSTALLER_FUNCPREFIX "un." |
| 49 |
|
| 50 |
;Generate unique ID |
| 51 |
!insertmacro MUI_UNSET MUI_UNIQUEID |
| 52 |
!define MUI_UNIQUEID ${__LINE__} |
| 53 |
|
| 54 |
!macroend |
| 55 |
|
| 56 |
|
| 57 |
;-------------------------------- |
| 58 |
;Header text for standard MUI page |
| 59 |
|
| 60 |
!macro MUI_HEADER_TEXT_PAGE TEXT SUBTEXT |
| 61 |
|
| 62 |
!ifdef MUI_PAGE_HEADER_TEXT & MUI_PAGE_HEADER_SUBTEXT |
| 63 |
!insertmacro MUI_HEADER_TEXT "${MUI_PAGE_HEADER_TEXT}" "${MUI_PAGE_HEADER_SUBTEXT}" |
| 64 |
!else ifdef MUI_PAGE_HEADER_TEXT |
| 65 |
!insertmacro MUI_HEADER_TEXT "${MUI_PAGE_HEADER_TEXT}" "${SUBTEXT}" |
| 66 |
!else ifdef MUI_PAGE_HEADER_SUBTEXT |
| 67 |
!insertmacro MUI_HEADER_TEXT "${TEXT}" "${MUI_PAGE_HEADER_SUBTEXT}" |
| 68 |
!else |
| 69 |
!insertmacro MUI_HEADER_TEXT "${TEXT}" "${SUBTEXT}" |
| 70 |
!endif |
| 71 |
|
| 72 |
!insertmacro MUI_UNSET MUI_PAGE_HEADER_TEXT |
| 73 |
!insertmacro MUI_UNSET MUI_PAGE_HEADER_SUBTEXT |
| 74 |
|
| 75 |
!macroend |
| 76 |
|
| 77 |
|
| 78 |
;-------------------------------- |
| 79 |
;Header text for custom page |
| 80 |
|
| 81 |
!macro MUI_HEADER_TEXT TEXT SUBTEXT ;Called from script |
| 82 |
|
| 83 |
!verbose push |
| 84 |
!verbose ${MUI_VERBOSE} |
| 85 |
|
| 86 |
!ifdef MUI_HEADER_TRANSPARENT_TEXT |
| 87 |
LockWindow on |
| 88 |
!endif |
| 89 |
|
| 90 |
SendMessage $mui.Header.Text ${WM_SETTEXT} 0 "STR:${TEXT}" |
| 91 |
SendMessage $mui.Header.SubText ${WM_SETTEXT} 0 "STR:${SUBTEXT}" |
| 92 |
|
| 93 |
!ifdef MUI_HEADER_TRANSPARENT_TEXT |
| 94 |
LockWindow off |
| 95 |
!endif |
| 96 |
|
| 97 |
!verbose pop |
| 98 |
|
| 99 |
!macroend |
| 100 |
|
| 101 |
|
| 102 |
;-------------------------------- |
| 103 |
;Custom page functions |
| 104 |
|
| 105 |
!macro MUI_PAGE_FUNCTION_CUSTOM TYPE |
| 106 |
|
| 107 |
!ifdef MUI_PAGE_CUSTOMFUNCTION_${TYPE} |
| 108 |
Call "${MUI_PAGE_CUSTOMFUNCTION_${TYPE}}" |
| 109 |
!undef MUI_PAGE_CUSTOMFUNCTION_${TYPE} |
| 110 |
!endif |
| 111 |
|
| 112 |
!macroend |
| 113 |
|
| 114 |
|
| 115 |
;-------------------------------- |
| 116 |
;Support for full window pages (like welcome/finish page) |
| 117 |
|
| 118 |
!macro MUI_PAGE_FUNCTION_FULLWINDOW |
| 119 |
|
| 120 |
!ifndef MUI_${MUI_PAGE_UNINSTALLER_PREFIX}PAGE_FUNCTION_FULLWINDOW |
| 121 |
!define MUI_${MUI_PAGE_UNINSTALLER_PREFIX}PAGE_FUNCTION_FULLWINDOW |
| 122 |
|
| 123 |
Function ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}muiPageLoadFullWindow |
| 124 |
|
| 125 |
LockWindow on |
| 126 |
|
| 127 |
;The branding text needs to be hidden because the full windows page |
| 128 |
;overlaps with it. |
| 129 |
ShowWindow $mui.Branding.Background ${SW_HIDE} |
| 130 |
ShowWindow $mui.Branding.Text ${SW_HIDE} |
| 131 |
|
| 132 |
;The texts need to be hidden because otherwise they may show through |
| 133 |
;the page above when the Alt key is pressed. |
| 134 |
ShowWindow $mui.Header.Text ${SW_HIDE} |
| 135 |
ShowWindow $mui.Header.SubText ${SW_HIDE} |
| 136 |
ShowWindow $mui.Header.Image ${SW_HIDE} |
| 137 |
|
| 138 |
;Show line below full width of page |
| 139 |
ShowWindow $mui.Line.Standard ${SW_HIDE} |
| 140 |
ShowWindow $mui.Line.FullWindow ${SW_NORMAL} |
| 141 |
|
| 142 |
LockWindow off |
| 143 |
|
| 144 |
FunctionEnd |
| 145 |
|
| 146 |
Function ${MUI_PAGE_UNINSTALLER_FUNCPREFIX}muiPageUnloadFullWindow |
| 147 |
|
| 148 |
;Set everything back to normal again |
| 149 |
|
| 150 |
LockWindow on |
| 151 |
|
| 152 |
ShowWindow $mui.Branding.Background ${SW_NORMAL} |
| 153 |
ShowWindow $mui.Branding.Text ${SW_NORMAL} |
| 154 |
|
| 155 |
ShowWindow $mui.Header.Text ${SW_NORMAL} |
| 156 |
ShowWindow $mui.Header.SubText ${SW_NORMAL} |
| 157 |
ShowWindow $mui.Header.Image ${SW_NORMAL} |
| 158 |
|
| 159 |
ShowWindow $mui.Line.Standard ${SW_NORMAL} |
| 160 |
ShowWindow $mui.Line.FullWindow ${SW_HIDE} |
| 161 |
|
| 162 |
LockWindow off |
| 163 |
|
| 164 |
FunctionEnd |
| 165 |
|
| 166 |
!endif |
| 167 |
|
| 168 |
!macroend |
| 169 |
|
| 170 |
!macro MUI_INTERNAL_FULLWINDOW_LOADWIZARDIMAGE _un _hwndImg _ImgPath _RetImgHandle |
| 171 |
|
| 172 |
!ifdef MUI_${_un}WELCOMEFINISHPAGE_BITMAP_NOSTRETCH |
| 173 |
!insertmacro MUI_DEFAULT MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH NoStretchNoCropNoAlign ; Legacy compatibility |
| 174 |
!endif |
| 175 |
!insertmacro MUI_DEFAULT MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH FitControl |
| 176 |
|
| 177 |
!if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" == "NoStretchNoCropNoAlign" |
| 178 |
|
| 179 |
${NSD_SetImage} ${_hwndImg} "${_ImgPath}" "${_RetImgHandle}" |
| 180 |
|
| 181 |
!else if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" == "NoStretchNoCrop" |
| 182 |
|
| 183 |
!insertmacro MUI_LOADANDXALIGNIMAGE ${_hwndImg} "${_ImgPath}" Auto "${_RetImgHandle}" |
| 184 |
|
| 185 |
!else if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" == "AspectFitHeight" |
| 186 |
|
| 187 |
!insertmacro MUI_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT ${_hwndImg} "${_ImgPath}" Auto "${_RetImgHandle}" |
| 188 |
|
| 189 |
!else |
| 190 |
|
| 191 |
!if "${MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH}" != "FitControl" |
| 192 |
!warning 'MUI_${_un}WELCOMEFINISHPAGE_BITMAP_STRETCH set to unknown value, defaulting to FitControl' |
| 193 |
!endif |
| 194 |
${NSD_SetStretchedImage} ${_hwndImg} "${_ImgPath}" "${_RetImgHandle}" |
| 195 |
|
| 196 |
!endif |
| 197 |
|
| 198 |
!macroend |
| 199 |
|
| 200 |
|
| 201 |
;-------------------------------- |
| 202 |
;Helper macros |
| 203 |
|
| 204 |
!include Util.nsh |
| 205 |
|
| 206 |
!macro MUI_INTERNAL_LOADANDSIZEIMAGE _macro _hwndImg _ImgPath _XAlign _RetImgHandle |
| 207 |
!if "${_XAlign}" == "Auto" |
| 208 |
${if} $(^RTL) == 1 |
| 209 |
Push "*${_ImgPath}" |
| 210 |
${Else} |
| 211 |
Push "${_ImgPath}" |
| 212 |
${EndIf} |
| 213 |
!else if "${_XAlign}" == "Right" |
| 214 |
Push "*${_ImgPath}" |
| 215 |
!else |
| 216 |
Push "${_ImgPath}" |
| 217 |
!endif |
| 218 |
Push "${_hwndImg}" |
| 219 |
${CallArtificialFunction} ${_macro} |
| 220 |
!if "${_RetImgHandle}" == "Leak" |
| 221 |
!insertmacro _LOGICLIB_TEMP |
| 222 |
Pop $_LOGICLIB_TEMP |
| 223 |
!else if "${_RetImgHandle}" != "Stack" |
| 224 |
Pop ${_RetImgHandle} |
| 225 |
!endif |
| 226 |
!macroend |
| 227 |
|
| 228 |
!macro MUI_LOADANDXALIGNIMAGE _hwndImg _ImgPath _XAlign _RetImgHandle |
| 229 |
!insertmacro MUI_INTERNAL_LOADANDSIZEIMAGE \ |
| 230 |
MUI_INTERNAL_LOADANDXALIGNIMAGE "${_hwndImg}" "${_ImgPath}" "${_XAlign}" "${_RetImgHandle}" |
| 231 |
!macroend |
| 232 |
!macro MUI_INTERNAL_LOADANDXALIGNIMAGE |
| 233 |
System::Store "S" |
| 234 |
System::Call 'USER32::GetWindowRect(psr0,@r1)' |
| 235 |
System::Call 'USER32::MapWindowPoints(p0,p$hwndparent,pr1,i2)' ; Note: Assuming control is not in inner dialog |
| 236 |
System::Call '*$1(i.r5,i.r6,i.r7,i.r8)' |
| 237 |
IntOp $7 $7 - $5 |
| 238 |
IntOp $8 $8 - $6 |
| 239 |
|
| 240 |
Pop $1 |
| 241 |
StrCpy $3 $1 1 |
| 242 |
${If} $3 == "*" ; Move control to the right? |
| 243 |
StrCpy $1 $1 "" 1 |
| 244 |
${Endif} |
| 245 |
System::Call 'USER32::LoadImage(p0,tr1,i${IMAGE_BITMAP},i0,i0,i${LR_LOADFROMFILE})p.r2' |
| 246 |
SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $2 $1 |
| 247 |
Push $2 ; Return value |
| 248 |
System::Call 'GDI32::DeleteObject(pr1)' ; Note: Assuming the previous image (if any) was a bitmap |
| 249 |
System::Call 'USER32::GetClientRect(pr0,@r1)' |
| 250 |
System::Call '*$1(i,i,i.r1,i.r2)' |
| 251 |
|
| 252 |
${If} $3 == "*" |
| 253 |
${AndIf} $1 < $7 ; ImgW < CtlW |
| 254 |
IntOp $3 $7 - $1 |
| 255 |
IntOp $5 $5 + $3 |
| 256 |
System::Call 'USER32::SetWindowPos(pr0,p0,ir5,ir6,i,i,i0x15)' |
| 257 |
${EndIf} |
| 258 |
|
| 259 |
System::Store "L" |
| 260 |
!macroend |
| 261 |
|
| 262 |
!macro MUI_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT _hwndImg _ImgPath _XAlign _RetImgHandle |
| 263 |
!insertmacro MUI_INTERNAL_LOADANDSIZEIMAGE \ |
| 264 |
MUI_INTERNAL_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT "${_hwndImg}" "${_ImgPath}" "${_XAlign}" "${_RetImgHandle}" |
| 265 |
!macroend |
| 266 |
!macro MUI_INTERNAL_LOADANDASPECTSTRETCHIMAGETOCONTROLHEIGHT |
| 267 |
System::Store "S" |
| 268 |
System::Call 'USER32::GetWindowRect(psr0,@r1)' |
| 269 |
System::Call 'USER32::MapWindowPoints(p0,p$hwndparent,pr1,i2)' ; Note: Assuming control is not in inner dialog |
| 270 |
System::Call '*$1(i.r5,i.r6,i.r7,i.r8)' |
| 271 |
IntOp $7 $7 - $5 |
| 272 |
IntOp $8 $8 - $6 |
| 273 |
|
| 274 |
Pop $1 |
| 275 |
StrCpy $3 $1 1 |
| 276 |
${If} $3 == "*" ; Move control to the right? |
| 277 |
StrCpy $1 $1 "" 1 |
| 278 |
${Endif} |
| 279 |
System::Call 'USER32::LoadImage(p0,tr1,i${IMAGE_BITMAP},i0,i0,i${LR_LOADFROMFILE})p.r2' |
| 280 |
SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $2 $1 |
| 281 |
Push $2 ; Return value |
| 282 |
System::Call 'GDI32::DeleteObject(pr1)' ; Note: Assuming the previous image (if any) was a bitmap |
| 283 |
System::Call 'USER32::GetClientRect(pr0,@r1)' |
| 284 |
System::Call '*$1(i,i,i.r1,i.r2)' |
| 285 |
|
| 286 |
IntOp $R7 $7 * 10000 |
| 287 |
IntOp $R8 $8 * 10000 |
| 288 |
IntOp $R1 $1 * 10000 |
| 289 |
IntOp $R2 $2 * 10000 |
| 290 |
IntOp $R3 $R1 / $2 |
| 291 |
StrCpy $R4 10000 |
| 292 |
${If} $R1 > $R2 |
| 293 |
StrCpy $R3 10000 |
| 294 |
IntOp $R4 $R2 / $1 |
| 295 |
${EndIf} |
| 296 |
|
| 297 |
${DoWhile} $R2 > $R8 ; ImgH > CtlH |
| 298 |
IntOp $R1 $R1 - $R3 |
| 299 |
IntOp $R2 $R2 - $R4 |
| 300 |
${Loop} |
| 301 |
${DoWhile} $R2 < $R8 ; ImgH < CtlH |
| 302 |
IntOp $R1 $R1 + $R3 |
| 303 |
IntOp $R2 $R2 + $R4 |
| 304 |
${Loop} |
| 305 |
IntOp $1 $R1 / 10000 |
| 306 |
IntOp $2 $R2 / 10000 |
| 307 |
|
| 308 |
${If} $1 < $7 |
| 309 |
${AndIf} $3 == "*" |
| 310 |
IntOp $R3 $7 - $1 |
| 311 |
IntOp $5 $5 + $R3 |
| 312 |
${EndIf} |
| 313 |
|
| 314 |
${DoWhile} $2 > $8 ; Non-aspect-maintained stretch to make it a pixel perfect match |
| 315 |
IntOp $2 $2 - 1 |
| 316 |
IntOp $1 $1 - 1 |
| 317 |
${IfThen} $3 == "*" ${|} IntOp $5 $5 + 1 ${|} |
| 318 |
${Loop} |
| 319 |
|
| 320 |
System::Call 'USER32::SetWindowPos(pr0,p0,ir5,ir6,ir1,ir2,i0x14)' |
| 321 |
System::Store "L" |
| 322 |
!macroend |
| 323 |
|
| 324 |
|