Some source reformatting.

This commit is contained in:
oliverschmidt 2007-12-15 21:04:20 +00:00
parent 4671ee3d10
commit 9c9e336f45
2 changed files with 26 additions and 89 deletions

View file

@ -29,7 +29,7 @@
* *
* This file is part of the "ctk" console GUI toolkit for cc65 * This file is part of the "ctk" console GUI toolkit for cc65
* *
* $Id: ctk-conio.c,v 1.7 2007/12/15 20:46:15 oliverschmidt Exp $ * $Id: ctk-conio.c,v 1.8 2007/12/15 21:04:20 oliverschmidt Exp $
* *
*/ */
@ -82,8 +82,7 @@ ctk_draw_init(void)
static void static void
draw_widget(struct ctk_widget *w, draw_widget(struct ctk_widget *w,
unsigned char x, unsigned char y, unsigned char x, unsigned char y,
unsigned char clipx, unsigned char clipx, unsigned char clipy,
unsigned char clipy,
unsigned char clipy1, unsigned char clipy2, unsigned char clipy1, unsigned char clipy2,
unsigned char focus) unsigned char focus)
{ {
@ -231,10 +230,8 @@ draw_widget(struct ctk_widget *w,
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void
ctk_draw_widget(struct ctk_widget *w, ctk_draw_widget(struct ctk_widget *w, unsigned char focus,
unsigned char focus, unsigned char clipy1, unsigned char clipy2)
unsigned char clipy1,
unsigned char clipy2)
{ {
struct ctk_window *win = w->window; struct ctk_window *win = w->window;
unsigned char posx, posy; unsigned char posx, posy;
@ -246,11 +243,7 @@ ctk_draw_widget(struct ctk_widget *w,
focus |= CTK_FOCUS_WIDGET; focus |= CTK_FOCUS_WIDGET;
} }
draw_widget(w, posx, posy, draw_widget(w, posx, posy, posx + win->w, posy + win->h, clipy1, clipy2, focus);
posx + win->w,
posy + win->h,
clipy1, clipy2,
focus);
#ifdef CTK_CONIO_CONF_UPDATE #ifdef CTK_CONIO_CONF_UPDATE
CTK_CONIO_CONF_UPDATE(); CTK_CONIO_CONF_UPDATE();
@ -258,10 +251,8 @@ ctk_draw_widget(struct ctk_widget *w,
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void
ctk_draw_clear_window(struct ctk_window *window, ctk_draw_clear_window(struct ctk_window *window, unsigned char focus,
unsigned char focus, unsigned char clipy1, unsigned char clipy2)
unsigned char clipy1,
unsigned char clipy2)
{ {
unsigned char i; unsigned char i;
unsigned char h; unsigned char h;
@ -293,9 +284,7 @@ draw_window_contents(struct ctk_window *window, unsigned char focus,
/* Draw inactive widgets. */ /* Draw inactive widgets. */
for(w = window->inactive; w != NULL; w = w->next) { for(w = window->inactive; w != NULL; w = w->next) {
draw_widget(w, x1, y1, x2, y2, draw_widget(w, x1, y1, x2, y2, clipy1, clipy2, focus);
clipy1, clipy2,
focus);
} }
/* Draw active widgets. */ /* Draw active widgets. */
@ -305,9 +294,7 @@ draw_window_contents(struct ctk_window *window, unsigned char focus,
wfocus |= CTK_FOCUS_WIDGET; wfocus |= CTK_FOCUS_WIDGET;
} }
draw_widget(w, x1, y1, x2, y2, draw_widget(w, x1, y1, x2, y2, clipy1, clipy2, wfocus);
clipy1, clipy2,
wfocus);
} }
#ifdef CTK_CONIO_CONF_UPDATE #ifdef CTK_CONIO_CONF_UPDATE
@ -373,8 +360,7 @@ ctk_draw_window(struct ctk_window *window, unsigned char focus,
cvlinexy(x, y1, h); cvlinexy(x, y1, h);
cvlinexy(x2, y1, h); cvlinexy(x2, y1, h);
if(y + window->h >= clipy1 && if(y + window->h >= clipy1 && y + window->h < clipy2) {
y + window->h < clipy2) {
cputcxy(x, y2, (char)CH_LLCORNER); cputcxy(x, y2, (char)CH_LLCORNER);
chlinexy(x1, y2, window->w); chlinexy(x1, y2, window->w);
cputcxy(x2, y2, (char)CH_LRCORNER); cputcxy(x2, y2, (char)CH_LRCORNER);
@ -403,15 +389,11 @@ ctk_draw_dialog(struct ctk_window *dialog)
y2 = y1 + dialog->h; y2 = y1 + dialog->h;
/* Draw dialog frame. */ /* Draw dialog frame. */
cvlinexy(x, y1, cvlinexy(x, y1, dialog->h);
dialog->h); cvlinexy(x2, y1, dialog->h);
cvlinexy(x2, y1,
dialog->h);
chlinexy(x1, y, chlinexy(x1, y, dialog->w);
dialog->w); chlinexy(x1, y2, dialog->w);
chlinexy(x1, y2,
dialog->w);
cputcxy(x, y, (char)CH_ULCORNER); cputcxy(x, y, (char)CH_ULCORNER);
cputcxy(x, y2, (char)CH_LLCORNER); cputcxy(x, y2, (char)CH_LLCORNER);
@ -423,8 +405,7 @@ ctk_draw_dialog(struct ctk_window *dialog)
cclearxy(x1, i, dialog->w); cclearxy(x1, i, dialog->w);
} }
draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey, draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey, x1, x2, y1, y2);
x1, x2, y1, y2);
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void

View file

@ -44,7 +44,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ctk.c,v 1.15 2007/12/15 20:46:15 oliverschmidt Exp $ * $Id: ctk.c,v 1.16 2007/12/15 21:04:20 oliverschmidt Exp $
* *
*/ */
@ -248,7 +248,6 @@ ctk_restore(void)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** /**
* \addtogroup ctkappfunc * \addtogroup ctkappfunc
* @{ * @{
@ -298,15 +297,6 @@ void
ctk_icon_add(CC_REGISTER_ARG struct ctk_widget *icon, struct process *p) ctk_icon_add(CC_REGISTER_ARG struct ctk_widget *icon, struct process *p)
{ {
#if CTK_CONF_ICONS #if CTK_CONF_ICONS
/* icon->x = iconx;
icon->y = icony;
icon->widget.icon.owner = id;
icony += ICONY_DELTA;
if(icony >= ICONY_MAX) {
icony = ICONY_START;
iconx += ICONX_DELTA;
}*/
icon->widget.icon.owner = p; icon->widget.icon.owner = p;
ctk_widget_add(&desktop_window, icon); ctk_widget_add(&desktop_window, icon);
arrange_icons(); arrange_icons();
@ -409,8 +399,7 @@ ctk_window_close(struct ctk_window *w)
return; return;
} }
/* Check if the window to be closed is the first window on the /* Check if the window to be closed is the first window on the list. */
list. */
if(w == windows) { if(w == windows) {
windows = w->next; windows = w->next;
if(windows != NULL) { if(windows != NULL) {
@ -424,8 +413,7 @@ ctk_window_close(struct ctk_window *w)
for(w2 = windows; w2 != NULL && w2->next != w; w2 = w2->next); for(w2 = windows; w2 != NULL && w2->next != w; w2 = w2->next);
if(w2 == NULL) { if(w2 == NULL) {
/* The window wasn't open, so there is nothing more for us to /* The window wasn't open, so there is nothing more for us to do. */
do. */
return; return;
} }
@ -569,8 +557,7 @@ do_redraw_all(unsigned char clipy1, unsigned char clipy2)
unsigned char focus; unsigned char focus;
#endif /* CTK_CONF_WINDOWS */ #endif /* CTK_CONF_WINDOWS */
if(mode != CTK_MODE_NORMAL && if(mode != CTK_MODE_NORMAL && mode != CTK_MODE_WINDOWMOVE) {
mode != CTK_MODE_WINDOWMOVE) {
return; return;
} }
@ -633,9 +620,7 @@ void
ctk_desktop_redraw(struct ctk_desktop *d) ctk_desktop_redraw(struct ctk_desktop *d)
{ {
if(PROCESS_CURRENT() == &ctk_process) { if(PROCESS_CURRENT() == &ctk_process) {
if(mode == CTK_MODE_NORMAL || if(mode == CTK_MODE_NORMAL || mode == CTK_MODE_WINDOWMOVE) {
mode == CTK_MODE_WINDOWMOVE) {
do_redraw_all(CTK_CONF_MENUS, height); do_redraw_all(CTK_CONF_MENUS, height);
} }
} else { } else {
@ -690,8 +675,7 @@ ctk_window_redraw(struct ctk_window *w)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
window_new(CC_REGISTER_ARG struct ctk_window *window, window_new(CC_REGISTER_ARG struct ctk_window *window,
unsigned char w, unsigned char h, unsigned char w, unsigned char h, char *title)
char *title)
{ {
#if CTK_CONF_WINDOWS #if CTK_CONF_WINDOWS
if(w >= width - 2) { if(w >= width - 2) {
@ -742,8 +726,7 @@ window_new(CC_REGISTER_ARG struct ctk_window *window,
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
ctk_window_new(struct ctk_window *window, ctk_window_new(struct ctk_window *window,
unsigned char w, unsigned char h, unsigned char w, unsigned char h, char *title)
char *title)
{ {
window_new(window, w, h, title); window_new(window, w, h, title);
@ -785,8 +768,7 @@ ctk_dialog_new(CC_REGISTER_ARG struct ctk_window *dialog,
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
ctk_menu_new(CC_REGISTER_ARG struct ctk_menu *menu, ctk_menu_new(CC_REGISTER_ARG struct ctk_menu *menu, char *title)
char *title)
{ {
#if CTK_CONF_MENUS #if CTK_CONF_MENUS
menu->next = NULL; menu->next = NULL;
@ -811,8 +793,7 @@ ctk_menu_new(CC_REGISTER_ARG struct ctk_menu *menu,
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
unsigned char unsigned char
ctk_menuitem_add(CC_REGISTER_ARG struct ctk_menu *menu, ctk_menuitem_add(CC_REGISTER_ARG struct ctk_menu *menu, char *name)
char *name)
{ {
#if CTK_CONF_MENUS #if CTK_CONF_MENUS
if(menu->nitems == CTK_MAXMENUITEMS) { if(menu->nitems == CTK_MAXMENUITEMS) {
@ -949,9 +930,6 @@ ctk_widget_add(CC_REGISTER_ARG struct ctk_window *window,
widget->next = window->active; widget->next = window->active;
window->active = widget; window->active = widget;
widget->window = window; widget->window = window;
/* if(window->focused == NULL) {
window->focused = widget;
}*/
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -1111,12 +1089,6 @@ switch_open_menu(unsigned char rightleft)
} }
menus.open->active = 0; menus.open->active = 0;
/* if(menus.open->nitems > maxnitems) {
maxnitems = menus.open->nitems;
}*/
/* ctk_desktop_redraw();*/
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
@ -1197,8 +1169,7 @@ activate(CC_REGISTER_ARG struct ctk_widget *w)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void CC_FASTCALL static void CC_FASTCALL
textentry_input(ctk_arch_key_t c, textentry_input(ctk_arch_key_t c, CC_REGISTER_ARG struct ctk_textentry *t)
CC_REGISTER_ARG struct ctk_textentry *t)
{ {
register char *cptr, *cptr2; register char *cptr, *cptr2;
static unsigned char len, txpos, typos, tlen; static unsigned char len, txpos, typos, tlen;
@ -1239,7 +1210,6 @@ textentry_input(ctk_arch_key_t c,
break; break;
case CH_ENTER: case CH_ENTER:
/* t->state = CTK_TEXTENTRY_NORMAL;*/
activate((struct ctk_widget *)t); activate((struct ctk_widget *)t);
switch_focus_widget(DOWN); switch_focus_widget(DOWN);
break; break;
@ -1309,16 +1279,13 @@ activate_menu(void)
static unsigned char static unsigned char
menus_input(ctk_arch_key_t c) menus_input(ctk_arch_key_t c)
{ {
if(menus.open->nitems > maxnitems) { if(menus.open->nitems > maxnitems) {
maxnitems = menus.open->nitems; maxnitems = menus.open->nitems;
} }
switch(c) { switch(c) {
case CH_CURS_RIGHT: case CH_CURS_RIGHT:
switch_open_menu(1); switch_open_menu(1);
return REDRAW_MENUPART; return REDRAW_MENUPART;
case CH_CURS_DOWN: case CH_CURS_DOWN:
@ -1629,9 +1596,6 @@ PROCESS_THREAD(ctk_process, ev, data)
if(windows != NULL && if(windows != NULL &&
window != windows && window != windows &&
windows->focused != NULL){ windows->focused != NULL){
/*add_redrawwidget(windows->focused);
windows->focused = NULL;
redraw |= REDRAW_WIDGETS;*/
unfocus_widget(windows->focused); unfocus_widget(windows->focused);
} }
@ -1681,13 +1645,6 @@ PROCESS_THREAD(ctk_process, ev, data)
redraw it. */ redraw it. */
if(window->focused != NULL && if(window->focused != NULL &&
widget != window->focused) { widget != window->focused) {
/* add_redrawwidget(window->focused);
if(CTK_WIDGET_TYPE(window->focused) ==
CTK_WIDGET_TEXTENTRY) {
((struct ctk_textentry *)(window->focused))->state =
CTK_TEXTENTRY_NORMAL;
}
window->focused = NULL;*/
unfocus_widget(window->focused); unfocus_widget(window->focused);
} }
redraw |= REDRAW_WIDGETS; redraw |= REDRAW_WIDGETS;
@ -1793,7 +1750,6 @@ PROCESS_THREAD(ctk_process, ev, data)
textentry_input(c, (struct ctk_textentry *)widget); textentry_input(c, (struct ctk_textentry *)widget);
add_redrawwidget(widget); add_redrawwidget(widget);
} else { } else {
/* window->focused = NULL;*/
unfocus_widget(window->focused); unfocus_widget(window->focused);
process_post_synch(window->owner, ctk_signal_keypress, process_post_synch(window->owner, ctk_signal_keypress,
(process_data_t)(size_t)c); (process_data_t)(size_t)c);