45 #include "contiki-conf.h"
46 #include "ctk/ctk_arch.h"
50 #define NULL (void *)0
54 static char cursx, cursy;
55 static unsigned char reversed;
58 unsigned char ctk_draw_windowtitle_height = 1;
61 #define revers(c) reversed = c
62 #define clip(y1, y2) cy1 = y1; cy2 = y2
63 #define OFFSET(x, y) y * SCREEN_WIDTH + x
67 if (cursy >= cy1 && cursy <= cy2
68 && cursy >= 0 && cursy <= SCREEN_HEIGHT
69 && cursx >= 0 && cursx < SCREEN_WIDTH) {
70 unsigned int offset = OFFSET(cursx, cursy);
71 *((
char *) VRAM_CHAR + offset) = c;
72 *((
char *) VRAM_ATTR + offset) = reversed ? COLOR_REVERSED : COLOR_NORMAL;
78 void cputs(
char *str) {
85 void cputsn(
char *str,
unsigned char len) {
86 while ((len > 0) && (*str != 0)) {
93 void chline(
unsigned char length) {
103 void cvline(
unsigned char length) {
112 void gotoxy(
unsigned char x,
unsigned char y) {
117 void clearTo(
char x) {
126 while (clipy1 < clipy2) {
128 clearTo(SCREEN_WIDTH);
135 clip(0, SCREEN_HEIGHT);
148 unsigned char x,
unsigned char y,
149 unsigned char focus) {
150 unsigned char xpos, ypos, xscroll;
166 text = w->
widget.label.text;
167 for(i = 0; i < w->
h; ++i) {
170 clearTo(xpos + w->
w);
179 cputsn(w->
widget.hyperlink.text, w->
w);
181 text = w->
widget.textentry.text;
183 if(w->
widget.textentry.xpos >= w->
w - 1) {
184 xscroll = w->
widget.textentry.xpos - w->
w + 1;
186 for(j = 0; j < w->
h; ++j) {
188 if(w->
widget.textentry.state == CTK_TEXTENTRY_EDIT &&
189 w->
widget.textentry.ypos == j) {
192 for(i = 0; i < w->
w; ++i) {
193 c = text[i + xscroll];
194 revers(i == w->
widget.textentry.xpos - xscroll);
195 cputc((c == 0) ? CH_SPACE : c);
202 clearTo(xpos + w->
w + 1);
211 for(i = 0; i < 3; ++i) {
213 cputc(w->
widget.icon.textmap[0 + 3 * i]);
214 cputc(w->
widget.icon.textmap[1 + 3 * i]);
215 cputc(w->
widget.icon.textmap[2 + 3 * i]);
220 len = strlen(w->
widget.icon.title);
221 if(x + len >= SCREEN_WIDTH) {
222 x = SCREEN_WIDTH - len;
225 cputs(w->
widget.icon.title);
236 unsigned char clipy1,
237 unsigned char clipy2) {
240 unsigned char posx, posy;
241 clip(clipy1, clipy2);
250 draw_widget(w, posx, posy, focus);
256 unsigned char clipy1,
257 unsigned char clipy2) {
260 unsigned char x1, x2, y1, y2;
266 for(i = y1; i < y2; ++i) {
272 void draw_window_sub(
struct ctk_window *window,
unsigned char focus) {
275 unsigned char x1, y1, x2;
277 unsigned char wfocus;
304 draw_widget(w, x1, y1, focus);
313 draw_widget(w, x1, y1, wfocus);
319 unsigned char clipy1,
unsigned char clipy2,
unsigned char draw_borders) {
320 clip(clipy1, clipy2);
323 draw_window_sub(window, focus);
327 clip(0, SCREEN_HEIGHT);
335 #if CC_CONF_UNSIGNED_CHAR_BUGS
348 if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
349 x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
352 for(y = 0; y < m->
nitems; y++) {
358 chline(CTK_CONF_MENUWIDTH);
362 clearTo(x + CTK_CONF_MENUWIDTH);
372 clip(0, SCREEN_HEIGHT);
377 draw_menu(m, menus->
open);
390 unsigned char ctk_draw_width(
void) {
393 unsigned char ctk_draw_height(
void) {
394 return SCREEN_HEIGHT;