Made StartRadioButtons not depend on $1 and added an option to work with multiple "radio buttons" blocks
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3308 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
3ab14efa82
commit
a6046b428a
2 changed files with 41 additions and 58 deletions
|
@ -48,11 +48,11 @@ Function .onInit
|
|||
FunctionEnd
|
||||
|
||||
Function .onSelChange
|
||||
Push $0
|
||||
|
||||
!ifdef USE_SUBSECTION
|
||||
; Check if the user have selected all of the sections using the sub-section
|
||||
; This piece of code is not needed when there are only two sections
|
||||
Push $0
|
||||
|
||||
SectionGetFlags ${subsec} $0
|
||||
IntOp $0 $0 & ${SF_SELECTED}
|
||||
StrCmp $0 0 skip
|
||||
|
@ -61,40 +61,14 @@ Function .onSelChange
|
|||
SectionSetFlags ${sec3} 0
|
||||
SectionSetFlags ${sec4} 0
|
||||
skip:
|
||||
|
||||
Pop $0
|
||||
!endif
|
||||
|
||||
; Turn off old selected section
|
||||
SectionGetFlags $1 $0
|
||||
IntOp $0 $0 & ${SECTION_OFF}
|
||||
SectionSetFlags $1 $0
|
||||
# !insertmacro UnselectSection $1
|
||||
|
||||
; Now remember the current selection
|
||||
Push $2
|
||||
StrCpy $2 $1
|
||||
|
||||
SectionGetFlags ${sec1} $0
|
||||
IntOp $0 $0 & ${SF_SELECTED}
|
||||
IntCmp $0 ${SF_SELECTED} 0 +2 +2
|
||||
StrCpy $1 ${sec1}
|
||||
SectionGetFlags ${sec2} $0
|
||||
IntOp $0 $0 & ${SF_SELECTED}
|
||||
IntCmp $0 ${SF_SELECTED} 0 +2 +2
|
||||
StrCpy $1 ${sec2}
|
||||
SectionGetFlags ${sec3} $0
|
||||
IntOp $0 $0 & ${SF_SELECTED}
|
||||
IntCmp $0 ${SF_SELECTED} 0 +2 +2
|
||||
StrCpy $1 ${sec3}
|
||||
SectionGetFlags ${sec4} $0
|
||||
IntOp $0 $0 & ${SF_SELECTED}
|
||||
IntCmp $0 ${SF_SELECTED} 0 +2 +2
|
||||
StrCpy $1 ${sec4}
|
||||
|
||||
StrCmp $2 $1 0 +4 ; selection hasn't changed
|
||||
SectionGetFlags $1 $0
|
||||
IntOp $0 $0 | ${SF_SELECTED}
|
||||
SectionSetFlags $1 $0
|
||||
# !insertmacro SelectSection $1
|
||||
Pop $2
|
||||
Pop $0
|
||||
!insertmacro StartRadioButtons $1
|
||||
!insertmacro RadioButton ${sec1}
|
||||
!insertmacro RadioButton ${sec2}
|
||||
!insertmacro RadioButton ${sec3}
|
||||
!insertmacro RadioButton ${sec4}
|
||||
!insertmacro EndRadioButtons
|
||||
FunctionEnd
|
|
@ -45,49 +45,58 @@
|
|||
# macros for mutually exclusive section selection
|
||||
# written by Tim Gallagher
|
||||
|
||||
#### usage example:
|
||||
#### usage example (see one-section.nsi too):
|
||||
|
||||
# Var SomeVar
|
||||
#
|
||||
# Function .onSelChange
|
||||
# !insertmacro StartRadioButtons
|
||||
# !insertmacro StartRadioButtons $SomeVar
|
||||
# !insertmacro RadioButton ${sec1}
|
||||
# !insertmacro RadioButton ${sec2}
|
||||
# !insertmacro RadioButton ${sec3}
|
||||
# !insertmacro EndRadioButtons
|
||||
# FunctionEnd
|
||||
|
||||
#
|
||||
# Function .onInit
|
||||
# !insertmacro UnselectSection ${sec1}
|
||||
# StrCpy $SomeVar ${sec1} ; default section
|
||||
# !insertmacro UnselectSection ${sec2}
|
||||
# !insertmacro UnselectSection ${sec3}
|
||||
# FunctionEnd
|
||||
|
||||
# starts the Radio Button Block
|
||||
!macro StartRadioButtons
|
||||
Push $0
|
||||
SectionGetFlags $1 $0
|
||||
IntOp $0 $0 & ${SECTION_OFF}
|
||||
SectionSetFlags $1 $0
|
||||
# Starts the Radio Button Block.
|
||||
# You should pass a variable that keeps the selected section
|
||||
# as the first parameter for this macro. This variable should
|
||||
# be initialized to the default section's index. As this macro
|
||||
# uses $R0 and $R1 you can't use those two as the varible
|
||||
# which will keep the selected section.
|
||||
!macro StartRadioButtons var
|
||||
!define StartRadioButtons_Var "${var}"
|
||||
Push $R0
|
||||
SectionGetFlags "${StartRadioButtons_Var}" $R0
|
||||
IntOp $R0 $R0 & ${SECTION_OFF}
|
||||
SectionSetFlags "${StartRadioButtons_Var}" $R0
|
||||
|
||||
Push $2
|
||||
StrCpy $2 $1
|
||||
Push $R1
|
||||
StrCpy $R1 "${StartRadioButtons_Var}"
|
||||
!macroend
|
||||
|
||||
!macro RadioButton SECTION_NAME
|
||||
SectionGetFlags ${SECTION_NAME} $0
|
||||
IntOp $0 $0 & ${SF_SELECTED}
|
||||
IntCmp $0 ${SF_SELECTED} 0 +2 +2
|
||||
StrCpy $1 ${SECTION_NAME}
|
||||
SectionGetFlags ${SECTION_NAME} $R0
|
||||
IntOp $R0 $R0 & ${SF_SELECTED}
|
||||
IntCmp $R0 ${SF_SELECTED} 0 +2 +2
|
||||
StrCpy "${StartRadioButtons_Var}" ${SECTION_NAME}
|
||||
!macroend
|
||||
|
||||
# ends the radio button block
|
||||
!macro EndRadioButtons
|
||||
StrCmp $2 $1 0 +4 ; selection hasn't changed
|
||||
SectionGetFlags $1 $0
|
||||
IntOp $0 $0 | ${SF_SELECTED}
|
||||
SectionSetFlags $1 $0
|
||||
StrCmp $R1 "${StartRadioButtons_Var}" 0 +4 ; selection hasn't changed
|
||||
SectionGetFlags "${StartRadioButtons_Var}" $R0
|
||||
IntOp $R0 $R0 | ${SF_SELECTED}
|
||||
SectionSetFlags "${StartRadioButtons_Var}" $R0
|
||||
|
||||
Pop $2
|
||||
Pop $0
|
||||
Pop $R1
|
||||
Pop $R0
|
||||
!undef StartRadioButtons_Var
|
||||
!macroend
|
||||
|
||||
; For details about SetSectionInInstType and ClearSectionInInstType, see
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue