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
|
FunctionEnd
|
||||||
|
|
||||||
Function .onSelChange
|
Function .onSelChange
|
||||||
Push $0
|
|
||||||
|
|
||||||
!ifdef USE_SUBSECTION
|
!ifdef USE_SUBSECTION
|
||||||
; Check if the user have selected all of the sections using the sub-section
|
; 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
|
; This piece of code is not needed when there are only two sections
|
||||||
|
Push $0
|
||||||
|
|
||||||
SectionGetFlags ${subsec} $0
|
SectionGetFlags ${subsec} $0
|
||||||
IntOp $0 $0 & ${SF_SELECTED}
|
IntOp $0 $0 & ${SF_SELECTED}
|
||||||
StrCmp $0 0 skip
|
StrCmp $0 0 skip
|
||||||
|
@ -61,40 +61,14 @@ Function .onSelChange
|
||||||
SectionSetFlags ${sec3} 0
|
SectionSetFlags ${sec3} 0
|
||||||
SectionSetFlags ${sec4} 0
|
SectionSetFlags ${sec4} 0
|
||||||
skip:
|
skip:
|
||||||
|
|
||||||
|
Pop $0
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
; Turn off old selected section
|
!insertmacro StartRadioButtons $1
|
||||||
SectionGetFlags $1 $0
|
!insertmacro RadioButton ${sec1}
|
||||||
IntOp $0 $0 & ${SECTION_OFF}
|
!insertmacro RadioButton ${sec2}
|
||||||
SectionSetFlags $1 $0
|
!insertmacro RadioButton ${sec3}
|
||||||
# !insertmacro UnselectSection $1
|
!insertmacro RadioButton ${sec4}
|
||||||
|
!insertmacro EndRadioButtons
|
||||||
; 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
|
|
||||||
FunctionEnd
|
FunctionEnd
|
|
@ -45,49 +45,58 @@
|
||||||
# macros for mutually exclusive section selection
|
# macros for mutually exclusive section selection
|
||||||
# written by Tim Gallagher
|
# written by Tim Gallagher
|
||||||
|
|
||||||
#### usage example:
|
#### usage example (see one-section.nsi too):
|
||||||
|
|
||||||
|
# Var SomeVar
|
||||||
|
#
|
||||||
# Function .onSelChange
|
# Function .onSelChange
|
||||||
# !insertmacro StartRadioButtons
|
# !insertmacro StartRadioButtons $SomeVar
|
||||||
# !insertmacro RadioButton ${sec1}
|
# !insertmacro RadioButton ${sec1}
|
||||||
# !insertmacro RadioButton ${sec2}
|
# !insertmacro RadioButton ${sec2}
|
||||||
# !insertmacro RadioButton ${sec3}
|
# !insertmacro RadioButton ${sec3}
|
||||||
# !insertmacro EndRadioButtons
|
# !insertmacro EndRadioButtons
|
||||||
# FunctionEnd
|
# FunctionEnd
|
||||||
|
#
|
||||||
# Function .onInit
|
# Function .onInit
|
||||||
# !insertmacro UnselectSection ${sec1}
|
# StrCpy $SomeVar ${sec1} ; default section
|
||||||
# !insertmacro UnselectSection ${sec2}
|
# !insertmacro UnselectSection ${sec2}
|
||||||
# !insertmacro UnselectSection ${sec3}
|
# !insertmacro UnselectSection ${sec3}
|
||||||
# FunctionEnd
|
# FunctionEnd
|
||||||
|
|
||||||
# starts the Radio Button Block
|
# Starts the Radio Button Block.
|
||||||
!macro StartRadioButtons
|
# You should pass a variable that keeps the selected section
|
||||||
Push $0
|
# as the first parameter for this macro. This variable should
|
||||||
SectionGetFlags $1 $0
|
# be initialized to the default section's index. As this macro
|
||||||
IntOp $0 $0 & ${SECTION_OFF}
|
# uses $R0 and $R1 you can't use those two as the varible
|
||||||
SectionSetFlags $1 $0
|
# 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
|
Push $R1
|
||||||
StrCpy $2 $1
|
StrCpy $R1 "${StartRadioButtons_Var}"
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
!macro RadioButton SECTION_NAME
|
!macro RadioButton SECTION_NAME
|
||||||
SectionGetFlags ${SECTION_NAME} $0
|
SectionGetFlags ${SECTION_NAME} $R0
|
||||||
IntOp $0 $0 & ${SF_SELECTED}
|
IntOp $R0 $R0 & ${SF_SELECTED}
|
||||||
IntCmp $0 ${SF_SELECTED} 0 +2 +2
|
IntCmp $R0 ${SF_SELECTED} 0 +2 +2
|
||||||
StrCpy $1 ${SECTION_NAME}
|
StrCpy "${StartRadioButtons_Var}" ${SECTION_NAME}
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
# ends the radio button block
|
# ends the radio button block
|
||||||
!macro EndRadioButtons
|
!macro EndRadioButtons
|
||||||
StrCmp $2 $1 0 +4 ; selection hasn't changed
|
StrCmp $R1 "${StartRadioButtons_Var}" 0 +4 ; selection hasn't changed
|
||||||
SectionGetFlags $1 $0
|
SectionGetFlags "${StartRadioButtons_Var}" $R0
|
||||||
IntOp $0 $0 | ${SF_SELECTED}
|
IntOp $R0 $R0 | ${SF_SELECTED}
|
||||||
SectionSetFlags $1 $0
|
SectionSetFlags "${StartRadioButtons_Var}" $R0
|
||||||
|
|
||||||
Pop $2
|
Pop $R1
|
||||||
Pop $0
|
Pop $R0
|
||||||
|
!undef StartRadioButtons_Var
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
; For details about SetSectionInInstType and ClearSectionInInstType, see
|
; For details about SetSectionInInstType and ClearSectionInInstType, see
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue