chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / buttons
1 ;
2 ; buttons.sh
3 ;
4 ; Definitions for button blocks
5 ;
6 ; © 1995-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire.  If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Overview -------------------------------------------------------------
28 ;
29 ; Functions provided:
30 ;
31 ;   buttons_setup
32 ;
33 ; Macros provided:
34 ;
35 ;   BUTTON
36 ;   BUTEND
37 ;   BCANCEL
38 ;   BOK
39 ;   BHELP
40 ;   BGAP
41
42                 [       :LNOT::DEF:buttons__dfn
43                 GBLL    buttons__dfn
44
45 ;+              LIB     sapphire:^.bsh.stdDbox
46
47 ; --- buttons_setup ---
48 ;
49 ; On entry:     R0 == dialogue box handle
50 ;               R1 == pointer to buttons block
51 ;               R2 == buttons base icon
52 ;               R3 == number of buttons to allow
53 ;
54 ; On exit:      R2 == buttons flag mask
55 ;               R3 == cancel button icon, or -1
56 ;
57 ; Use:          Sets up a dialogue box's buttons according to a buttons
58 ;               block.
59
60                 IMPORT  buttons_setup
61
62 ;----- Macros ---------------------------------------------------------------
63
64                 GBLA    but__c
65 but__c          SETA    0
66                 GBLA    but__fl
67 but__fl         SETA    0
68
69 ; --- Macro: BUTTON ---
70 ;
71 ; Arguments:    msg == message tag to put in button
72 ;
73 ; Use:          Inserts a text button into a buttons definition block.
74
75                 MACRO
76 $label          BUTTON  $msg
77 but__f$but__c   EQU     but__fl
78 but__c          SETA    but__c+1
79 but__fl         SETA    bFlag_text
80 $label          DCD     but__f$but__c
81                 DCB     "$msg",0
82                 ALIGN
83                 MEND
84
85 ; --- Macro: BCANCEL ---
86 ;
87 ; Arguments:    text == optional text string (default is `Cancel')
88 ;
89 ; Use:          Inserts a cancel button into a buttons definition block.
90
91                 MACRO
92 $label          BCANCEL $text
93 but__f$but__c   EQU     but__fl
94 but__c          SETA    but__c+1
95 but__fl         SETA    bFlag_cancel
96
97 $label          DCD     but__f$but__c
98
99                 [       "$text"<>""
100 but__fl         SETA    but__fl :OR: bFlag_text
101                 DCB     "$text",0
102                 ]
103
104                 MEND
105
106 ; --- Macro: BOK ---
107 ;
108 ; Arguments:    --
109 ;
110 ; Use:          Inserts an OK button into a buttons definition block.
111
112                 MACRO
113 $label          BOK
114 but__f$but__c   EQU     but__fl
115 but__c          SETA    but__c+1
116 but__fl         SETA    bFlag_ok
117 $label          DCD     but__f$but__c
118                 MEND
119
120 ; --- Macro: BHELP ---
121 ;
122 ; Arguments:    --
123 ;
124 ; Use:          Inserts a help button into a buttons definition block.
125
126                 MACRO
127 $label          BHELP
128 but__f$but__c   EQU     but__fl
129 but__c          SETA    but__c+1
130 but__fl         SETA    bFlag_help
131 $label          DCD     but__f$but__c
132                 MEND
133
134 ; --- Macro: BGAP ---
135 ;
136 ; Arguments:    --
137 ;
138 ; Use:          Omits a button in a buttons definition block.
139
140                 MACRO
141 $label          BGAP
142 but__f$but__c   EQU     but__fl
143 but__c          SETA    but__c+1
144 but__fl         SETA    0
145 $label          DCD     but__f$but__c
146                 MEND
147
148 ; --- Macro: BUTEND ---
149 ;
150 ; Arguments:    --
151 ;
152 ; Use:          Terminates a buttons definition block.
153
154                 MACRO
155 $label          BUTEND
156 but__f$but__c   EQU     but__fl+bFlag_last
157 but__c          SETA    but__c+1
158 $label
159                 MEND
160
161
162
163 ;----- Button block formats -------------------------------------------------
164
165 bFlag_cancel    EQU     (1<<0)                  ;This is the cancel button
166                                                 ;+0
167
168 bFlag_ok        EQU     (1<<1)                  ;This is the OK button
169                                                 ;+0
170
171 bFlag_help      EQU     (1<<2)                  ;This is the help button
172                                                 ;+0
173
174 bFlag_text      EQU     (1<<3)                  ;This button contains text
175                                                 ;+0 == message tag
176                                                 ;+n
177
178 bFlag_last      EQU     (1<<31)                 ;This is the last item
179                                                 ;+0
180
181                 ]
182
183 ;----- That's all, folks ----------------------------------------------------
184
185                 END