chiark / gitweb /
Initial revision
[ssr] / StraySrc / Glass / !Glass / c / intMsgs
1 /*
2  * intMsgs.h
3  *
4  * Definitions of Glass internal broadcasts
5  *
6  * © 1994-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Glass.
12  *
13  * Glass 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  * Glass 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 Glass.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 /*----- Header files ------------------------------------------------------*/
29
30 /*
31  * ANSI standard headers
32  */
33
34 #include <stdarg.h>
35
36 /*
37  * Steel headers
38  */
39
40 #define _STDAPP
41 #include "steel/Steel.h"
42
43 /*
44  * Glass headers
45  */
46
47 #include "glass.h"
48 #include "intMsgs.h"
49
50 /*----- Static variables --------------------------------------------------*/
51
52 /*
53  * This array is to explain to intMsgs_send how many parameters there are
54  * for each message.  -1 as an entry indicates special processing (i.e. the
55  * entries are not all 1 word in length.
56  */
57
58 static int intMsgs__parameters[]=
59 {
60   1,                             /* glass_DELETEWINDOW                  */
61   1,                             /* glass_DELETEFILE                    */
62   0,                             /* glass_KILLFILES                     */
63   0,                             /* glass_CLOSEDOWN                     */
64   1,                             /* glass_RENAME                        */
65   1,                             /* glass_SAVEFILE                      */
66   1,                             /* glass_REDRAW                        */
67   1,                             /* glass_AUTOSAVE                      */
68   1,                             /* glass_SPRITECHANGE                  */
69   0,                             /* glass_MODECHANGE                    */
70 };
71
72 /*----- External routines -------------------------------------------------*/
73
74 /*
75  * void intMsgs_send(glass_intMessage type,...)
76  *
77  * Use
78  *  Sends out an internal broadcast message.  The routine constructs a
79  *  Message_StraylightInternal block and sends it out via win_broadcast.
80  *  The parameters should be as for the entries in the appropriate
81  *  structure, in order (i.e one for glass_DELETEWINDOW, two for
82  *  glass_DELETEICON).
83  *
84  * Parameters
85  *  glass_intMessage type == the message type.  This is used to decide
86  *    how many and what type of parameters to accept.
87  */
88
89 void intMsgs_send(glass_intMessage type,...)
90 {
91   va_list ap;
92   int i;
93   wimp_eventstr e;
94   va_start(ap,type);
95   e.data.msg.hdr.action=wimp_MINTERNAL;
96   e.data.msg.data.words[0]=type;
97   if (intMsgs__parameters[type]==-1)
98   {
99      switch (type)
100      {
101        default:
102          werr(TRUE,msgs_lookup("imSMT"));
103          break;
104      }
105   }
106   else for (i=1;i<=intMsgs__parameters[type];i++)
107     e.data.msg.data.words[i]=va_arg(ap,int);
108   e.e=wimp_ESEND;
109   win_broadcast(&e);
110   va_end(ap);
111 }