blob: d5d153ffa3ce3eec2d2a0ce11b185a71977f947a [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 *
oliverschmidt6307bff2005-05-04 19:54:50 +000032 * $Id: ctk-conio.c,v 1.21 2005/05/04 19:54:51 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;
oliverschmidt6307bff2005-05-04 19:54:50 +0000155 revers(wfocus != 0);
adamdunkels09c28b62003-04-02 10:17:52 +0000156 xscroll = 0;
157 if(w->widget.textentry.xpos >= w->w - 1) {
158 xscroll = w->widget.textentry.xpos - w->w + 1;
159 }
adamdunkels62393fb2003-07-30 23:31:56 +0000160 for(j = 0; j < w->h; ++j) {
adamdunkels09c28b62003-04-02 10:17:52 +0000161 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, '>');
166 for(i = 0; i < w->w; ++i) {
167 c = text[i + xscroll];
oliverschmidt6307bff2005-05-04 19:54:50 +0000168 revers(i == w->widget.textentry.xpos - xscroll);
adamdunkels09c28b62003-04-02 10:17:52 +0000169 if(c == 0) {
170 cputc(' ');
171 } else {
172 cputc(c);
173 }
174 revers(0);
175 }
176 cputc('<');
177 } else {
178 cvlinexy(xpos, ypos, 1);
179 gotoxy(xpos + 1, ypos);
180 cputsn(text, w->w);
181 i = wherex();
182 if(i - xpos - 1 < w->w) {
183 cclear(w->w - (i - xpos) + 1);
184 }
185 cvline(1);
186 }
187 }
188 ++ypos;
189 text += w->w;
190 }
191 revers(0);
192 break;
oliverschmidta98def52004-06-27 18:32:10 +0000193#if CTK_CONF_ICONS
adamdunkels09c28b62003-04-02 10:17:52 +0000194 case CTK_WIDGET_ICON:
195 if(ypos >= clipy1 && ypos < clipy2) {
oliverschmidt6307bff2005-05-04 19:54:50 +0000196 revers(wfocus != 0);
oliverschmidta98def52004-06-27 18:32:10 +0000197#if CTK_CONF_ICON_TEXTMAPS
adamdunkels09c28b62003-04-02 10:17:52 +0000198 if(w->widget.icon.textmap != NULL) {
199 for(i = 0; i < 3; ++i) {
200 gotoxy(xpos, ypos);
201 if(ypos >= clipy1 && ypos < clipy2) {
202 cputc(w->widget.icon.textmap[0 + 3 * i]);
203 cputc(w->widget.icon.textmap[1 + 3 * i]);
204 cputc(w->widget.icon.textmap[2 + 3 * i]);
205 }
206 ++ypos;
207 }
208 }
oliverschmidta98def52004-06-27 18:32:10 +0000209#endif /* CTK_CONF_ICON_TEXTMAPS */
adamdunkels09c28b62003-04-02 10:17:52 +0000210
211 len = strlen(w->widget.icon.title);
oliverschmidta98def52004-06-27 18:32:10 +0000212 if(xpos + len >= sizex) {
213 xpos = sizex - len;
adamdunkels09c28b62003-04-02 10:17:52 +0000214 }
215
oliverschmidta98def52004-06-27 18:32:10 +0000216 gotoxy(xpos, ypos);
adamdunkels09c28b62003-04-02 10:17:52 +0000217 if(ypos >= clipy1 && ypos < clipy2) {
218 cputs(w->widget.icon.title);
219 }
220 revers(0);
221 }
222 break;
oliverschmidta98def52004-06-27 18:32:10 +0000223#endif /* CTK_CONF_ICONS */
adamdunkels09c28b62003-04-02 10:17:52 +0000224
225 default:
226 break;
227 }
228}
229/*-----------------------------------------------------------------------------------*/
230void
231ctk_draw_widget(struct ctk_widget *w,
232 unsigned char focus,
233 unsigned char clipy1,
234 unsigned char clipy2)
235{
236 struct ctk_window *win = w->window;
237 unsigned char posx, posy;
238
239 posx = win->x + 1;
240 posy = win->y + 2;
241
242 if(w == win->focused) {
243 focus |= CTK_FOCUS_WIDGET;
244 }
245
246 draw_widget(w, posx, posy,
247 posx + win->w,
248 posy + win->h,
249 clipy1, clipy2,
250 focus);
adamdunkelsfe32f8d2003-04-28 20:31:48 +0000251
252#ifdef CTK_CONIO_CONF_UPDATE
253 CTK_CONIO_CONF_UPDATE();
254#endif /* CTK_CONIO_CONF_UPDATE */
adamdunkels09c28b62003-04-02 10:17:52 +0000255}
256/*-----------------------------------------------------------------------------------*/
257void
258ctk_draw_clear_window(struct ctk_window *window,
259 unsigned char focus,
260 unsigned char clipy1,
261 unsigned char clipy2)
262{
263 unsigned char i;
264 unsigned char h;
265
oliverschmidt0e144fb2004-08-12 21:52:03 +0000266 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000267 (void)textcolor(WINDOWCOLOR_FOCUS);
oliverschmidt0e144fb2004-08-12 21:52:03 +0000268 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000269 (void)textcolor(WINDOWCOLOR);
oliverschmidt0e144fb2004-08-12 21:52:03 +0000270 }
adamdunkels09c28b62003-04-02 10:17:52 +0000271
272 h = window->y + 2 + window->h;
oliverschmidt2b1582b2005-03-15 14:19:40 +0000273
adamdunkels09c28b62003-04-02 10:17:52 +0000274 /* Clear window contents. */
275 for(i = window->y + 2; i < h; ++i) {
276 if(i >= clipy1 && i < clipy2) {
277 cclearxy(window->x + 1, i, window->w);
278 }
279 }
280}
281/*-----------------------------------------------------------------------------------*/
adamdunkelsa45d8a12003-04-08 07:22:13 +0000282static void
283draw_window_contents(struct ctk_window *window, unsigned char focus,
284 unsigned char clipy1, unsigned char clipy2,
285 unsigned char x1, unsigned char x2,
286 unsigned char y1, unsigned char y2)
287{
288 struct ctk_widget *w;
289 unsigned char wfocus;
290
291 /* Draw inactive widgets. */
292 for(w = window->inactive; w != NULL; w = w->next) {
293 draw_widget(w, x1, y1, x2, y2,
294 clipy1, clipy2,
295 focus);
296 }
297
298 /* Draw active widgets. */
299 for(w = window->active; w != NULL; w = w->next) {
300 wfocus = focus;
301 if(w == window->focused) {
302 wfocus |= CTK_FOCUS_WIDGET;
303 }
304
305 draw_widget(w, x1, y1, x2, y2,
306 clipy1, clipy2,
307 wfocus);
308 }
309
adamdunkelsfe32f8d2003-04-28 20:31:48 +0000310#ifdef CTK_CONIO_CONF_UPDATE
311 CTK_CONIO_CONF_UPDATE();
312#endif /* CTK_CONIO_CONF_UPDATE */
adamdunkelsa45d8a12003-04-08 07:22:13 +0000313}
314/*-----------------------------------------------------------------------------------*/
adamdunkels09c28b62003-04-02 10:17:52 +0000315void
316ctk_draw_window(struct ctk_window *window, unsigned char focus,
oliverschmidtadf27db2005-03-15 15:51:17 +0000317 unsigned char clipy1, unsigned char clipy2,
318 unsigned char draw_borders)
adamdunkels09c28b62003-04-02 10:17:52 +0000319{
320 unsigned char x, y;
321 unsigned char h;
adamdunkels09c28b62003-04-02 10:17:52 +0000322 unsigned char x1, y1, x2, y2;
323
324 if(window->y + 1 >= clipy2) {
325 return;
326 }
327
328 x = window->x;
329 y = window->y + 1;
adamdunkels09c28b62003-04-02 10:17:52 +0000330 x1 = x + 1;
331 y1 = y + 1;
332 x2 = x1 + window->w;
333 y2 = y1 + window->h;
334
oliverschmidtadf27db2005-03-15 15:51:17 +0000335 if(draw_borders) {
adamdunkels09c28b62003-04-02 10:17:52 +0000336
oliverschmidtadf27db2005-03-15 15:51:17 +0000337 /* Draw window frame. */
338 if(focus & CTK_FOCUS_WINDOW) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000339 (void)textcolor(WINDOWCOLOR_FOCUS);
oliverschmidtadf27db2005-03-15 15:51:17 +0000340 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000341 (void)textcolor(WINDOWCOLOR);
oliverschmidtadf27db2005-03-15 15:51:17 +0000342 }
343
344 if(y >= clipy1) {
345 cputcxy(x, y, CH_ULCORNER);
oliverschmidt7b9025d2005-03-18 01:08:35 +0000346 gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
oliverschmidtadf27db2005-03-15 15:51:17 +0000347 chline(window->w - (wherex() - x) - 2);
348 cputcxy(x2, y, CH_URCORNER);
349 }
350
351 h = window->h;
adamdunkels09c28b62003-04-02 10:17:52 +0000352
oliverschmidtadf27db2005-03-15 15:51:17 +0000353 if(clipy1 > y1) {
354 if(clipy1 - y1 < h) {
355 h = clipy1 - y1;
356 y1 = clipy1;
357 } else {
358 h = 0;
359 }
adamdunkels09c28b62003-04-02 10:17:52 +0000360 }
adamdunkels09c28b62003-04-02 10:17:52 +0000361
oliverschmidtadf27db2005-03-15 15:51:17 +0000362 if(clipy2 < y1 + h) {
363 if(y1 >= clipy2) {
364 h = 0;
365 } else {
366 h = clipy2 - y1;
367 }
adamdunkels09c28b62003-04-02 10:17:52 +0000368 }
adamdunkels62393fb2003-07-30 23:31:56 +0000369
oliverschmidtadf27db2005-03-15 15:51:17 +0000370 cvlinexy(x, y1, h);
371 cvlinexy(x2, y1, h);
adamdunkels09c28b62003-04-02 10:17:52 +0000372
oliverschmidtadf27db2005-03-15 15:51:17 +0000373 if(y + window->h >= clipy1 &&
374 y + window->h < clipy2) {
375 cputcxy(x, y2, CH_LLCORNER);
376 chlinexy(x1, y2, window->w);
377 cputcxy(x2, y2, CH_LRCORNER);
378 }
adamdunkels09c28b62003-04-02 10:17:52 +0000379 }
380
oliverschmidte99386b2004-12-27 22:03:04 +0000381 draw_window_contents(window, focus, clipy1, clipy2,
adamdunkels62393fb2003-07-30 23:31:56 +0000382 x1, x2, y + 1, y2);
adamdunkels09c28b62003-04-02 10:17:52 +0000383}
384/*-----------------------------------------------------------------------------------*/
385void
386ctk_draw_dialog(struct ctk_window *dialog)
387{
388 unsigned char x, y;
389 unsigned char i;
adamdunkels09c28b62003-04-02 10:17:52 +0000390 unsigned char x1, y1, x2, y2;
391
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000392 (void)textcolor(DIALOGCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +0000393
394 x = dialog->x;
395 y = dialog->y + 1;
396
adamdunkels09c28b62003-04-02 10:17:52 +0000397 x1 = x + 1;
398 y1 = y + 1;
399 x2 = x1 + dialog->w;
400 y2 = y1 + dialog->h;
401
adamdunkels09c28b62003-04-02 10:17:52 +0000402 /* Draw dialog frame. */
adamdunkels09c28b62003-04-02 10:17:52 +0000403 cvlinexy(x, y1,
404 dialog->h);
405 cvlinexy(x2, y1,
406 dialog->h);
407
408 chlinexy(x1, y,
409 dialog->w);
410 chlinexy(x1, y2,
411 dialog->w);
412
413 cputcxy(x, y, CH_ULCORNER);
414 cputcxy(x, y2, CH_LLCORNER);
415 cputcxy(x2, y, CH_URCORNER);
416 cputcxy(x2, y2, CH_LRCORNER);
417
adamdunkels09c28b62003-04-02 10:17:52 +0000418 /* Clear dialog contents. */
419 for(i = y1; i < y2; ++i) {
420 cclearxy(x1, i, dialog->w);
421 }
adamdunkels09c28b62003-04-02 10:17:52 +0000422
adamdunkelsa45d8a12003-04-08 07:22:13 +0000423 draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
424 x1, x2, y1, y2);
adamdunkels09c28b62003-04-02 10:17:52 +0000425}
426/*-----------------------------------------------------------------------------------*/
427void
428ctk_draw_clear(unsigned char y1, unsigned char y2)
429{
430 unsigned char i;
431
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000432 (void)textcolor(BACKGROUNDCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +0000433 for(i = y1; i < y2; ++i) {
434 cclearxy(0, i, sizex);
435 }
436}
437/*-----------------------------------------------------------------------------------*/
438static void
oliverschmidt2b1582b2005-03-15 14:19:40 +0000439draw_menu(struct ctk_menu *m, unsigned char open)
adamdunkels09c28b62003-04-02 10:17:52 +0000440{
441 unsigned char x, x2, y;
oliverschmidt2b1582b2005-03-15 14:19:40 +0000442
443 if(open) {
444 x = x2 = wherex();
445 if(x2 + CTK_CONF_MENUWIDTH > sizex) {
446 x2 = sizex - CTK_CONF_MENUWIDTH;
447 }
448
449 for(y = 0; y < m->nitems; ++y) {
450 if(y == m->active) {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000451 (void)textcolor(ACTIVEMENUITEMCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000452 revers(0);
453 } else {
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000454 (void)textcolor(MENUCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000455 revers(1);
456 }
457 gotoxy(x2, y + 1);
458 if(m->items[y].title[0] == '-') {
459 chline(CTK_CONF_MENUWIDTH);
460 } else {
461 cputs(m->items[y].title);
462 }
463 if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
464 cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
465 }
466 }
467
468 gotoxy(x, 0);
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000469 (void)textcolor(OPENMENUCOLOR);
oliverschmidt2b1582b2005-03-15 14:19:40 +0000470 revers(0);
471 }
472
adamdunkels09c28b62003-04-02 10:17:52 +0000473 cputs(m->title);
474 cputc(' ');
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000475 (void)textcolor(MENUCOLOR);
oliverschmidtd9a91072004-07-29 11:49:45 +0000476 revers(1);
adamdunkels09c28b62003-04-02 10:17:52 +0000477}
478/*-----------------------------------------------------------------------------------*/
479void
480ctk_draw_menus(struct ctk_menus *menus)
481{
oliverschmidt2b1582b2005-03-15 14:19:40 +0000482 struct ctk_menu *m;
adamdunkels62393fb2003-07-30 23:31:56 +0000483
adamdunkels09c28b62003-04-02 10:17:52 +0000484 /* Draw menus */
oliverschmidt7fdf5f52005-03-29 20:30:32 +0000485 (void)textcolor(MENUCOLOR);
adamdunkels09c28b62003-04-02 10:17:52 +0000486 gotoxy(0, 0);
487 revers(1);
adamdunkelse68091d2003-04-16 18:29:10 +0000488 cputc(' ');
adamdunkels09c28b62003-04-02 10:17:52 +0000489 for(m = menus->menus->next; m != NULL; m = m->next) {
oliverschmidt2b1582b2005-03-15 14:19:40 +0000490 draw_menu(m, m == menus->open);
adamdunkels09c28b62003-04-02 10:17:52 +0000491 }
492
oliverschmidt2b1582b2005-03-15 14:19:40 +0000493 /* Draw desktopmenu */
494 if(wherex() + strlen(menus->desktopmenu->title) + 1 >= sizex) {
adamdunkels09c28b62003-04-02 10:17:52 +0000495 gotoxy(sizex - strlen(menus->desktopmenu->title) - 1, 0);
496 } else {
497 cclear(sizex - wherex() -
498 strlen(menus->desktopmenu->title) - 1);
499 }
oliverschmidt2b1582b2005-03-15 14:19:40 +0000500 draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
adamdunkels09c28b62003-04-02 10:17:52 +0000501
502 revers(0);
503}
504/*-----------------------------------------------------------------------------------*/
505unsigned char
506ctk_draw_height(void)
507{
508 return sizey;
509}
510/*-----------------------------------------------------------------------------------*/
511unsigned char
512ctk_draw_width(void)
513{
514 return sizex;
515}
516/*-----------------------------------------------------------------------------------*/
adamdunkelsca2cbe52004-07-04 11:38:43 +0000517int
518ctk_arch_isprint(char c)
519{
520 return isprint(c);
521}