/***********************************************************************
* 
*               *****   ***    ***
*                  *   *   *  *   *
*                 *     ***    ***
*                *     *   *  *   *
*               *****   ***    ***
*
* A FREE Finite Elements Analysis Program in ANSI C for the UNIX OS.
*
* Composed and edited and copyright by 
* Professor Dr.-Ing. Frank Rieg, University of Bayreuth, Germany
*
* eMail: 
* frank.rieg@uni-bayreuth.de
* dr.frank.rieg@t-online.de
* 
* V10.0  December 12, 2001
*
* Z88 should compile and run under any UNIX OS and Motif 2.0.
*
* 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, 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; see the file COPYING.  If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
***********************************************************************/ 
/***********************************************************************
* ale88p gibt Alert-Boxen aus (1 int)
* Fuer UNIX
* 23.3.2002 Rieg
***********************************************************************/ 
/***********************************************************************
* UNIX
***********************************************************************/
#ifdef FR_UNIX
#include <z88p.h>
#include <Xm/XmAll.h>
#endif

/***********************************************************************
* Functions, speziell fuer X11
***********************************************************************/
void CB_OK(Widget hcallw,XtPointer data,XmPushButtonCallbackStruct *cbs);

/***********************************************************************
* hier beginnt Function ale88p
***********************************************************************/
int ale88p(int ialert)
{
extern Widget   hform;

extern FR_INT4  LANG;

extern int      IBELL;

extern char     CF_ENTRIES[], CF_BUTTONS[];
extern char     CO_BACKGR[],  CO_FOREGR[], CO_ENTRIES[];
extern char     CF_GRAFICS[], CO_FARBE[];

Widget   	halert;
Arg      	args[40];
Cardinal 	n;

XmString 	cxstring = NULL;

int             idiag;

char            cmess[256];

switch(ialert)
  {
  case AL_NOLOG:
    if(LANG == 1) strcpy(cmess,"Kann Z88P.LOG nicht oeffnen ! STOP !");
    if(LANG == 2) strcpy(cmess,"Cannot open Z88P.LOG ! STOP !");
    idiag= 1;
  break;

  case AL_NODYN:
    if(LANG == 1) strcpy(cmess,"Kann Z88.DYN nicht oeffnen ! STOP !");
    if(LANG == 2) strcpy(cmess,"Cannot open Z88.DYN ! STOP !");
    idiag= 1;
  break;

  case AL_WRONGDYN:
    if(LANG == 1) strcpy(cmess,"Z88.DYN ist falsch ! STOP !");
    if(LANG == 2) strcpy(cmess,"Z88.DYN is  wrong ! STOP !");
    idiag= 1;
  break;

  case AL_NOMEMY:
    if(LANG == 1) strcpy(cmess,"Nicht genug dynamischer Speicher ! STOP !\n\
Abhilfe: Eintraege in Z88.DYN erhoehen.");
    if(LANG == 2) strcpy(cmess,"Dynamic memory exhausted ! STOP !\n\
Recover: increase entries in Z88.DYN .");
    idiag= 1;
  break;

  case AL_NOSTRFI:
    if(LANG == 1) strcpy(cmess,"Strukturfile nicht gefunden !\n\
Anderes Strukturfile im Textfeld *Strukturfile* angeben.");
    if(LANG == 2) strcpy(cmess,"Structure file not found !\n\
Enter a valid filename in textfield *Structure File*.");
    idiag= 2;
  break;   

  case AL_NOO2:
    if(LANG == 1) strcpy(cmess,"Z88O2.TXT nicht gefunden !\n\
Daher keine Anzeige der verformten Struktur.\n\
Zuerst Verformungsrechnung mit Z88F.");
    if(LANG == 2) strcpy(cmess,"Z88O2.TXT not found !\n\
Thus no view of deflected structure.\n\
Start a solver run with Z88F first.");
    idiag= 2;
  break;
    
  case AL_NOO5:
    if(LANG == 1) strcpy(cmess,"Z88O5.TXT nicht gefunden !\n\
Daher keine Anzeige der Vergleichsspannungen.\n\
Zuerst Spannungsberechnung mit Z88D,\nin Z88I3.TXT NINT > 0 setzen.");
    if(LANG == 2) strcpy(cmess,"Z88O5.TXT not found !\n\
Thus no view of von Mises stresses.\n\
Start a stress computation with Z88D,\nchoose NINT > 0 in Z88I3.TXT .");
    idiag= 2;
  break;    

  case AL_NOPLOF:
    if(LANG == 1) strcpy(cmess,"Konnte Plotterfile nicht oeffnen !\n\
File gesperrt ? Attribute ?\nOder Device nicht vorhanden ?");
    if(LANG == 2) strcpy(cmess,"Could not open plotter file !\n\
File locked ? Attributes ?\nDevice not existing ?");
    idiag= 2;
  break;  

  case AL_EXMAXGP:
    if(LANG == 1) strcpy(cmess,"Speicher fuer Gausspunkte ueberschritten !\n\
STOP ! Abhilfe: MAXGP in Z88.DYN erhoehen.");
    if(LANG == 2) strcpy(cmess,"Memory for Gauss points exhausted !\n\
STOP ! Recover: increase MAXGP in Z88.DYN .");
    idiag= 1;
  break;

  case AL_NINT0:
    if(LANG == 1) strcpy(cmess,"Integrationsordnung ist Null: Eckknoten !\n\
STOP ! Neuer Lauf Z88D mit \nNINT > 0 in Z88I3.TXT erforderlich.");
    if(LANG == 2) strcpy(cmess,"Integration constant is zero: corner nodes !\n\
STOP ! Needs a new Z88D run,\nenter NINT > 0 in Z88I3.TXT .");
    idiag= 2;
  break;

  case AL_EXMAXK:
    if(LANG == 1) strcpy(cmess,"Speicher fuer Knoten ueberschritten ! STOP !\n\
Abhilfe: MAXK oder MFACCOMMON in Z88.DYN erhoehen.");
    if(LANG == 2) strcpy(cmess,"Memory for nodes exhausted ! STOP !\n\
Recover: increase MAXK or MFACCOMMON in Z88.DYN .");
    idiag= 1;
  break;

  case AL_EXMAXE:
    if(LANG == 1) strcpy(cmess,"Speicher fuer Elemente ueberschritten !\n\
STOP ! Abhilfe: MAXE oder MFACCOMMON in Z88.DYN erhoehen.");
    if(LANG == 2) strcpy(cmess,"Memory for elements exhausted ! STOP !\n\
Recover: increase MAXE or MFACCOMMON in Z88.DYN .");
    idiag= 1;
  break;

  case AL_WRONGDIM:
    if(LANG == 1) strcpy(cmess,"Falsche Dimension im Structurfile ! STOP !\n\
Abhilfe: Im Strukturfile 2 oder 3 fuer Dimension waehlen.");
    if(LANG == 2) strcpy(cmess,"Wrong dimension in structur file ! STOP !\n\
Recover: enter 2 or 3 for dimension in structure file.");
    idiag= 1;
  break;

  case AL_NO_CF_ENTRIES:
    if(LANG == 1) sprintf(cmess,"Font <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Einen anderen Font waehlen.",CF_ENTRIES);
    if(LANG == 2) sprintf(cmess,"Font <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing font.",CF_ENTRIES);
    idiag= 1;
  break;

  case AL_NO_CF_BUTTONS:
    if(LANG == 1) sprintf(cmess,"Font <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Einen anderen Font waehlen.",CF_BUTTONS);
    if(LANG == 2) sprintf(cmess,"Font <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing font.",CF_BUTTONS);
    idiag= 1;
  break;

  case AL_NO_CO_BACKGR:
    if(LANG == 1) sprintf(cmess,"Farbe <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Eine andere Farbe waehlen.",CO_BACKGR);
    if(LANG == 2) sprintf(cmess,"Color <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing color.",CO_BACKGR);
    idiag= 1;
  break;

  case AL_NO_CO_FOREGR:
    if(LANG == 1) sprintf(cmess,"Farbe <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Eine andere Farbe waehlen.",CO_FOREGR);
    if(LANG == 2) sprintf(cmess,"Color <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing color.",CO_FOREGR);
    idiag= 1;
  break;

  case AL_NO_CO_ENTRIES:
    if(LANG == 1) sprintf(cmess,"Farbe <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Eine andere Farbe waehlen.",CO_ENTRIES);
    if(LANG == 2) sprintf(cmess,"Color <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing color.",CO_ENTRIES);
    idiag= 1;
  break;

  case INF_GENPLOT:
    if(LANG == 1) strcpy(cmess,"Plotter-Datei erzeugt !");
    if(LANG == 2) strcpy(cmess,"Plotter File created !");
    idiag= 3;
  break;

  case AL_NO_GC:
    if(LANG == 1) strcpy(cmess,"Kann Grafikkontext nicht oeffnen ! STOP !");
    if(LANG == 2) strcpy(cmess,"Cannot open Grafics Context ! STOP !");
    idiag= 1;
  break;

  case AL_NO_CF_GRAFICS:
    if(LANG == 1) sprintf(cmess,"Font <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Einen anderen Font waehlen.",CF_GRAFICS);
    if(LANG == 2) sprintf(cmess,"Font <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing font.",CF_GRAFICS);
    idiag= 1;
  break;

  case AL_NO_CO_FARBE:
    if(LANG == 1) sprintf(cmess,"Farbe <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Eine andere Farbe waehlen.",CO_FARBE);
    if(LANG == 2) sprintf(cmess,"Color <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing color.",CO_FARBE);
    idiag= 1;
  break;

  }

/*----------------------------------------------------------------------
* nun die Questionbox
*---------------------------------------------------------------------*/
n = 0;

XtSetArg(args[n], XmNautoUnmanage, TRUE);                           n++;
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;

cxstring = XmStringCreateLtoR(cmess, XmFONTLIST_DEFAULT_TAG);
XtSetArg(args[n], XmNmessageString, cxstring);                      n++;

if(idiag==1) halert = XmCreateErrorDialog(hform, "z88p", args, n);
if(idiag==2) halert = XmCreateQuestionDialog(hform, "z88p", args, n);
if(idiag==3) halert = XmCreateInformationDialog(hform, "z88p", args, n);

XtUnmanageChild(XmMessageBoxGetChild(halert,XmDIALOG_HELP_BUTTON));
XtUnmanageChild(XmMessageBoxGetChild(halert,XmDIALOG_CANCEL_BUTTON));

XtManageChild(halert);

XtAddCallback(halert,XmNokCallback,(XtCallbackProc)CB_OK,(XtPointer)NULL);

XtPopup(XtParent(halert),XtGrabNone);

XBell(XtDisplay(halert),IBELL);

if(cxstring) XmStringFree(cxstring);

return 0;
}  

