1
2 /*
3 * Diverse Bristol audio routines.
4 * Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 /*
23 * Render a brightonBitmap into an area.
24 */
25 #include "brightoninternals.h"
26
27 int
destroyKbd(brightonDevice * dev)28 destroyKbd(brightonDevice *dev)
29 {
30 printf("destroyKbd()\n");
31
32 if (dev->image)
33 brightonFreeBitmap(dev->bwin, dev->image);
34
35 dev->image = NULL;
36
37 return(0);
38 }
39
40 static int
displayKbd(brightonDevice * dev)41 displayKbd(brightonDevice *dev)
42 {
43 brightonIResource *panel;
44
45 /*printf("displayKbd\n"); */
46 /*
47 * We should render any text we desire into the bmap, and then have it
48 * painted
49 */
50 if (dev->bwin->app->resources[dev->panel].flags & BRIGHTON_WITHDRAWN)
51 return(0);
52
53 panel = &dev->bwin->app->resources[dev->panel];
54
55 brightonDevUndraw(dev->bwin, dev->bwin->dlayer,
56 dev->x + dev->bwin->app->resources[dev->panel].sx,
57 dev->y + dev->bwin->app->resources[dev->panel].sy,
58 dev->width, dev->height);
59
60 /*
61 * Only draw fixed number of steps.
62 */
63 brightonStretch(dev->bwin, dev->image,
64 dev->bwin->dlayer,
65 dev->x + dev->bwin->app->resources[dev->panel].sx,
66 dev->y + dev->bwin->app->resources[dev->panel].sy,
67 dev->width, dev->height,
68 dev->position);
69
70 brightonFinalRender(dev->bwin,
71 dev->x + dev->bwin->app->resources[dev->panel].sx,
72 dev->y + dev->bwin->app->resources[dev->panel].sy,
73 dev->width, dev->height);
74
75 return(0);
76 }
77
78 static int
configure(brightonDevice * dev,brightonEvent * event)79 configure(brightonDevice *dev, brightonEvent *event)
80 {
81 /*printf("configureKbd(%i)\n", event->command); */
82
83 if (event->command == -1)
84 return(-1);
85
86 if (event->command == BRIGHTON_RESIZE)
87 {
88 dev->originx = event->x;
89 dev->originy = event->y;
90
91 dev->x = event->x;
92 dev->y = event->y;
93 dev->width = event->w;
94 dev->height = event->h;
95
96 displayKbd(dev);
97
98 return(0);
99 }
100
101 if (event->command == BRIGHTON_PARAMCHANGE)
102 {
103 /*
104 * This will be used to configure different background images */ if ((event->type == BRIGHTON_MEM) && (event->m != 0))
105 {
106 if (dev->image)
107 brightonFreeBitmap(dev->bwin, dev->image);
108
109 dev->image = brightonReadImage(dev->bwin, event->m);
110
111 displayKbd(dev);
112 }
113 }
114
115 return(0);
116 }
117
118 int *
createKbd(brightonWindow * bwin,brightonDevice * dev,int index,char * bitmap)119 createKbd(brightonWindow *bwin, brightonDevice *dev, int index, char *bitmap)
120 {
121 printf("createKbd(%s)\n", bitmap);
122
123 dev->destroy = destroyKbd;
124 dev->configure = configure;
125 dev->bwin = bwin;
126
127 if (bitmap != 0)
128 {
129 if (dev->image)
130 brightonFreeBitmap(bwin, dev->image);
131 dev->image = brightonReadImage(bwin, bitmap);
132 }
133
134 /*
135 * These will force an update when we first display ourselves.
136 */
137 dev->value = 0;
138 dev->lastvalue = -1;
139 dev->lastposition = -1;
140
141 return(0);
142 }
143
144