#include <allegro.h>
#include <stdio.h>



int blanco_fondo,azul_fondo,color_agenda,agenda_claro,agenda_oscuro,midx,midy,letras,letra_oscura,i;
int opcion,salir;
char caracter;
BITMAP *boton,*boton2,*boton3,*boton4,*boton5,*botonsal;
PALETTE pal,pal2,pal3,pal4,pal5,palsal;
FILE *fichero;

#define LEN 32
#define MAX_BYTES_PER_CHAR 6
char nombre[(LEN + 1) * MAX_BYTES_PER_CHAR] = "nombre identificativo de tarea";
char descripcion[(LEN + 1) * MAX_BYTES_PER_CHAR] = "descripcion (breve) de tarea";
char hora[(LEN + 1) * MAX_BYTES_PER_CHAR] = "hora";
char minutos[(LEN + 1) * MAX_BYTES_PER_CHAR] = "minutos";
char segundos[(LEN + 1) * MAX_BYTES_PER_CHAR] = "segundos";
char dia[(LEN + 1) * MAX_BYTES_PER_CHAR] = "dia";
char mes[(LEN + 1) * MAX_BYTES_PER_CHAR] = "mes";
char anio[(LEN + 1) * MAX_BYTES_PER_CHAR] = "anio";
char prioridad[(LEN + 1) * MAX_BYTES_PER_CHAR] = "prioridad";

/* for the d_textbox_proc object */
char the_text[] = "Bienvenido a la agenda de Sofi Saltana.\nElija la opcion que le apetezca y apunte los datos en el cuadro de la derecha.";

void limpia_recuadro_adjunto()
{
   acquire_screen();
   rectfill(screen,3*midx/2-120,midy-110,SCREEN_W,SCREEN_H,azul_fondo);
   release_screen();
}

void pinta_recuadro_adjunto()
{
   acquire_screen();
   rectfill(screen,3*midx/2-120,midy-110,3*midx/2+150,midy-105,agenda_claro);
   rectfill(screen,3*midx/2-120,midy-105,3*midx/2+150,midy+40,color_agenda);
   rectfill(screen,3*midx/2-120,midy+40,3*midx/2+150,midy+45,agenda_oscuro);
   release_screen();
}

void pinta_agenda()
{
   /*se llama a esta función para que sea mas rapido pintar en pantalla*/
   acquire_screen();
   clear_to_color(screen, azul_fondo);
   
//------------------------pinta el cuadro de la agenda----------------------------   
   rectfill(screen,midx/2-140,midy/2-20,3*midx/2-140,3*midy/2+20,color_agenda);
   rectfill(screen,midx/2-140,midy/2-20,3*midx/2-140,midy/2-5,agenda_claro);
   rectfill(screen,midx/2-140,3*midy/2+5,3*midx/2-140,3*midy/2+20,agenda_oscuro);

//--------------------pinta el cuadro de dialogo de la agenda---------------------   
   vline(screen,midx-320,midy-140,midy-90,agenda_oscuro);
   vline(screen,midx+40,midy-140,midy-90,agenda_oscuro);
   hline(screen,midx-320,midy-90,midx+40,agenda_oscuro);
   hline(screen,midx-320,midy-140,midx+40,agenda_oscuro);
   
   vline(screen,midx-315,midy-135,midy-95,agenda_oscuro);
   vline(screen,midx+35,midy-135,midy-95,agenda_oscuro);
   hline(screen,midx-315,midy-95,midx+35,agenda_oscuro);
   hline(screen,midx-315,midy-135,midx+35,agenda_oscuro);
   
   floodfill(screen, midx-317, midy-137, agenda_oscuro);
  
   show_mouse(screen);
   /*si se ha llamado a la funcion acquire screen, siempre hay que llamar a esta funcion antes
   de cualquier otra operacion de entrada de datos*/
   release_screen();
}
/* Apunta en un registro un valor que servirá para que la función main sepa que
 se ha pulsado este botón*/
int aniadir(void)
{
    opcion=1;
    return D_EXIT;
}

int eliminar(void)
{
    opcion=2;
    return D_EXIT;
}

int aumentar(void)
{
    opcion=3;
    return D_EXIT;
}

int disminuir(void)
{
    opcion=4;
    return D_EXIT;
}

int listar(void)
{
    opcion=5;
    return D_EXIT;
}

int quit(void)
{
   if (alert("Really Quit?", NULL, NULL, "&Yes", "&No", 'y', 'n') == 1)
   {
      salir=1;
      return D_CLOSE;
   }
   else
      return D_O_K;
}

int kita(void)
{
   
   int semaforo=0;
   semaforo=alert3("Quiere guardar los cambios del fichero?", NULL, NULL, "&Si", "&No","&Cancelar", 'y', 'n','c');
   if (semaforo == 1)
   {
      fprintf(fichero,"Nombre: %s",nombre);
      return D_CLOSE;
   }
   else if (semaforo == 2)
      return D_CLOSE;
   else
      return D_REDRAW;
}

/* A custom dialog procedure, derived from d_button_proc. It intercepts
 * the D_CLOSE return of d_button_proc, and calls the function in dp3.
 */
int my_icon_proc (int msg, DIALOG *d, int c)
{
   int ret = d_icon_proc (msg, d, c);
   if (ret == D_CLOSE && d->dp3)
      return ((int (*)(void))d->dp3)();
   return ret;
}
int my_button_proc (int msg, DIALOG *d, int c)
{
   int ret = d_button_proc (msg, d, c);
   if (ret == D_CLOSE && d->dp3)
      return ((int (*)(void))d->dp3)();
   return ret;
}
DIALOG aniadetarea[] =
{
   
   { d_text_proc,             5,     5,    0,    0,     0,   -1,     0,       0,    0,   0,             "nombre",   NULL,        NULL},
   { d_text_proc,             5,    29,    0,    0,     0,   -1,     0,       0,    0,   0,        "descripcion",   NULL,        NULL},
   { d_text_proc,             5,    45,    0,    0,     0,   -1,     0,       0,    0,   0,               "hora",   NULL,        NULL},
   { d_text_proc,            90,    45,    0,    0,     0,   -1,     0,       0,    0,   0,            "minutos",   NULL,        NULL},
   { d_text_proc,           145,    45,    0,    0,     0,   -1,     0,       0,    0,   0,           "segundos",   NULL,        NULL},
   { d_text_proc,             5,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "dia",   NULL,        NULL},
   { d_text_proc,            60,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "mes",   NULL,        NULL},
   { d_text_proc,           115,    61,    0,    0,     0,   -1,     0,       0,    0,   0,               "anio",   NULL,        NULL},
   { d_text_proc,             5,    77,    0,    0,     0,   -1,     0,       0,    0,   0,          "prioridad",   NULL,        NULL},
   
   { d_edit_proc,            10,    13,  200,   32,     0,   -1,     0,       0,  LEN,   0,       (void *)nombre,   NULL,        NULL},
   { d_edit_proc,            10,    37,  200,   32,     0,   -1,     0,       0,  LEN,   0,  (void *)descripcion,   NULL,        NULL},
   { d_edit_proc,            10,    53,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)hora,   NULL,        NULL},
   { d_edit_proc,            65,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,      (void *)minutos,   NULL,        NULL},
   { d_edit_proc,           150,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,     (void *)segundos,   NULL,        NULL},
   { d_edit_proc,            10,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)dia,   NULL,        NULL},
   { d_edit_proc,            65,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)mes,   NULL,        NULL},
   { d_edit_proc,           120,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)anio,   NULL,        NULL},
   { d_edit_proc,            10,    85,  100,   32,     0,   -1,     0,       0,  LEN,   0,    (void *)prioridad,   NULL,        NULL},
   { my_icon_proc,          100,   110,  162,   31,     0,   -1,   's',  D_EXIT,    0,   0,                 NULL,   NULL,(void *)kita},
   { NULL,                    0,     0,    0,    0,     0,    0,     0,       0,    0,   0,                 NULL,   NULL,        NULL}
};
//escribir los dialogos eliminatarea, aumentar_prioridad y disminuir_prioridad
DIALOG eliminatarea[] =
{
   
   { d_text_proc,             5,     5,    0,    0,     0,   -1,     0,       0,    0,   0,             "nombre",   NULL,        NULL},
   { d_text_proc,             5,    29,    0,    0,     0,   -1,     0,       0,    0,   0,        "descripcion",   NULL,        NULL},
   { d_text_proc,             5,    45,    0,    0,     0,   -1,     0,       0,    0,   0,               "hora",   NULL,        NULL},
   { d_text_proc,            90,    45,    0,    0,     0,   -1,     0,       0,    0,   0,            "minutos",   NULL,        NULL},
   { d_text_proc,           145,    45,    0,    0,     0,   -1,     0,       0,    0,   0,           "segundos",   NULL,        NULL},
   { d_text_proc,             5,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "dia",   NULL,        NULL},
   { d_text_proc,            60,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "mes",   NULL,        NULL},
   { d_text_proc,           115,    61,    0,    0,     0,   -1,     0,       0,    0,   0,               "anio",   NULL,        NULL},
   { d_text_proc,             5,    77,    0,    0,     0,   -1,     0,       0,    0,   0,          "prioridad",   NULL,        NULL},
   
   { d_edit_proc,            10,    13,  200,   32,     0,   -1,     0,       0,  LEN,   0,       (void *)nombre,   NULL,        NULL},
   { d_edit_proc,            10,    37,  200,   32,     0,   -1,     0,       0,  LEN,   0,  (void *)descripcion,   NULL,        NULL},
   { d_edit_proc,            10,    53,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)hora,   NULL,        NULL},
   { d_edit_proc,            65,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,      (void *)minutos,   NULL,        NULL},
   { d_edit_proc,           150,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,     (void *)segundos,   NULL,        NULL},
   { d_edit_proc,            10,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)dia,   NULL,        NULL},
   { d_edit_proc,            65,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)mes,   NULL,        NULL},
   { d_edit_proc,           120,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)anio,   NULL,        NULL},
   { d_edit_proc,            10,    85,  100,   32,     0,   -1,     0,       0,  LEN,   0,    (void *)prioridad,   NULL,        NULL},
   { my_button_proc,        100,   110,  160,   20,     0,   -1,   's',  D_EXIT,    0,   0,             "&Salir",   NULL,(void *)kita},
   { NULL,                    0,     0,    0,    0,     0,    0,     0,       0,    0,   0,                 NULL,   NULL,        NULL}
};
DIALOG aumentar_prioridad[] =
{
   
   { d_text_proc,             5,     5,    0,    0,     0,   -1,     0,       0,    0,   0,             "nombre",   NULL,        NULL},
   { d_text_proc,             5,    29,    0,    0,     0,   -1,     0,       0,    0,   0,        "descripcion",   NULL,        NULL},
   { d_text_proc,             5,    45,    0,    0,     0,   -1,     0,       0,    0,   0,               "hora",   NULL,        NULL},
   { d_text_proc,            90,    45,    0,    0,     0,   -1,     0,       0,    0,   0,            "minutos",   NULL,        NULL},
   { d_text_proc,           145,    45,    0,    0,     0,   -1,     0,       0,    0,   0,           "segundos",   NULL,        NULL},
   { d_text_proc,             5,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "dia",   NULL,        NULL},
   { d_text_proc,            60,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "mes",   NULL,        NULL},
   { d_text_proc,           115,    61,    0,    0,     0,   -1,     0,       0,    0,   0,               "anio",   NULL,        NULL},
   { d_text_proc,             5,    77,    0,    0,     0,   -1,     0,       0,    0,   0,          "prioridad",   NULL,        NULL},
   
   { d_edit_proc,            10,    13,  200,   32,     0,   -1,     0,       0,  LEN,   0,       (void *)nombre,   NULL,        NULL},
   { d_edit_proc,            10,    37,  200,   32,     0,   -1,     0,       0,  LEN,   0,  (void *)descripcion,   NULL,        NULL},
   { d_edit_proc,            10,    53,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)hora,   NULL,        NULL},
   { d_edit_proc,            65,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,      (void *)minutos,   NULL,        NULL},
   { d_edit_proc,           150,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,     (void *)segundos,   NULL,        NULL},
   { d_edit_proc,            10,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)dia,   NULL,        NULL},
   { d_edit_proc,            65,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)mes,   NULL,        NULL},
   { d_edit_proc,           120,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)anio,   NULL,        NULL},
   { d_edit_proc,            10,    85,  100,   32,     0,   -1,     0,       0,  LEN,   0,    (void *)prioridad,   NULL,        NULL},
   { my_button_proc,        100,   110,  160,   20,     0,   -1,   's',  D_EXIT,    0,   0,             "&Salir",   NULL,(void *)kita},
   { NULL,                    0,     0,    0,    0,     0,    0,     0,       0,    0,   0,                 NULL,   NULL,        NULL}
};
DIALOG disminuir_prioridad[] =
{
   
   { d_text_proc,             5,     5,    0,    0,     0,   -1,     0,       0,    0,   0,             "nombre",   NULL,        NULL},
   { d_text_proc,             5,    29,    0,    0,     0,   -1,     0,       0,    0,   0,        "descripcion",   NULL,        NULL},
   { d_text_proc,             5,    45,    0,    0,     0,   -1,     0,       0,    0,   0,               "hora",   NULL,        NULL},
   { d_text_proc,            90,    45,    0,    0,     0,   -1,     0,       0,    0,   0,            "minutos",   NULL,        NULL},
   { d_text_proc,           145,    45,    0,    0,     0,   -1,     0,       0,    0,   0,           "segundos",   NULL,        NULL},
   { d_text_proc,             5,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "dia",   NULL,        NULL},
   { d_text_proc,            60,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "mes",   NULL,        NULL},
   { d_text_proc,           115,    61,    0,    0,     0,   -1,     0,       0,    0,   0,               "anio",   NULL,        NULL},
   { d_text_proc,             5,    77,    0,    0,     0,   -1,     0,       0,    0,   0,          "prioridad",   NULL,        NULL},
   
   { d_edit_proc,            10,    13,  200,   32,     0,   -1,     0,       0,  LEN,   0,       (void *)nombre,   NULL,        NULL},
   { d_edit_proc,            10,    37,  200,   32,     0,   -1,     0,       0,  LEN,   0,  (void *)descripcion,   NULL,        NULL},
   { d_edit_proc,            10,    53,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)hora,   NULL,        NULL},
   { d_edit_proc,            65,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,      (void *)minutos,   NULL,        NULL},
   { d_edit_proc,           150,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,     (void *)segundos,   NULL,        NULL},
   { d_edit_proc,            10,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)dia,   NULL,        NULL},
   { d_edit_proc,            65,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)mes,   NULL,        NULL},
   { d_edit_proc,           120,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)anio,   NULL,        NULL},
   { d_edit_proc,            10,    85,  100,   32,     0,   -1,     0,       0,  LEN,   0,    (void *)prioridad,   NULL,        NULL},
   { my_button_proc,        100,   110,  160,   20,     0,   -1,   's',  D_EXIT,    0,   0,             "&Salir",   NULL,(void *)kita},
   { NULL,                    0,     0,    0,    0,     0,    0,     0,       0,    0,   0,                 NULL,   NULL,        NULL}
};
DIALOG listar_tarea[] =
{
   
   { d_text_proc,             5,     5,    0,    0,     0,   -1,     0,       0,    0,   0,             "nombre",   NULL,        NULL},
   { d_text_proc,             5,    29,    0,    0,     0,   -1,     0,       0,    0,   0,        "descripcion",   NULL,        NULL},
   { d_text_proc,             5,    45,    0,    0,     0,   -1,     0,       0,    0,   0,               "hora",   NULL,        NULL},
   { d_text_proc,            90,    45,    0,    0,     0,   -1,     0,       0,    0,   0,            "minutos",   NULL,        NULL},
   { d_text_proc,           145,    45,    0,    0,     0,   -1,     0,       0,    0,   0,           "segundos",   NULL,        NULL},
   { d_text_proc,             5,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "dia",   NULL,        NULL},
   { d_text_proc,            60,    61,    0,    0,     0,   -1,     0,       0,    0,   0,                "mes",   NULL,        NULL},
   { d_text_proc,           115,    61,    0,    0,     0,   -1,     0,       0,    0,   0,               "anio",   NULL,        NULL},
   { d_text_proc,             5,    77,    0,    0,     0,   -1,     0,       0,    0,   0,          "prioridad",   NULL,        NULL},
   
   { d_edit_proc,            10,    13,  200,   32,     0,   -1,     0,       0,  LEN,   0,       (void *)nombre,   NULL,        NULL},
   { d_edit_proc,            10,    37,  200,   32,     0,   -1,     0,       0,  LEN,   0,  (void *)descripcion,   NULL,        NULL},
   { d_edit_proc,            10,    53,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)hora,   NULL,        NULL},
   { d_edit_proc,            65,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,      (void *)minutos,   NULL,        NULL},
   { d_edit_proc,           150,    53,   80,   32,     0,   -1,     0,       0,  LEN,   0,     (void *)segundos,   NULL,        NULL},
   { d_edit_proc,            10,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)dia,   NULL,        NULL},
   { d_edit_proc,            65,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,          (void *)mes,   NULL,        NULL},
   { d_edit_proc,           120,    69,   50,   32,     0,   -1,     0,       0,  LEN,   0,         (void *)anio,   NULL,        NULL},
   { d_edit_proc,            10,    85,  100,   32,     0,   -1,     0,       0,  LEN,   0,    (void *)prioridad,   NULL,        NULL},
   { my_button_proc,        100,   110,  160,   20,     0,   -1,   's',  D_EXIT,    0,   0,             "&Salir",   NULL,(void *)kita},
   { NULL,                    0,     0,    0,    0,     0,    0,     0,       0,    0,   0,                 NULL,   NULL,        NULL}
};
DIALOG the_dialog[] =
{
   /* (dialog proc)          (x)    (y)   (w)   (h)   (fg)  (bg)  (key)  (flags)  (d1) (d2)                 (dp)     dp2)         (dp3) */
   { my_icon_proc,           0,    85,  156,   32,     0,   -1,   'a',  D_EXIT,    0,   0,                  NULL,   NULL,  (void *)aniadir},
   { my_icon_proc,           0,   135,  156,   31,     0,   -1,   'e',  D_EXIT,    0,   0,                  NULL,   NULL, (void *)eliminar},
   { my_icon_proc,           0,   185,  156,   32,     0,   -1,   'm',  D_EXIT,    0,   0,                  NULL,   NULL, (void *)aumentar},
   { my_icon_proc,           0,   235,  156,   32,     0,   -1,   'd',  D_EXIT,    0,   0,                  NULL,   NULL,(void *)disminuir},
   { my_icon_proc,         195,    85,  162,   31,     0,   -1,   'd',  D_EXIT,    0,   0,                  NULL,   NULL,   (void *)listar},
   { d_textbox_proc,         0,     0,  349,   39,     0,  125,     0,       0,    0,   0,      (void *)the_text,   NULL,             NULL},
   { my_icon_proc,         195,   235,  162,   31,     0,   -1,   's',  D_EXIT,    0,   0,                  NULL,   NULL,     (void *)quit},
   { NULL,                   0,     0,    0,    0,     0,    0,     0,       0,    0,   0,                  NULL,   NULL,             NULL}
};

int main(int argc,char *argv[])
{
   if ((fichero=fopen("tareas.txt","r+t")) ==NULL){
   allegro_message("Error al abrir fichero.");
    }
   else
   allegro_message("fichero ABIERTO.");
   
   allegro_init();
   install_keyboard();
   install_mouse();
   install_timer();
   
   
   if ( set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1024, 768, 0, 0) < 0 ) 
   { 
      allegro_message("Error al inicializar modo grafico."); 
      exit(1); 
   }

   azul_fondo=makecol(124,169,243);
   color_agenda=makecol(248,197,129);
   agenda_claro=makecol(251,218,172);
   agenda_oscuro=makecol(244,165,57);
   blanco_fondo=makecol(254,235,195);
   letras=makecol(153,153,153);
   letra_oscura=makecol(130,130,130);
      
   midx=SCREEN_W/2;
   midy=SCREEN_H/2;
   
   

   
   pinta_agenda();
   salir=0;

   position_dialog (the_dialog, midx-314, midy-134);
   position_dialog (aniadetarea, 3*midx/2-110, midy-100);
   position_dialog (eliminatarea, 3*midx/2-110, midy-100);
   position_dialog (aumentar_prioridad, 3*midx/2-110, midy-100);
   position_dialog (disminuir_prioridad, 3*midx/2-110, midy-100);
      
   gui_fg_color = letras;
   gui_mg_color = agenda_oscuro;
   gui_bg_color = color_agenda;
   set_dialog_color (the_dialog, gui_fg_color, gui_bg_color);

   the_dialog[4].fg = letras;
   the_dialog[4].bg = color_agenda;
   the_dialog[1].fg = letras;
   the_dialog[1].bg = agenda_claro;
   the_dialog[2].fg = letras;
   the_dialog[2].bg = color_agenda;
   
   for(i=0;i<9;i++)
   {
       aniadetarea[i].fg = letra_oscura;
       aniadetarea[i].bg = color_agenda;
   }
   for(i=9;i<18;i++)
   {
       aniadetarea[i].fg = letras;
       aniadetarea[i].bg = agenda_claro;
   }
   
   aniadetarea[18].fg = letras;
   aniadetarea[18].bg = color_agenda;
   
   boton = load_bitmap("boton.bmp", pal);
   the_dialog[0].dp = boton;
   boton2 = load_bitmap("boton2.bmp", pal2);
   the_dialog[1].dp = boton2;
   boton3 = load_bitmap("boton3.bmp", pal3);
   the_dialog[2].dp = boton3;
   boton4 = load_bitmap("boton4.bmp", pal4);
   the_dialog[3].dp = boton4;
   boton5 = load_bitmap("boton5.bmp", pal5);
   the_dialog[4].dp = boton5;
   botonsal = load_bitmap("botonsal.bmp", palsal);
   the_dialog[6].dp = botonsal;
   aniadetarea[18].dp=botonsal;
   
   do
   {
       do_dialog(the_dialog, -1);
       switch(opcion)
       {
           case 1:
                pinta_recuadro_adjunto(); 
                do_dialog(aniadetarea, -1);
                limpia_recuadro_adjunto();
                opcion=0;
                break;
           case 2:
                pinta_recuadro_adjunto(); 
                do_dialog(eliminatarea, -1);
                limpia_recuadro_adjunto();
                opcion=0;
                break;
           case 3:
                pinta_recuadro_adjunto(); 
                do_dialog(aumentar_prioridad, -1);
                limpia_recuadro_adjunto();
                opcion=0;
                break;
           case 4:
                pinta_recuadro_adjunto(); 
                do_dialog(disminuir_prioridad, -1);
                limpia_recuadro_adjunto();
                opcion=0;
                break;
           case 5:
                pinta_recuadro_adjunto(); 
                do_dialog(listar_tarea, -1);
                limpia_recuadro_adjunto();
                opcion=0;
                break;
       }
   }while(salir==0);
   
   fclose(fichero);

   allegro_exit();  
   return 0; 
}END_OF_MAIN()
