; ; stringSet.s ; ; String set dialogue box control ; ; © 1994 Straylight ; ;----- Standard header ------------------------------------------------------ GET libs:header GET libs:swis GET libs:stream ;----- External dependencies ------------------------------------------------ GET sapphire:dbox GET sapphire:menu GET sapphire:menuDefs GET sapphire:msgs GET sapphire:string GET sapphire:dbx.dbx GET sapphire:dbx._dbxMacs ;----- Main code ------------------------------------------------------------ AREA |Sapphire$$Code|,CODE,READONLY ; --- stringSet --- ; ; Control data: +0 == address of menu definition ; +4 == address of string table ; +8 == icon number in which to write string ; +12 ; ; Workspace: +0 == current value of radio selection ; +4 ; ; Flags: -- ; ; Use: Provides handling for a `menu button' -- when clicked, a ; menu of possible values appears, from which the user may ; choose an entry. The chosen string is copied to the icon. EXPORT stringSet stringSet ROUT DBXWS strs__wSpace DCD dbxMask_click TST R2,#7 ;Ensure it's a mouse click MOVEQS PC,R14 ;No -- then return right now STMFD R13!,{R0-R3,R14} ;Save some registers LDR R14,[R9,#8] ;Load destination icon STMIA R12,{R10,R14} ;Save icon and dbox away MOV R0,R10 ;Get dialogue in R0 BL dbox_slab ;Slab the button he clicked LDR R0,[R9,#0] ;Load the menu address ADR R1,strs__menu ;Point to my menu handler MOV R2,R8 ;Point to radio selector MOV R3,R12 ;Pass workspace in R12 BL menu_create ;Display the menu nicely BL dbox_unslab ;Now unslab the icon again LDMFD R13!,{R0-R3,PC}^ ;And return to caller LTORG ; --- strs__menu --- ; ; On entry: R0 == menu event code ; R1 == index of item chosen ; ; On exit: -- ; ; Use: Handles a selection from a string set menu. strs__menu ROUT CMP R0,#mEvent_select ;Is this a menu selection? MOVNES PC,R14 ;No -- then return to caller STMFD R13!,{R0-R2,R10,R14} ;Save some registers LDR R14,[R10,#0] ;Load the old value out CMP R14,R1 ;Do they match up? LDMEQFD R13!,{R0-R2,R10,PC}^ ;Yes -- ignore the select STR R1,[R10,#0] ;Store new radio button value MOV R2,R1 ;Look after this value now LDMIA R12,{R0,R1} ;Load saved icon and dialogue MOV R10,R0 ;Put dialogue in R10 nicely BL stringSet_setValue ;Set up the icon string MOV R0,#stringSet_event ;Put event code in R0 BL dbx_sendEvent ;Inform client of change LDMFD R13!,{R0-R2,R10,PC}^ ;And return to caller LTORG ; --- stringSet_setValue --- ; ; On entry: R0 == dialogue box handle ; R1 == icon handle ; ; On exit: -- ; ; Use: Sets the contents of the display area attached to a string ; set control from the current state of the control. EXPORT stringSet_setValue stringSet_setValue ROUT STMFD R13!,{R0-R2,R8-R10,R14} ;Save some registers MOV R10,R0 ;Put dialogue handle in R10 MOV R0,R1 ;Get control icon in R0 BL dbx_findData ;Find my control data LDMCCFD R13!,{R0-R2,R8-R10,PC}^ ;If failed, ignore this ; --- Now look up the correct string --- LDR R1,[R8,#0] ;Load the current value LDR R0,[R9,#4] ;Load string table base BL str_index ;Find the correct one ; --- Fill in the icon number --- 10 BL msgs_lookup ;Translate the string MOV R2,R0 ;Point to the result LDR R1,[R9,#8] ;Load the display icon handle MOV R0,R10 ;Get the dialogue box handle BL dbox_setField ;Write the string in LDMFD R13!,{R0-R2,R8-R10,PC}^ ;And return to caller LTORG strs__wSpace DCD 0 stringSet_event EQU &80000005 ;----- Workspace ------------------------------------------------------------ ^ 0,R12 strs__wStart # 0 strs__dbox # 4 ;Dbox of current stringset strs__icon # 4 ;Icon of current stringset strs__wSize EQU {VAR}-strs__wStart AREA |Sapphire$$LibData|,CODE,READONLY DCD strs__wSize DCD strs__wSpace DCD 0 DCD 0 ;----- That's all, folks ---------------------------------------------------- END