X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/e44976130072017b4bd9bcb0444887f480d2a7f2..644f5b4e0e4f92a88f1d9bd31272cac612cd480f:/emufs_gui/form.c?ds=inline diff --git a/emufs_gui/form.c b/emufs_gui/form.c index d86d4b1..b8907a0 100644 --- a/emufs_gui/form.c +++ b/emufs_gui/form.c @@ -80,6 +80,7 @@ void form_agregar_widget(t_Form *f, t_Campo tipo, const char *nombre, unsigned i /* Si se creo wl widget, lo agrego al formulario al final */ if (tmp) { + tmp->modificable = 1; if (f->primero == NULL) { f->primero = f->ultimo = tmp; } else { @@ -91,7 +92,7 @@ void form_agregar_widget(t_Form *f, t_Campo tipo, const char *nombre, unsigned i void form_ejecutar(t_Form *f, int x, int y) { - int offset = 0, my_y, salida; + int offset = 0, my_y, salida, i; t_Widget *tmp = f->primero; my_y = y-1; @@ -114,8 +115,20 @@ void form_ejecutar(t_Form *f, int x, int y) mvwaddstr(f->win, my_y, x, tmp->nombre); waddch(f->win, ':'); waddch(f->win, ' '); - /* TODO : VER QUE SI ES UNA OPCION ES DISTINTO!! */ - mvwaddstr(f->win, my_y, x+offset, tmp->valor); + if (tmp->tipo == INPUT){ + for(i=0; imax; i++) + mvwaddch(f->win, my_y, x+offset+i, ' '); + mvwaddstr(f->win, my_y, x+offset, tmp->valor); + } else { + wmove(f->win, my_y, x+offset); + for(i=0; imax; i++) { + waddch(f->win, '('); + waddch(f->win, ' '); + waddch(f->win, ')'); + waddstr(f->win, tmp->opciones[i]); + waddch(f->win, ' '); + } + } tmp = tmp->sig; } wrefresh(f->win); @@ -126,7 +139,8 @@ void form_ejecutar(t_Form *f, int x, int y) while (tmp) { ++my_y; wmove(f->win, my_y, x+offset); - salida = tmp->ejecutar(f->win, x+offset, my_y, tmp); + if (tmp->modificable) + salida = tmp->ejecutar(f->win, x+offset, my_y, tmp); wrefresh(f->win); tmp = tmp->sig; } @@ -356,3 +370,29 @@ int form_radio(WINDOW *win, int x, int y, t_Widget *w) return 0; } +void form_es_modificable(t_Form *f, const char *widget, int b) +{ + /* Busco el widget */ + t_Widget *tmp = f->primero; + while (tmp) { + if (strcmp(widget, tmp->nombre) == 0) { + tmp->modificable = b; + break; + } + tmp = tmp->sig; + } +} + +void form_set_valor(t_Form *f, const char *widget, const char *s) +{ + /* Busco el widget */ + t_Widget *tmp = f->primero; + while (tmp) { + if (strcmp(widget, tmp->nombre) == 0) { + strcpy(tmp->valor, s); + break; + } + tmp = tmp->sig; + } +} +