4 ; Constant definitions and macros for dealing with menus
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
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)
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.
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.
27 ;----- Overview -------------------------------------------------------------
56 [ :LNOT::DEF:menuDefs__dfn
59 ;+ LIB sapphire:^.bsh.menuDefs
61 ;----- Constants for menus --------------------------------------------------
63 ; In the descriptions of flags below, the data required in the packed menu
64 ; definition is shown in the comments. Insert items in the order of the
65 ; bit precedences of the flags.
67 ; Note -- a (*) following a description means the flag is only supported by
68 ; tms (the tearoff system), and a (+) means that the flag is only supported
69 ; by menu (the WIMP system).
71 ; --- Flags for menu titles and items ---
73 mFlag_indirect EQU (1<<0) ;Data string is indirect
74 ;+0 == offset of text pointer
77 mFlag_R12 EQU (1<<16) ;Use R12 for writable data
80 mFlag_noTrans EQU (1<<19) ;Don't translate messages
83 ; --- Menu title flags ---
85 mFlag_tearoff EQU (1<<1) ;Menu may be torn off (*)
88 mFlag_makeMe EQU (1<<2) ;Menu recreated by client (+)
89 ;+0 == pointer to recreate fn
92 mFlag_maxHeight EQU (1<<3) ;Menu has a max height (*)
93 ;+0 == max height in OS units
96 mFlag_global EQU (1<<4) ;Menu is `global' (*)
99 ; --- Menu item flags ---
101 mFlag_shortCut EQU (1<<1) ;Item has a shortcut
102 ;+0 == shortcut key number
105 mFlag_iShortCut EQU (1<<2) ;Item has indirected shortcut
106 ;+0 == offset of key number
109 mFlag_shade EQU (1<<3) ;Item may be shaded
110 ;+0 == bitspec of shade bit
113 mFlag_invShade EQU (1<<4) ;Item may be unshaded
114 ;+0 == bitspec of unshade bit
117 mFlag_switch EQU (1<<5) ;Item is a switch (tickable)
118 ;+0 == bitspec of tick bit
121 mFlag_radio EQU (1<<6) ;Item is a radio button
122 ;+0 == offset of grp selector
123 ;+4 == number of item in grp
126 mFlag_sprite EQU (1<<7) ;Item contains a sprite (*)
128 ;+0 == ptr to validation str
131 ;+0 == offset of name pointer
132 ;+4 == sprite area (-1==res)
135 mFlag_halfSize EQU (1<<8) ;Display sprite half sized
138 mFlag_subWarn EQU (1<<9) ;Make event on opening sub
141 mFlag_subMenu EQU (1<<10) ;Item has a submenu
142 ;+0 == pointer to submenu def
145 mFlag_noWarn EQU (1<<17) ;Don't open sub when shaded
148 mFlag_ruleOff EQU (1<<18) ;Rule off after the item
151 mFlag_end EQU (1<<31) ;There are no more items
154 ; --- Event codes ---
156 ; Event codes are returned in R0, with R1 being the item number within
157 ; the packed menu definition, indexed from 0.
159 ; Note: mEvent_deleted is only sent to the topmost menu title by the
160 ; standard menu system, but is sent to the titles of all menus being closed
161 ; by TMS. If you are converting from one to the other, bear this in mind.
163 mEvent_select EQU 0 ;The user chose a menu item
165 ;R2 == address of packed def
167 mEvent_subMenu EQU 1 ;A submenu is about to open
170 mEvent_deleted EQU 2 ;A menu has just closed
172 mEvent_help EQU 3 ;Help is wanted for an item
174 ;R2 == address of packed def
176 ;----- Menu creation macros -------------------------------------------------
178 ; --- Note to reader ---
180 ; These macros make a lot of use of private constants and variables. Try to
181 ; avoid examining these too closely, because you'll probably get lost.
183 ; --- Set up the variables ---
190 ; --- Macro: BITSPEC ---
192 ; Arguments: offset == offset into workspace of target word
193 ; bit == bitmask with a 1 in the position of the bit
195 ; Use: Assembles a bit specification referencing the described bit.
196 ; The bit is described by a mask word rather than a bit
197 ; position, because it is expected that you will already have
198 ; set up constants for bit masks.
208 ! 1,"Bit mask is 0 in BITSPEC"
216 DCD ($offset << 5) :OR: bn
219 ; --- Macro: SETBIT ---
221 ; Arguments: flag == which menu flag above to set
223 ; Use: Sets a bit within the current item or menu title's flags
224 ; word. It ensures that items are inserted in the correct
229 [ (md__f :AND: &ffff) >= $flag
230 ! 1,"Flags built in bad order in menuDefs"
232 md__f SETA md__f :OR: $flag
235 ; --- Macro: NEWITEM ---
239 ; Use: Starts a new menu item or menu title. It also inserts a new
240 ; flags word in the current position.
246 md__F$md__i EQU md__f
252 ; --- Macro: MENU ---
254 ; Arguments: title == the menu's title string/message tag
256 ; Use: Creates a nonindirected menu title and starts a new menu.
262 ! 1,"Menu title too long"
268 ; --- Macro: MENUI ---
270 ; Arguments: title == offset to title pointer in client's workspace
272 ; Use: Creates an indirected menu title and starts a new menu.
277 SETBIT mFlag_indirect
281 ; --- Macro: TEAROFF ---
283 ; Arguments: title == menu's title string/message tag
285 ; Use: Creates a nonindirected tearoff menu title and starts a new
289 $label TEAROFF $title
296 ; --- Macro: TEARI ---
298 ; Arguments: title == offset to title pointer in client's workspace
300 ; Use: Creates an indirected tearoff menu title and starts a new
306 SETBIT mFlag_indirect
311 ; --- Macro: R12DATA ---
315 ; Use: Sets the current menu item or menu title to use the client's
316 ; R12 pointer rather than its R10 pointer for workspace.
323 ; --- Macro: NOTRANS ---
327 ; Use: Disables message translation of the current item or menu
328 ; title. This is useful if you're building the item or title
336 ; --- Macro: MAKEME ---
338 ; Arguments: makeProc == pointer to procedure which will remake the menu
340 ; Use: Sets the current menu to require being remade from scratch
341 ; when being updated (e.g. after an item is selected).
349 ; --- Macro: MHEIGHT ---
351 ; Arguments: height == maximum permitted height for menu in OS units
353 ; Use: Sets the menu's maximum allowable height.
357 SETBIT mFlag_maxHeight
361 ; --- Macro: GLOBALM ---
365 ; Use: Sets the menu's maximum allowable height.
372 ; --- Macro: ITEM ---
374 ; Arguments: text == item's text string/message tag
376 ; Use: Creates a new nonindirected menu item.
385 ; --- Macro: ITEMI ---
387 ; Arguments: text == offset of pointer to menu text
389 ; Use: Creates a new indirected menu item
394 SETBIT mFlag_indirect
398 ; --- Macro: SHADE ---
400 ; Arguments: $offset,$bit == bitspec of item's `shaded' bit
402 ; Use: Sets the current item to be shadable.
410 ; --- Macro: ISHADE ---
412 ; Arguments: offset,$bit == bitspec of item's `unshaded' bit
414 ; Use: Sets the current item to be inverse shadable.
418 SETBIT mFlag_invShade
422 ; --- Macro: SWITCH ---
424 ; Arguments: offset,$bit == bitspec of item's `ticked' bit
426 ; Use: Sets the current item to be tickable.
434 ; --- Macro: RADIO ---
436 ; Arguments: group == offset of this item's radio group selector
437 ; selector == value of selector to blob this item
439 ; Use: Marks this item as a radio item, so that it is blobbed (or
440 ; ticked under the WIMP menu system) when the selector in the
441 ; client's workspace matches the item's selector.
444 RADIO $group,$selector
449 ; --- Macro: SPRITE ---
451 ; Arguments: sprite == EITHER address of validation string, OR offset of
452 ; sprite name pointer (if area argument given)
453 ; area == (optional) sprite area, or -1 for resspr_area
455 ; Use: Adds a sprite to the menu item definition.
466 ; --- Macro: HALFSZ ---
470 ; Use: Sets the item to display its sprite at half size
474 SETBIT mFlag_halfSize
477 ; --- Macro: SUBWARN ---
481 ; Use: Sets the item to generate submenu warnings when its submenu
482 ; arrow is pointed at.
489 ; --- Macro: SUBMENU ---
491 ; Arguments: subMenu == pointer to packed definition of the submenu
492 ; handler == pointer to handler routine
494 ; Use: Attaches the given menu as a submenu of this item.
497 SUBMENU $subMenu,$handler
499 DCD $subMenu,$handler
502 ; --- Macro: NOWARN ---
506 ; Use: Prevents this item from returning submenu events if it is
514 ; --- Macro: RULEOFF ---
518 ; Use: Inserts a ruleoff after the current item, assuming there are
519 ; some more items after it.
526 ; --- Macro: MENUEND ---
530 ; Use: Finishes off the current menu.
534 md__F$md__i EQU md__f
542 ;----- That's all, folks ----------------------------------------------------