/***********************************************************************
* 
*               *****   ***    ***
*                  *   *   *  *   *
*                 *     ***    ***
*                *     *   *  *   *
*               *****   ***    ***
*
* 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
* 
* V11.0  December 12, 2003
*
* 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.
***********************************************************************/ 
/***********************************************************************
* Z88P fuer X11
* 9.2.2004 Rieg
***********************************************************************/

/***********************************************************************
* Includes
***********************************************************************/
/*----------------------------------------------------------------------------
* UNIX
*---------------------------------------------------------------------------*/
#ifdef FR_UNIX
#include <z88p.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Xm/XmAll.h>
#endif

/***********************************************************************
* globale Variable, speziell fuer X11
***********************************************************************/
Widget hmain;     /* das oberste Widget                               */      
Widget hform;     /* Form-Widget, Kind von hmain                      */
Widget hw[61];    /* alle anderen Widgets, Kinder von hform           */

/*----------------------------------------------------------------------
* Definition der Widgets
*---------------------------------------------------------------------*/
/*----------------------------------------------------------------------
* [0]  WER   [1]  EXIT  [2]  AUTOS    [3]  ZOOM+  [4]  ZOOM-  
* [5]  X+    [6]  X-    [7]  Y+       [8]  Y-     [9]  Z+     [10]  Z-
* [11] RX+   [12] RX-   [13] RY+      [14] RY-    [15] RZ+    [16]  RZ-
* [17] ROT 0 [18] VSPAN [19] PLOT.  
* [20] Label STRUKTUR   [21] Textf STRUKTUR
* [22] Label PLOTFILE   [23] Textf PLOTFILE
* [24] Frame STRUKTUR   
* [25] Unverformt       [26] Verformt [27] Un+Verformt
* [28] Radio STRUKTUR  
* [29] Frame ANSICHT   
* [30] XY    [31] XZ    [32] YZ       [33] 3DIM
* [34] Radio ANSICHT
* [35] Frame LABELS   
* [36] No Labels        [37] Knoten   [38] Elemente           [39] Alles
* [40] Radio LABELS
* [41] Label FUX        [42] Textf FUX
* [43] Label FUY        [44] Textf FUY
* [45] Label FUZ        [46] Textf FUZ
* [47] Label FXCOR      [48] Textf FXCOR
* [49] REGEN
* [50] PAINT
* [51] Frame obere Ta   [52] RowCol obere Ta
* [53] Frame untere Ta  [54] RowCol untere Ta
* [55] Frame STRUK/PLOT [56] RowCol STRUK/PLOT
* [57] Frame FACXYZ     [58] RowCol FACXYZ
* [59] Frame FXCOR      [60] RowCol FXCOR
*---------------------------------------------------------------------*/

GC  hgc[15]; /* alle GCs, intern lokal definierte GCs heissen gc      */

/*----------------------------------------------------------------------
* Definition der Grafikkontexte, sie werden in CB88P gesetzt
*---------------------------------------------------------------------*/
/*----------------------------------------------------------------------
* [0]  CO_NORMAL
* [1]  CO_DEFLECTED
* [2]  CO_NODES
* [3]  CO_ELEMENTS
* [4]  CO_STRESS0    Farbe niedrigste Spannung
* ................
* [13] CO_STRESS9    Farbe hoechste Spannung
* [14] CO_DRAWAR     Grundfarbe der Drawing Area
*---------------------------------------------------------------------*/   

int IBELL;                                       /* Wert XBell        */

int IX_WINDOW,IY_WINDOW,IW_WINDOW,IH_WINDOW;     /* das ganze Z88P    */

int IX_UPBROW,IY_UPBROW,IW_UPBROW,IH_UPBROW;     /* RC obere Tastenr. */
int IX_LPBROW,IY_LPBROW,IW_LPBROW,IH_LPBROW;     /* RC untere Tastenr.*/

int IX_RBSTRUC,IY_RBSTRUC,IW_RBSTRUC,IH_RBSTRUC; /* Radio STRUKTUR    */ 
int IX_RBVIEW,IY_RBVIEW,IW_RBVIEW,IH_RBVIEW;     /* Radio ANSICHT     */
int IX_RBLABEL,IY_RBLABEL,IW_RBLABEL,IH_RBLABEL; /* Radio LABELS      */

int IX_RCSPLOT,IY_RCSPLOT,IW_RCSPLOT,IH_RCSPLOT,NC_RCSPLOT;/* RC Files*/ 

int IX_RCFXYZ,IY_RCFXYZ,IW_RCFXYZ,IH_RCFXYZ,NC_RCFXYZ;  /* RC FACXXZ  */

int IX_RCFXCOR,IY_RCFXCOR,IW_RCFXCOR,IH_RCFXCOR,NC_RCFXCOR;/* RC FXCOR*/

int IX_DRAWAR,IY_DRAWAR,IW_DRAWAR,IH_DRAWAR;          /* Drawing Area */    

char CF_BUTTONS[128],CF_ENTRIES[128],CF_GRAFICS[128]; /* Fonts Win+Gra*/

char CO_FOREGR[128],CO_BACKGR[128],CO_ENTRIES[128];   /* Farben Window*/

char CO_FARBE[128];  /* globaler Uebergabe-Wert fuer Farben, RCOL88   */

char CO_DRAWAR[128]; /* Hintergrundfarbe Drawing Area                 */

/* Farben Grafik unverformt,unverformt,Elemente,Knoten                */
char CO_NORMAL[128],CO_DEFLECTED[128],CO_ELEMENTS[128],CO_NODES[128];

/* Farben Grafik der Spannungswerte in VGPP88                         */
char CO_STRESS0[128],CO_STRESS1[128],CO_STRESS2[128],CO_STRESS3[128];
char CO_STRESS4[128],CO_STRESS5[128],CO_STRESS6[128],CO_STRESS7[128];
char CO_STRESS8[128],CO_STRESS9[128];

/***********************************************************************
* Functions, speziell fuer X11
***********************************************************************/
Widget WindowProcedure(Widget hmain);

void CB_WER           (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_EXIT          (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);

void CB_YESSCALE      (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);

void CB_PRIOR         (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_NEXT          (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_RIGHT         (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_LEFT          (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_UP            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_DOWN          (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_HOME          (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_END           (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);

void CB_F3            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_F2            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_F5            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_F4            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_F7            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_F6            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_F8            (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);

void CB_SHOWSPANN     (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);
void CB_PLOTTER       (Widget hcallw, XtPointer data, 
                              XmPushButtonCallbackStruct *cbs);

void CB_STRUKTUR      (Widget hcallw, XtPointer data, 
                              XmToggleButtonCallbackStruct *cbs);

void CB_ANSICHT       (Widget hcallw, XtPointer data, 
                              XmToggleButtonCallbackStruct *cbs);

void CB_LABELS        (Widget hcallw, XtPointer data, 
                              XmToggleButtonCallbackStruct *cbs);

void CB_STRUKTURFILE  (Widget hcallw, XtPointer data, 
                              XmTextVerifyCallbackStruct *cbs);
void CB_INTERFACE     (Widget hcallw, XtPointer data, 
                              XmTextVerifyCallbackStruct *cbs);
void CB_FUX           (Widget hcallw, XtPointer data, 
                              XmTextVerifyCallbackStruct *cbs);
void CB_FUY           (Widget hcallw, XtPointer data, 
                              XmTextVerifyCallbackStruct *cbs);
void CB_FUZ           (Widget hcallw, XtPointer data, 
                              XmTextVerifyCallbackStruct *cbs);
void CB_FXCOR         (Widget hcallw, XtPointer data, 
                              XmTextVerifyCallbackStruct *cbs);

void CB_REGEN         (Widget hcallw, XtPointer data, 
                              XmTextVerifyCallbackStruct *cbs);

void CB_PAINT         (Widget hcallw, Cardinal data,
                              XmDrawingAreaCallbackStruct *cbs);

/***********************************************************************
*  Function-Declarationen
***********************************************************************/
int dyn88p(void);
int wsto88(void);
int rsto88(void);
int ale88p(int);
int rcol88(void);
int lan88p(void);
int wlog88p(FR_INT4,int);

/***********************************************************************
*  globale Variable
***********************************************************************/
FILE *fdyn,*fwlo,*f2,*f3,*f4,*f6,*f8;

/*------------------------------------
* fdyn= z88.dyn
* fwlo= z88p.log
* f2=   z88o6.txt
* f3=   z88o2.txt
* f4=   z88i1.txt
* f6=   z88o5.txt
* f8=   z88p.sto
*-----------------------------------*/ 
  
FR_DOUBLEAY x;
FR_DOUBLEAY y;
FR_DOUBLEAY z;
FR_DOUBLEAY ux;
FR_DOUBLEAY uy;
FR_DOUBLEAY uz;
FR_DOUBLEAY xgp;
FR_DOUBLEAY ygp;
FR_DOUBLEAY zgp;
FR_DOUBLEAY siggp;

FR_INT4AY ityp;
FR_INT4AY koffs;
FR_INT4AY koi;

FR_INT4AY kx;
FR_INT4AY ky;
FR_INT4AY kgpx;
FR_INT4AY kgpy;

FR_DOUBLE spamax,spamin,spainc;
FR_DOUBLE facx= 1.,facy= 1.,facz= 1.;
FR_DOUBLE cx= 0.,cy= 0.,cz= 0.;
FR_DOUBLE rotx= 0.,roty= 0.,rotz= 0.;
FR_DOUBLE fux= 100.,fuy= 100.,fuz= 100.;
FR_DOUBLE xmin= 0.,xmax= 0.,ymin= 0.,ymax= 0.,zmin= 0.,zmax= 0.;

FR_DOUBLE fzoom= 1.1;
FR_DOUBLE fxcor= 0.85; 

FR_INT4 MAXKOI,MAXE,MAXK,MFACCOMMON,MAXGP;
FR_INT4 LANG= 0,IDYNMEM = 0;
FR_INT4 ndim,nkp,ne,nfg,neg,kflag,isflag,igpanz,ibflag,ipflag;
FR_INT4 izoom= 1;

int II1_OK= 0;
int IO2_OK= 0;
int IO5_OK= 0;

int ITRADIO= 0;

int iflade= ID_NOTLOADSTRUC;
int iflaver=ID_NOTLOADVERF;
int iflspa= ID_NOTLOADSPANN;

int ifverf= IDM_UNVERFORMT;
int ifdevi= IDM_CRT;
int ifansi= IDM_XY;
int iflabe= IDM_NOLABELS;
int iztogg= IDM_NOSHOWSPANN;

int ifstala= ID_ENABLELABELS;
int ifscale;
int ifvcur= 0;

int IALERT= 0; /* 1: Gefahr,sperrt CB_PAINT,wird in CB_OK wieder zu 0 */
int IDEATH= 0; /* 1: STOP,wird in CB_OK(Callback von ale88p) geprueft */
  
char  cdyn[8]   = "z88.dyn";
char  clog[12]  = "z88p.log";
char  csto[12]  = "z88p.sto";
char  cstrn[32] = "z88i1.txt";
char  cintfn[32]= "z88o6.txt";
char  co2[10]   = "z88o2.txt";
char  co5[10]   = "z88o5.txt";

/***********************************************************************
* Hauptprogramm
***********************************************************************/
int main(int argc,char **argv)
{
extern Widget hmain;

Widget MainDialog;

XtAppContext app_context;

/*----------------------------------------------------------------------
* Los geht's
*---------------------------------------------------------------------*/
/* XtSetLanguageProc(NULL,NULL,NULL); */

hmain= XtAppInitialize(&app_context,"z88p",NULL,0,&argc,argv,NULL,NULL,0);

MainDialog = WindowProcedure(hmain);

XtManageChild(MainDialog);
XtRealizeWidget(hmain);

XtAppMainLoop(app_context);
wsto88();
}

/***********************************************************************
* Window- Procedure
***********************************************************************/
Widget WindowProcedure(Widget hmain)
{
extern Widget hform;
extern Widget hw[];

extern FR_INT4 LANG;

extern int IX_WINDOW,IY_WINDOW,IW_WINDOW,IH_WINDOW;

extern int IX_UPBROW,IY_UPBROW,IW_UPBROW,IH_UPBROW;
extern int IX_LPBROW,IY_LPBROW,IW_LPBROW,IH_LPBROW;

extern int IX_RBSTRUC,IY_RBSTRUC,IW_RBSTRUC,IH_RBSTRUC;
extern int IX_RBVIEW,IY_RBVIEW,IW_RBVIEW,IH_RBVIEW;
extern int IX_RBLABEL,IY_RBLABEL,IW_RBLABEL,IH_RBLABEL;

extern int IX_RCSPLOT,IY_RCSPLOT,IW_RCSPLOT,IH_RCSPLOT,NC_RCSPLOT;

extern int IX_RCFXYZ,IY_RCFXYZ,IW_RCFXYZ,IH_RCFXYZ,NC_RCFXYZ;

extern int IX_RCFXCOR,IY_RCFXCOR,IW_RCFXCOR,IH_RCFXCOR,NC_RCFXCOR;

extern int IX_DRAWAR,IY_DRAWAR,IW_DRAWAR,IH_DRAWAR;  

extern int IALERT;

extern char CF_BUTTONS[],CF_ENTRIES[];

extern char CO_FOREGR[],CO_BACKGR[],CO_ENTRIES[];

XColor RGBColor, HwColor;

Colormap cmap;

Pixel fg,bg,eg;

Arg args[40];
Cardinal n;

XmFontListEntry entry1,entry2;
XmFontList      fontlist;

XmString cxstring = NULL;

int iret;

char cstring[256];

/*----------------------------------------------------------------------
* lan88p starten
* Muss als erstes sein, weil hier Z88P.LOG geoeffnet wird
*---------------------------------------------------------------------*/
iret= lan88p();

if(iret != 0)
  {
  fprintf(stderr,"File Z88P.LOG is invalid or wrong! STOP !\n"); 
  exit(1); 
  }

/*----------------------------------------------------------------------
* Z88.FCD einlesen. rcol88 nutzt intern wlog88p.
* Muss vor Form- Widget gestartet werden, um Dimensionen zu erhalten
*---------------------------------------------------------------------*/
iret= rcol88();

if(iret != 0)
  {
  if(LANG == 1)
    fprintf(stderr,"Datei Z88.FCD is ungueltig oder falsch! STOP !\n"); 
  if(LANG == 2)
    fprintf(stderr,"File Z88.FCD is invalid or wrong! STOP !\n");
  exit(1);
  }

/*----------------------------------------------------------------------
* Form-Widget, Basis fuer den Rest
*---------------------------------------------------------------------*/
n = 0;

XtSetArg(args[n], XmNx,      IX_WINDOW); n++;
XtSetArg(args[n], XmNy,      IY_WINDOW); n++;
XtSetArg(args[n], XmNwidth,  IW_WINDOW); n++;
XtSetArg(args[n], XmNheight, IH_WINDOW); n++;

hform = XmCreateForm(hmain, "hform", args, n);

XtManageChild(hform);

/*----------------------------------------------------------------------
* Fonts laden
* Hier wird folgender Effekt ausgenutzt: Fuer die Funktion
* XmTextFieldSetString bei den Textfields kann kein Tag angegeben
* werden, weil das keine Compound- Strings sind. Fuer das Widget
* XmCreateTextField kann nur eine Fontlist angeben werden. Anscheinend
* wird dann der erste Eintrag der Fontlist gezogen. Daher keine weitere
* Verwendung von cf_entries
*---------------------------------------------------------------------*/
entry1= XmFontListEntryLoad(
        XtDisplay(hmain),CF_ENTRIES,XmFONT_IS_FONT,"cf_entries");

if(entry1 == NULL) 
  {
  wlog88p(0,LOG_NO_CF_ENTRIES);
  IALERT= 1; 
  IDEATH= 1;
  ale88p(AL_NO_CF_ENTRIES);
  }
  
entry2= XmFontListEntryLoad(
        XtDisplay(hmain),CF_BUTTONS,XmFONT_IS_FONT,"cf_buttons");

if(entry2 == NULL)
  {
  wlog88p(0,LOG_NO_CF_BUTTONS);
  IALERT= 1; 
  IDEATH= 1;
  ale88p(AL_NO_CF_BUTTONS);
  }

fontlist= XmFontListAppendEntry(NULL,    entry1);
fontlist= XmFontListAppendEntry(fontlist,entry2);

XmFontListEntryFree(&entry1);
XmFontListEntryFree(&entry2);

/*----------------------------------------------------------------------
* Farben laden
*---------------------------------------------------------------------*/
cmap= DefaultColormap(XtDisplay(hmain),DefaultScreen(XtDisplay(hmain)));

if(XAllocNamedColor(XtDisplay(hmain),cmap,CO_BACKGR,&RGBColor,&HwColor))
  bg= HwColor.pixel;
else
  {
  wlog88p(0,LOG_NO_CO_BACKGR);
  IALERT= 1; 
  IDEATH= 1;
  ale88p(     AL_NO_CO_BACKGR);
  }  

if(XAllocNamedColor(XtDisplay(hmain),cmap,CO_FOREGR,&RGBColor,&HwColor))
  fg= HwColor.pixel;
else
  {
  wlog88p(0,LOG_NO_CO_FOREGR);
  IALERT= 1; 
  IDEATH= 1;
  ale88p(    AL_NO_CO_FOREGR);
  }  

if(XAllocNamedColor(XtDisplay(hmain),cmap,CO_ENTRIES,&RGBColor,&HwColor))
  eg= HwColor.pixel;
else
  {
  wlog88p(0,LOG_NO_CO_ENTRIES);
  IALERT= 1; 
  IDEATH= 1;
  ale88p(    AL_NO_CO_ENTRIES);
  }  

/*----------------------------------------------------------------------
* dyn88p starten
*---------------------------------------------------------------------*/
iret= dyn88p();

if(iret != 0)
  {
  IALERT= 1; 
  IDEATH= 1;
  ale88p(iret);
  }

/*----------------------------------------------------------------------
* gibt's schon ein Z88P.STO ?
*---------------------------------------------------------------------*/
if( rsto88() ==1) ifscale= IDM_YESSCALE; /* kein Z88P.STO */
else              ifscale= IDM_NOSCALE;

/*----------------------------------------------------------------------
* Obere PushButton- Reihe
*---------------------------------------------------------------------*/
/*======================================================================
* Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_UPBROW); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_UPBROW); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_UPBROW); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_UPBROW); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[51]= XmCreateFrame(hform, "hw[51]", args, n);

XtManageChild(hw[51]);

/*======================================================================
* RowColumn
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_UPBROW); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_UPBROW); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_UPBROW); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_UPBROW); n++;
XtSetArg(args[n], XmNadjustLast, FALSE); n++;
XtSetArg(args[n], XmNnumColumns,1); n++;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_COLUMN); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE ); n++;
XtSetArg(args[n], XmNresizeWidth, FALSE); n++;
/* XtSetArg(args[n], XmNbackground, bg); n++; geht, ist aber bloed */

hw[52] = XmCreateRowColumn(hw[51], "hw[52]", args, n);

/*======================================================================
* Info PB_WER
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Info", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[0] = XmCreatePushButton(hw[52], "hw[0]", args, n);

XtManageChild(hw[0]);

XtAddCallback(
  hw[0],XmNactivateCallback,(XtCallbackProc) CB_WER,(XtPointer)NULL);

/*======================================================================
* Ende PB_EXIT
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"Ende");
if(LANG == 2) strcpy(cstring,"Exit");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[1] = XmCreatePushButton(hw[52], "hw[1]", args, n);

XtManageChild(hw[1]);

XtAddCallback(
  hw[1],XmNactivateCallback,(XtCallbackProc) CB_EXIT,(XtPointer)NULL);

/*======================================================================
* Autoscale PB_YESAUTOSCALE
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("AutoS", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[2] = XmCreatePushButton(hw[52], "hw[2]", args, n);

XtManageChild(hw[2]);

XtAddCallback(
  hw[2],XmNactivateCallback,(XtCallbackProc) CB_YESSCALE,(XtPointer)NULL);

/*======================================================================
* Zoom + : PB_PRIOR
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Zoom+", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[3] = XmCreatePushButton(hw[52], "hw[3]", args, n);

XtManageChild(hw[3]);

XtAddCallback(
  hw[3],XmNactivateCallback,(XtCallbackProc) CB_PRIOR,(XtPointer)NULL);

/*======================================================================
* Zoom - : PB_NEXT
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Zoom-", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[4] = XmCreatePushButton(hw[52], "hw[4]", args, n);

XtManageChild(hw[4]);

XtAddCallback(
  hw[4],XmNactivateCallback,(XtCallbackProc) CB_NEXT,(XtPointer)NULL);

/*======================================================================
* Rot 0 : PB_F8
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Rot 0", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[17] = XmCreatePushButton(hw[52], "hw[17]", args, n);

XtManageChild(hw[17]);

XtAddCallback(
  hw[17],XmNactivateCallback,(XtCallbackProc) CB_F8,(XtPointer)NULL);

/*======================================================================
* V-Span : PB_SHOWSPANN
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"VSpan");
if(LANG == 2) strcpy(cstring,"Mises");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[18] = XmCreatePushButton(hw[52], "hw[18]", args, n);

XtManageChild(hw[18]);

XtAddCallback(
  hw[18],XmNactivateCallback,(XtCallbackProc) CB_SHOWSPANN,(XtPointer)NULL);

/*======================================================================
* Plotter : PB_PLOTTER
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Plot.", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[19] = XmCreatePushButton(hw[52], "hw[19]", args, n);

XtManageChild(hw[19]);

XtAddCallback(
  hw[19],XmNactivateCallback,(XtCallbackProc) CB_PLOTTER,(XtPointer)NULL);

/*======================================================================
* Regen : PB_REGEN
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Regen", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[49] = XmCreatePushButton(hw[52], "hw[49]", args, n);

XtManageChild(hw[49]);

XtAddCallback(hw[49],XmNactivateCallback,
  (XtCallbackProc) CB_REGEN,(XtPointer)NULL);

XtManageChild(hw[52]); /* das RowColumn obere Tastenreihe */

/*----------------------------------------------------------------------
* untere Tastenreihe
*---------------------------------------------------------------------*/
/*======================================================================
* Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_LPBROW); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_LPBROW); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_LPBROW); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_LPBROW); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[53]= XmCreateFrame(hform, "hw[53]", args, n);

XtManageChild(hw[53]);

/*======================================================================
* RowColumn
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_LPBROW); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_LPBROW); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_LPBROW); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_LPBROW); n++;
XtSetArg(args[n], XmNadjustLast, FALSE); n++;
XtSetArg(args[n], XmNnumColumns,1); n++;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_COLUMN); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE ); n++;
XtSetArg(args[n], XmNresizeWidth, FALSE); n++;

hw[54] = XmCreateRowColumn(hw[53], "hw[54]", args, n);

/*======================================================================
* X + : PB_RIGHT
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("X +", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[5] = XmCreatePushButton(hw[54], "hw[5]", args, n);

XtManageChild(hw[5]);

XtAddCallback(
  hw[5],XmNactivateCallback,(XtCallbackProc) CB_RIGHT,(XtPointer)NULL);

/*======================================================================
* X - : PB_LEFT
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("X -", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[6] = XmCreatePushButton(hw[54], "hw[6]", args, n);

XtManageChild(hw[6]);

XtAddCallback(
  hw[6],XmNactivateCallback,(XtCallbackProc) CB_LEFT,(XtPointer)NULL);

/*======================================================================
* Y + : PB_UP
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Y +", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[7] = XmCreatePushButton(hw[54], "hw[7]", args, n);

XtManageChild(hw[7]);

XtAddCallback(
  hw[7],XmNactivateCallback,(XtCallbackProc) CB_UP,(XtPointer)NULL);

/*======================================================================
* Y - : PB_DOWN
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Y -", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[8] = XmCreatePushButton(hw[54], "hw[8]", args, n);

XtManageChild(hw[8]);

XtAddCallback(
  hw[8],XmNactivateCallback,(XtCallbackProc) CB_DOWN,(XtPointer)NULL);

/*======================================================================
* Z + : PB_HOME
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Z +", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[9] = XmCreatePushButton(hw[54], "hw[9]", args, n);

XtManageChild(hw[9]);

XtAddCallback(
  hw[9],XmNactivateCallback,(XtCallbackProc) CB_HOME,(XtPointer)NULL);

/*======================================================================
* Z - : PB_END
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("Z -", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[10] = XmCreatePushButton(hw[54], "hw[10]", args, n);

XtManageChild(hw[10]);

XtAddCallback(
  hw[10],XmNactivateCallback,(XtCallbackProc) CB_END,(XtPointer)NULL);

/*======================================================================
* RX + : PB_F3
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("RX+", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[11] = XmCreatePushButton(hw[54], "hw[11]", args, n);

XtManageChild(hw[11]);

XtAddCallback(
  hw[11],XmNactivateCallback,(XtCallbackProc) CB_F3,(XtPointer)NULL);

/*======================================================================
* RX - : PB_F2
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("RX-", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[12] = XmCreatePushButton(hw[54], "hw[12]", args, n);

XtManageChild(hw[12]);

XtAddCallback(
  hw[12],XmNactivateCallback,(XtCallbackProc) CB_F2,(XtPointer)NULL);

/*======================================================================
* RY + : PB_F5
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("RY+", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[13] = XmCreatePushButton(hw[54], "hw[13]", args, n);

XtManageChild(hw[13]);

XtAddCallback(
  hw[13],XmNactivateCallback,(XtCallbackProc) CB_F5,(XtPointer)NULL);

/*======================================================================
* RY - : PB_F4
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("RY-", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[14] = XmCreatePushButton(hw[54], "hw[14]", args, n);

XtManageChild(hw[14]);

XtAddCallback(
  hw[14],XmNactivateCallback,(XtCallbackProc) CB_F4,(XtPointer)NULL);

/*======================================================================
* RZ + : PB_F7
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("RZ+", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[15] = XmCreatePushButton(hw[54], "hw[15]", args, n);

XtManageChild(hw[15]);

XtAddCallback(
  hw[15],XmNactivateCallback,(XtCallbackProc) CB_F7,(XtPointer)NULL);

/*======================================================================
* RZ - : PB_F6
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("RZ-", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNbackground, bg); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

hw[16] = XmCreatePushButton(hw[54], "hw[16]", args, n);

XtManageChild(hw[16]);

XtAddCallback(
  hw[16],XmNactivateCallback,(XtCallbackProc) CB_F6,(XtPointer)NULL);

XtManageChild(hw[54]); /* das RowColumn untere Tastenreihe */

/*----------------------------------------------------------------------
* Radiobox STRUKTUR
*---------------------------------------------------------------------*/
/*======================================================================
* der Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RBSTRUC); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RBSTRUC); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RBSTRUC); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RBSTRUC); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[24] = XmCreateFrame(hform,"hw[24]",args, n);

XtManageChild(hw[24]);

/*======================================================================
* die Radiobox
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RBSTRUC); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RBSTRUC); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RBSTRUC); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RBSTRUC); n++;

XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_COLUMN); n++;

XtSetArg(args[n], XmNresizeWidth, FALSE); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE); n++;

hw[28]= XmCreateRadioBox(hw[24],"hw[28]",args, n);
                              
/*======================================================================
* Toggle Unverformt
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"Unverfo.");
if(LANG == 2) strcpy(cstring,"Undefle.");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

XtSetArg(args[n], XmNset, TRUE ); n++;

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[25]= XmCreateToggleButton(hw[28],"hw[25]",args, n);

XtManageChild(hw[25]);

XtAddCallback(hw[25],XmNvalueChangedCallback,
  (XtCallbackProc) CB_STRUKTUR,(XtPointer)IDM_UNVERFORMT);

/*======================================================================
* Toggle Verformt
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"Verformt");
if(LANG == 2) strcpy(cstring,"Deflected");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[26] = XmCreateToggleButton(hw[28],"hw[26]",args, n);

XtManageChild(hw[26]);

XtAddCallback(hw[26],XmNvalueChangedCallback,
  (XtCallbackProc) CB_STRUKTUR,(XtPointer)IDM_VERFORMT);

/*======================================================================
* Toggle Un-und Verformt
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"Un+Verfo.");
if(LANG == 2) strcpy(cstring,"Un+Defle.");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[27] = XmCreateToggleButton(hw[28],"hw[27]",args, n);

XtManageChild(hw[27]);

XtAddCallback(hw[27],XmNvalueChangedCallback,
  (XtCallbackProc) CB_STRUKTUR,(XtPointer)IDM_UNUNDVERFORMT);

XtManageChild(hw[28]); /* die Radiobox */

/*----------------------------------------------------------------------
* Radiobox ANSICHT
*---------------------------------------------------------------------*/
/*======================================================================
* der Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RBVIEW); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RBVIEW); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RBVIEW); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RBVIEW); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[29] = XmCreateFrame(hform,"hw[29]",args,n);

XtManageChild(hw[29]);

/*======================================================================
* die Radiobox
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RBVIEW); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RBVIEW); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RBVIEW); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RBVIEW); n++;

XtSetArg(args[n], XmNnumColumns,2); n++;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_COLUMN); n++;

XtSetArg(args[n], XmNresizeWidth, FALSE); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE); n++;

hw[34] = XmCreateRadioBox(hw[29],"hw[34]",args, n);

/*======================================================================
* Toggle XY
*=====================================================================*/
n = 0;

cxstring = XmStringCreate("XY", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(ifansi == IDM_XY) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[30] = XmCreateToggleButton(hw[34],"hw[30]",args, n);

XtManageChild(hw[30]);

XtAddCallback(hw[30],XmNvalueChangedCallback,
  (XtCallbackProc) CB_ANSICHT,(XtPointer)IDM_XY);

/*======================================================================
* Toggle XZ
*=====================================================================*/
n = 0;

cxstring = XmStringCreate("XZ", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(ifansi == IDM_XZ) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[31] = XmCreateToggleButton(hw[34],"hw[31]",args, n);

XtManageChild(hw[31]);

XtAddCallback(hw[31],XmNvalueChangedCallback,
  (XtCallbackProc) CB_ANSICHT,(XtPointer)IDM_XZ);

/*======================================================================
* Toggle YZ
*=====================================================================*/
n = 0;

cxstring = XmStringCreate("YZ", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(ifansi == IDM_YZ) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[32] = XmCreateToggleButton(hw[34],"hw[32]",args, n);

XtManageChild(hw[32]);

XtAddCallback(hw[32],XmNvalueChangedCallback,
  (XtCallbackProc) CB_ANSICHT,(XtPointer)IDM_YZ);

/*======================================================================
* Toggle 3DIM
*=====================================================================*/
n = 0;

cxstring = XmStringCreate("3D", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(ifansi == IDM_3DIM) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[33] = XmCreateToggleButton(hw[34],"hw[33]",args, n);

XtManageChild(hw[33]);

XtAddCallback(hw[33],XmNvalueChangedCallback,
  (XtCallbackProc) CB_ANSICHT,(XtPointer)IDM_3DIM);

XtManageChild(hw[34]); /* Radiobox ANSICHT */

/*----------------------------------------------------------------------
* Radiobox LABELS
*---------------------------------------------------------------------*/
/*======================================================================
* der Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RBLABEL); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RBLABEL); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RBLABEL); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RBLABEL); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[35] = XmCreateFrame(hform,"hw[35]",args, n);

XtManageChild(hw[35]);

/*======================================================================
* die Radiobox
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RBLABEL); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RBLABEL); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RBLABEL); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RBLABEL); n++;

XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_COLUMN); n++;

XtSetArg(args[n], XmNresizeWidth, FALSE); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE); n++;

hw[40] = XmCreateRadioBox(hw[35],"hw[40]",args, n);

/*======================================================================
* Toggle No Labels
*=====================================================================*/
n = 0;

cxstring = XmStringCreate("No Labels", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(iflabe == IDM_NOLABELS) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[36] = XmCreateToggleButton(hw[40],"hw[36]",args, n);

XtManageChild(hw[36]);

XtAddCallback(hw[36],XmNvalueChangedCallback,
  (XtCallbackProc) CB_LABELS,(XtPointer)IDM_NOLABELS);

/*======================================================================
* Toggle Knoten
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"Knoten");
if(LANG == 2) strcpy(cstring,"Nodes");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(iflabe == IDM_KNOTEN) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[37] = XmCreateToggleButton(hw[40],"hw[37]",args, n);

XtManageChild(hw[37]);

XtAddCallback(hw[37],XmNvalueChangedCallback,
  (XtCallbackProc) CB_LABELS,(XtPointer)IDM_KNOTEN);

/*======================================================================
* Toggle Elemente
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"Elemente");
if(LANG == 2) strcpy(cstring,"Elements");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(iflabe == IDM_ELEMENTE) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[38] = XmCreateToggleButton(hw[40],"hw[38]",args, n);

XtManageChild(hw[38]);

XtAddCallback(hw[38],XmNvalueChangedCallback,
  (XtCallbackProc) CB_LABELS,(XtPointer)IDM_ELEMENTE);

/*======================================================================
* Toggle Alles
*=====================================================================*/
n = 0;

if(LANG == 1) strcpy(cstring,"Alles");
if(LANG == 2) strcpy(cstring,"Both");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

if(iflabe == IDM_ALLES) 
  { 
  XtSetArg(args[n], XmNset, TRUE ); 
  n++;
  }

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;

hw[39] = XmCreateToggleButton(hw[40],"hw[39]",args, n);

XtManageChild(hw[39]);

XtAddCallback(hw[39],XmNvalueChangedCallback,
  (XtCallbackProc) CB_LABELS,(XtPointer)IDM_ALLES);

XtManageChild(hw[40]); /* Radiobox LABELS */

/*----------------------------------------------------------------------
* RowColumn Strukturfile & Plotterfile
*---------------------------------------------------------------------*/
/*======================================================================
* Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RCSPLOT); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RCSPLOT); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RCSPLOT); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RCSPLOT); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[55]= XmCreateFrame(hform, "hw[55]", args, n);

XtManageChild(hw[55]);

/*======================================================================
* RowColumn
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RCSPLOT); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RCSPLOT); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RCSPLOT); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RCSPLOT); n++;
XtSetArg(args[n], XmNadjustLast, FALSE); n++;
XtSetArg(args[n], XmNnumColumns,2); n++;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_TIGHT); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE ); n++;
XtSetArg(args[n], XmNresizeWidth, FALSE); n++;

hw[56] = XmCreateRowColumn(hw[55], "hw[56]", args, n);

/*======================================================================
* Label STRUKTURFILE
*=====================================================================*/
n = 0;

strcpy(cstring,"Stru.");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;
XtSetArg(args[n], XmNalignment, 1 ); n++;

hw[20] = XmCreateLabel(hw[56],"hw[20]",args, n);

XtManageChild(hw[20]);

/*======================================================================
* Textfield STRUKTURFILE
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNmaxLength, 64); n++;
XtSetArg(args[n], XmNcolumns, NC_RCSPLOT); n++;
XtSetArg(args[n], XmNforeground, eg); n++; 
XtSetArg(args[n], XmNfontList, fontlist); n++;

hw[21] = XmCreateTextField(hw[56],"hw[21]",args, n);

XmTextSetString(hw[21], cstrn);

XtManageChild(hw[21]);

XtAddCallback(
  hw[21],XmNactivateCallback,(XtCallbackProc) CB_STRUKTURFILE,(XtPointer)NULL);

/*======================================================================
* Label PLOTDATEI
*=====================================================================*/
n = 0;

strcpy(cstring,"Plot.");
cxstring = XmStringCreateLtoR(cstring, "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;
XtSetArg(args[n], XmNalignment, 1 ); n++;

hw[22] = XmCreateLabel(hw[56],"hw[22]",args, n);

XtManageChild(hw[22]);

/*======================================================================
* Textfield PLOTDATEI
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNmaxLength, 64); n++;
XtSetArg(args[n], XmNcolumns, NC_RCSPLOT); n++;
XtSetArg(args[n], XmNforeground, eg); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;

hw[23] = XmCreateTextField(hw[56],"hw[23]",args, n);

XmTextSetString(hw[23], cintfn);

XtManageChild(hw[23]);

XtAddCallback(
  hw[23],XmNactivateCallback,(XtCallbackProc) CB_INTERFACE,(XtPointer)NULL);

XtManageChild(hw[56]); /* das RowColumn */

/*----------------------------------------------------------------------
* RowColumn FUX, FUY & FUZ       
*---------------------------------------------------------------------*/
/*======================================================================
* Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RCFXYZ); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RCFXYZ); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RCFXYZ); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RCFXYZ); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[57]= XmCreateFrame(hform, "hw[57]", args, n);

XtManageChild(hw[57]);

/*======================================================================
* RowColumn
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RCFXYZ); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RCFXYZ); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RCFXYZ); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RCFXYZ); n++;
XtSetArg(args[n], XmNadjustLast, FALSE); n++;
XtSetArg(args[n], XmNnumColumns,1); n++;
XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_TIGHT); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE ); n++;
XtSetArg(args[n], XmNresizeWidth, FALSE); n++;

hw[58] = XmCreateRowColumn(hw[57], "hw[58]", args, n);

/*======================================================================
* Label FUX, FUY & FUZ
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("FUX,FUY,FUZ", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;
XtSetArg(args[n], XmNalignment, 1 ); n++;

hw[41] = XmCreateLabel(hw[58],"hw[41]",args, n);

XtManageChild(hw[41]);

/*======================================================================
* Textfield FUX
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNmaxLength, 32); n++;
XtSetArg(args[n], XmNcolumns, NC_RCFXYZ); n++;
XtSetArg(args[n], XmNforeground, eg); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;

hw[42] = XmCreateTextField(hw[58],"hw[42]",args, n);

sprintf(cstring,"%lf",fux);
XmTextSetString(hw[42],cstring);

XtManageChild(hw[42]);

XtAddCallback(hw[42],XmNactivateCallback,
  (XtCallbackProc) CB_FUX,(XtPointer)NULL);

/*======================================================================
* Textfield FUY
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNmaxLength, 32); n++;
XtSetArg(args[n], XmNcolumns, NC_RCFXYZ); n++;
XtSetArg(args[n], XmNforeground, eg); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;

hw[44] = XmCreateTextField(hw[58],"hw[44]",args, n);

sprintf(cstring,"%lf",fuy);
XmTextSetString(hw[44],cstring);

XtManageChild(hw[44]);

XtAddCallback(hw[44],XmNactivateCallback,
  (XtCallbackProc) CB_FUY,(XtPointer)NULL);

/*======================================================================
* Textfield FUZ
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNmaxLength, 32); n++;
XtSetArg(args[n], XmNcolumns, NC_RCFXYZ); n++;
XtSetArg(args[n], XmNforeground, eg); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;

hw[46] = XmCreateTextField(hw[58],"hw[46]",args, n);

sprintf(cstring,"%lf",fuz);
XmTextSetString(hw[46],cstring);

XtManageChild(hw[46]);

XtAddCallback(hw[46],XmNactivateCallback,
  (XtCallbackProc) CB_FUZ,(XtPointer)NULL);

XtManageChild(hw[58]); /* das RowColumn */

/*----------------------------------------------------------------------
* RowColumn FXCOR      
*---------------------------------------------------------------------*/
/*======================================================================
* Frame
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RCFXCOR); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RCFXCOR); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RCFXCOR); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RCFXCOR); n++;
XtSetArg(args[n], XmNshadowType, XmSHADOW_IN); n++;

hw[59]= XmCreateFrame(hform, "hw[59]", args, n);

XtManageChild(hw[59]);

/*======================================================================
* RowColumn
*=====================================================================*/
n=0;

XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx, IX_RCFXCOR); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy, IY_RCFXCOR); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth,  IW_RCFXCOR); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight, IH_RCFXCOR); n++;
XtSetArg(args[n], XmNadjustLast, FALSE); n++;
XtSetArg(args[n], XmNnumColumns,1); n++;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_TIGHT); n++;
XtSetArg(args[n], XmNresizeHeight, FALSE ); n++;
XtSetArg(args[n], XmNresizeWidth, FALSE); n++;

hw[60] = XmCreateRowColumn(hw[59], "hw[60]", args, n);

/*======================================================================
* Label FXCOR
*=====================================================================*/
n = 0;

cxstring = XmStringCreateLtoR("FXCOR", "cf_buttons");
XtSetArg(args[n], XmNlabelString, cxstring); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;
XtSetArg(args[n], XmNforeground, fg); n++;

XtSetArg(args[n], XmNrecomputeSize, TRUE ); n++;
XtSetArg(args[n], XmNalignment, 1 ); n++;

hw[47] = XmCreateLabel(hw[60],"hw[47]",args, n);

XtManageChild(hw[47]);

/*======================================================================
* Textfield FXCOR
*=====================================================================*/
n = 0;

XtSetArg(args[n], XmNmaxLength, 16); n++;
XtSetArg(args[n], XmNcolumns, NC_RCFXCOR); n++;
XtSetArg(args[n], XmNforeground, eg); n++;
XtSetArg(args[n], XmNfontList, fontlist); n++;

hw[48] = XmCreateTextField(hw[60],"hw[48]",args, n);

sprintf(cstring,"%lf",fxcor);
XmTextSetString(hw[48],cstring);

XtManageChild(hw[48]);

XtAddCallback(hw[48],XmNactivateCallback,
  (XtCallbackProc) CB_FXCOR,(XtPointer)NULL);

XtManageChild(hw[60]);/* das RowColumn */

/*----------------------------------------------------------------------------
* Zeichenebene hpaint
*---------------------------------------------------------------------------*/
n = 0;
XtSetArg(args[n], XmNleftAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNx,IX_DRAWAR); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNy,IY_DRAWAR); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNwidth, IW_DRAWAR); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_SELF); n++;
XtSetArg(args[n], XmNheight,IH_DRAWAR); n++;
XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;

hw[50] = XmCreateDrawingArea(hform, "hw[50]", args, n);

XtManageChild(hw[50]);

XtAddCallback(hw[50],XmNexposeCallback,
  (XtCallbackProc) CB_PAINT,(XtPointer)NULL);

/*----------------------------------------------------------------------
* String freigeben
*---------------------------------------------------------------------*/
if(cxstring) XmStringFree(cxstring);

/*----------------------------------------------------------------------
* Fontliste freigeben
*---------------------------------------------------------------------*/
if(fontlist) XmFontListFree(fontlist);

/*----------------------------------------------------------------------
* Ende WindowProcedure
*---------------------------------------------------------------------*/
return hform;
}

