Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2322 gchristi 1
!include "MUI2.nsh"
2
!include "LogicLib.nsh"
3
!include "nsDialogs.nsh"
4
 
5
; Simple PAGES based on MUI2 that contains 1, 2 or 3 edit boxes with labels and a titles
6
;
7
; Usage Use the !insertmacro to insert the pages in the order you require as with standard pages
8
; There are 3 macros one for pages with a single edit box, one for a page with 2 edit boxes and another for one with 3 edit boxes
9
; !insertmacro VIX_PAGE_EDIT1 "Label1" $Var1 
10
; !insertmacro VIX_PAGE_EDIT2 "Label1" $Var1 "Label2" $Var2 
11
; !insertmacro VIX_PAGE_EDIT3 "Label1" $Var1 "Label2" $Var2 "Label3" $Var3
12
;
13
; They will display a dialog with the appropriate number of edit boxes with the assoctaied label next to it
14
; The edit boxes and labels are fixed size & position so labels need to checked that they are not truncated
15
; The VarN variables are used to supply the current value when the dialog is displayed and also return what was entered (or default if not changed)
16
;
17
; The Macros can be used multiple times to display multiple edit pages
18
;
19
; The Dialogs use several defines for messages.
20
; !define VIX_PAGE_EDIT_TEXT     The (short) Text in the top section of the Dialog (in the same section as the VIX icon)
21
;                                Defaults to "Edit Data"
22
; !define VIX_PAGE_EDIT_SUBTEXT  The (short) SubText in the top section of the Dialog under the Text (in the same section as the VIX icon)
23
;                                Defaults to "Enter Requested Data"
24
; !define VIX_PAGE_EDIT_TITLE    The Title that appears in the main body of the dialog above the edit fields.  Used to detail whart is required to be entered.
25
;                                Defaults to "Enter Required fields"
26
;
27
; Example
28
; !include "MUI2.nsh"
29
; !include "VixPageEditDialogs.nsh"
30
; Var OracleSID
31
; Var OracleUser
32
; Var OraclePasswd
33
; !insertmacro MUI_PAGE_WELCOME
34
; !define      VIX_PAGE_EDIT_TEXT     "Oracle Login Details"
35
; !define      VIX_PAGE_EDIT_SUBTEXT  "Enter the Oracle connection details"
36
; !define      VIX_PAGE_EDIT_TITLE    "Enter the Oracle Database SID and associated user name and password to log on with"
37
; !insertmacro VIX_PAGE_EDIT3 "Oracle SID:" $OracleSID "User name:" $OracleUser "Password:" $OraclePasswd
38
; !insertmacro MUI_PAGE_DIRECTORY
39
; !insertmacro MUI_PAGE_INSTFILES
40
 
41
 
42
;==========================================================================
43
; VIX_PAGE_EDIT1 Label1 Var1 
44
;==========================================================================
45
!macro VIX_PAGE_EDIT1 Label1 Var1 
46
    !insertmacro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID
47
 
48
    ; Sets the defines for the var and label to use for single edit box
49
    !insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS
50
    !insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 1 "${Label1}" "${Var1}"
51
 
52
    ; define the var to save the edit box control to
53
    Var Text1${VIX_PAGE_EDIT_UNIQUE_ID}
54
 
55
    ; now run the page
56
    !insertmacro _VIX_PAGE_EDIT
57
 
58
    !insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS
59
    !undef VIX_PAGE_EDIT_UNIQUE_ID
60
!macroend
61
 
62
 
63
;==========================================================================
64
; VIX_PAGE_EDIT2 Label1 Var1 Label2 Var2
65
;==========================================================================
66
!macro VIX_PAGE_EDIT2 Label1 Var1 Label2 Var2
67
    !insertmacro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID
68
 
69
    ; Sets the defines for the var and label to use for single edit box
70
    !insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS
71
    !insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 1 "${Label1}" "${Var1}"
72
    !insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 2 "${Label2}" "${Var2}"
73
 
74
    ; define the var to save the edit box control to
75
    Var Text1${VIX_PAGE_EDIT_UNIQUE_ID}
76
    Var Text2${VIX_PAGE_EDIT_UNIQUE_ID}
77
 
78
    ; now run the page
79
    !insertmacro _VIX_PAGE_EDIT
80
 
81
    !insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS
82
    !undef VIX_PAGE_EDIT_UNIQUE_ID
83
!macroend
84
 
85
 
86
;==========================================================================
87
; VIX_PAGE_EDIT3 Label1 Var1 Label2 Var2 Label3 Var3
88
;==========================================================================
89
!macro VIX_PAGE_EDIT3 Label1 Var1 Label2 Var2 Label3 Var3
90
    !insertmacro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID
91
 
92
    ; Sets the defines for the var and label to use for single edit box
93
    !insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS
94
    !insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 1 "${Label1}" "${Var1}"
95
    !insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 2 "${Label2}" "${Var2}"
96
    !insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 3 "${Label3}" "${Var3}"
97
 
98
    ; define the var to save the edit box control to
99
    Var Text1${VIX_PAGE_EDIT_UNIQUE_ID}
100
    Var Text2${VIX_PAGE_EDIT_UNIQUE_ID}
101
    Var Text3${VIX_PAGE_EDIT_UNIQUE_ID}
102
 
103
    ; now run the page
104
    !insertmacro _VIX_PAGE_EDIT
105
 
106
    !insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS
107
    !undef VIX_PAGE_EDIT_UNIQUE_ID
108
!macroend
109
 
110
 
111
 
112
 
113
;==========================================================================
114
; INTERNAL MACROS
115
;==========================================================================
116
 
117
; defines a unique id so this dialog can be used multiple times
118
!macro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID
119
    !ifdef VIX_PAGE_EDIT_UNIQUE_ID
120
        !undef VIX_PAGE_EDIT_UNIQUE_ID
121
    !endif
122
    !define VIX_PAGE_EDIT_UNIQUE_ID _VIX_PAGE_EDIT_${__LINE__}
123
!macroend
124
 
125
 
126
 
127
!macro _DEFINE_VIX_PAGE_EDIT_VAR Num Label Variable
128
    !define _VIX_PAGE_EDIT_LABEL${Num} "${Label}"
129
    !define _VIX_PAGE_EDIT_VAR${Num} "${Variable}"
130
!macroend
131
 
132
 
133
 
134
!macro _UNDEF_ALL_VIX_PAGE_EDIT_VARS
135
    !ifdef _VIX_PAGE_EDIT_LABEL1
136
        !undef _VIX_PAGE_EDIT_LABEL1
137
    !endif
138
    !ifdef _VIX_PAGE_EDIT_VAR1
139
        !undef _VIX_PAGE_EDIT_VAR1
140
    !endif
141
    !ifdef _VIX_PAGE_EDIT_LABEL2
142
        !undef _VIX_PAGE_EDIT_LABEL2
143
    !endif
144
    !ifdef _VIX_PAGE_EDIT_VAR2
145
        !undef _VIX_PAGE_EDIT_VAR2
146
    !endif
147
    !ifdef _VIX_PAGE_EDIT_LABEL3
148
        !undef _VIX_PAGE_EDIT_LABEL3
149
    !endif
150
    !ifdef _VIX_PAGE_EDIT_VAR3
151
        !undef _VIX_PAGE_EDIT_VAR3
152
    !endif
153
!macroend
154
 
155
 
156
 
157
!macro _VIX_PAGE_EDIT
158
    Page custom PageFunc${VIX_PAGE_EDIT_UNIQUE_ID} LeaveFunc${VIX_PAGE_EDIT_UNIQUE_ID}
159
 
160
    Var Dialog${VIX_PAGE_EDIT_UNIQUE_ID}
161
 
162
    Function PageFunc${VIX_PAGE_EDIT_UNIQUE_ID}
163
        Push $0 ; save $0
164
 
165
        nsDialogs::Create 1018
166
        Pop $Dialog${VIX_PAGE_EDIT_UNIQUE_ID}
167
 
168
        ${If} $Dialog${VIX_PAGE_EDIT_UNIQUE_ID} == error
169
            Abort
170
        ${EndIf}
171
 
172
        !ifdef VIX_PAGE_EDIT_TEXT & VIX_PAGE_EDIT_SUBTEXT
173
            !insertmacro MUI_HEADER_TEXT "${VIX_PAGE_EDIT_TEXT}" "${VIX_PAGE_EDIT_SUBTEXT}"
174
            !undef VIX_PAGE_EDIT_TEXT
175
            !undef VIX_PAGE_EDIT_SUBTEXT
176
        !else ifdef VIX_PAGE_EDIT_TEXT
177
            !insertmacro MUI_HEADER_TEXT "${VIX_PAGE_EDIT_TEXT}" "Enter Requested Data"
178
            !undef VIX_PAGE_EDIT_TEXT
179
        !else ifdef VIX_PAGE_EDIT_SUBTEXT
180
            !insertmacro MUI_HEADER_TEXT "Edit Data" "${VIX_PAGE_HEADER_SUBTEXT}"
181
            !undef VIX_PAGE_EDIT_SUBTEXT
182
        !else
183
            !insertmacro MUI_HEADER_TEXT "Edit Data" "Enter Requested Data"
184
        !endif
185
 
186
        !ifdef VIX_PAGE_EDIT_TITLE
187
            ${NSD_CreateLabel} 0 0 100% 36u "${VIX_PAGE_EDIT_TITLE}"
188
            !undef VIX_PAGE_EDIT_TITLE
189
        !else
190
            ${NSD_CreateLabel} 0 0 100% 36u "Enter Required fields"
191
        !endif
192
        Pop $0
193
 
194
        !ifdef _VIX_PAGE_EDIT_VAR1
195
            ${NSD_CreateLabel} 0 41u 19% 12u "${_VIX_PAGE_EDIT_LABEL1}"
196
            Pop $0
197
 
198
            ${NSD_CreateText} 20% 40u 80% 12u "${_VIX_PAGE_EDIT_VAR1}"
199
            Pop $Text1${VIX_PAGE_EDIT_UNIQUE_ID}
200
        !endif
201
 
202
        !ifdef _VIX_PAGE_EDIT_VAR2
203
            ${NSD_CreateLabel} 0 71u 19% 12u "${_VIX_PAGE_EDIT_LABEL2}"
204
            Pop $0
205
 
206
            ${NSD_CreateText} 20% 70u 80% 12u "${_VIX_PAGE_EDIT_VAR2}"
207
            Pop $Text2${VIX_PAGE_EDIT_UNIQUE_ID}
208
        !endif
209
 
210
        !ifdef _VIX_PAGE_EDIT_VAR3
211
            ${NSD_CreateLabel} 0 101u 19% 12u "${_VIX_PAGE_EDIT_LABEL3}"
212
            Pop $0
213
 
214
            ${NSD_CreateText} 20% 100u 80% 12u "${_VIX_PAGE_EDIT_VAR3}"
215
            Pop $Text3${VIX_PAGE_EDIT_UNIQUE_ID}
216
        !endif
217
 
218
        nsDialogs::Show
219
        Pop $0
220
    FunctionEnd
221
 
222
    Function LeaveFunc${VIX_PAGE_EDIT_UNIQUE_ID}
223
        !ifdef _VIX_PAGE_EDIT_VAR1
224
            ${NSD_GetText} $Text1${VIX_PAGE_EDIT_UNIQUE_ID} ${_VIX_PAGE_EDIT_VAR1}
225
        !endif
226
        !ifdef _VIX_PAGE_EDIT_VAR2
227
            ${NSD_GetText} $Text2${VIX_PAGE_EDIT_UNIQUE_ID} ${_VIX_PAGE_EDIT_VAR2}
228
        !endif
229
        !ifdef _VIX_PAGE_EDIT_VAR3
230
            ${NSD_GetText} $Text3${VIX_PAGE_EDIT_UNIQUE_ID} ${_VIX_PAGE_EDIT_VAR3}
231
        !endif
232
    FunctionEnd
233
!macroend