Initial revision
[ssr] / StraySrc / Libraries / Sapphire / dbx / s / stringSet
1 ;
2 ; stringSet.s
3 ;
4 ; String set dialogue box control
5 ;
6 ; © 1994 Straylight
7 ;
8
9 ;----- Standard header ------------------------------------------------------
10
11 GET libs:header
12 GET libs:swis
13
14 GET libs:stream
15
16 ;----- External dependencies ------------------------------------------------
17
18 GET sapphire:dbox
19 GET sapphire:menu
20 GET sapphire:menuDefs
21 GET sapphire:msgs
22 GET sapphire:string
23
24 GET sapphire:dbx.dbx
25 GET sapphire:dbx._dbxMacs
26
27 ;----- Main code ------------------------------------------------------------
28
29 AREA |Sapphire$$Code|,CODE,READONLY
30
31 ; --- stringSet ---
32 ;
33 ; Control data: +0 == address of menu definition
34 ; +4 == address of string table
35 ; +8 == icon number in which to write string
36 ; +12
37 ;
38 ; Workspace: +0 == current value of radio selection
39 ; +4
40 ;
41 ; Flags: --
42 ;
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.
46
47 EXPORT stringSet
48 stringSet ROUT
49
50 DBXWS strs__wSpace
51 DCD dbxMask_click
52
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
67
68 LTORG
69
70 ; --- strs__menu ---
71 ;
72 ; On entry: R0 == menu event code
73 ; R1 == index of item chosen
74 ;
75 ; On exit: --
76 ;
77 ; Use: Handles a selection from a string set menu.
78
79 strs__menu ROUT
80
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
95
96 LTORG
97
98 ; --- stringSet_setValue ---
99 ;
100 ; On entry: R0 == dialogue box handle
101 ; R1 == icon handle
102 ;
103 ; On exit: --
104 ;
105 ; Use: Sets the contents of the display area attached to a string
106 ; set control from the current state of the control.
107
108 EXPORT stringSet_setValue
109 stringSet_setValue ROUT
110
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
116
117 ; --- Now look up the correct string ---
118
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
122
123 ; --- Fill in the icon number ---
124
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
131
132 LTORG
133
134 strs__wSpace DCD 0
135
136 stringSet_event EQU &80000005
137
138 ;----- Workspace ------------------------------------------------------------
139
140 ^ 0,R12
141 strs__wStart # 0
142
143 strs__dbox # 4 ;Dbox of current stringset
144 strs__icon # 4 ;Icon of current stringset
145
146 strs__wSize EQU {VAR}-strs__wStart
147
148 AREA |Sapphire$$LibData|,CODE,READONLY
149
150 DCD strs__wSize
151 DCD strs__wSpace
152 DCD 0
153 DCD 0
154
155 ;----- That's all, folks ----------------------------------------------------
156
157 END