chiark / gitweb /
JPEG support and other fixes from Nick Clark
[ssr] / StraySrc / Libraries / Sapphire / s / mbox
1 ;
2 ; mbox.s
3 ;
4 ; Handling for monologue boxes (MDW)
5 ;
6 ; © 1994-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 ;----- Standard header ------------------------------------------------------
28
29                 GET     libs:header
30                 GET     libs:swis
31
32 ;----- External dependencies ------------------------------------------------
33
34                 GET     sapphire:dbox
35                 GET     sapphire:help
36                 GET     sapphire:msgs
37
38 ;----- Main code ------------------------------------------------------------
39
40                 AREA    |Sapphire$$Code|,CODE,READONLY
41
42 ; --- mbox ---
43 ;
44 ; On entry:     R0 == dialogue box handle
45 ;               R1 == pointer to help message tag for dialogue box
46 ;               R2 == icon handle for embedded title
47 ;
48 ; On exit:      --
49 ;
50 ; Use:          Displays a `monologue' box (i.e. a dialogue box which just
51 ;               displays information to the user) on the screen and sets up
52 ;               an event handler for it.  The dialogue box is destroyed when
53 ;               it is closed.
54 ;
55 ;               If the dialogue box does not have a title bar (read by
56 ;               dbox_hasTitle) then R2 is used to give the monologue box
57 ;               an embedded title.  R2 is not used otherwise, and thus may
58 ;               safely contain any old rubbish.
59
60                 EXPORT  mbox
61 mbox            ROUT
62
63                 STMFD   R13!,{R1-R3,R14}        ;Save some registers
64                 BL      dbox_hasTitle           ;Does it have a title bar?
65                 MOVCC   R1,R2                   ;Yes -- move icon number in
66                 BLCC    dbox_setEmbeddedTitle   ;Give dbox embedded title
67                 BLCC    dbox_setClickDrag       ;And make clicks move it
68                 LDR     R3,[R13,#0]             ;Pass help message in R12
69                 MOV     R2,R0                   ;Pass dbox handle in R10
70                 ADR     R1,mbox__handler        ;Point to event handler
71                 BL      dbox_eventHandler       ;Register my event handler
72                 MOV     R1,#dbOpen_pointer :OR: dbOpen_trans
73                 BL      dbox_open               ;Open as transient dialogue
74                 LDMFD   R13!,{R1-R3,PC}^        ;Return to caller
75
76                 LTORG
77
78 ; --- mbox__handler ---
79 ;
80 ; On entry:     R0 == dialogue box event code
81 ;               R1-R9 == dependent on event type
82 ;               R10 == dialogue box handle
83 ;               R12 == pointer to help message for the dialogue box
84 ;
85 ; On exit:      --
86 ;
87 ; Use:          Handles events for a monologue box window.
88
89 mbox__handler   ROUT
90
91                 ; --- Return unknown events very quickly ---
92
93                 CMP     R0,#dbEvent_close       ;Is the window closing?
94                 BEQ     %00mbox__handler        ;Yes -- jump round to it
95                 CMPNE   R0,#dbEvent_help        ;Or is the user wanting help?
96                 MOVNES  PC,R14                  ;Neither -- ignore it
97
98                 ; --- User wants some help on the dbox ---
99
100                 STMFD   R13!,{R0,R14}           ;Save some registers
101                 MOV     R0,R12                  ;Find the help message
102                 BL      msgs_lookup             ;Translate it nicely
103                 BL      help_add                ;Add it to the help message
104                 BL      dbox_help               ;Read help from the window
105                 LDMFD   R13!,{R0,R14}           ;Restore the registers
106                 ORRS    PC,R14,#C_flag          ;I handled the event
107
108                 ; --- Something closed the window ---
109
110 00mbox__handler STMFD   R13!,{R0,R14}           ;Save some registers
111                 MOV     R0,R10                  ;Get the dialogue box handle
112                 BL      dbox_destroy            ;Get rid of the dialogue
113                 LDMFD   R13!,{R0,R14}           ;Restore the registers
114                 ORRS    PC,R14,#C_flag          ;I handled the event again
115
116                 LTORG
117
118 ;----- That's all, folks ----------------------------------------------------
119
120                 END