/*-----------------------------------------------------------------------------------*/ static void draw_widget(struct ctk_widget *w, unsigned char x, unsigned char y, unsigned char clipx, unsigned char clipy, unsigned char clipy1, unsigned char clipy2, unsigned char focus) { unsigned char xpos, ypos, xscroll; unsigned char i, j; unsigned char iconnum; char c, *text; unsigned char len; /* if(focus & CTK_FOCUS_WINDOW) { textcolor(WIDGETCOLOR_FWIN); if(focus & CTK_FOCUS_WIDGET) { textcolor(WIDGETCOLOR_FOCUS); } } else if(focus & CTK_FOCUS_DIALOG) { textcolor(WIDGETCOLOR_DIALOG); if(focus & CTK_FOCUS_WIDGET) { textcolor(WIDGETCOLOR_FOCUS); } } else { textcolor(WIDGETCOLOR); } */ xpos = x + w->x; ypos = y + w->y; switch(w->type) { case CTK_WIDGET_SEPARATOR: textcolor(VNC_OUT_SEPARATORCOLOR + focus); if(ypos >= clipy1 && ypos < clipy2) { /* chlinexy(xpos, ypos, w->w);*/ gotoxy(xpos, ypos); for(i = 0; i < w->w; ++i) { cputc(CH_SEPARATOR); } } break; case CTK_WIDGET_LABEL: textcolor(VNC_OUT_LABELCOLOR + focus); text = w->widget.label.text; for(i = 0; i < w->h; ++i) { if(ypos >= clipy1 && ypos < clipy2) { gotoxy(xpos, ypos); cputsn(text, w->w); if(w->w - (wherex() - xpos) > 0) { cclear(w->w - (wherex() - xpos)); } } ++ypos; text += w->w; } break; case CTK_WIDGET_BUTTON: textcolor(VNC_OUT_BUTTONCOLOR + focus); if(ypos >= clipy1 && ypos < clipy2) { if(focus & CTK_FOCUS_WIDGET) { revers(1); } else { revers(0); } cputcxy(xpos, ypos, CH_BUTTONLEFT); cputsn(w->widget.button.text, w->w); cputc(CH_BUTTONRIGHT); revers(0); } break; case CTK_WIDGET_HYPERLINK: textcolor(VNC_OUT_HYPERLINKCOLOR + focus); if(ypos >= clipy1 && ypos < clipy2) { /* if(focus & CTK_FOCUS_WIDGET) { textcolor(WIDGETCOLOR_HLINK_FOCUS); revers(0); } else { textcolor(WIDGETCOLOR_HLINK); revers(1); }*/ gotoxy(xpos, ypos); cputsn(w->widget.button.text, w->w); revers(0); } break; case CTK_WIDGET_TEXTENTRY: textcolor(VNC_OUT_TEXTENTRYCOLOR + focus); 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) { if(ypos >= clipy1 && ypos < clipy2) { if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT && w->widget.textentry.ypos == j) { revers(0); cputcxy(xpos, ypos, '>'); c = 1; for(i = 0; i < w->w; ++i) { if(c != 0) { c = text[i + xscroll]; } if(i == w->widget.textentry.xpos - xscroll) { textcolor(VNC_OUT_TEXTENTRYCOLOR + (focus ^ 0x01)); revers(1); } else { revers(0); } if(c == 0) { cputc(' '); } else { cputc(c); } revers(0); textcolor(VNC_OUT_TEXTENTRYCOLOR + focus); } cputc('<'); } else { if(focus & CTK_FOCUS_WIDGET && j == w->widget.textentry.ypos) { revers(1); } else { revers(0); } cvlinexy(xpos, ypos, 1); gotoxy(xpos + 1, ypos); cputsn(text, w->w); i = wherex(); if(i - xpos - 1 < w->w) { cclear(w->w - (i - xpos) + 1); } cvline(1); } } ++ypos; text += w->widget.textentry.len + 1; } revers(0); break; #if CTK_CONF_ICONS case CTK_WIDGET_ICON: if(ypos >= clipy1 && ypos < clipy2) { textcolor(VNC_OUT_ICONCOLOR + focus); if(focus & 1) { revers(1); } else { revers(0); } x = xpos; len = strlen(w->widget.icon.title); if(x + len >= sizex) { x = sizex - len; } gotoxy(x, ypos + 3); if(ypos >= clipy1 && ypos < clipy2) { cputs(w->widget.icon.title); } #if CTK_CONF_ICON_BITMAPS if(w->widget.icon.bitmap != NULL) { iconnum = vnc_out_add_icon((struct ctk_icon *)w); textcolor(iconnum | (focus << 6)); gotoxy(xpos, ypos); cputc(0x80); cputc(0x81); cputc(0x82); cputc(0x83); ++ypos; gotoxy(xpos, ypos); cputc(0x90); cputc(0x91); cputc(0x92); cputc(0x93); ++ypos; gotoxy(xpos, ypos); cputc(0xa0); cputc(0xa1); cputc(0xa2); cputc(0xa3); ++ypos; textcolor(0); /* for(i = 0; i < 3; ++i) { if(ypos >= clipy1 && ypos < clipy2) { 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; }*/ } #endif /* CTK_CONF_ICON_BITMAPS */ revers(0); } break; #endif /* CTK_CONF_ICONS */ default: break; } }
/*-----------------------------------------------------------------------------------*/ static void draw_widget(struct ctk_widget *w, unsigned char x, unsigned char y, unsigned char clipx, unsigned char clipy, unsigned char clipy1, unsigned char clipy2, unsigned char focus) { unsigned char xpos, ypos, xscroll; unsigned char i, j; char c, *text; unsigned char wfocus; #if CTK_CONF_ICONS unsigned char len; #endif /* CTK_CONF_ICONS */ wfocus = 0; if(focus & CTK_FOCUS_WINDOW) { (void)textcolor(WIDGETCOLOR_FWIN); if(focus & CTK_FOCUS_WIDGET) { (void)textcolor(WIDGETCOLOR_FOCUS); wfocus = 1; } #if CTK_CONF_WINDOWS } else if(focus & CTK_FOCUS_DIALOG) { (void)textcolor(WIDGETCOLOR_DIALOG); if(focus & CTK_FOCUS_WIDGET) { (void)textcolor(WIDGETCOLOR_FOCUS); wfocus = 1; } #endif /* CTK_CONF_WINDOWS */ } else { (void)textcolor(WIDGETCOLOR); } xpos = x + w->x; ypos = y + w->y; switch(w->type) { case CTK_WIDGET_SEPARATOR: if(ypos >= clipy1 && ypos < clipy2) { chlinexy(xpos, ypos, w->w); } break; case CTK_WIDGET_LABEL: text = w->widget.label.text; for(i = 0; i < w->h; ++i) { if(ypos >= clipy1 && ypos < clipy2) { gotoxy(xpos, ypos); cputsn(text, w->w); if(w->w - (wherex() - xpos) > 0) { cclear(w->w - (wherex() - xpos)); } } ++ypos; text += w->w; } break; case CTK_WIDGET_BUTTON: if(ypos >= clipy1 && ypos < clipy2) { revers(wfocus != 0); cputcxy(xpos, ypos, '['); cputsn(w->widget.button.text, w->w); cputc(']'); revers(0); } break; case CTK_WIDGET_HYPERLINK: if(ypos >= clipy1 && ypos < clipy2) { revers(wfocus == 0); gotoxy(xpos, ypos); (void)textcolor(WIDGETCOLOR_HLINK); cputsn(w->widget.button.text, w->w); revers(0); } break; case 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) { if(ypos >= clipy1 && ypos < clipy2) { if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT && w->widget.textentry.ypos == j) { revers(0); cputcxy(xpos, ypos, '>'); c = 1; for(i = 0; i < w->w; ++i) { if(c != 0) { c = text[i + xscroll]; } revers(i == w->widget.textentry.xpos - xscroll); if(c == 0) { cputc(' '); } else { cputc(c); } } revers(0); cputc('<'); } else { revers(wfocus != 0 && j == w->widget.textentry.ypos); cvlinexy(xpos, ypos, 1); gotoxy(xpos + 1, ypos); cputsn(text, w->w); i = wherex(); if(i - xpos - 1 < w->w) { cclear(w->w - (i - xpos) + 1); } cvline(1); } } ++ypos; text += w->widget.textentry.len + 1; } revers(0); break; #if CTK_CONF_ICONS case CTK_WIDGET_ICON: if(ypos >= clipy1 && ypos < clipy2) { revers(wfocus != 0); #if CTK_CONF_ICON_TEXTMAPS if(w->widget.icon.textmap != NULL) { for(i = 0; i < 3; ++i) { gotoxy(xpos, ypos); if(ypos >= clipy1 && ypos < clipy2) { 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; } } #endif /* CTK_CONF_ICON_TEXTMAPS */ len = (unsigned char)strlen(w->widget.icon.title); if(xpos + len >= sizex) { xpos = sizex - len; } gotoxy(xpos, ypos); if(ypos >= clipy1 && ypos < clipy2) { cputs(w->widget.icon.title); } revers(0); } break; #endif /* CTK_CONF_ICONS */ default: break; } }
/* * 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); }