blob: 75d082fcd5b6a7bb8eace75429e7efdffa932a0a [file] [log] [blame]
adamdunkels60612e72004-08-09 20:21:30 +00001/*
2 * Copyright (c) 2002, Adam Dunkels.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
14 * 3. The name of the author may not be used to endorse or promote
15 * products derived from this software without specific prior
16 * written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * This file is part of the "ctk" console GUI toolkit for cc65
31 *
oliverschmidte43cb182006-05-28 20:38:19 +000032 * $Id: ctk-conio-service.c,v 1.12 2006/05/28 20:38:19 oliverschmidt Exp $
adamdunkels60612e72004-08-09 20:21:30 +000033 *
34 */
35
36#include <conio.h>
37
38#include "ctk.h"
39#include "ctk-draw.h"
40
41#include "ctk-draw-service.h"
42
43#include "ctk-conio-conf.h"
44#include <string.h>
45
46#ifndef NULL
47#define NULL (void *)0
48#endif /* NULL */
49
50static unsigned char sizex, sizey;
51
52/*unsigned char ctk_draw_windowborder_height = 1;
53unsigned char ctk_draw_windowborder_width = 1;
54unsigned char ctk_draw_windowtitle_height = 1;*/
55
56
57/*-----------------------------------------------------------------------------------*/
58static void
59cputsn(char *str, unsigned char len)
60{
61 char c;
62
63 while(len > 0) {
64 --len;
65 c = *str;
66 if(c == 0) {
67 break;
68 }
69 cputc(c);
70 ++str;
71 }
72}
73/*-----------------------------------------------------------------------------------*/
74static void
75s_ctk_draw_init(void)
76{
oliverschmidt7fdf5f52005-03-29 20:30:32 +000077 (void)bgcolor(SCREENCOLOR);
78 (void)bordercolor(BORDERCOLOR);
adamdunkels60612e72004-08-09 20:21:30 +000079 screensize(&sizex, &sizey);
80 ctk_draw_clear(0, sizey);
81}
82/*-----------------------------------------------------------------------------------*/
83static void
84draw_widget(struct ctk_widget *w,
85 unsigned char x, unsigned char y,
86 unsigned char clipx,
87 unsigned char clipy,
88 unsigned char clipy1, unsigned char clipy2,
89 unsigned char focus)
90{
91 unsigned char xpos, ypos, xscroll;
92 unsigned char i, j;
93 char c, *text;
94 unsigned char len, wfocus;
95
96 wfocus = 0;
97 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +000098 (void)textcolor(WIDGETCOLOR_FWIN);
adamdunkels60612e72004-08-09 20:21:30 +000099 if(focus & CTK_FOCUS_WIDGET) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000100 (void)textcolor(WIDGETCOLOR_FOCUS);
adamdunkels60612e72004-08-09 20:21:30 +0000101 wfocus = 1;
102 }
103 } else if(focus & CTK_FOCUS_DIALOG) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000104 (void)textcolor(WIDGETCOLOR_DIALOG);
adamdunkels60612e72004-08-09 20:21:30 +0000105 if(focus & CTK_FOCUS_WIDGET) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000106 (void)textcolor(WIDGETCOLOR_FOCUS);
adamdunkels60612e72004-08-09 20:21:30 +0000107 wfocus = 1;
108 }
109 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000110 (void)textcolor(WIDGETCOLOR);
adamdunkels60612e72004-08-09 20:21:30 +0000111 }
112
113 xpos = x + w->x;
114 ypos = y + w->y;
115
116 switch(w->type) {
117 case CTK_WIDGET_SEPARATOR:
118 if(ypos >= clipy1 && ypos < clipy2) {
119 chlinexy(xpos, ypos, w->w);
120 }
121 break;
122 case CTK_WIDGET_LABEL:
123 text = w->widget.label.text;
124 for(i = 0; i < w->h; ++i) {
125 if(ypos >= clipy1 && ypos < clipy2) {
126 gotoxy(xpos, ypos);
127 cputsn(text, w->w);
128 if(w->w - (wherex() - xpos) > 0) {
129 cclear(w->w - (wherex() - xpos));
130 }
131 }
132 ++ypos;
133 text += w->w;
134 }
135 break;
136 case CTK_WIDGET_BUTTON:
137 if(ypos >= clipy1 && ypos < clipy2) {
oliverschmidt6307bff2005-05-04 19:54:50 +0000138 revers(wfocus != 0);
adamdunkels60612e72004-08-09 20:21:30 +0000139 cputcxy(xpos, ypos, '[');
140 cputsn(w->widget.button.text, w->w);
141 cputc(']');
142 revers(0);
143 }
144 break;
145 case CTK_WIDGET_HYPERLINK:
146 if(ypos >= clipy1 && ypos < clipy2) {
oliverschmidt6307bff2005-05-04 19:54:50 +0000147 revers(wfocus == 0);
adamdunkels60612e72004-08-09 20:21:30 +0000148 gotoxy(xpos, ypos);
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000149 (void)textcolor(WIDGETCOLOR_HLINK);
adamdunkels60612e72004-08-09 20:21:30 +0000150 cputsn(w->widget.button.text, w->w);
151 revers(0);
152 }
153 break;
154 case CTK_WIDGET_TEXTENTRY:
155 text = w->widget.textentry.text;
adamdunkels60612e72004-08-09 20:21:30 +0000156 xscroll = 0;
157 if(w->widget.textentry.xpos >= w->w - 1) {
158 xscroll = w->widget.textentry.xpos - w->w + 1;
159 }
160 for(j = 0; j < w->h; ++j) {
161 if(ypos >= clipy1 && ypos < clipy2) {
162 if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
163 w->widget.textentry.ypos == j) {
164 revers(0);
165 cputcxy(xpos, ypos, '>');
oliverschmidte43cb182006-05-28 20:38:19 +0000166 c = 1;
adamdunkels60612e72004-08-09 20:21:30 +0000167 for(i = 0; i < w->w; ++i) {
oliverschmidte43cb182006-05-28 20:38:19 +0000168 if(c != 0) {
169 c = text[i + xscroll];
170 }
oliverschmidt6307bff2005-05-04 19:54:50 +0000171 revers(i == w->widget.textentry.xpos - xscroll);
adamdunkels60612e72004-08-09 20:21:30 +0000172 if(c == 0) {
173 cputc(' ');
174 } else {
175 cputc(c);
176 }
adamdunkels60612e72004-08-09 20:21:30 +0000177 }
oliverschmidtacdf6e92005-05-04 22:04:35 +0000178 revers(0);
adamdunkels60612e72004-08-09 20:21:30 +0000179 cputc('<');
180 } else {
oliverschmidtacdf6e92005-05-04 22:04:35 +0000181 revers(wfocus != 0 && j == w->widget.textentry.ypos);
adamdunkels60612e72004-08-09 20:21:30 +0000182 cvlinexy(xpos, ypos, 1);
183 gotoxy(xpos + 1, ypos);
184 cputsn(text, w->w);
185 i = wherex();
186 if(i - xpos - 1 < w->w) {
187 cclear(w->w - (i - xpos) + 1);
188 }
189 cvline(1);
190 }
191 }
192 ++ypos;
oliverschmidtcd6c30b2005-05-05 20:54:16 +0000193 text += w->widget.textentry.len + 1;
adamdunkels60612e72004-08-09 20:21:30 +0000194 }
195 revers(0);
196 break;
197 case CTK_WIDGET_ICON:
198 if(ypos >= clipy1 && ypos < clipy2) {
oliverschmidt6307bff2005-05-04 19:54:50 +0000199 revers(wfocus != 0);
adamdunkels60612e72004-08-09 20:21:30 +0000200 gotoxy(xpos, ypos);
201 if(w->widget.icon.textmap != NULL) {
202 for(i = 0; i < 3; ++i) {
203 gotoxy(xpos, ypos);
204 if(ypos >= clipy1 && ypos < clipy2) {
205 cputc(w->widget.icon.textmap[0 + 3 * i]);
206 cputc(w->widget.icon.textmap[1 + 3 * i]);
207 cputc(w->widget.icon.textmap[2 + 3 * i]);
208 }
209 ++ypos;
210 }
211 }
212 x = xpos;
213
214 len = strlen(w->widget.icon.title);
215 if(x + len >= sizex) {
216 x = sizex - len;
217 }
218
219 gotoxy(x, ypos);
220 if(ypos >= clipy1 && ypos < clipy2) {
221 cputs(w->widget.icon.title);
222 }
223 revers(0);
224 }
225 break;
226
227 default:
228 break;
229 }
230}
231/*-----------------------------------------------------------------------------------*/
232static void
233s_ctk_draw_widget(struct ctk_widget *w,
234 unsigned char focus,
235 unsigned char clipy1,
236 unsigned char clipy2)
237{
238 struct ctk_window *win = w->window;
239 unsigned char posx, posy;
240
241 posx = win->x + 1;
242 posy = win->y + 2;
243
244 if(w == win->focused) {
245 focus |= CTK_FOCUS_WIDGET;
246 }
247
248 draw_widget(w, posx, posy,
249 posx + win->w,
250 posy + win->h,
251 clipy1, clipy2,
252 focus);
253
254#ifdef CTK_CONIO_CONF_UPDATE
255 CTK_CONIO_CONF_UPDATE();
256#endif /* CTK_CONIO_CONF_UPDATE */
257}
258/*-----------------------------------------------------------------------------------*/
259static void
260s_ctk_draw_clear_window(struct ctk_window *window,
261 unsigned char focus,
262 unsigned char clipy1,
263 unsigned char clipy2)
264{
265 unsigned char i;
266 unsigned char h;
267
oliverschmidt0e144fb2004-08-12 21:52:03 +0000268 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000269 (void)textcolor(WINDOWCOLOR_FOCUS);
oliverschmidt0e144fb2004-08-12 21:52:03 +0000270 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000271 (void)textcolor(WINDOWCOLOR);
oliverschmidt0e144fb2004-08-12 21:52:03 +0000272 }
273
adamdunkels60612e72004-08-09 20:21:30 +0000274 h = window->y + 2 + window->h;
oliverschmidt2b1582b2005-03-15 14:19:40 +0000275
adamdunkels60612e72004-08-09 20:21:30 +0000276 /* Clear window contents. */
277 for(i = window->y + 2; i < h; ++i) {
278 if(i >= clipy1 && i < clipy2) {
279 cclearxy(window->x + 1, i, window->w);
280 }
281 }
282}
283/*-----------------------------------------------------------------------------------*/
284static void
285draw_window_contents(struct ctk_window *window, unsigned char focus,
286 unsigned char clipy1, unsigned char clipy2,
287 unsigned char x1, unsigned char x2,
288 unsigned char y1, unsigned char y2)
289{
290 struct ctk_widget *w;
291 unsigned char wfocus;
292
293 /* Draw inactive widgets. */
294 for(w = window->inactive; w != NULL; w = w->next) {
295 draw_widget(w, x1, y1, x2, y2,
296 clipy1, clipy2,
297 focus);
298 }
299
300 /* Draw active widgets. */
301 for(w = window->active; w != NULL; w = w->next) {
302 wfocus = focus;
303 if(w == window->focused) {
304 wfocus |= CTK_FOCUS_WIDGET;
305 }
306
307 draw_widget(w, x1, y1, x2, y2,
308 clipy1, clipy2,
309 wfocus);
310 }
311
312#ifdef CTK_CONIO_CONF_UPDATE
313 CTK_CONIO_CONF_UPDATE();
314#endif /* CTK_CONIO_CONF_UPDATE */
adamdunkels60612e72004-08-09 20:21:30 +0000315}
316/*-----------------------------------------------------------------------------------*/
317static void
318s_ctk_draw_window(struct ctk_window *window, unsigned char focus,
oliverschmidtadf27db2005-03-15 15:51:17 +0000319 unsigned char clipy1, unsigned char clipy2,
320 unsigned char draw_borders)
adamdunkels60612e72004-08-09 20:21:30 +0000321{
322 unsigned char x, y;
323 unsigned char h;
324 unsigned char x1, y1, x2, y2;
325
326 if(window->y + 1 >= clipy2) {
327 return;
328 }
329
330 x = window->x;
331 y = window->y + 1;
adamdunkels60612e72004-08-09 20:21:30 +0000332 x1 = x + 1;
333 y1 = y + 1;
334 x2 = x1 + window->w;
335 y2 = y1 + window->h;
336
oliverschmidtadf27db2005-03-15 15:51:17 +0000337 if(draw_borders) {
adamdunkels60612e72004-08-09 20:21:30 +0000338
oliverschmidtadf27db2005-03-15 15:51:17 +0000339 /* Draw window frame. */
340 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000341 (void)textcolor(WINDOWCOLOR_FOCUS);
oliverschmidtadf27db2005-03-15 15:51:17 +0000342 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000343 (void)textcolor(WINDOWCOLOR);
oliverschmidtadf27db2005-03-15 15:51:17 +0000344 }
345
346 if(y >= clipy1) {
347 cputcxy(x, y, CH_ULCORNER);
oliverschmidt7b9025d2005-03-18 01:08:35 +0000348 gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
oliverschmidtadf27db2005-03-15 15:51:17 +0000349 chline(window->w - (wherex() - x) - 2);
350 cputcxy(x2, y, CH_URCORNER);
351 }
352
353 h = window->h;
adamdunkels60612e72004-08-09 20:21:30 +0000354
oliverschmidtadf27db2005-03-15 15:51:17 +0000355 if(clipy1 > y1) {
356 if(clipy1 - y1 < h) {
357 h = clipy1 - y1;
358 y1 = clipy1;
359 } else {
360 h = 0;
361 }
adamdunkels60612e72004-08-09 20:21:30 +0000362 }
adamdunkels60612e72004-08-09 20:21:30 +0000363
oliverschmidtadf27db2005-03-15 15:51:17 +0000364 if(clipy2 < y1 + h) {
365 if(y1 >= clipy2) {
366 h = 0;
367 } else {
368 h = clipy2 - y1;
369 }
adamdunkels60612e72004-08-09 20:21:30 +0000370 }
adamdunkels60612e72004-08-09 20:21:30 +0000371
oliverschmidtadf27db2005-03-15 15:51:17 +0000372 cvlinexy(x, y1, h);
373 cvlinexy(x2, y1, h);
adamdunkels60612e72004-08-09 20:21:30 +0000374
oliverschmidtadf27db2005-03-15 15:51:17 +0000375 if(y + window->h >= clipy1 &&
376 y + window->h < clipy2) {
377 cputcxy(x, y2, CH_LLCORNER);
378 chlinexy(x1, y2, window->w);
379 cputcxy(x2, y2, CH_LRCORNER);
380 }
adamdunkels60612e72004-08-09 20:21:30 +0000381 }
382
oliverschmidte99386b2004-12-27 22:03:04 +0000383 draw_window_contents(window, focus, clipy1, clipy2,
adamdunkels60612e72004-08-09 20:21:30 +0000384 x1, x2, y + 1, y2);
385}
386/*-----------------------------------------------------------------------------------*/
387static void
388s_ctk_draw_dialog(struct ctk_window *dialog)
389{
390 unsigned char x, y;
391 unsigned char i;
392 unsigned char x1, y1, x2, y2;
393
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000394 (void)textcolor(DIALOGCOLOR);
adamdunkels60612e72004-08-09 20:21:30 +0000395
396 x = dialog->x;
397 y = dialog->y + 1;
398
adamdunkels60612e72004-08-09 20:21:30 +0000399 x1 = x + 1;
400 y1 = y + 1;
401 x2 = x1 + dialog->w;
402 y2 = y1 + dialog->h;
403
adamdunkels60612e72004-08-09 20:21:30 +0000404 /* Draw dialog frame. */
adamdunkels60612e72004-08-09 20:21:30 +0000405 cvlinexy(x, y1,
406 dialog->h);
407 cvlinexy(x2, y1,
408 dialog->h);
409
410 chlinexy(x1, y,
411 dialog->w);
412 chlinexy(x1, y2,
413 dialog->w);
414
415 cputcxy(x, y, CH_ULCORNER);
416 cputcxy(x, y2, CH_LLCORNER);
417 cputcxy(x2, y, CH_URCORNER);
418 cputcxy(x2, y2, CH_LRCORNER);
419
adamdunkels60612e72004-08-09 20:21:30 +0000420 /* Clear dialog contents. */
421 for(i = y1; i < y2; ++i) {
422 cclearxy(x1, i, dialog->w);
423 }
424
425 draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
426 x1, x2, y1, y2);
427}
428/*-----------------------------------------------------------------------------------*/
429static void
430s_ctk_draw_clear(unsigned char y1, unsigned char y2)
431{
432 unsigned char i;
433
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000434 (void)textcolor(BACKGROUNDCOLOR);
adamdunkels60612e72004-08-09 20:21:30 +0000435 for(i = y1; i < y2; ++i) {
436 cclearxy(0, i, sizex);
437 }
438}
439/*-----------------------------------------------------------------------------------*/
440static void
oliverschmidt2b1582b2005-03-15 14:19:40 +0000441draw_menu(struct ctk_menu *m, unsigned char open)
adamdunkels60612e72004-08-09 20:21:30 +0000442{
443 unsigned char x, x2, y;
oliverschmidt2b1582b2005-03-15 14:19:40 +0000444
445 if(open) {
446 x = x2 = wherex();
447 if(x2 + CTK_CONF_MENUWIDTH > sizex) {
448 x2 = sizex - CTK_CONF_MENUWIDTH;
449 }
450
451 for(y = 0; y < m->nitems; ++y) {
452 if(y == m->active) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000453 (void)textcolor(ACTIVEMENUITEMCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000454 revers(0);
455 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000456 (void)textcolor(MENUCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000457 revers(1);
458 }
459 gotoxy(x2, y + 1);
460 if(m->items[y].title[0] == '-') {
461 chline(CTK_CONF_MENUWIDTH);
462 } else {
463 cputs(m->items[y].title);
464 }
465 if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
466 cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
467 }
468 }
469
470 gotoxy(x, 0);
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000471 (void)textcolor(OPENMENUCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000472 revers(0);
473 }
474
adamdunkels60612e72004-08-09 20:21:30 +0000475 cputs(m->title);
476 cputc(' ');
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000477 (void)textcolor(MENUCOLOR);
adamdunkels60612e72004-08-09 20:21:30 +0000478 revers(1);
479}
480/*-----------------------------------------------------------------------------------*/
481static void
482s_ctk_draw_menus(struct ctk_menus *menus)
483{
oliverschmidt2b1582b2005-03-15 14:19:40 +0000484 struct ctk_menu *m;
adamdunkels60612e72004-08-09 20:21:30 +0000485
486 /* Draw menus */
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000487 (void)textcolor(MENUCOLOR);
adamdunkels60612e72004-08-09 20:21:30 +0000488 gotoxy(0, 0);
489 revers(1);
490 cputc(' ');
491 for(m = menus->menus->next; m != NULL; m = m->next) {
oliverschmidt2b1582b2005-03-15 14:19:40 +0000492 draw_menu(m, m == menus->open);
adamdunkels60612e72004-08-09 20:21:30 +0000493 }
494
oliverschmidt2b1582b2005-03-15 14:19:40 +0000495 /* Draw desktopmenu */
496 if(wherex() + strlen(menus->desktopmenu->title) + 1 >= sizex) {
adamdunkels60612e72004-08-09 20:21:30 +0000497 gotoxy(sizex - strlen(menus->desktopmenu->title) - 1, 0);
498 } else {
499 cclear(sizex - wherex() -
500 strlen(menus->desktopmenu->title) - 1);
501 }
oliverschmidt2b1582b2005-03-15 14:19:40 +0000502 draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
adamdunkels60612e72004-08-09 20:21:30 +0000503
504 revers(0);
505}
506/*-----------------------------------------------------------------------------------*/
507static unsigned char
508s_ctk_draw_height(void)
509{
510 return sizey;
511}
512/*-----------------------------------------------------------------------------------*/
513static unsigned char
514s_ctk_draw_width(void)
515{
516 return sizex;
517}
518/*-----------------------------------------------------------------------------------*/
519static unsigned short
520s_ctk_mouse_xtoc(unsigned short x)
521{
522 return x / 8;
523}
524/*-----------------------------------------------------------------------------------*/
525static unsigned short
526s_ctk_mouse_ytoc(unsigned short y)
527{
528 return y / 8;
529}
530/*-----------------------------------------------------------------------------------*/
531static const struct ctk_draw_service_interface interface =
532 {CTK_DRAW_SERVICE_VERSION,
533 1,
534 1,
535 1,
536 s_ctk_draw_init,
537 s_ctk_draw_clear,
538 s_ctk_draw_clear_window,
539 s_ctk_draw_window,
540 s_ctk_draw_dialog,
541 s_ctk_draw_widget,
542 s_ctk_draw_menus,
543 s_ctk_draw_width,
544 s_ctk_draw_height,
545 s_ctk_mouse_xtoc,
546 s_ctk_mouse_ytoc,
547 };
548
549EK_EVENTHANDLER(eventhandler, ev, data);
550EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": text", EK_PRIO_NORMAL,
551 eventhandler, NULL, (void *)&interface);
552
553/*--------------------------------------------------------------------------*/
554LOADER_INIT_FUNC(ctk_conio_service_init, arg)
adamdunkels8478bee2004-09-12 17:54:12 +0000555{
556 s_ctk_draw_init();
adamdunkels60612e72004-08-09 20:21:30 +0000557 ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
558}
559/*--------------------------------------------------------------------------*/
560EK_EVENTHANDLER(eventhandler, ev, data)
561{
562 EK_EVENTHANDLER_ARGS(ev, data);
563
564 switch(ev) {
565 case EK_EVENT_INIT:
566 case EK_EVENT_REPLACE:
adamdunkels8478bee2004-09-12 17:54:12 +0000567 s_ctk_draw_init();
adamdunkels60612e72004-08-09 20:21:30 +0000568 ctk_restore();
569 break;
570 case EK_EVENT_REQUEST_REPLACE:
571 ek_replace((struct ek_proc *)data, NULL);
572 LOADER_UNLOAD();
573 break;
574 }
575}
576/*--------------------------------------------------------------------------*/