4 ; String set dialogue box control
9 ;----- Standard header ------------------------------------------------------
16 ;----- External dependencies ------------------------------------------------
25 GET sapphire:dbx._dbxMacs
27 ;----- Main code ------------------------------------------------------------
29 AREA |Sapphire$$Code|,CODE,READONLY
33 ; Control data: +0 == address of menu definition
34 ; +4 == address of string table
35 ; +8 == icon number in which to write string
38 ; Workspace: +0 == current value of radio selection
43 ; Use: Provides handling for a `menu button' -- when clicked, a
44 ; menu of possible values appears, from which the user may
45 ; choose an entry. The chosen string is copied to the icon.
53 TST R2,#7 ;Ensure it's a mouse click
54 MOVEQS PC,R14 ;No -- then return right now
55 STMFD R13!,{R0-R3,R14} ;Save some registers
56 LDR R14,[R9,#8] ;Load destination icon
57 STMIA R12,{R10,R14} ;Save icon and dbox away
58 MOV R0,R10 ;Get dialogue in R0
59 BL dbox_slab ;Slab the button he clicked
60 LDR R0,[R9,#0] ;Load the menu address
61 ADR R1,strs__menu ;Point to my menu handler
62 MOV R2,R8 ;Point to radio selector
63 MOV R3,R12 ;Pass workspace in R12
64 BL menu_create ;Display the menu nicely
65 BL dbox_unslab ;Now unslab the icon again
66 LDMFD R13!,{R0-R3,PC}^ ;And return to caller
72 ; On entry: R0 == menu event code
73 ; R1 == index of item chosen
77 ; Use: Handles a selection from a string set menu.
81 CMP R0,#mEvent_select ;Is this a menu selection?
82 MOVNES PC,R14 ;No -- then return to caller
83 STMFD R13!,{R0-R2,R10,R14} ;Save some registers
84 LDR R14,[R10,#0] ;Load the old value out
85 CMP R14,R1 ;Do they match up?
86 LDMEQFD R13!,{R0-R2,R10,PC}^ ;Yes -- ignore the select
87 STR R1,[R10,#0] ;Store new radio button value
88 MOV R2,R1 ;Look after this value now
89 LDMIA R12,{R0,R1} ;Load saved icon and dialogue
90 MOV R10,R0 ;Put dialogue in R10 nicely
91 BL stringSet_setValue ;Set up the icon string
92 MOV R0,#stringSet_event ;Put event code in R0
93 BL dbx_sendEvent ;Inform client of change
94 LDMFD R13!,{R0-R2,R10,PC}^ ;And return to caller
98 ; --- stringSet_setValue ---
100 ; On entry: R0 == dialogue box handle
105 ; Use: Sets the contents of the display area attached to a string
106 ; set control from the current state of the control.
108 EXPORT stringSet_setValue
109 stringSet_setValue ROUT
111 STMFD R13!,{R0-R2,R8-R10,R14} ;Save some registers
112 MOV R10,R0 ;Put dialogue handle in R10
113 MOV R0,R1 ;Get control icon in R0
114 BL dbx_findData ;Find my control data
115 LDMCCFD R13!,{R0-R2,R8-R10,PC}^ ;If failed, ignore this
117 ; --- Now look up the correct string ---
119 LDR R1,[R8,#0] ;Load the current value
120 LDR R0,[R9,#4] ;Load string table base
121 BL str_index ;Find the correct one
123 ; --- Fill in the icon number ---
125 10 BL msgs_lookup ;Translate the string
126 MOV R2,R0 ;Point to the result
127 LDR R1,[R9,#8] ;Load the display icon handle
128 MOV R0,R10 ;Get the dialogue box handle
129 BL dbox_setField ;Write the string in
130 LDMFD R13!,{R0-R2,R8-R10,PC}^ ;And return to caller
136 stringSet_event EQU &80000005
138 ;----- Workspace ------------------------------------------------------------
143 strs__dbox # 4 ;Dbox of current stringset
144 strs__icon # 4 ;Icon of current stringset
146 strs__wSize EQU {VAR}-strs__wStart
148 AREA |Sapphire$$LibData|,CODE,READONLY
155 ;----- That's all, folks ----------------------------------------------------