chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Steel / c / xproginfo
1 /*
2  * xproginfo.c
3  *
4  * Fancy scrolling message in a proginfo box
5  *
6  * © 1994-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Steel library.
12  *
13  * Steel 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  * Steel 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 Steel.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #define _CORE
29 #define _STDAPP
30
31 #include "steel.h"
32 #include "scroller.h"
33 #include "xproginfo.h"
34
35 #define xprogInfo__TITLE 0
36 #define xprogInfo__NAME 7
37 #define xprogInfo__PURPOSE 5
38 #define xprogInfo__AUTHOR 3
39 #define xprogInfo__VERSION 1
40 #define xprogInfo__SCROLLER 9
41
42 typedef struct
43 {
44   dbox d;
45   scroller s;
46   BOOL hasTitle;
47 }
48 xprogInfo__str;
49
50 static void xprogInfo__redraw(wimp_redrawstr *r,void *handle)
51 {
52   xprogInfo__str *s=handle;
53   if (!s->hasTitle)
54     dbox_drawEmbeddedTitle(r,s->d);
55   scroller_redraw(s->s,r);
56 }
57
58 static BOOL xprogInfo__raw(dbox d,wimp_eventstr *e,void *handle)
59 {
60   xprogInfo__str *s=handle;
61   BOOL handled=FALSE;
62   switch (e->e)
63   {
64     case wimp_EREDRAW:
65       wimpt_redraw(xprogInfo__redraw,s);
66       handled=TRUE;
67       break;
68     case wimp_ECLOSE:
69       scroller_destroy(s->s);
70       dbox_delete(s->d);
71       mem_free(s);
72       handled=TRUE;
73       break;
74   }
75   return (handled);
76 }
77
78 void xprogInfo(char *name,
79                char *purpose,
80                char *author,
81                int version,
82                char *date,
83                char *scrolltext,
84                char *initText,
85                int delay)
86 {
87   xprogInfo__str *s=mem_alloc(sizeof(xprogInfo__str));
88   if (!s)
89     return;
90   s->d=dbox_create("progInfo");
91   if (!s->d)
92   {
93     mem_free(s);
94     return;
95   }
96   s->s=scroller_create(s->d,xprogInfo__SCROLLER,scrolltext,initText,delay);
97   if (!s->s)
98   {
99     dbox_delete(s->d);
100     mem_free(s);
101     return;
102   }
103   if (s->hasTitle=dbox_hasTitle(s->d),!s->hasTitle)
104     dbox_setEmbeddedTitle(s->d,xprogInfo__TITLE,TRUE);
105   dbox_setfield(s->d,xprogInfo__NAME,"%s",name);
106   dbox_setfield(s->d,xprogInfo__PURPOSE,"%s",purpose);
107   dbox_setfield(s->d,xprogInfo__AUTHOR,"%s",author);
108   dbox_setfield
109   (
110     s->d,
111     xprogInfo__VERSION,
112     "%i.%02i (%s)",
113     version/100,
114     version%100,
115     date
116   );
117
118   dbox_rawEventHandler(s->d,xprogInfo__raw,s);
119   dbox_display(s->d,dbox_MENU_OVERPTR);
120   scroller_go(s->s);
121 }