Statistiques
| Révision :

root / tmp / org.txm.setups / nsis-2.5 / Include / nsDialogs.nsh @ 3106

Historique | Voir | Annoter | Télécharger (22,78 ko)

1
/*
2

    
3
nsDialogs.nsh
4
Header file for creating custom installer pages with nsDialogs
5

    
6
*/
7

    
8
!ifndef NSDIALOGS_INCLUDED
9
!define NSDIALOGS_INCLUDED
10
!verbose push
11
!verbose 3
12

    
13
!include LogicLib.nsh
14
!include WinMessages.nsh
15

    
16
!define WS_EX_DLGMODALFRAME  0x00000001
17
!define WS_EX_NOPARENTNOTIFY 0x00000004
18
!define WS_EX_TOPMOST        0x00000008
19
!define WS_EX_ACCEPTFILES    0x00000010
20
!define WS_EX_TRANSPARENT    0x00000020
21
!define WS_EX_MDICHILD       0x00000040
22
!define WS_EX_TOOLWINDOW     0x00000080
23
!define WS_EX_WINDOWEDGE     0x00000100
24
!define WS_EX_CLIENTEDGE     0x00000200
25
!define WS_EX_CONTEXTHELP    0x00000400
26
!define WS_EX_RIGHT          0x00001000
27
!define WS_EX_LEFT           0x00000000
28
!define WS_EX_RTLREADING     0x00002000
29
!define WS_EX_LTRREADING     0x00000000
30
!define WS_EX_LEFTSCROLLBAR  0x00004000
31
!define WS_EX_RIGHTSCROLLBAR 0x00000000
32
!define WS_EX_CONTROLPARENT  0x00010000
33
!define WS_EX_STATICEDGE     0x00020000
34
!define WS_EX_APPWINDOW      0x00040000
35

    
36
!define WS_CHILD             0x40000000
37
!define WS_VISIBLE           0x10000000
38
!define WS_DISABLED          0x08000000
39
!define WS_CLIPSIBLINGS      0x04000000
40
!define WS_CLIPCHILDREN      0x02000000
41
!define WS_MAXIMIZE          0x01000000
42
!define WS_VSCROLL           0x00200000
43
!define WS_HSCROLL           0x00100000
44
!define WS_GROUP             0x00020000
45
!define WS_TABSTOP           0x00010000
46

    
47
!define ES_LEFT              0x00000000
48
!define ES_CENTER            0x00000001
49
!define ES_RIGHT             0x00000002
50
!define ES_MULTILINE         0x00000004
51
!define ES_UPPERCASE         0x00000008
52
!define ES_LOWERCASE         0x00000010
53
!define ES_PASSWORD          0x00000020
54
!define ES_AUTOVSCROLL       0x00000040
55
!define ES_AUTOHSCROLL       0x00000080
56
!define ES_NOHIDESEL         0x00000100
57
!define ES_OEMCONVERT        0x00000400
58
!define ES_READONLY          0x00000800
59
!define ES_WANTRETURN        0x00001000
60
!define ES_NUMBER            0x00002000
61

    
62
!define SS_LEFT              0x00000000
63
!define SS_CENTER            0x00000001
64
!define SS_RIGHT             0x00000002
65
!define SS_ICON              0x00000003
66
!define SS_BLACKRECT         0x00000004
67
!define SS_GRAYRECT          0x00000005
68
!define SS_WHITERECT         0x00000006
69
!define SS_BLACKFRAME        0x00000007
70
!define SS_GRAYFRAME         0x00000008
71
!define SS_WHITEFRAME        0x00000009
72
!define SS_USERITEM          0x0000000A
73
!define SS_SIMPLE            0x0000000B
74
!define SS_LEFTNOWORDWRAP    0x0000000C
75
!define SS_OWNERDRAW         0x0000000D
76
!define SS_BITMAP            0x0000000E
77
!define SS_ENHMETAFILE       0x0000000F
78
!define SS_ETCHEDHORZ        0x00000010
79
!define SS_ETCHEDVERT        0x00000011
80
!define SS_ETCHEDFRAME       0x00000012
81
!define SS_TYPEMASK          0x0000001F
82
!define SS_REALSIZECONTROL   0x00000040
83
!define SS_NOPREFIX          0x00000080
84
!define SS_NOTIFY            0x00000100
85
!define SS_CENTERIMAGE       0x00000200
86
!define SS_RIGHTJUST         0x00000400
87
!define SS_REALSIZEIMAGE     0x00000800
88
!define SS_SUNKEN            0x00001000
89
!define SS_EDITCONTROL       0x00002000
90
!define SS_ENDELLIPSIS       0x00004000
91
!define SS_PATHELLIPSIS      0x00008000
92
!define SS_WORDELLIPSIS      0x0000C000
93
!define SS_ELLIPSISMASK      0x0000C000
94

    
95
!define BS_PUSHBUTTON        0x00000000
96
!define BS_DEFPUSHBUTTON     0x00000001
97
!define BS_CHECKBOX          0x00000002
98
!define BS_AUTOCHECKBOX      0x00000003
99
!define BS_RADIOBUTTON       0x00000004
100
!define BS_3STATE            0x00000005
101
!define BS_AUTO3STATE        0x00000006
102
!define BS_GROUPBOX          0x00000007
103
!define BS_USERBUTTON        0x00000008
104
!define BS_AUTORADIOBUTTON   0x00000009
105
!define BS_PUSHBOX           0x0000000A
106
!define BS_OWNERDRAW         0x0000000B
107
!define BS_TYPEMASK          0x0000000F
108
!define BS_LEFTTEXT          0x00000020
109
!define BS_TEXT              0x00000000
110
!define BS_ICON              0x00000040
111
!define BS_BITMAP            0x00000080
112
!define BS_LEFT              0x00000100
113
!define BS_RIGHT             0x00000200
114
!define BS_CENTER            0x00000300
115
!define BS_TOP               0x00000400
116
!define BS_BOTTOM            0x00000800
117
!define BS_VCENTER           0x00000C00
118
!define BS_PUSHLIKE          0x00001000
119
!define BS_MULTILINE         0x00002000
120
!define BS_NOTIFY            0x00004000
121
!define BS_FLAT              0x00008000
122
!define BS_RIGHTBUTTON       ${BS_LEFTTEXT}
123

    
124
!define CBS_SIMPLE            0x0001
125
!define CBS_DROPDOWN          0x0002
126
!define CBS_DROPDOWNLIST      0x0003
127
!define CBS_OWNERDRAWFIXED    0x0010
128
!define CBS_OWNERDRAWVARIABLE 0x0020
129
!define CBS_AUTOHSCROLL       0x0040
130
!define CBS_OEMCONVERT        0x0080
131
!define CBS_SORT              0x0100
132
!define CBS_HASSTRINGS        0x0200
133
!define CBS_NOINTEGRALHEIGHT  0x0400
134
!define CBS_DISABLENOSCROLL   0x0800
135
!define CBS_UPPERCASE         0x2000
136
!define CBS_LOWERCASE         0x4000
137

    
138
!define LBS_NOTIFY            0x0001
139
!define LBS_SORT              0x0002
140
!define LBS_NOREDRAW          0x0004
141
!define LBS_MULTIPLESEL       0x0008
142
!define LBS_OWNERDRAWFIXED    0x0010
143
!define LBS_OWNERDRAWVARIABLE 0x0020
144
!define LBS_HASSTRINGS        0x0040
145
!define LBS_USETABSTOPS       0x0080
146
!define LBS_NOINTEGRALHEIGHT  0x0100
147
!define LBS_MULTICOLUMN       0x0200
148
!define LBS_WANTKEYBOARDINPUT 0x0400
149
!define LBS_EXTENDEDSEL       0x0800
150
!define LBS_DISABLENOSCROLL   0x1000
151
!define LBS_NODATA            0x2000
152
!define LBS_NOSEL             0x4000
153
!define LBS_COMBOBOX          0x8000
154

    
155
!define LR_DEFAULTCOLOR     0x0000
156
!define LR_MONOCHROME       0x0001
157
!define LR_COLOR            0x0002
158
!define LR_COPYRETURNORG    0x0004
159
!define LR_COPYDELETEORG    0x0008
160
!define LR_LOADFROMFILE     0x0010
161
!define LR_LOADTRANSPARENT  0x0020
162
!define LR_DEFAULTSIZE      0x0040
163
!define LR_VGACOLOR         0x0080
164
!define LR_LOADMAP3DCOLORS  0x1000
165
!define LR_CREATEDIBSECTION 0x2000
166
!define LR_COPYFROMRESOURCE 0x4000
167
!define LR_SHARED           0x8000
168

    
169
!define IMAGE_BITMAP        0
170
!define IMAGE_ICON          1
171
!define IMAGE_CURSOR        2
172
!define IMAGE_ENHMETAFILE   3
173

    
174
!define GWL_STYLE           -16
175
!define GWL_EXSTYLE         -20
176

    
177
!define DEFAULT_STYLES ${WS_CHILD}|${WS_VISIBLE}|${WS_CLIPSIBLINGS}
178

    
179
!define __NSD_HLine_CLASS STATIC
180
!define __NSD_HLine_STYLE ${DEFAULT_STYLES}|${SS_ETCHEDHORZ}|${SS_SUNKEN}
181
!define __NSD_HLine_EXSTYLE ${WS_EX_TRANSPARENT}
182

    
183
!define __NSD_VLine_CLASS STATIC
184
!define __NSD_VLine_STYLE ${DEFAULT_STYLES}|${SS_ETCHEDVERT}|${SS_SUNKEN}
185
!define __NSD_VLine_EXSTYLE ${WS_EX_TRANSPARENT}
186

    
187
!define __NSD_Label_CLASS STATIC
188
!define __NSD_Label_STYLE ${DEFAULT_STYLES}|${SS_NOTIFY}
189
!define __NSD_Label_EXSTYLE ${WS_EX_TRANSPARENT}
190

    
191
!define __NSD_Icon_CLASS STATIC
192
!define __NSD_Icon_STYLE ${DEFAULT_STYLES}|${SS_ICON}|${SS_NOTIFY}
193
!define __NSD_Icon_EXSTYLE 0
194

    
195
!define __NSD_Bitmap_CLASS STATIC
196
!define __NSD_Bitmap_STYLE ${DEFAULT_STYLES}|${SS_BITMAP}|${SS_NOTIFY}
197
!define __NSD_Bitmap_EXSTYLE 0
198

    
199
!define __NSD_BrowseButton_CLASS BUTTON
200
!define __NSD_BrowseButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}
201
!define __NSD_BrowseButton_EXSTYLE 0
202

    
203
!define __NSD_Link_CLASS LINK
204
!define __NSD_Link_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_OWNERDRAW}
205
!define __NSD_Link_EXSTYLE 0
206

    
207
!define __NSD_Button_CLASS BUTTON
208
!define __NSD_Button_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}
209
!define __NSD_Button_EXSTYLE 0
210

    
211
!define __NSD_GroupBox_CLASS BUTTON
212
!define __NSD_GroupBox_STYLE ${DEFAULT_STYLES}|${BS_GROUPBOX}
213
!define __NSD_GroupBox_EXSTYLE ${WS_EX_TRANSPARENT}
214

    
215
!define __NSD_CheckBox_CLASS BUTTON
216
!define __NSD_CheckBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_TEXT}|${BS_VCENTER}|${BS_AUTOCHECKBOX}|${BS_MULTILINE}
217
!define __NSD_CheckBox_EXSTYLE 0
218

    
219
!define __NSD_RadioButton_CLASS BUTTON
220
!define __NSD_RadioButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_TEXT}|${BS_VCENTER}|${BS_AUTORADIOBUTTON}|${BS_MULTILINE}
221
!define __NSD_RadioButton_EXSTYLE 0
222

    
223
!define __NSD_Text_CLASS EDIT
224
!define __NSD_Text_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
225
!define __NSD_Text_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
226

    
227
!define __NSD_Password_CLASS EDIT
228
!define __NSD_Password_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_PASSWORD}
229
!define __NSD_Password_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
230

    
231
!define __NSD_Number_CLASS EDIT
232
!define __NSD_Number_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_NUMBER}
233
!define __NSD_Number_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
234

    
235
!define __NSD_FileRequest_CLASS EDIT
236
!define __NSD_FileRequest_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
237
!define __NSD_FileRequest_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
238

    
239
!define __NSD_DirRequest_CLASS EDIT
240
!define __NSD_DirRequest_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
241
!define __NSD_DirRequest_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
242

    
243
!define __NSD_ComboBox_CLASS COMBOBOX
244
!define __NSD_ComboBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${WS_CLIPCHILDREN}|${CBS_AUTOHSCROLL}|${CBS_HASSTRINGS}|${CBS_DROPDOWN}
245
!define __NSD_ComboBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
246

    
247
!define __NSD_DropList_CLASS COMBOBOX
248
!define __NSD_DropList_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${WS_CLIPCHILDREN}|${CBS_AUTOHSCROLL}|${CBS_HASSTRINGS}|${CBS_DROPDOWNLIST}
249
!define __NSD_DropList_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
250

    
251
!define __NSD_ListBox_CLASS LISTBOX
252
!define __NSD_ListBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LBS_DISABLENOSCROLL}|${LBS_HASSTRINGS}|${LBS_NOINTEGRALHEIGHT}|${LBS_NOTIFY}
253
!define __NSD_ListBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
254

    
255
!define __NSD_ProgressBar_CLASS msctls_progress32
256
!define __NSD_ProgressBar_STYLE ${DEFAULT_STYLES}
257
!define __NSD_ProgressBar_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
258

    
259
!macro __NSD_DefineControl NAME
260

    
261
	!define NSD_Create${NAME} "nsDialogs::CreateControl ${__NSD_${Name}_CLASS} ${__NSD_${Name}_STYLE} ${__NSD_${Name}_EXSTYLE}"
262

    
263
!macroend
264

    
265
!insertmacro __NSD_DefineControl HLine
266
!insertmacro __NSD_DefineControl VLine
267
!insertmacro __NSD_DefineControl Label
268
!insertmacro __NSD_DefineControl Icon
269
!insertmacro __NSD_DefineControl Bitmap
270
!insertmacro __NSD_DefineControl BrowseButton
271
!insertmacro __NSD_DefineControl Link
272
!insertmacro __NSD_DefineControl Button
273
!insertmacro __NSD_DefineControl GroupBox
274
!insertmacro __NSD_DefineControl CheckBox
275
!insertmacro __NSD_DefineControl RadioButton
276
!insertmacro __NSD_DefineControl Text
277
!insertmacro __NSD_DefineControl Password
278
!insertmacro __NSD_DefineControl Number
279
!insertmacro __NSD_DefineControl FileRequest
280
!insertmacro __NSD_DefineControl DirRequest
281
!insertmacro __NSD_DefineControl ComboBox
282
!insertmacro __NSD_DefineControl DropList
283
!insertmacro __NSD_DefineControl ListBox
284
!insertmacro __NSD_DefineControl ProgressBar
285

    
286
!macro __NSD_OnControlEvent EVENT HWND FUNCTION
287

    
288
	Push $0
289
	Push $1
290

    
291
	StrCpy $1 "${HWND}"
292

    
293
	GetFunctionAddress $0 "${FUNCTION}"
294
	nsDialogs::On${EVENT} $1 $0
295

    
296
	Pop $1
297
	Pop $0
298

    
299
!macroend
300

    
301
!macro __NSD_DefineControlCallback EVENT
302

    
303
	!define NSD_On${EVENT} `!insertmacro __NSD_OnControlEvent ${EVENT}`
304

    
305
!macroend
306

    
307
!macro __NSD_OnDialogEvent EVENT FUNCTION
308

    
309
	Push $0
310

    
311
	GetFunctionAddress $0 "${FUNCTION}"
312
	nsDialogs::On${EVENT} $0
313

    
314
	Pop $0
315

    
316
!macroend
317

    
318
!macro __NSD_DefineDialogCallback EVENT
319

    
320
	!define NSD_On${EVENT} `!insertmacro __NSD_OnDialogEvent ${EVENT}`
321

    
322
!macroend
323

    
324
!insertmacro __NSD_DefineControlCallback Click
325
!insertmacro __NSD_DefineControlCallback Change
326
!insertmacro __NSD_DefineControlCallback Notify
327
!insertmacro __NSD_DefineDialogCallback Back
328

    
329
!macro _NSD_CreateTimer FUNCTION INTERVAL
330

    
331
	Push $0
332

    
333
	GetFunctionAddress $0 "${FUNCTION}"
334
	nsDialogs::CreateTimer $0 "${INTERVAL}"
335

    
336
	Pop $0
337

    
338
!macroend
339

    
340
!define NSD_CreateTimer `!insertmacro _NSD_CreateTimer`
341

    
342
!macro _NSD_KillTimer FUNCTION
343

    
344
	Push $0
345

    
346
	GetFunctionAddress $0 "${FUNCTION}"
347
	nsDialogs::KillTimer $0
348

    
349
	Pop $0
350

    
351
!macroend
352

    
353
!define NSD_KillTimer `!insertmacro _NSD_KillTimer`
354

    
355
!macro _NSD_AddStyle CONTROL STYLE
356

    
357
	Push $0
358

    
359
	System::Call "user32::GetWindowLong(i ${CONTROL}, i ${GWL_STYLE}) i .r0"
360
	System::Call "user32::SetWindowLong(i ${CONTROL}, i ${GWL_STYLE}, i $0|${STYLE})"
361

    
362
	Pop $0
363

    
364
!macroend
365

    
366
!define NSD_AddStyle "!insertmacro _NSD_AddStyle"
367

    
368
!macro _NSD_AddExStyle CONTROL EXSTYLE
369

    
370
	Push $0
371

    
372
	System::Call "user32::GetWindowLong(i ${CONTROL}, i ${GWL_EXSTYLE}) i .r0"
373
	System::Call "user32::SetWindowLong(i ${CONTROL}, i ${GWL_EXSTYLE}, i $0|${EXSTYLE})"
374

    
375
	Pop $0
376

    
377
!macroend
378

    
379
!define NSD_AddExStyle "!insertmacro _NSD_AddExStyle"
380

    
381
!macro __NSD_GetText CONTROL VAR
382

    
383
	System::Call user32::GetWindowText(i${CONTROL},t.s,i${NSIS_MAX_STRLEN})
384
	Pop ${VAR}
385

    
386
!macroend
387

    
388
!define NSD_GetText `!insertmacro __NSD_GetText`
389

    
390
!macro __NSD_SetText CONTROL TEXT
391

    
392
	SendMessage ${CONTROL} ${WM_SETTEXT} 0 `STR:${TEXT}`
393

    
394
!macroend
395

    
396
!define NSD_SetText `!insertmacro __NSD_SetText`
397

    
398
!macro _NSD_SetTextLimit CONTROL LIMIT
399

    
400
	SendMessage ${CONTROL} ${EM_SETLIMITTEXT} ${LIMIT} 0
401

    
402
!macroend
403

    
404
!define NSD_SetTextLimit "!insertmacro _NSD_SetTextLimit"
405

    
406
!macro __NSD_GetState CONTROL VAR
407

    
408
	SendMessage ${CONTROL} ${BM_GETCHECK} 0 0 ${VAR}
409

    
410
!macroend
411

    
412
!define NSD_GetState `!insertmacro __NSD_GetState`
413

    
414
!macro __NSD_SetState CONTROL STATE
415

    
416
	SendMessage ${CONTROL} ${BM_SETCHECK} ${STATE} 0
417

    
418
!macroend
419

    
420
!define NSD_SetState `!insertmacro __NSD_SetState`
421

    
422
!macro __NSD_Check CONTROL
423

    
424
	${NSD_SetState} ${CONTROL} ${BST_CHECKED}
425

    
426
!macroend
427

    
428
!define NSD_Check `!insertmacro __NSD_Check`
429

    
430
!macro __NSD_Uncheck CONTROL
431

    
432
	${NSD_SetState} ${CONTROL} ${BST_UNCHECKED}
433

    
434
!macroend
435

    
436
!define NSD_Uncheck `!insertmacro __NSD_Uncheck`
437

    
438
!macro __NSD_SetFocus HWND
439

    
440
	System::Call "user32::SetFocus(i${HWND})"
441
  
442
!macroend
443

    
444
!define NSD_SetFocus `!insertmacro __NSD_SetFocus`
445

    
446
!macro _NSD_CB_AddString CONTROL STRING
447

    
448
	SendMessage ${CONTROL} ${CB_ADDSTRING} 0 `STR:${STRING}`
449

    
450
!macroend
451

    
452
!define NSD_CB_AddString "!insertmacro _NSD_CB_AddString"
453

    
454
!macro _NSD_CB_SelectString CONTROL STRING
455

    
456
	SendMessage ${CONTROL} ${CB_SELECTSTRING} -1 `STR:${STRING}`
457

    
458
!macroend
459

    
460
!define NSD_CB_SelectString "!insertmacro _NSD_CB_SelectString"
461

    
462
!macro _NSD_LB_AddString CONTROL STRING
463

    
464
	SendMessage ${CONTROL} ${LB_ADDSTRING} 0 `STR:${STRING}`
465

    
466
!macroend
467

    
468
!define NSD_LB_AddString "!insertmacro _NSD_LB_AddString"
469

    
470
!macro __NSD_LB_DelString CONTROL STRING
471

    
472
	SendMessage ${CONTROL} ${LB_DELETESTRING} 0 `STR:${STRING}`
473

    
474
!macroend
475

    
476
!define NSD_LB_DelString `!insertmacro __NSD_LB_DelString`
477

    
478
!macro __NSD_LB_Clear CONTROL VAR
479

    
480
	SendMessage ${CONTROL} ${LB_RESETCONTENT} 0 0 ${VAR}
481

    
482
!macroend
483

    
484
!define NSD_LB_Clear `!insertmacro __NSD_LB_Clear`
485

    
486
!macro __NSD_LB_GetCount CONTROL VAR
487

    
488
	SendMessage ${CONTROL} ${LB_GETCOUNT} 0 0 ${VAR}
489

    
490
!macroend
491

    
492
!define NSD_LB_GetCount `!insertmacro __NSD_LB_GetCount`
493

    
494
!macro _NSD_LB_SelectString CONTROL STRING
495

    
496
	SendMessage ${CONTROL} ${LB_SELECTSTRING} -1 `STR:${STRING}`
497

    
498
!macroend
499

    
500
!define NSD_LB_SelectString "!insertmacro _NSD_LB_SelectString"
501

    
502
!macro __NSD_LB_GetSelection CONTROL VAR
503

    
504
	SendMessage ${CONTROL} ${LB_GETCURSEL} 0 0 ${VAR}
505
	System::Call 'user32::SendMessage(i ${CONTROL}, i ${LB_GETTEXT}, i ${VAR}, t .s)'
506
	Pop ${VAR}
507

    
508
!macroend
509

    
510
!define NSD_LB_GetSelection `!insertmacro __NSD_LB_GetSelection`
511

    
512

    
513
!macro __NSD_LoadAndSetImage _LIHINSTMODE _IMGTYPE _LIHINSTSRC _LIFLAGS CONTROL IMAGE HANDLE
514
	
515
	Push $0
516
	Push $R0
517

    
518
	StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0
519
	
520
	!if "${_LIHINSTMODE}" == "exeresource"
521
		System::Call 'kernel32::GetModuleHandle(i0) i.r0'
522
		!undef _LIHINSTSRC
523
		!define _LIHINSTSRC r0
524
	!endif
525
	
526
	System::Call 'user32::LoadImage(i ${_LIHINSTSRC}, ts, i ${_IMGTYPE}, i0, i0, i${_LIFLAGS}) i.r0' "${IMAGE}"
527
	SendMessage $R0 ${STM_SETIMAGE} ${_IMGTYPE} $0
528

    
529
	Pop $R0
530
	Exch $0
531

    
532
	Pop ${HANDLE}
533

    
534
!macroend
535

    
536
!macro __NSD_SetIconFromExeResource CONTROL IMAGE HANDLE
537
	!insertmacro __NSD_LoadAndSetImage exeresource ${IMAGE_ICON} 0 ${LR_DEFAULTSIZE} "${CONTROL}" "${IMAGE}" ${HANDLE}
538
!macroend
539

    
540
!macro __NSD_SetIconFromInstaller CONTROL HANDLE
541
	!insertmacro __NSD_SetIconFromExeResource "${CONTROL}" "#103" ${HANDLE}
542
!macroend
543

    
544
!define NSD_SetImage `!insertmacro __NSD_LoadAndSetImage file ${IMAGE_BITMAP} 0 "${LR_LOADFROMFILE}"`
545
!define NSD_SetBitmap `${NSD_SetImage}`
546

    
547
!define NSD_SetIcon `!insertmacro __NSD_LoadAndSetImage file ${IMAGE_ICON} 0 "${LR_LOADFROMFILE}|${LR_DEFAULTSIZE}"`
548
!define NSD_SetIconFromExeResource `!insertmacro __NSD_SetIconFromExeResource`
549
!define NSD_SetIconFromInstaller `!insertmacro __NSD_SetIconFromInstaller`
550

    
551

    
552
!macro __NSD_SetStretchedImage CONTROL IMAGE HANDLE
553

    
554
	Push $0
555
	Push $1
556
	Push $2
557
	Push $R0
558

    
559
	StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0
560

    
561
	StrCpy $1 ""
562
	StrCpy $2 ""
563

    
564
	System::Call '*(i, i, i, i) i.s'
565
	Pop $0
566

    
567
	${If} $0 <> 0
568
	
569
		System::Call 'user32::GetClientRect(iR0, ir0)'
570
		System::Call '*$0(i, i, i .s, i .s)'
571
		System::Free $0
572
		Pop $1
573
		Pop $2
574

    
575
	${EndIf}
576

    
577
	System::Call 'user32::LoadImage(i0, ts, i ${IMAGE_BITMAP}, ir1, ir2, i${LR_LOADFROMFILE}) i.s' "${IMAGE}"
578
	Pop $0
579
    SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0
580

    
581
	Pop $R0
582
	Pop $2
583
	Pop $1
584
	Exch $0
585

    
586
	Pop ${HANDLE}
587

    
588
!macroend
589

    
590
!define NSD_SetStretchedImage `!insertmacro __NSD_SetStretchedImage`
591

    
592
!macro __NSD_FreeImage IMAGE
593

    
594
	${If} ${IMAGE} <> 0
595

    
596
		System::Call gdi32::DeleteObject(is) ${IMAGE}
597

    
598
	${EndIf}
599

    
600
!macroend
601

    
602
!define NSD_FreeImage `!insertmacro __NSD_FreeImage`
603
!define NSD_FreeBitmap `${NSD_FreeImage}`
604

    
605
!macro __NSD_FreeIcon IMAGE
606
	System::Call user32::DestroyIcon(is) ${IMAGE}
607
!macroend
608

    
609
!define NSD_FreeIcon `!insertmacro __NSD_FreeIcon`
610

    
611
!macro __NSD_ClearImage _IMGTYPE CONTROL
612

    
613
	SendMessage ${CONTROL} ${STM_SETIMAGE} ${_IMGTYPE} 0
614

    
615
!macroend
616

    
617
!define NSD_ClearImage `!insertmacro __NSD_ClearImage ${IMAGE_BITMAP}`
618
!define NSD_ClearIcon  `!insertmacro __NSD_ClearImage ${IMAGE_ICON}`
619

    
620

    
621
!define DEBUG `System::Call kernel32::OutputDebugString(ts)`
622

    
623
!macro __NSD_ControlCase TYPE
624

    
625
	${Case} ${TYPE}
626
		${NSD_Create${TYPE}} $R3u $R4u $R5u $R6u $R7
627
		Pop $R9
628
		${Break}
629

    
630
!macroend
631

    
632
!macro __NSD_ControlCaseEx TYPE
633

    
634
	${Case} ${TYPE}
635
		Call ${TYPE}
636
		${Break}
637

    
638
!macroend
639

    
640
!macro NSD_FUNCTION_INIFILE
641

    
642
	!insertmacro NSD_INIFILE ""
643

    
644
!macroend
645

    
646
!macro NSD_UNFUNCTION_INIFILE
647

    
648
	!insertmacro NSD_INIFILE un.
649

    
650
!macroend
651

    
652
!macro NSD_INIFILE UNINSTALLER_FUNCPREFIX
653

    
654
	;Functions to create dialogs based on old InstallOptions INI files
655

    
656
	Function ${UNINSTALLER_FUNCPREFIX}CreateDialogFromINI
657

    
658
		# $0 = ini
659

    
660
		ReadINIStr $R0 $0 Settings RECT
661
		${If} $R0 == ""
662
			StrCpy $R0 1018
663
		${EndIf}
664

    
665
		nsDialogs::Create $R0
666
		Pop $R9
667

    
668
		ReadINIStr $R0 $0 Settings RTL
669
		nsDialogs::SetRTL $R0
670

    
671
		ReadINIStr $R0 $0 Settings NumFields
672

    
673
		${DEBUG} "NumFields = $R0"
674

    
675
		${For} $R1 1 $R0
676
			${DEBUG} "Creating field $R1"
677
			ReadINIStr $R2 $0 "Field $R1" Type
678
			${DEBUG} "  Type = $R2"
679
			ReadINIStr $R3 $0 "Field $R1" Left
680
			${DEBUG} "  Left = $R3"
681
			ReadINIStr $R4 $0 "Field $R1" Top
682
			${DEBUG} "  Top = $R4"
683
			ReadINIStr $R5 $0 "Field $R1" Right
684
			${DEBUG} "  Right = $R5"
685
			ReadINIStr $R6 $0 "Field $R1" Bottom
686
			${DEBUG} "  Bottom = $R6"
687
			IntOp $R5 $R5 - $R3
688
			${DEBUG} "  Width = $R5"
689
			IntOp $R6 $R6 - $R4
690
			${DEBUG} "  Height = $R6"
691
			ReadINIStr $R7 $0 "Field $R1" Text
692
			${DEBUG} "  Text = $R7"
693
			${Switch} $R2
694
				!insertmacro __NSD_ControlCase   HLine
695
				!insertmacro __NSD_ControlCase   VLine
696
				!insertmacro __NSD_ControlCase   Label
697
				!insertmacro __NSD_ControlCase   Icon
698
				!insertmacro __NSD_ControlCase   Bitmap
699
				!insertmacro __NSD_ControlCaseEx Link
700
				!insertmacro __NSD_ControlCase   Button
701
				!insertmacro __NSD_ControlCase   GroupBox
702
				!insertmacro __NSD_ControlCase   CheckBox
703
				!insertmacro __NSD_ControlCase   RadioButton
704
				!insertmacro __NSD_ControlCase   Text
705
				!insertmacro __NSD_ControlCase   Password
706
				!insertmacro __NSD_ControlCaseEx FileRequest
707
				!insertmacro __NSD_ControlCaseEx DirRequest
708
				!insertmacro __NSD_ControlCase   ComboBox
709
				!insertmacro __NSD_ControlCase   DropList
710
				!insertmacro __NSD_ControlCase   ListBox
711
			${EndSwitch}
712

    
713
			WriteINIStr $0 "Field $R1" HWND $R9
714
		${Next}
715

    
716
		nsDialogs::Show
717

    
718
	FunctionEnd
719

    
720
	Function ${UNINSTALLER_FUNCPREFIX}UpdateINIState
721

    
722
		${DEBUG} "Updating INI state"
723

    
724
		ReadINIStr $R0 $0 Settings NumFields
725

    
726
		${DEBUG} "NumField = $R0"
727

    
728
		${For} $R1 1 $R0
729
			ReadINIStr $R2 $0 "Field $R1" HWND
730
			ReadINIStr $R3 $0 "Field $R1" "Type"
731
			${Switch} $R3
732
				${Case} "CheckBox"
733
				${Case} "RadioButton"
734
					${DEBUG} "  HWND = $R2"
735
					${NSD_GetState} $R2 $R2
736
					${DEBUG} "  Window selection = $R2"
737
				${Break}
738
				${CaseElse}
739
					${DEBUG} "  HWND = $R2"
740
					${NSD_GetText} $R2 $R2
741
					${DEBUG} "  Window text = $R2"
742
				${Break}
743
			${EndSwitch}
744
			WriteINIStr $0 "Field $R1" STATE $R2
745
		${Next}
746

    
747
	FunctionEnd
748

    
749
	Function ${UNINSTALLER_FUNCPREFIX}FileRequest
750

    
751
		IntOp $R5 $R5 - 15
752
		IntOp $R8 $R3 + $R5
753

    
754
		${NSD_CreateBrowseButton} $R8u $R4u 15u $R6u ...
755
		Pop $R8
756

    
757
		nsDialogs::SetUserData $R8 $R1 # remember field id
758

    
759
		WriteINIStr $0 "Field $R1" HWND2 $R8
760

    
761
		${NSD_OnClick} $R8 ${UNINSTALLER_FUNCPREFIX}OnFileBrowseButton
762

    
763
		ReadINIStr $R9 $0 "Field $R1" State
764

    
765
		${NSD_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
766
		Pop $R9
767

    
768
	FunctionEnd
769

    
770
	Function ${UNINSTALLER_FUNCPREFIX}DirRequest
771

    
772
		IntOp $R5 $R5 - 15
773
		IntOp $R8 $R3 + $R5
774

    
775
		${NSD_CreateBrowseButton} $R8u $R4u 15u $R6u ...
776
		Pop $R8
777

    
778
		nsDialogs::SetUserData $R8 $R1 # remember field id
779

    
780
		WriteINIStr $0 "Field $R1" HWND2 $R8
781

    
782
		${NSD_OnClick} $R8 ${UNINSTALLER_FUNCPREFIX}OnDirBrowseButton
783

    
784
		ReadINIStr $R9 $0 "Field $R1" State
785

    
786
		${NSD_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
787
		Pop $R9
788

    
789
	FunctionEnd
790

    
791
	Function ${UNINSTALLER_FUNCPREFIX}OnFileBrowseButton
792

    
793
		Pop $R0
794

    
795
		nsDialogs::GetUserData $R0
796
		Pop $R1
797

    
798
		ReadINIStr $R2 $0 "Field $R1" HWND
799
		ReadINIStr $R4 $0 "Field $R1" Filter
800

    
801
		${NSD_GetText} $R2 $R3
802

    
803
		nsDialogs::SelectFileDialog save $R3 $R4
804
		Pop $R3
805

    
806
		${If} $R3 != ""
807
			SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
808
		${EndIf}
809

    
810
	FunctionEnd
811

    
812
	Function ${UNINSTALLER_FUNCPREFIX}OnDirBrowseButton
813

    
814
		Pop $R0
815

    
816
		nsDialogs::GetUserData $R0
817
		Pop $R1
818

    
819
		ReadINIStr $R2 $0 "Field $R1" HWND
820
		ReadINIStr $R3 $0 "Field $R1" Text
821

    
822
		${NSD_GetText} $R2 $R4
823

    
824
		nsDialogs::SelectFolderDialog $R3 $R4
825
		Pop $R3
826

    
827
		${If} $R3 != error
828
			SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
829
		${EndIf}
830

    
831
	FunctionEnd
832

    
833
	Function ${UNINSTALLER_FUNCPREFIX}Link
834

    
835
		${NSD_CreateLink} $R3u $R4u $R5u $R6u $R7
836
		Pop $R9
837

    
838
		nsDialogs::SetUserData $R9 $R1 # remember field id
839

    
840
		${NSD_OnClick} $R9 ${UNINSTALLER_FUNCPREFIX}OnLink
841

    
842
	FunctionEnd
843

    
844
	Function ${UNINSTALLER_FUNCPREFIX}OnLink
845

    
846
		Pop $R0
847

    
848
		nsDialogs::GetUserData $R0
849
		Pop $R1
850

    
851
		ReadINIStr $R1 $0 "Field $R1" STATE
852

    
853
		ExecShell "" $R1
854

    
855
	FunctionEnd
856

    
857
!macroend
858

    
859
!verbose pop
860
!endif