Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Examples / NSISMenu.nsi @ 3097

Historique | Voir | Annoter | Télécharger (12,23 ko)

1
OutFile "NSIS.exe"
2
Name "NSIS Menu"
3
Unicode True
4
RequestExecutionLevel User
5
XPStyle On
6
ManifestDPIAware System
7
SetCompressor LZMA
8
ChangeUI IDD_INST "${NSISDIR}\Contrib\UIs\modern_headerbmp.exe"
9
Icon "${NSISDIR}\Contrib\Graphics\Icons\nsis-menu.ico"
10
BrandingText " "
11
MiscButtonText " " " " " " " "
12
InstallButtonText " "
13
CompletedText " "
14
LangString ^ClickInstall 0 " "
15
Caption "$(^Name)"
16

    
17
!macro UNPACKVERFIELD out in shr mask fmt
18
!define /redef /math ${out} ${in} >>> ${shr}
19
!define /redef /math ${out} ${${out}} & ${mask}
20
!define /redef /intfmt ${out} "${fmt}" ${${out}}
21
!macroend
22

    
23
!ifndef VER_MAJOR & VER_MINOR
24
!ifdef NSIS_PACKEDVERSION
25
!insertmacro UNPACKVERFIELD VER_MAJOR ${NSIS_PACKEDVERSION} 24 0x0ff "%X"
26
!insertmacro UNPACKVERFIELD VER_MINOR ${NSIS_PACKEDVERSION} 12 0xfff "%X"
27
!insertmacro UNPACKVERFIELD VER_REVISION ${NSIS_PACKEDVERSION} 4 255 "%X"
28
!insertmacro UNPACKVERFIELD VER_BUILD ${NSIS_PACKEDVERSION} 00 0x00f "%X"
29
!endif
30
!endif
31
!ifdef VER_MAJOR & VER_MINOR
32
!define /ifndef VER_REVISION 0
33
!define /ifndef VER_BUILD 0
34
!searchreplace VERSTR "${NSIS_VERSION}" "v" ""
35
VIProductVersion ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD}
36
VIAddVersionKey "ProductName" "NSIS"
37
VIAddVersionKey "ProductVersion" "${VERSTR}"
38
VIAddVersionKey "FileVersion" "${VERSTR}"
39
VIAddVersionKey "FileDescription" "NSIS Menu"
40
VIAddVersionKey "LegalCopyright" "http://nsis.sf.net/License"
41
!endif
42

    
43
!include nsDialogs.nsh
44
!include WinMessages.nsh
45
!include LogicLib.nsh
46
!define /IfNDef IDC_CHILDRECT 1018
47
!define QUIT_ON_EXECUTE
48
!define PR $ExeDir ; Local root path
49
!define PD "Docs" ; Local with WWW fallback (located at the same relative path)
50
!define WWW "http://nsis.sf.net"
51

    
52
!define CB_HEADER '0x755585 0x222222'
53
!define UY_HEADER 28
54
!define CT_PAGE '0x000000 0xaaaaaa'
55
!define CB_PAGE '0xffffff 0x111111'
56
!define CT_SECTION '0x666666 0xeeeeee'
57
!define CB_SECTION '${CB_PAGE}'
58
!define UY_SECTION 11 ; Height of a section
59
!define UY_SECTIONBPAD 2 ; Extra padding on the bottom of section headers
60
!define UY_TXT 9 ; Height of a normal item
61
!define UY_TXTBPAD 1 ; Extra padding on the bottom of normal items
62
!define UX_COLPAD 7 ; Spacing between columns
63
!define UY_ROW2 104 ; Absolute position of the 2nd row
64
!define CT_LINK '0x0c6e97 0x0c6e97' ; SYSCLR:HOTLIGHT
65
!define /Math UX_PAGE 00 + ${UX_COLPAD}
66
!define /Math UY_PAGE ${UY_HEADER} + 20
67
!define UX ${UX_PAGE}
68
!define CB_FOOTERLINE '0xc4c4c4 0x333333'
69
!define CT_FOOTER '0xbbbbbb 0x444444'
70

    
71
Var UseLightTheme
72

    
73
Function .onGUIInit
74
ReadRegDWORD $UseLightTheme HKCU "Software\NSIS" "UseLightTheme"
75
StrCmp $UseLightTheme "" 0 +2
76
ReadRegDWORD $UseLightTheme HKCU "Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" "AppsUseLightTheme"
77
StrCmp $UseLightTheme "" 0 +2
78
StrCpy $UseLightTheme 1 ; Default
79

    
80
StrCmp $UseLightTheme "0" 0 +2
81
System::Call 'USER32::SetProp(p$hWndParent,t"UseImmersiveDarkModeColors",i1)'
82
FunctionEnd
83

    
84
!define SetCtlColors "!insertmacro SetCtlColors "
85
!macro SetCtlColors hWnd ctlig ctdar cblig cbdar
86
StrCmp $UseLightTheme "0" 0 +3
87
SetCtlColors ${hWnd} "${ctdar}" ${cbdar}
88
Goto +2
89
SetCtlColors ${hWnd} "${ctlig}" ${cblig}
90
!macroend
91

    
92

    
93
Function PageLeave
94
System::Call 'USER32::GetFocus()p.r0'
95
System::Call 'USER32::GetDlgCtrlID(pr0)i.r1'
96
System::Call 'USER32::GetParent(pr0)p.r2'
97
SendMessage $2 ${WM_COMMAND} $1 $0 ; Handle <ENTER> in dialog by pretending it was a click on the active control
98
Abort
99
FunctionEnd
100

    
101
Function PageCreate
102
GetDlgItem $0 $hWndParent 1
103
ShowWindow $0 0
104
GetDlgItem $0 $hWndParent 2
105
ShowWindow $0 0
106

    
107
System::Call 'USER32::GetClientRect(p$hWndParent,@r0)'
108
System::Call '*$0(i,i,i.r3,i.r4)'
109
GetDlgItem $0 $hWndParent ${IDC_CHILDRECT}
110
System::Call 'USER32::MoveWindow(pr0,i0,i0,ir3,ir4,i0)'
111

    
112
nsDialogs::Create ${IDC_CHILDRECT}
113
Pop $R9
114
${SetCtlColors} $R9 ${CT_PAGE} ${CB_PAGE}
115

    
116
!macro StartColumn W
117
!define /ReDef UY ${UY_PAGE}
118
!define /ReDef UX_W ${W}
119
!ifdef UX_INTERNAL_PREV_W
120
!define /ReDef /Math UX ${UX} + ${UX_INTERNAL_PREV_W}
121
!define /ReDef /Math UX ${UX} + ${UX_COLPAD}
122
!define /ReDef UX_INTERNAL_PREV_W ${UX_W}
123
!else
124
!define /Math UX_INTERNAL_PREV_W 0 + ${UX_W}
125
!endif
126
!macroend
127
!macro CreateHeader Txt W
128
!define /ReDef /Math W ${W} + 4 ; Make it slightly wider
129
${NSD_CreateLabel} ${UX}u ${UY}u ${W}u ${UY_SECTION}u "${Txt}"
130
Pop $0
131
${SetCtlColors} $0 ${CT_SECTION} transparent transparent
132
SendMessage $0 ${WM_SETFONT} ${HF_HEADER} 1
133
!define /ReDef /Math UY ${UY} + ${UY_SECTION}
134
!define /ReDef /Math UY ${UY} + ${UY_SECTIONBPAD}
135
!macroend
136
!macro CreateControl Class Txt W H
137
${NSD_Create${Class}} ${UX}u ${UY}u ${W}u ${H}u "${Txt}"
138
!define /ReDef /Math UY ${UY} + ${H}
139
!define /ReDef /Math UY ${UY} + ${UY_TXTBPAD}
140
!macroend
141
!macro CreateSimpleLinkHelper Txt Url W
142
!insertmacro CreateControl Link "${Txt}|${Url}" ${W} ${UY_TXT}
143
!macroend
144
!macro CreateSimpleLink Txt Url W
145
!insertmacro CreateSimpleLinkHelper "${Txt}" "${Url}" ${W}
146
Call ConfigureLink
147
!macroend
148

    
149

    
150
; --- Header ---
151
!define HF_HEADER $R8
152
CreateFont ${HF_HEADER} "Arial" ${UY_SECTION} 700
153

    
154
nsDialogs::CreateControl ${__NSD_Label_CLASS} ${__NSD_Label_STYLE} ${__NSD_Label_EXSTYLE} 33u 0 -33u ${UY_HEADER}u ""
155
Pop $0
156
${SetCtlColors} $0 0xffffff 0xffffff ${CB_HEADER}
157

    
158
nsDialogs::CreateControl ${__NSD_Icon_CLASS} ${__NSD_Icon_STYLE}|${SS_CENTERIMAGE}|${SS_CENTER} ${__NSD_Icon_EXSTYLE} 0 0 33u ${UY_HEADER}u ""
159
Pop $0
160
${SetCtlColors} $0 "" "" ${CB_HEADER}
161
${NSD_SetIconFromInstaller} $0 $1
162

    
163
CreateFont $1 "Trebuchet MS" 17
164
!searchreplace VERSTR "${NSIS_VERSION}" "v" ""
165
nsDialogs::CreateControl ${__NSD_Label_CLASS} ${__NSD_Label_STYLE}|${SS_CENTERIMAGE}|${SS_ENDELLIPSIS} ${__NSD_Label_EXSTYLE} 34u 1u -34u ${UY_HEADER}u "nullsoft scriptable install system ${VERSTR}"
166
Pop $0
167
SetCtlColors $0 0x3A2A42 transparent
168
SendMessage $0 ${WM_SETFONT} $1 1
169
nsDialogs::CreateControl ${__NSD_Label_CLASS} ${__NSD_Label_STYLE}|${SS_CENTERIMAGE}|${SS_ENDELLIPSIS} ${__NSD_Label_EXSTYLE} 33u 0 -33u ${UY_HEADER}u "nullsoft scriptable install system ${VERSTR}"
170
Pop $0
171
SetCtlColors $0 0xffffff transparent
172
SendMessage $0 ${WM_SETFONT} $1 1
173

    
174

    
175
; --- Page ---
176
!insertmacro StartColumn 90
177
!insertmacro CreateHeader "Compiler" ${UX_W}
178
!insertmacro CreateSimpleLink "Compile NSI scripts" "${PR}\MakeNSISW" ${UX_W}
179
!insertmacro CreateSimpleLink "Installer based on .ZIP file" "${PR}\bin\Zip2Exe" ${UX_W}
180

    
181

    
182
!define /ReDef UY ${UY_ROW2}
183
!insertmacro CreateHeader "Developer Center" ${UX_W}
184
!define /ReDef UY_MULTILINE 42
185
!insertmacro CreateControl Label "Many more examples, tutorials, plug-ins and NSIS-releted software are available at the online Developer Center." ${UX_W} ${UY_MULTILINE}
186
Pop $0
187
${SetCtlColors} $0 ${CT_PAGE} ${CB_PAGE}
188

    
189

    
190
!insertmacro StartColumn 80
191
!insertmacro CreateHeader "Documentation" ${UX_W}
192
!insertmacro CreateSimpleLink "NSIS Users Manual" "${PR}\NSIS.chm|${WWW}/Docs/" ${UX_W}
193
!insertmacro CreateSimpleLink "Example scripts" "${PR}\Examples|${WWW}/Examples" ${UX_W}
194
!insertmacro CreateSimpleLink "Modern UI 2" "${PD}\Modern UI 2\Readme.html" ${UX_W}
195

    
196

    
197
!define /ReDef UY ${UY_ROW2}
198
!insertmacro CreateHeader "Online Help" ${UX_W}
199
!insertmacro CreateSimpleLink "Developer Center" "${WWW}/Developer_Center" ${UX_W}
200
!insertmacro CreateSimpleLink "FAQ" "${WWW}/FAQ" ${UX_W}
201
!insertmacro CreateSimpleLink "Forum" "http://forums.winamp.com/forumdisplay.php?forumid=65" ${UX_W}
202
;"Project Tracker" "http://sourceforge.net/tracker/?group_id=22049"
203
!insertmacro CreateSimpleLink "Bug Tracker" "http://sourceforge.net/tracker/?group_id=22049&atid=373085" ${UX_W}
204
!insertmacro CreateSimpleLink "Stackoverflow" "http://stackoverflow.com/questions/tagged/nsis" ${UX_W}
205
!insertmacro CreateSimpleLink "Slack collaboration hub" "${WWW}/r/Slack" ${UX_W}
206
;insertmacro CreateSimpleLink "IRC channel" "irc://irc.landoleet.org/nsis" ${UX_W}
207
;"Pastebin" "http://nsis.pastebin.com/index/1FtyKP89"
208
;"Search" "http://www.google.com/cse/home?cx=005317984255499820329:c_glv1-6a6a"
209

    
210

    
211
!insertmacro StartColumn 130
212
!insertmacro CreateHeader "Plug-ins" ${UX_W}
213
!macro CreatePluginLink Name Desc Url
214
!define /ReDef SAVE_UY ${UY}
215
!insertmacro CreateSimpleLinkHelper "${Name}" "${Url}" ${UX_W} ; AdjustLinkPair will configure this link
216
!define /ReDef UY ${SAVE_UY}
217
!insertmacro CreateControl Label "${Name} - ${Desc}" ${UX_W} ${UY_TXT}
218
Call AdjustLinkPair
219
!macroend
220
!insertmacro CreatePluginLink "AdvSplash" "splash with fade in/out"     "${PD}\AdvSplash\advsplash.txt"
221
!insertmacro CreatePluginLink "Banner"    "banner with custom text"     "${PD}\Banner\Readme.txt"
222
!insertmacro CreatePluginLink "BgImage"   "background image"            "${PD}\BgImage\BgImage.txt"
223
!insertmacro CreatePluginLink "Dialer"    "internet connection"         "${PD}\Dialer\Dialer.txt"
224
!insertmacro CreatePluginLink "Math"      "math operations"             "${PD}\Math\Math.txt"
225
!insertmacro CreatePluginLink "nsDialogs" "custom wizard pages"         "${PD}\nsDialogs\Readme.html"
226
!insertmacro CreatePluginLink "nsExec"    "launch command line tools"   "${PD}\nsExec\nsExec.txt"
227
!insertmacro CreatePluginLink "NSISdl"    "download files"              "${PD}\NSISdl\Readme.txt"
228
!insertmacro CreatePluginLink "Splash"    "splash screen"               "${PD}\Splash\splash.txt"
229
!insertmacro CreatePluginLink "StartMenu" "Start Menu folder selection" "${PD}\StartMenu\Readme.txt"
230
!insertmacro CreatePluginLink "System"    "Windows API calls"           "${PD}\System\System.html"
231
!insertmacro CreatePluginLink "VPatch"    "update existing files"       "${PD}\VPatch\Readme.html"
232

    
233

    
234
; --- Footer ---
235
${NSD_CreateLabel} 0 -22u 100% 1 ""
236
Pop $0
237
${SetCtlColors} $0 000000 000000 ${CB_FOOTERLINE}
238

    
239
nsDialogs::CreateControl ${__NSD_Label_CLASS} ${__NSD_Label_STYLE}|${SS_CENTERIMAGE}|${SS_NOTIFY} ${__NSD_Label_EXSTYLE} -110u -20u 100% 20u "nsis.sourceforge.net"
240
Pop $0
241
${SetCtlColors} $0 ${CT_FOOTER} transparent transparent
242
SendMessage $0 ${WM_SETFONT} ${HF_HEADER} 1
243
nsDialogs::SetUserData $0 "https://nsis.sourceforge.io"
244
${NSD_OnClick} $0 OnLinkClick
245

    
246
nsDialogs::Show
247
FunctionEnd
248

    
249
Function OnLinkClick
250
Pop $1 ; HWND
251
nsDialogs::GetUserData $1
252
Call SplitPipe
253
Pop $0 ; First URL in UserData from SplitPipe
254
StrCpy $3 ""
255
StrCpy $1 $0 4 ; Copy length of ${PD}
256
${IfThen} $1 == "${PD}" ${|} StrCpy $3 "${PR}\" ${|}
257
!ifdef QUIT_ON_EXECUTE
258
System::Call 'USER32::GetKeyState(i0x11)i.r9' ; VK_CONTROL
259
!endif
260
ClearErrors
261
ExecShell "" "$3$0"
262
Pop $1 ; ... the rest of SplitPipe ...
263
${If} $1 != ""  ; ... might contain a fallback location
264
	StrCpy $0 $1
265
	StrCpy $3 ""
266
${ElseIf} $3 != "" ; Local docs path failed, use WWW fallback
267
	StrCpy $3 0
268
	slashconvloop:
269
		StrCpy $2 $0 1 $3
270
		${If} $2 == "\"
271
			StrCpy $2 $0 $3
272
			IntOp $3 $3 + 1
273
			StrCpy $0 $0 "" $3
274
			StrCpy $0 "$2/$0"
275
		${Else}
276
			IntOp $3 $3 + 1
277
		${EndIf}
278
		StrCmp $2 "" 0 slashconvloop
279
	StrCpy $3 "${WWW}/"
280
${EndIf}
281
${If} "$3$1" != ""
282
${AndIf} ${Errors}
283
	ExecShell "" "$3$0"
284
${EndIf}
285
${If} ${Errors}
286
	!ifdef QUIT_ON_EXECUTE
287
	StrCpy $9 0 ; Don't allow close
288
	!endif
289
	MessageBox MB_IconStop 'Error: Unable to open "$0"!'
290
${EndIf}
291
!ifdef QUIT_ON_EXECUTE
292
${IfThen} $9 < 0 ${|} SendMessage $hWndParent ${WM_CLOSE} 0 0 ${|}
293
!endif
294
FunctionEnd
295

    
296
Function ConfigureLink
297
Pop $1 ; HWND
298
${NSD_OnClick} $1 OnLinkClick
299
${SetCtlColors} $1 ${CT_LINK} ${CB_PAGE}
300
${NSD_GetText} $1 $4
301
Push $4
302
Call SplitPipe
303
Pop $4
304
Pop $2
305
${NSD_SetText} $1 $4
306
nsDialogs::SetUserData $1 $2
307
System::Call 'USER32::GetDC(pr1)p.r3'
308
SendMessage $1 ${WM_GETFONT} 0 0 $5
309
System::Call 'GDI32::SelectObject(pr3,pr5)p.s'
310
StrLen $5 $4
311
System::Call 'GDI32::GetTextExtentPoint32(pr3,tr4,ir5,@r5)'
312
System::Call '*$5(i.r6)'
313
System::Call 'GDI32::SelectObject(pr3,ps)'
314
System::Call 'USER32::ReleaseDC(pr1,pr3)'
315
System::Call 'USER32::GetWindowRect(pr1,@r3)'
316
System::Call '*$3(i,i.r5,i,i.r7)'
317
IntOp $7 $7 - $5
318
IntOp $6 $6 + 4 ; Padding for focus rect
319
System::Call 'USER32::SetWindowPos(pr1,p,i,i,ir6,ir7,i0x16)'
320
FunctionEnd
321

    
322
Function AdjustLinkPair
323
Pop $2 ; Label
324
${SetCtlColors} $2 ${CT_PAGE} ${CB_PAGE}
325
Call ConfigureLink
326
FunctionEnd
327

    
328
Function SplitPipe
329
Exch $0
330
Push $1
331
Push $2
332
StrCpy $2 0
333
findSep:
334
StrCpy $1 $0 1 $2
335
IntOp $2 $2 + 1
336
StrCmp $1 "" +2
337
StrCmp $1 "|" "" findSep
338
StrCpy $1 $0 "" $2
339
IntOp $2 $2 - 1
340
StrCpy $0 $0 $2
341
Pop $2
342
Exch $1
343
Exch
344
Exch $0
345
FunctionEnd
346

    
347
Section
348
SectionEnd
349

    
350
Page Custom PageCreate PageLeave
351
!pragma warning disable 8000 ; Page instfiles not used