/***********************************************************************
* 
*               *****   ***    ***
*                  *   *   *  *   *
*                 *     ***    ***
*                *     *   *  *   *
*               *****   ***    ***
*
* 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 10, 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.
***********************************************************************/ 
/***********************************************************************
* ale88c gibt Alert-Boxen aus (1 int)
* Fuer UNIX
* 23.3.2002 Rieg
***********************************************************************/ 
/***********************************************************************
* UNIX
***********************************************************************/
#ifdef FR_UNIX
#include <z88com.h>
#include <Xm/XmAll.h>
#endif

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

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

extern FR_INT4  LANG;

extern int      IBELL;

extern char     CF_ENTRIES[], CF_FLARGE[], CF_FSMALL[];
extern char     CO_BACKGR[],  CO_FOREGR[], CO_ENTRIES[];

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 Z88COM.LOG nicht oeffnen ! STOP !");
    if(LANG == 2) strcpy(cmess,"Cannot open Z88COM.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_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_FLARGE:
    if(LANG == 1) sprintf(cmess,"Font <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Einen anderen Font waehlen.",CF_FLARGE);
    if(LANG == 2) sprintf(cmess,"Font <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing font.",CF_FLARGE);
    idiag= 1;
  break;

  case AL_NO_CF_FSMALL:
    if(LANG == 1) sprintf(cmess,"Font <%s> in Z88.FCD unbekannt in X ! STOP !\n\
Abhilfe: Einen anderen Font waehlen.",CF_FSMALL);
    if(LANG == 2) sprintf(cmess,"Font <%s> in Z88.FCD unknown in X ! STOP !\n\
Recover: Choose an existing font.",CF_FSMALL);
    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;

  }

/*----------------------------------------------------------------------
* 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, "z88com", args, n);
if(idiag==2) halert = XmCreateQuestionDialog(hform, "z88com", args, n);
if(idiag==3) halert = XmCreateInformationDialog(hform, "z88com", 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;
}  

