void draw_menu(struct ctk_menu *m, struct ctk_menu *open) { #if CC_CONF_UNSIGNED_CHAR_BUGS unsigned char x2; unsigned int x, y; #else unsigned char x2; unsigned char x, y; #endif x = cursx; cputs(m->title); cputc(CH_SPACE); if (m == open) { x2 = cursx; if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) { x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH; } for(y = 0; y < m->nitems; y++) { if(y == m->active) { revers(0); } gotoxy(x, y + 1); if(m->items[y].title[0] == '-') { chline(CTK_CONF_MENUWIDTH); } else { cputs(m->items[y].title); } clearTo(x + CTK_CONF_MENUWIDTH); revers(1); } gotoxy(x2, 0); } }
/*---------------------------------------------------------------------------*/ void ctk_draw_clear(unsigned char clipy1, unsigned char clipy2) { while (clipy1 < clipy2) { gotoxy(0, clipy1); clearTo(SCREEN_WIDTH); clipy1++; } }
/*---------------------------------------------------------------------------*/ void ctk_draw_menus(struct ctk_menus *menus) { struct ctk_menu *m; clip(0, SCREEN_HEIGHT); /* Draw menus */ gotoxy(0, 0); revers(1); for(m = menus->menus->next; m != NULL; m = m->next) { draw_menu(m, menus->open); } clearTo(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 1); /* Draw desktopmenu */ draw_menu(menus->desktopmenu, menus->open); revers(0); }
/*---------------------------------------------------------------------------*/ void ctk_draw_clear_window(struct ctk_window *window, unsigned char focus, unsigned char clipy1, unsigned char clipy2) { unsigned char i; unsigned char x1, x2, y1, y2; x1 = window->x + 1; x2 = x1 + window->w; y1 = window->y + 2; y2 = y1 + window->h; for(i = y1; i < y2; ++i) { gotoxy(x1, i); clearTo(x2); } }
void FileUtils::clearAll() { clearTo(std::numeric_limits<int64_t>::max()); }
/* * w: widget * x, y: screen position of client drawing area (left, top) * clipx, clipy: screen position of client drawing area (right, bottom) * clipy1, clipy2: min/max y position of screen * focus: boolean */ void draw_widget(struct ctk_widget *w, unsigned char x, unsigned char y, unsigned char focus) { unsigned char xpos, ypos, xscroll; unsigned char i, j; char c, *text; #if CTK_CONF_ICONS unsigned char len; #endif /* CTK_CONF_ICONS */ xpos = x + w->x; ypos = y + w->y; revers(focus & CTK_FOCUS_WIDGET); gotoxy(xpos, ypos); if (w->type == CTK_WIDGET_SEPARATOR) { chline(w->w); } else if (w->type == CTK_WIDGET_LABEL) { text = w->widget.label.text; for(i = 0; i < w->h; ++i) { gotoxy(xpos, ypos); cputsn(text, w->w); clearTo(xpos + w->w); ++ypos; text += w->w; } } else if (w->type == CTK_WIDGET_BUTTON) { cputc('['); cputsn(w->widget.button.text, w->w); cputc(']'); } else if (w->type == CTK_WIDGET_HYPERLINK) { cputsn(w->widget.hyperlink.text, w->w); } else if (w->type == CTK_WIDGET_TEXTENTRY) { text = w->widget.textentry.text; xscroll = 0; if(w->widget.textentry.xpos >= w->w - 1) { xscroll = w->widget.textentry.xpos - w->w + 1; } for(j = 0; j < w->h; ++j) { gotoxy(xpos, ypos); if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT && w->widget.textentry.ypos == j) { revers(0); cputc('>'); for(i = 0; i < w->w; ++i) { c = text[i + xscroll]; revers(i == w->widget.textentry.xpos - xscroll); cputc((c == 0) ? CH_SPACE : c); } revers(0); cputc('<'); } else { cputc(CH_VERTLINE); cputsn(text, w->w); clearTo(xpos + w->w + 1); cputc(CH_VERTLINE); } ++ypos; text += w->w; } #if CTK_CONF_ICONS } else if (w->type == CTK_WIDGET_ICON) { if(w->widget.icon.textmap != NULL) { for(i = 0; i < 3; ++i) { gotoxy(xpos, ypos); cputc(w->widget.icon.textmap[0 + 3 * i]); cputc(w->widget.icon.textmap[1 + 3 * i]); cputc(w->widget.icon.textmap[2 + 3 * i]); ++ypos; } x = xpos; len = strlen(w->widget.icon.title); if(x + len >= SCREEN_WIDTH) { x = SCREEN_WIDTH - len; } gotoxy(x, ypos); cputs(w->widget.icon.title); } #endif /* CTK_CONF_ICONS */ } revers(0); }