Debian Codegraph @

Contrib/nsDialogs/welcome.nsi

raw
1 !include MUI.nsh
2 !include LogicLib.nsh
3 !include nsDialogs.nsh
4 !include WinMessages.nsh
5 !include FileFunc.nsh
6
7 Name "nsDialogs Welcome"
8 OutFile "nsDialogs Welcome.exe"
9
10 Page custom nsDialogsWelcome
11 Page custom nsDialogsDirectory
12 !insertmacro MUI_PAGE_INSTFILES
13
14 !insertmacro MUI_LANGUAGE English
15
16
17 Var DIALOG
18 Var HEADLINE
19 Var TEXT
20 Var IMAGECTL
21 Var IMAGE
22 Var DIRECTORY
23 Var FREESPACE
24
25 Var HEADLINE_FONT
26
27 Function .onInit
28
29 CreateFont $HEADLINE_FONT "$(^Font)" "14" "700"
30
31 InitPluginsDir
32 File /oname=$PLUGINSDIR\welcome.bmp "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp"
33
34 FunctionEnd
35
36 Function HideControls
37
38 LockWindow on
39 GetDlgItem $0 $HWNDPARENT 1028
40 ShowWindow $0 ${SW_HIDE}
41
42 GetDlgItem $0 $HWNDPARENT 1256
43 ShowWindow $0 ${SW_HIDE}
44
45 GetDlgItem $0 $HWNDPARENT 1035
46 ShowWindow $0 ${SW_HIDE}
47
48 GetDlgItem $0 $HWNDPARENT 1037
49 ShowWindow $0 ${SW_HIDE}
50
51 GetDlgItem $0 $HWNDPARENT 1038
52 ShowWindow $0 ${SW_HIDE}
53
54 GetDlgItem $0 $HWNDPARENT 1039
55 ShowWindow $0 ${SW_HIDE}
56
57 GetDlgItem $0 $HWNDPARENT 1045
58 ShowWindow $0 ${SW_NORMAL}
59 LockWindow off
60
61 FunctionEnd
62
63 Function ShowControls
64
65 LockWindow on
66 GetDlgItem $0 $HWNDPARENT 1028
67 ShowWindow $0 ${SW_NORMAL}
68
69 GetDlgItem $0 $HWNDPARENT 1256
70 ShowWindow $0 ${SW_NORMAL}
71
72 GetDlgItem $0 $HWNDPARENT 1035
73 ShowWindow $0 ${SW_NORMAL}
74
75 GetDlgItem $0 $HWNDPARENT 1037
76 ShowWindow $0 ${SW_NORMAL}
77
78 GetDlgItem $0 $HWNDPARENT 1038
79 ShowWindow $0 ${SW_NORMAL}
80
81 GetDlgItem $0 $HWNDPARENT 1039
82 ShowWindow $0 ${SW_NORMAL}
83
84 GetDlgItem $0 $HWNDPARENT 1045
85 ShowWindow $0 ${SW_HIDE}
86 LockWindow off
87
88 FunctionEnd
89
90 Function nsDialogsWelcome
91
92 nsDialogs::Create 1044
93 Pop $DIALOG
94
95 nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
96 Pop $IMAGECTL
97
98 StrCpy $0 $PLUGINSDIR\welcome.bmp
99 System::Call 'user32::LoadImage(p 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE})p.s'
100 Pop $IMAGE
101
102 SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
103
104 nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
105 Pop $HEADLINE
106
107 SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
108
109 nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "nsDialogs is the next generation of user interfaces in NSIS. It gives the developer full control over custom pages. Some of the features include control text containing variables, callbacks directly into script functions and creation of any type of control. Create boring old edit boxes or load some external library and create custom controls with no need of creating your own plug-in.$\r$\n$\r$\nUnlike InstallOptions, nsDialogs doesn't use INI files to communicate with the script. By interacting directly with the script, nsDialogs can perform much faster without the need of costly, old and inefficient INI operations. Direct interaction also allows direct calls to functions defined in the script and removes the need of conversion functions like Io2Nsis.$\r$\n$\r$\nHit the Next button to see how it all fits into a mock directory page."
110 Pop $TEXT
111
112 SetCtlColors $DIALOG 0 0xffffff
113 SetCtlColors $HEADLINE 0 0xffffff
114 SetCtlColors $TEXT 0 0xffffff
115
116 Call HideControls
117
118 nsDialogs::Show
119
120 Call ShowControls
121
122 System::Call gdi32::DeleteObject(p$IMAGE)
123
124 FunctionEnd
125
126 !define SHACF_FILESYSTEM 1
127
128 Function nsDialogsDirectory
129
130 !insertmacro MUI_HEADER_TEXT "Choose Install Location" "Choose the folder in which to install $(^NameDA)."
131
132 GetDlgItem $0 $HWNDPARENT 1
133 EnableWindow $0 0
134
135 nsDialogs::Create 1018
136 Pop $DIALOG
137
138 nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
139 Pop $HEADLINE
140
141 SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
142
143 nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
144 Pop $TEXT
145
146 nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
147 Pop $DIRECTORY
148
149 SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
150
151 GetFunctionAddress $0 DirChange
152 nsDialogs::OnChange $DIRECTORY $0
153
154 System::Call shlwapi::SHAutoComplete(p$DIRECTORY,i${SHACF_FILESYSTEM})
155
156 nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
157 Pop $FREESPACE
158
159 Call UpdateFreeSpace
160
161 nsDialogs::Show
162
163 FunctionEnd
164
165 Function UpdateFreeSpace
166
167 ${GetRoot} $INSTDIR $0
168 StrCpy $1 " bytes"
169
170 System::Call kernel32::GetDiskFreeSpaceEx(tr0,*l,*l,*l.r0)
171
172 ${If} $0 > 1024
173 ${OrIf} $0 < 0
174 System::Int64Op $0 / 1024
175 Pop $0
176 StrCpy $1 "kb"
177 ${If} $0 > 1024
178 ${OrIf} $0 < 0
179 System::Int64Op $0 / 1024
180 Pop $0
181 StrCpy $1 "mb"
182 ${If} $0 > 1024
183 ${OrIf} $0 < 0
184 System::Int64Op $0 / 1024
185 Pop $0
186 StrCpy $1 "gb"
187 ${EndIf}
188 ${EndIf}
189 ${EndIf}
190
191 SendMessage $FREESPACE ${WM_SETTEXT} 0 "STR:Free space: $0$1"
192
193 FunctionEnd
194
195 Function DirChange
196
197 Pop $0 # dir hwnd
198
199 GetDlgItem $0 $HWNDPARENT 1
200
201 System::Call user32::GetWindowText(p$DIRECTORY,t.d,i${NSIS_MAX_STRLEN})
202
203 ${If} ${FileExists} $INSTDIR\makensis.exe
204 EnableWindow $0 1
205 ${Else}
206 EnableWindow $0 0
207 ${EndIf}
208
209 Call UpdateFreeSpace
210
211 FunctionEnd
212
213 Section
214 SectionEnd