45 #define NULL (void *)0
48 static unsigned char sizex, sizey;
50 unsigned char ctk_draw_windowborder_height = 1;
51 unsigned char ctk_draw_windowborder_width = 1;
52 unsigned char ctk_draw_windowtitle_height = 1;
57 cputsn(
char *str,
unsigned char len)
59 unsigned char cnt = 0;
77 (void)bgcolor(SCREENCOLOR);
78 (void)bordercolor(BORDERCOLOR);
79 (void)textcolor(WINDOWCOLOR_FOCUS);
80 screensize(&sizex, &sizey);
87 unsigned char x,
unsigned char y,
88 unsigned char clipx,
unsigned char clipy,
89 unsigned char clipy1,
unsigned char clipy2,
92 unsigned char xpos, ypos, xscroll;
102 (void)textcolor(WIDGETCOLOR_FWIN);
104 (void)textcolor(WIDGETCOLOR_FOCUS);
109 (void)textcolor(WIDGETCOLOR_DIALOG);
110 if(focus & CTK_FOCUS_WIDGET) {
111 (void)textcolor(WIDGETCOLOR_FOCUS);
116 (void)textcolor(WIDGETCOLOR);
124 if(ypos >= clipy1 && ypos < clipy2) {
125 chlinexy(xpos, ypos, w->
w);
129 text = w->
widget.label.text;
130 for(j = 0; j < w->
h; ++j) {
131 if(ypos >= clipy1 && ypos < clipy2) {
133 i = cputsn(text, w->
w);
143 if(ypos >= clipy1 && ypos < clipy2) {
145 cputcxy(xpos, ypos,
'[');
152 if(ypos >= clipy1 && ypos < clipy2) {
155 (void)textcolor(WIDGETCOLOR_HLINK);
161 text = w->
widget.textentry.text;
163 if(w->
widget.textentry.xpos >= w->
w - 1) {
164 xscroll = w->
widget.textentry.xpos - w->
w + 1;
166 for(j = 0; j < w->
h; ++j) {
167 if(ypos >= clipy1 && ypos < clipy2) {
168 if(w->
widget.textentry.state == CTK_TEXTENTRY_EDIT &&
169 w->
widget.textentry.ypos == j) {
171 cputcxy(xpos, ypos,
'>');
173 for(i = 0; i < w->
w; ++i) {
175 c = text[i + xscroll];
177 revers(i == w->
widget.textentry.xpos - xscroll);
187 revers(wfocus != 0 && j == w->
widget.textentry.ypos);
188 cvlinexy(xpos, ypos, 1);
189 gotoxy(xpos + 1, ypos);
190 i = cputsn(text, w->
w);
198 text += w->
widget.textentry.len + 1;
204 if(ypos >= clipy1 && ypos < clipy2) {
206 #if CTK_CONF_ICON_TEXTMAPS
208 for(i = 0; i < 3; ++i) {
210 if(ypos >= clipy1 && ypos < clipy2) {
211 cputc(w->
widget.icon.textmap[0 + 3 * i]);
212 cputc(w->
widget.icon.textmap[1 + 3 * i]);
213 cputc(w->
widget.icon.textmap[2 + 3 * i]);
220 len = (
unsigned char)strlen(w->
widget.icon.title);
221 if(xpos + len >= sizex) {
226 if(ypos >= clipy1 && ypos < clipy2) {
227 cputs(w->
widget.icon.title);
241 unsigned char clipy1,
unsigned char clipy2)
244 unsigned char posx, posy;
248 posy = win->y + 1 + CTK_CONF_MENUS;
258 draw_widget(w, posx, posy, posx + win->
w, posy + win->
h, clipy1, clipy2, focus);
260 #ifdef CTK_CONIO_CONF_UPDATE
261 CTK_CONIO_CONF_UPDATE();
267 unsigned char clipy1,
unsigned char clipy2)
274 if(focus & CTK_FOCUS_WINDOW) {
275 (void)textcolor(WINDOWCOLOR_FOCUS);
277 (void)textcolor(WINDOWCOLOR);
281 h = window->y + 1 + CTK_CONF_MENUS + window->
h;
284 for(i = window->y + 1 + CTK_CONF_MENUS; i < h; ++i) {
285 if(i >= clipy1 && i < clipy2) {
286 cclearxy(window->x + 1, i, window->
w);
290 for(i = 0; i < window->
h; ++i) {
291 if(i >= clipy1 && i < clipy2) {
292 cclearxy(0, i, window->
w);
299 draw_window_contents(
struct ctk_window *window,
unsigned char focus,
300 unsigned char clipy1,
unsigned char clipy2,
301 unsigned char x1,
unsigned char x2,
302 unsigned char y1,
unsigned char y2)
305 unsigned char wfocus;
309 draw_widget(w, x1, y1, x2, y2, clipy1, clipy2, focus);
319 draw_widget(w, x1, y1, x2, y2, clipy1, clipy2, wfocus);
322 #ifdef CTK_CONIO_CONF_UPDATE
323 CTK_CONIO_CONF_UPDATE();
329 unsigned char clipy1,
unsigned char clipy2,
330 unsigned char draw_borders)
334 unsigned char x1, y1, x2, y2;
337 if(window->y + CTK_CONF_MENUS >= clipy2) {
342 y = window->y + CTK_CONF_MENUS;
351 if(focus & CTK_FOCUS_WINDOW) {
352 (void)textcolor(WINDOWCOLOR_FOCUS);
354 (void)textcolor(WINDOWCOLOR);
358 cputcxy(x, y, (
char)CH_ULCORNER);
359 gotoxy(wherex() + window->
titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
360 chline(window->
w - (wherex() - x) - 2);
361 cputcxy(x2, y, (
char)CH_URCORNER);
367 if(clipy1 - y1 < h) {
375 if(clipy2 < y1 + h) {
386 if(y + window->
h >= clipy1 && y + window->
h < clipy2) {
387 cputcxy(x, y2, (
char)CH_LLCORNER);
388 chlinexy(x1, y2, window->
w);
389 cputcxy(x2, y2, (
char)CH_LRCORNER);
393 draw_window_contents(window, focus, clipy1, clipy2, x1, x2, y + 1, y2);
397 draw_window_contents(window, focus, clipy1, clipy2, 0, window->
w, 0, window->
h);
408 unsigned char x1, y1, x2, y2;
410 (void)textcolor(DIALOGCOLOR);
413 y = dialog->y + CTK_CONF_MENUS;
421 cvlinexy(x, y1, dialog->
h);
422 cvlinexy(x2, y1, dialog->
h);
424 chlinexy(x1, y, dialog->
w);
425 chlinexy(x1, y2, dialog->
w);
427 cputcxy(x, y, (
char)CH_ULCORNER);
428 cputcxy(x, y2, (
char)CH_LLCORNER);
429 cputcxy(x2, y, (
char)CH_URCORNER);
430 cputcxy(x2, y2, (
char)CH_LRCORNER);
433 for(i = y1; i < y2; ++i) {
434 cclearxy(x1, i, dialog->
w);
437 draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey, x1, x2, y1, y2);
446 for(i = y1; i < y2; ++i) {
447 cclearxy(0, i, sizex);
453 draw_menu(
struct ctk_menu *m,
unsigned char open)
455 unsigned char x, x2,
y;
459 if(x2 + CTK_CONF_MENUWIDTH > sizex) {
460 x2 = sizex - CTK_CONF_MENUWIDTH;
463 for(y = 0; y < m->
nitems; ++
y) {
465 (void)textcolor(ACTIVEMENUITEMCOLOR);
468 (void)textcolor(MENUCOLOR);
473 chline(CTK_CONF_MENUWIDTH);
477 if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
478 cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
483 (void)textcolor(OPENMENUCOLOR);
489 (void)textcolor(MENUCOLOR);
499 (void)textcolor(MENUCOLOR);
504 draw_menu(m, m == menus->
open);
511 cclear(sizex - wherex() -
521 ctk_draw_height(
void)