blob: 2f8399b46facac63547aa96d44b5fb6d7b47af52 [file] [log] [blame]
adamdunkels09c28b62003-04-02 10:17:52 +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.
adamdunkels76a4c4a2004-06-06 05:52:21 +000014 * 3. The name of the author may not be used to endorse or promote
adamdunkels09c28b62003-04-02 10:17:52 +000015 * 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.c,v 1.24 2006/05/28 20:38:19 oliverschmidt Exp $
adamdunkels09c28b62003-04-02 10:17:52 +000033 *
34 */
35
adamdunkels09e27572004-03-25 09:50:13 +000036#include <conio.h>
37
adamdunkels09c28b62003-04-02 10:17:52 +000038#include "ctk.h"
39#include "ctk-draw.h"
40
41#include "ctk-conio-conf.h"
adamdunkels09c28b62003-04-02 10:17:52 +000042#include <string.h>
adamdunkelsca2cbe52004-07-04 11:38:43 +000043#include <ctype.h>
adamdunkels09c28b62003-04-02 10:17:52 +000044
45#ifndef NULL
46#define NULL (void *)0
47#endif /* NULL */
48
49static unsigned char sizex, sizey;
50
adamdunkelsca2cbe52004-07-04 11:38:43 +000051unsigned char ctk_draw_windowborder_height = 1;
52unsigned char ctk_draw_windowborder_width = 1;
53unsigned char ctk_draw_windowtitle_height = 1;
54
55
adamdunkels09c28b62003-04-02 10:17:52 +000056/*-----------------------------------------------------------------------------------*/
adamdunkels09c28b62003-04-02 10:17:52 +000057static void
58cputsn(char *str, unsigned char len)
59{
oliverschmidt4037b262004-06-27 20:59:05 +000060 char c;
61
62 while(len > 0) {
63 --len;
64 c = *str;
65 if(c == 0) {
66 break;
67 }
68 cputc(c);
69 ++str;
70 }
adamdunkels09c28b62003-04-02 10:17:52 +000071}
72/*-----------------------------------------------------------------------------------*/
73void
74ctk_draw_init(void)
75{
oliverschmidt7fdf5f52005-03-29 20:30:32 +000076 (void)bgcolor(SCREENCOLOR);
77 (void)bordercolor(BORDERCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +000078 screensize(&sizex, &sizey);
79 ctk_draw_clear(0, sizey);
80}
81/*-----------------------------------------------------------------------------------*/
82static void
83draw_widget(struct ctk_widget *w,
84 unsigned char x, unsigned char y,
85 unsigned char clipx,
86 unsigned char clipy,
87 unsigned char clipy1, unsigned char clipy2,
88 unsigned char focus)
89{
90 unsigned char xpos, ypos, xscroll;
91 unsigned char i, j;
92 char c, *text;
adamdunkels09e27572004-03-25 09:50:13 +000093 unsigned char len, wfocus;
94
95 wfocus = 0;
adamdunkels09c28b62003-04-02 10:17:52 +000096 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +000097 (void)textcolor(WIDGETCOLOR_FWIN);
adamdunkels09c28b62003-04-02 10:17:52 +000098 if(focus & CTK_FOCUS_WIDGET) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +000099 (void)textcolor(WIDGETCOLOR_FOCUS);
adamdunkels09e27572004-03-25 09:50:13 +0000100 wfocus = 1;
adamdunkels09c28b62003-04-02 10:17:52 +0000101 }
102 } else if(focus & CTK_FOCUS_DIALOG) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000103 (void)textcolor(WIDGETCOLOR_DIALOG);
adamdunkels09c28b62003-04-02 10:17:52 +0000104 if(focus & CTK_FOCUS_WIDGET) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000105 (void)textcolor(WIDGETCOLOR_FOCUS);
adamdunkels09e27572004-03-25 09:50:13 +0000106 wfocus = 1;
adamdunkels09c28b62003-04-02 10:17:52 +0000107 }
108 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000109 (void)textcolor(WIDGETCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +0000110 }
111
112 xpos = x + w->x;
113 ypos = y + w->y;
114
115 switch(w->type) {
116 case CTK_WIDGET_SEPARATOR:
117 if(ypos >= clipy1 && ypos < clipy2) {
118 chlinexy(xpos, ypos, w->w);
119 }
120 break;
121 case CTK_WIDGET_LABEL:
122 text = w->widget.label.text;
adamdunkels62393fb2003-07-30 23:31:56 +0000123 for(i = 0; i < w->h; ++i) {
adamdunkels09c28b62003-04-02 10:17:52 +0000124 if(ypos >= clipy1 && ypos < clipy2) {
125 gotoxy(xpos, ypos);
126 cputsn(text, w->w);
127 if(w->w - (wherex() - xpos) > 0) {
128 cclear(w->w - (wherex() - xpos));
129 }
130 }
131 ++ypos;
132 text += w->w;
133 }
134 break;
135 case CTK_WIDGET_BUTTON:
136 if(ypos >= clipy1 && ypos < clipy2) {
oliverschmidt6307bff2005-05-04 19:54:50 +0000137 revers(wfocus != 0);
adamdunkels09c28b62003-04-02 10:17:52 +0000138 cputcxy(xpos, ypos, '[');
139 cputsn(w->widget.button.text, w->w);
140 cputc(']');
141 revers(0);
142 }
143 break;
144 case CTK_WIDGET_HYPERLINK:
145 if(ypos >= clipy1 && ypos < clipy2) {
oliverschmidt6307bff2005-05-04 19:54:50 +0000146 revers(wfocus == 0);
adamdunkels09c28b62003-04-02 10:17:52 +0000147 gotoxy(xpos, ypos);
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000148 (void)textcolor(WIDGETCOLOR_HLINK);
adamdunkels09c28b62003-04-02 10:17:52 +0000149 cputsn(w->widget.button.text, w->w);
150 revers(0);
151 }
152 break;
153 case CTK_WIDGET_TEXTENTRY:
154 text = w->widget.textentry.text;
adamdunkels09c28b62003-04-02 10:17:52 +0000155 xscroll = 0;
156 if(w->widget.textentry.xpos >= w->w - 1) {
157 xscroll = w->widget.textentry.xpos - w->w + 1;
158 }
adamdunkels62393fb2003-07-30 23:31:56 +0000159 for(j = 0; j < w->h; ++j) {
adamdunkels09c28b62003-04-02 10:17:52 +0000160 if(ypos >= clipy1 && ypos < clipy2) {
161 if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
162 w->widget.textentry.ypos == j) {
163 revers(0);
164 cputcxy(xpos, ypos, '>');
oliverschmidte43cb182006-05-28 20:38:19 +0000165 c = 1;
adamdunkels09c28b62003-04-02 10:17:52 +0000166 for(i = 0; i < w->w; ++i) {
oliverschmidte43cb182006-05-28 20:38:19 +0000167 if(c != 0) {
168 c = text[i + xscroll];
169 }
oliverschmidt6307bff2005-05-04 19:54:50 +0000170 revers(i == w->widget.textentry.xpos - xscroll);
adamdunkels09c28b62003-04-02 10:17:52 +0000171 if(c == 0) {
172 cputc(' ');
173 } else {
174 cputc(c);
175 }
adamdunkels09c28b62003-04-02 10:17:52 +0000176 }
oliverschmidtacdf6e92005-05-04 22:04:35 +0000177 revers(0);
adamdunkels09c28b62003-04-02 10:17:52 +0000178 cputc('<');
179 } else {
oliverschmidtacdf6e92005-05-04 22:04:35 +0000180 revers(wfocus != 0 && j == w->widget.textentry.ypos);
adamdunkels09c28b62003-04-02 10:17:52 +0000181 cvlinexy(xpos, ypos, 1);
182 gotoxy(xpos + 1, ypos);
183 cputsn(text, w->w);
184 i = wherex();
185 if(i - xpos - 1 < w->w) {
186 cclear(w->w - (i - xpos) + 1);
187 }
188 cvline(1);
189 }
190 }
191 ++ypos;
oliverschmidtcd6c30b2005-05-05 20:54:16 +0000192 text += w->widget.textentry.len + 1;
adamdunkels09c28b62003-04-02 10:17:52 +0000193 }
194 revers(0);
195 break;
oliverschmidta98def52004-06-27 18:32:10 +0000196#if CTK_CONF_ICONS
adamdunkels09c28b62003-04-02 10:17:52 +0000197 case CTK_WIDGET_ICON:
198 if(ypos >= clipy1 && ypos < clipy2) {
oliverschmidt6307bff2005-05-04 19:54:50 +0000199 revers(wfocus != 0);
oliverschmidta98def52004-06-27 18:32:10 +0000200#if CTK_CONF_ICON_TEXTMAPS
adamdunkels09c28b62003-04-02 10:17:52 +0000201 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 }
oliverschmidta98def52004-06-27 18:32:10 +0000212#endif /* CTK_CONF_ICON_TEXTMAPS */
adamdunkels09c28b62003-04-02 10:17:52 +0000213
214 len = strlen(w->widget.icon.title);
oliverschmidta98def52004-06-27 18:32:10 +0000215 if(xpos + len >= sizex) {
216 xpos = sizex - len;
adamdunkels09c28b62003-04-02 10:17:52 +0000217 }
218
oliverschmidta98def52004-06-27 18:32:10 +0000219 gotoxy(xpos, ypos);
adamdunkels09c28b62003-04-02 10:17:52 +0000220 if(ypos >= clipy1 && ypos < clipy2) {
221 cputs(w->widget.icon.title);
222 }
223 revers(0);
224 }
225 break;
oliverschmidta98def52004-06-27 18:32:10 +0000226#endif /* CTK_CONF_ICONS */
adamdunkels09c28b62003-04-02 10:17:52 +0000227
228 default:
229 break;
230 }
231}
232/*-----------------------------------------------------------------------------------*/
233void
234ctk_draw_widget(struct ctk_widget *w,
235 unsigned char focus,
236 unsigned char clipy1,
237 unsigned char clipy2)
238{
239 struct ctk_window *win = w->window;
240 unsigned char posx, posy;
241
242 posx = win->x + 1;
243 posy = win->y + 2;
244
245 if(w == win->focused) {
246 focus |= CTK_FOCUS_WIDGET;
247 }
248
249 draw_widget(w, posx, posy,
250 posx + win->w,
251 posy + win->h,
252 clipy1, clipy2,
253 focus);
adamdunkelsfe32f8d2003-04-28 20:31:48 +0000254
255#ifdef CTK_CONIO_CONF_UPDATE
256 CTK_CONIO_CONF_UPDATE();
257#endif /* CTK_CONIO_CONF_UPDATE */
adamdunkels09c28b62003-04-02 10:17:52 +0000258}
259/*-----------------------------------------------------------------------------------*/
260void
261ctk_draw_clear_window(struct ctk_window *window,
262 unsigned char focus,
263 unsigned char clipy1,
264 unsigned char clipy2)
265{
266 unsigned char i;
267 unsigned char h;
268
oliverschmidt0e144fb2004-08-12 21:52:03 +0000269 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000270 (void)textcolor(WINDOWCOLOR_FOCUS);
oliverschmidt0e144fb2004-08-12 21:52:03 +0000271 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000272 (void)textcolor(WINDOWCOLOR);
oliverschmidt0e144fb2004-08-12 21:52:03 +0000273 }
adamdunkels09c28b62003-04-02 10:17:52 +0000274
275 h = window->y + 2 + window->h;
oliverschmidt2b1582b2005-03-15 14:19:40 +0000276
adamdunkels09c28b62003-04-02 10:17:52 +0000277 /* Clear window contents. */
278 for(i = window->y + 2; i < h; ++i) {
279 if(i >= clipy1 && i < clipy2) {
280 cclearxy(window->x + 1, i, window->w);
281 }
282 }
283}
284/*-----------------------------------------------------------------------------------*/
adamdunkelsa45d8a12003-04-08 07:22:13 +0000285static void
286draw_window_contents(struct ctk_window *window, unsigned char focus,
287 unsigned char clipy1, unsigned char clipy2,
288 unsigned char x1, unsigned char x2,
289 unsigned char y1, unsigned char y2)
290{
291 struct ctk_widget *w;
292 unsigned char wfocus;
293
294 /* Draw inactive widgets. */
295 for(w = window->inactive; w != NULL; w = w->next) {
296 draw_widget(w, x1, y1, x2, y2,
297 clipy1, clipy2,
298 focus);
299 }
300
301 /* Draw active widgets. */
302 for(w = window->active; w != NULL; w = w->next) {
303 wfocus = focus;
304 if(w == window->focused) {
305 wfocus |= CTK_FOCUS_WIDGET;
306 }
307
308 draw_widget(w, x1, y1, x2, y2,
309 clipy1, clipy2,
310 wfocus);
311 }
312
adamdunkelsfe32f8d2003-04-28 20:31:48 +0000313#ifdef CTK_CONIO_CONF_UPDATE
314 CTK_CONIO_CONF_UPDATE();
315#endif /* CTK_CONIO_CONF_UPDATE */
adamdunkelsa45d8a12003-04-08 07:22:13 +0000316}
317/*-----------------------------------------------------------------------------------*/
adamdunkels09c28b62003-04-02 10:17:52 +0000318void
319ctk_draw_window(struct ctk_window *window, unsigned char focus,
oliverschmidtadf27db2005-03-15 15:51:17 +0000320 unsigned char clipy1, unsigned char clipy2,
321 unsigned char draw_borders)
adamdunkels09c28b62003-04-02 10:17:52 +0000322{
323 unsigned char x, y;
324 unsigned char h;
adamdunkels09c28b62003-04-02 10:17:52 +0000325 unsigned char x1, y1, x2, y2;
326
327 if(window->y + 1 >= clipy2) {
328 return;
329 }
330
331 x = window->x;
332 y = window->y + 1;
adamdunkels09c28b62003-04-02 10:17:52 +0000333 x1 = x + 1;
334 y1 = y + 1;
335 x2 = x1 + window->w;
336 y2 = y1 + window->h;
337
oliverschmidtadf27db2005-03-15 15:51:17 +0000338 if(draw_borders) {
adamdunkels09c28b62003-04-02 10:17:52 +0000339
oliverschmidtadf27db2005-03-15 15:51:17 +0000340 /* Draw window frame. */
341 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000342 (void)textcolor(WINDOWCOLOR_FOCUS);
oliverschmidtadf27db2005-03-15 15:51:17 +0000343 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000344 (void)textcolor(WINDOWCOLOR);
oliverschmidtadf27db2005-03-15 15:51:17 +0000345 }
346
347 if(y >= clipy1) {
348 cputcxy(x, y, CH_ULCORNER);
oliverschmidt7b9025d2005-03-18 01:08:35 +0000349 gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
oliverschmidtadf27db2005-03-15 15:51:17 +0000350 chline(window->w - (wherex() - x) - 2);
351 cputcxy(x2, y, CH_URCORNER);
352 }
353
354 h = window->h;
adamdunkels09c28b62003-04-02 10:17:52 +0000355
oliverschmidtadf27db2005-03-15 15:51:17 +0000356 if(clipy1 > y1) {
357 if(clipy1 - y1 < h) {
358 h = clipy1 - y1;
359 y1 = clipy1;
360 } else {
361 h = 0;
362 }
adamdunkels09c28b62003-04-02 10:17:52 +0000363 }
adamdunkels09c28b62003-04-02 10:17:52 +0000364
oliverschmidtadf27db2005-03-15 15:51:17 +0000365 if(clipy2 < y1 + h) {
366 if(y1 >= clipy2) {
367 h = 0;
368 } else {
369 h = clipy2 - y1;
370 }
adamdunkels09c28b62003-04-02 10:17:52 +0000371 }
adamdunkels62393fb2003-07-30 23:31:56 +0000372
oliverschmidtadf27db2005-03-15 15:51:17 +0000373 cvlinexy(x, y1, h);
374 cvlinexy(x2, y1, h);
adamdunkels09c28b62003-04-02 10:17:52 +0000375
oliverschmidtadf27db2005-03-15 15:51:17 +0000376 if(y + window->h >= clipy1 &&
377 y + window->h < clipy2) {
378 cputcxy(x, y2, CH_LLCORNER);
379 chlinexy(x1, y2, window->w);
380 cputcxy(x2, y2, CH_LRCORNER);
381 }
adamdunkels09c28b62003-04-02 10:17:52 +0000382 }
383
oliverschmidte99386b2004-12-27 22:03:04 +0000384 draw_window_contents(window, focus, clipy1, clipy2,
adamdunkels62393fb2003-07-30 23:31:56 +0000385 x1, x2, y + 1, y2);
adamdunkels09c28b62003-04-02 10:17:52 +0000386}
387/*-----------------------------------------------------------------------------------*/
388void
389ctk_draw_dialog(struct ctk_window *dialog)
390{
391 unsigned char x, y;
392 unsigned char i;
adamdunkels09c28b62003-04-02 10:17:52 +0000393 unsigned char x1, y1, x2, y2;
394
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000395 (void)textcolor(DIALOGCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +0000396
397 x = dialog->x;
398 y = dialog->y + 1;
399
adamdunkels09c28b62003-04-02 10:17:52 +0000400 x1 = x + 1;
401 y1 = y + 1;
402 x2 = x1 + dialog->w;
403 y2 = y1 + dialog->h;
404
adamdunkels09c28b62003-04-02 10:17:52 +0000405 /* Draw dialog frame. */
adamdunkels09c28b62003-04-02 10:17:52 +0000406 cvlinexy(x, y1,
407 dialog->h);
408 cvlinexy(x2, y1,
409 dialog->h);
410
411 chlinexy(x1, y,
412 dialog->w);
413 chlinexy(x1, y2,
414 dialog->w);
415
416 cputcxy(x, y, CH_ULCORNER);
417 cputcxy(x, y2, CH_LLCORNER);
418 cputcxy(x2, y, CH_URCORNER);
419 cputcxy(x2, y2, CH_LRCORNER);
420
adamdunkels09c28b62003-04-02 10:17:52 +0000421 /* Clear dialog contents. */
422 for(i = y1; i < y2; ++i) {
423 cclearxy(x1, i, dialog->w);
424 }
adamdunkels09c28b62003-04-02 10:17:52 +0000425
adamdunkelsa45d8a12003-04-08 07:22:13 +0000426 draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
427 x1, x2, y1, y2);
adamdunkels09c28b62003-04-02 10:17:52 +0000428}
429/*-----------------------------------------------------------------------------------*/
430void
431ctk_draw_clear(unsigned char y1, unsigned char y2)
432{
433 unsigned char i;
434
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000435 (void)textcolor(BACKGROUNDCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +0000436 for(i = y1; i < y2; ++i) {
437 cclearxy(0, i, sizex);
438 }
439}
440/*-----------------------------------------------------------------------------------*/
441static void
oliverschmidt2b1582b2005-03-15 14:19:40 +0000442draw_menu(struct ctk_menu *m, unsigned char open)
adamdunkels09c28b62003-04-02 10:17:52 +0000443{
444 unsigned char x, x2, y;
oliverschmidt2b1582b2005-03-15 14:19:40 +0000445
446 if(open) {
447 x = x2 = wherex();
448 if(x2 + CTK_CONF_MENUWIDTH > sizex) {
449 x2 = sizex - CTK_CONF_MENUWIDTH;
450 }
451
452 for(y = 0; y < m->nitems; ++y) {
453 if(y == m->active) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000454 (void)textcolor(ACTIVEMENUITEMCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000455 revers(0);
456 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000457 (void)textcolor(MENUCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000458 revers(1);
459 }
460 gotoxy(x2, y + 1);
461 if(m->items[y].title[0] == '-') {
462 chline(CTK_CONF_MENUWIDTH);
463 } else {
464 cputs(m->items[y].title);
465 }
466 if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
467 cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
468 }
469 }
470
471 gotoxy(x, 0);
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000472 (void)textcolor(OPENMENUCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000473 revers(0);
474 }
475
adamdunkels09c28b62003-04-02 10:17:52 +0000476 cputs(m->title);
477 cputc(' ');
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000478 (void)textcolor(MENUCOLOR);
oliverschmidtd9a91072004-07-29 11:49:45 +0000479 revers(1);
adamdunkels09c28b62003-04-02 10:17:52 +0000480}
481/*-----------------------------------------------------------------------------------*/
482void
483ctk_draw_menus(struct ctk_menus *menus)
484{
oliverschmidt2b1582b2005-03-15 14:19:40 +0000485 struct ctk_menu *m;
adamdunkels62393fb2003-07-30 23:31:56 +0000486
adamdunkels09c28b62003-04-02 10:17:52 +0000487 /* Draw menus */
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000488 (void)textcolor(MENUCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +0000489 gotoxy(0, 0);
490 revers(1);
adamdunkelse68091d2003-04-16 18:29:10 +0000491 cputc(' ');
adamdunkels09c28b62003-04-02 10:17:52 +0000492 for(m = menus->menus->next; m != NULL; m = m->next) {
oliverschmidt2b1582b2005-03-15 14:19:40 +0000493 draw_menu(m, m == menus->open);
adamdunkels09c28b62003-04-02 10:17:52 +0000494 }
495
oliverschmidt2b1582b2005-03-15 14:19:40 +0000496 /* Draw desktopmenu */
497 if(wherex() + strlen(menus->desktopmenu->title) + 1 >= sizex) {
adamdunkels09c28b62003-04-02 10:17:52 +0000498 gotoxy(sizex - strlen(menus->desktopmenu->title) - 1, 0);
499 } else {
500 cclear(sizex - wherex() -
501 strlen(menus->desktopmenu->title) - 1);
502 }
oliverschmidt2b1582b2005-03-15 14:19:40 +0000503 draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
adamdunkels09c28b62003-04-02 10:17:52 +0000504
505 revers(0);
506}
507/*-----------------------------------------------------------------------------------*/
508unsigned char
509ctk_draw_height(void)
510{
511 return sizey;
512}
513/*-----------------------------------------------------------------------------------*/
514unsigned char
515ctk_draw_width(void)
516{
517 return sizex;
518}
519/*-----------------------------------------------------------------------------------*/
adamdunkelsca2cbe52004-07-04 11:38:43 +0000520int
521ctk_arch_isprint(char c)
522{
523 return isprint(c);
524}