File: dialog.c | Size: 2,564 bytes | Download file | Back to directory listing | BWPOW's homepage
/*
    expC - Expressions analyzator and viewer
    Copyright (C) 2004 Samuel Kupka
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
 
#include <stdio.h>
#include <string.h>
#include <allegro.h>
 
#include "expC.h"
 
char vyrok[512];
 
DIALOG the_vyrok_dialog[] =
{
   /* (dialog proc)     (x)   (y)   (w)   (h)   (fg)  (bg)  (key) (flags)  (d1) (d2)  (dp)           (dp2) (dp3) */
   { d_shadow_box_proc,   0,   0,    500, 120,   0,    0,    0,        0,   0,   0, NULL, NULL, NULL },
   { d_button_proc,     400,   80,    90,  30, 255,    0,   13,   D_EXIT,   0,   0, "OK",       NULL, NULL  },
   { d_button_proc,     300,   80,    90,  30,   0,    0,    0,   D_EXIT,   0,   0, "Validate",   NULL, NULL  },
   { d_ctext_proc,      250,   12,     0,   0,   0,    0,    0,        0,   0,   0, "_______________",    NULL, NULL  },
   { d_ctext_proc,      250,   10,     0,   0,   0,    0,    0,        0,   0,   0, "Editacia vyroku",    NULL, NULL  },
   { d_text_proc,        10,   45,     0,   0,   0,    0,    0,        0,   0,   0, "Vyrok:",    NULL, NULL  },
   { d_edit_proc,        70,   45,   420,  48,   0,    0,    0,        0, 128,   0, vyrok,    NULL, NULL  },
 
   { NULL,              0,    0,    0,    0,    0,    0,    0,    0,       0,   0,    NULL,          NULL, NULL  }
};
 
int vdialog_show(void)
{
  int r,a;
  char temp[512];
 
  centre_dialog(the_vyrok_dialog);
	set_dialog_color(the_vyrok_dialog,makecol(50,50,50),makecol(228, 228, 228));
 
  the_vyrok_dialog[6].fg=makecol(200,200,200);
  the_vyrok_dialog[6].bg=makecol(128,128,128);
 
  while(1){
    r=do_dialog(the_vyrok_dialog,-1);
    if(r>0){
      strcpy(temp,vyrok);
      a=expr_to_tree(temp);
      if(a==0){
        if(r==1) break;
        if(r==2) alert("Validator","Vyrok vyzera byt v poriadku.",NULL,"&OK",NULL,'o',0);
      }
    }
  }
 
  return 0;
}