/*********************************************************
***                  WINDOWS-TOOLKIT                   ***
***                                                    ***
*** Dies ist ein Oberlaechen-Toolkit, um eine          ***
*** komfortable Schnittstelle zu erhalten und um von   ***
*** anderen Schnittstellen als X11 unabhaengig zu sein ***
***                                                    ***
*********************************************************/
/*
Dieser Source-code ist nicht sehr toll programmiert  
Ich weiss dies ! Bitte keine Flames !

THIS SOURCE-CODE IS NOT GOOD. I KNOW THIS !
PLEASE DO NOT FLAME ME FOR THIS UGLY CODE !
*/

#include "win.h"
#include <X11/cursorfont.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>

#define ANFANGPFAD "/"

#define CTRL	1
#define ALT	2

 GC			gc;
 XColor   		exact_def;
 Colormap 		cmap;
 XSizeHints 		hint;
 Cursor			MyCursor[12];
 int			screen_number,raised, depth ;
 int 			cu = -1;
 XEvent          	event;
 int (* MProc)();

 char 			fontname[]  	= "8x13";
 Display                *display        = NULL ;
 char            	*myDisplayName 	= NULL;
 XFontStruct            *xfontinfo	= NULL;
 int	        foreground,background;
 Window			window;
 int doo = 0;
 Region			leere_region;
 struct Objekt		*ObjektListe	= NULL;
 struct Objekt		*FokusVater = NULL;
 unsigned long     color_gray,color_black,color_lightgray,color_white,color_red,color_lightdarkgray;
 unsigned long    color_gelb,color_blue,color_lightblue;
 struct Objekt		*LastButton 	= NULL;
 struct Objekt          *LastBild       = NULL;
 struct Objekt          *LastEingabeListe=NULL;
 struct Objekt          *LastSliderV    = NULL;
 struct Objekt          *LastObjekt     = NULL;
 struct Objekt          *LastListe    = NULL;
 struct Objekt          *LastSliderH    = NULL;
 long 			MaxSize_x,MaxSize_y,MaxSize_dx,MaxSize_dy,LastMouseX,LastMouseY;
 long 			KeyStatus = 0;   
 Pixmap                 bilder[10];
 unsigned char G1[] = 
 {
  0x00, 0x00, 0xff, 0x03, 0xff, 0x03, 0xfe, 0x01, 0xfc, 0x00, 0x78, 0x00,
    0x30, 0x00, 0xff, 0x03, 0xff, 0x03, 0x00, 0x00,
 };
 unsigned char G2[] = 
 {
   0x00, 0x00, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xfe, 0x01, 0xfc, 0x00,
   0x78, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 unsigned char G3[] = 
 {
  0x00, 0x00, 0x30, 0x00, 0x78, 0x00, 0xfc, 0x00, 0xfe, 0x01, 0xff, 0x03,
  0xff, 0x03, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
 };
 unsigned char G4[] = 
 {
   0x1c, 0x00, 0x3c, 0x00, 0x7c, 0x00, 0xfc, 0x00, 0xfc, 0x01, 0xfc, 0x01,
   0xfc, 0x00, 0x7c, 0x00, 0x3c, 0x00, 0x1c, 0x00, 
 };
 unsigned char G5[] = 
 {
  0xc0, 0x01, 0xe0, 0x01, 0xf0, 0x01, 0xf8, 0x01, 0xfc, 0x01, 0xfc, 0x01,
  0xf8, 0x01, 0xf0, 0x01, 0xe0, 0x01, 0xc0, 0x01,
 };
 unsigned char G6[] = 
 {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x02, 0x01, 0x02, 0x01,
   0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 };
    
 void BerechneCliping();  
 struct Objekt *CreateListbox();
 void BerechneFensterCliping();
 void CheckRepaintArea();    
 void Male_Objekt();   
 void Male_Objekt_alle_Kinder_und_alle_Brueder();
 void SetObjektSichtbar();
 void WechsleKarteiKarte();
 short int CheckKlickAreaKind();
 void SetFocus();


void PutValue(Ptr,wert)
struct Objekt *Ptr;
long wert;
{
 switch (Ptr->Objekt_Typ)
 {
  case SLIDER_V:
       {
        struct SliderV *Ptr1;
        Ptr1=(struct SliderV *)Ptr->Pointer;
        Ptr1->wert=wert; Male_Objekt(Ptr);
        break;
       }
  case SLIDER_H:
       {
        struct SliderH *Ptr1;
        Ptr1=(struct SliderH *)Ptr->Pointer;
        Ptr1->wert=wert; Male_Objekt(Ptr);
        break;
       }
  case CHECKBOX:
       {
        struct Checkbox *Ptr1;
        Ptr1=(struct Checkbox *)Ptr->Pointer;
        Ptr1->value=wert;  Male_Objekt(Ptr);
        break;
       }
  case EINGABE:
       {
        struct Eingabe *Ptr1;
        Ptr1=(struct Eingabe *)Ptr->Pointer;
        if (Ptr1->Art==ZAHLEN) Ptr1->wert=wert;
        Male_Objekt(Ptr);
        break;
       }
 }   
}



long GetValue(Ptr)
struct Objekt *Ptr;
{
 switch (Ptr->Objekt_Typ)
 {
  case WINDOW: 
       {
        return(0);
       }
  case MENU: 
       {
        return(0);
       }

  case BILD:
       {
        return(0);
       }
  case SLIDER_V:
       {
        struct SliderV *Ptr1;
        Ptr1=(struct SliderV *)Ptr->Pointer;
        return(Ptr1->wert);
       }
  case SLIDER_H:
       {
        struct SliderH *Ptr1;
        Ptr1=(struct SliderH *)Ptr->Pointer;
        return(Ptr1->wert);
                        
       }
  case CHECKBOX:
       {
        struct Checkbox *Ptr1;
        Ptr1=(struct Checkbox *)Ptr->Pointer;
        return(Ptr1->value);
       }
  case BUTTON:
       {
        return(0);
       }
  case LISTBUTTON:
       {
       return(0);
       }
  case KARTEI:
       {
       return(0);
       }
  case LISTE:
       {
        struct Liste *Ptr1;
        struct Element *P;
        long t;
        t=0;
        Ptr1=(struct Liste *)Ptr->Pointer;
        
        for (P=Ptr1->Elemente;P!=NULL;P=P->NextPtr)
        {
        if (P->Selected==WAHR) return(t);
        t++;
        }
        return(-1);
       }
  case TEXT:
       {
        return(0);
       }
  case ORDNERLISTE:
       {
        return(0);
       }
  case EINGABE:
       {
        struct Eingabe *Ptr1;
        Ptr1=(struct Eingabe *)Ptr->Pointer;
        if (Ptr1->Art==ZAHLEN) return(Ptr1->wert);
        return(0);
       }
  case KARTEI_ELEMENT:
       {
        return(0);
       }
  case EINGABELISTE:
       {
        struct Eingabeliste *Ptr1;
        Ptr1=(struct Eingabeliste *)Ptr->Pointer;
        return(GetValue(Ptr1->EingabePtr));
       }
  case BOX:
       {
        return(0);
       }
 }   
 return(0);
}

void PutString(Ptr,wert)
struct Objekt *Ptr;
char *wert;
{
 switch (Ptr->Objekt_Typ)
 {
 case TEXT:
        {
        struct Text *Ptr1;
        Ptr1=(struct Text *)Ptr->Pointer;
        strcpy(Ptr1->Titel,wert); 
        Ptr->Size.dx=XTextWidth(xfontinfo,Ptr1->Titel,strlen(Ptr1->Titel))+10; 
       
        break;
       }
    

 case EINGABE:
       {
        struct Eingabe *Ptr1;
        Ptr1=(struct Eingabe *)Ptr->Pointer;
        if (Ptr1->Art!=ZAHLEN) {  
        strcpy(Ptr1->Titel,wert); 
        Ptr1->Cursor=strlen(wert);
        } ;
        break;
       }
  case EINGABELISTE:
       {
        struct Eingabeliste *Ptr1;
        Ptr1=(struct Eingabeliste *)Ptr->Pointer;
        PutString(Ptr1->EingabePtr); break;
       }
  }
  BerechneFensterCliping(ObjektListe);
  CheckRepaintArea(Ptr->Size.X,Ptr->Size.Y,Ptr->Size.dx+1,Ptr->Size.dy+1);
  XFlush(display);
}


char *GetString(Ptr)
struct Objekt *Ptr;
{
 switch (Ptr->Objekt_Typ)
 {
  case EINGABE:
       {
        struct Eingabe *Ptr1;
        Ptr1=(struct Eingabe *)Ptr->Pointer;
        if (Ptr1->Art!=ZAHLEN) {  return(Ptr1->Titel); } ;
       }
  case EINGABELISTE:
       {
        struct Eingabeliste *Ptr1;
        Ptr1=(struct Eingabeliste *)Ptr->Pointer;
        return(GetString(Ptr1->EingabePtr));
       }
 }
 return(NULL);
}

XImage *GetScreen(x,y,xx,yy,backx,backy,backdx,backdy)
long x,y,xx,yy,*backx,*backy,*backdx,*backdy;
{
 Window rrr;
 int width,height,xx3,yy3,border,depth;
 XGetGeometry(display,window,&rrr,&xx3,&yy3,&width,&height,&border,&depth);
 if (x<0) x=0;
 if (y<0) y=0;
 if (xx>width) xx=width;
 if (yy>height) yy=height;
 *backx=x;
 *backy=y;
 *backdx=xx-x;
 *backdy=yy-y;
 if (((yy-y)>0) && ((xx-x)>0)) return(XGetImage(display,window,x,y,xx-x,yy-y,AllPlanes,ZPixmap));  
 return(NULL);
}

void ButtonEingabeListeNotifyProc()
 {
 struct Eingabeliste *Ptr1;
 struct Liste *L;
 struct Element *EPtr;
  
 Ptr1=(struct Eingabeliste *)LastButton->Vater->Pointer;
 L=(struct Liste *)Ptr1->ListePtr->Pointer;
 if (L->Start!=NULL)
 {
  for (EPtr=L->Elemente;EPtr!=NULL;EPtr=EPtr->NextPtr) EPtr->Selected=FALSCH; 
  L->Start->Selected=WAHR;
  SetFocus(Ptr1->ListePtr);
 }
 SetObjektSichtbar(Ptr1->ListePtr,WAHR);
 LastEingabeListe=Ptr1->ListePtr;
}

void Pause(msek)
long msek;
{
 struct timeval timeout;
 timeout.tv_sec=0;
 timeout.tv_usec=msek*1000;
 select(0,0,0,0,&timeout);
}

struct Menu_Element *CreateMenuEintrag(menu1,item,buttonitem,nr,pos,flag,Text,typ,sichtbar,Proc)
struct Objekt *menu1;
struct Menu_Element *item;
struct Objekt *buttonitem;
int nr,pos;
short int flag,typ,sichtbar;
char *Text;
int (* Proc)();
{
 struct Menu *menu;
 struct Button *Ptr5;
 struct Menu_Element *Ptr;
 menu=NULL;
 Ptr =(struct Menu_Element *) calloc(1,sizeof(struct Menu_Element));
 if (menu1!=NULL) menu=(struct Menu *)menu1->Pointer;
 if (Ptr!=NULL)
 {
  Ptr->Proc=Proc;
  Ptr->Art=typ;
  strcpy(Ptr->Titel,Text);
  Ptr->Disable=sichtbar;
  Ptr->Selected=FALSCH;
  Ptr->Flag=flag;
  Ptr->NextPtr=NULL; Ptr->Child=NULL;
  Ptr->x=0; Ptr->xx=0; Ptr->yy=0; Ptr->y=0;
  if (menu1!=NULL) 
  { 
   Ptr->NextPtr=menu->Start[nr]; 
   menu->Start[nr]=Ptr;    
  }
  if (item!=NULL)
  {
   Ptr->NextPtr=item->Child;
   item->Child=Ptr; 
  }
  if (buttonitem!=NULL)
  {
   Ptr5=(struct Button *)buttonitem->Pointer;
   Ptr->NextPtr=Ptr5->MenuPtr;
   Ptr5->MenuPtr=Ptr; 
  }
 } else
 {
  printf("Not enough mem to alloc menu-item \n");
 } 
 return(Ptr);
}


struct Objekt *FindFocus(Ptr)
struct Objekt *Ptr;
{
 struct Objekt *Ptr1;
 if (Ptr!=NULL)
 {
  if (Ptr->Sichtbar==WAHR) if (Ptr->Kind!=NULL)   { Ptr1=FindFocus(Ptr->Kind);   if (Ptr1!=NULL) return(Ptr1); }
  if (Ptr->Bruder!=NULL) { Ptr1=FindFocus(Ptr->Bruder); if (Ptr1!=NULL) return(Ptr1); } 
  if ((Ptr->Focus==WAHR) && (Ptr->Sichtbar==WAHR)) return(Ptr);
 }
 return(NULL);
}

void CheckKeyRelease()
{
 switch(XLookupKeysym(&(event.xkey),0))
 {
  case XK_Alt_L:
  case XK_Alt_R:
  			KeyStatus=KeyStatus & (~ALT);
  			return;
  case XK_Control_L:
  case XK_Control_R:  	
  			KeyStatus=KeyStatus & (~CTRL);
  			return;
 } 
}

struct Objekt *FindNextFocus(Ptr)
struct Objekt *Ptr;
{
 struct Objekt *Ptr1,*Ptr2 ;
 struct FokusObjektListe *FPtr;
 for (Ptr1=Ptr;Ptr1!=NULL;Ptr1=Ptr1->Vater)
 {
  if (Ptr1->Vater==NULL) break;
 }
 if (Ptr1->Objekt_Typ!=WINDOW) { Ptr1=FokusVater; }
 if (Ptr1!=NULL)
 { /* habe Super-Daddy (Window) */
   Ptr2=Ptr1;
   for (FPtr=Ptr2->Fokusliste;FPtr!=NULL;FPtr=FPtr->NextPtr)
   {
    if (FPtr->FokusObjekt==Ptr) if (FPtr->NextPtr!=NULL) 
    { 
      return(FPtr->NextPtr->FokusObjekt); 
      } else 
    { 
     return(Ptr2->Fokusliste->FokusObjekt);  
    }   
   }
 }
 return(Ptr);
}

void SetFokusListe(Vater,Ptr1)
struct Objekt *Vater;
struct Objekt **Ptr1;
{
 int t;
 struct Objekt *Ptr;
 struct FokusObjektListe *FPtr,*LastFPtr;
 LastFPtr=NULL;
 for (t=0;;t++)
 {
  Ptr=Ptr1[t];
  if (Ptr==NULL) return;
  FPtr=(struct FokusObjektListe *)malloc(sizeof(struct FokusObjektListe));
  if (FPtr==NULL) return;
  if (LastFPtr!=NULL) LastFPtr->NextPtr=FPtr;
  FPtr->FokusObjekt=Ptr;
  FPtr->NextPtr=NULL;
  if (t==0) 
  { 
    if (Vater==NULL) { Vater=Ptr1[0]; FokusVater=Vater; } 
    Vater->Fokusliste=FPtr; 
    SetFocus(FPtr->FokusObjekt); 
  }
  LastFPtr=FPtr;
 
 }
}

void CheckKeyPress()
{
 int t,KeyCode;
 struct Objekt *Ptr,*Ptr1;
 char buffer[100];
 KeySym keysym_return;
 XComposeStatus status_in_out;
 for (t=0;t<80;t++) buffer[t]=0;
 KeyCode=XLookupKeysym(&(event.xkey),0);
 switch(KeyCode)
 {
  case XK_Alt_L:
  case XK_Alt_R:
  			KeyStatus=KeyStatus | ALT;
			return;
  case XK_Control_L:
  case XK_Control_R:  	
  			KeyStatus=KeyStatus | CTRL;
  			return;
 } 
 XLookupString(&(event.xkey),buffer,80,&keysym_return,&status_in_out);


 if (KeyStatus!=0) 
 { /* Spezial-taste gedrueckt ! */
   
 /*  printf("Spezial %d + %s !!\n",KeyStatus,buffer);
 */
  
  return;
 }
 if (KeyCode==XK_Tab)
 { /* springe zum naechsten fokus-element */
  Ptr=FindFocus(ObjektListe);
  if (Ptr==NULL) return; /* Kein sichtbares element mit focus */
  Ptr1=Ptr;
  for (;;) 
  {
   Ptr1=FindNextFocus(Ptr1);
   if (Ptr1->Sichtbar==WAHR) break;
   if (Ptr1==Ptr) break;
  }
  if (Ptr1!=Ptr)
  {
   Ptr->Focus=FALSCH; 
   Ptr1->Focus=WAHR;
   Male_Objekt(Ptr);
   Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
   Male_Objekt(Ptr1);
   Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr1->Kind);
  }
  return;
 }

 Ptr=FindFocus(ObjektListe);
 if (Ptr!=NULL)
 {
  switch(Ptr->Objekt_Typ)
  {
   case KARTEI:
                {
                struct Kartei *Ptr1;
                Ptr1=(struct Kartei *)Ptr->Pointer;
                if (KeyCode==XK_Left)
                {
                 WechsleKarteiKarte(Ptr,Ptr1->LastX-1,Ptr1->Spalten-1);
                }
                if (KeyCode==XK_Right)
                {
                 WechsleKarteiKarte(Ptr,Ptr1->LastX+1,Ptr1->Spalten-1);
                }
                }
   		return;
   case BUTTON:
   		if ((KeyCode==XK_Return) || (KeyCode==XK_KP_Enter))
   		{ /* Wie klick auf Button */
   		 CheckKlickAreaKind(0,Ptr,Ptr->Size.X+1,Ptr->Size.Y+1);
   		}
   		break;
   case LISTE: 
               {
                struct Liste *Ptr1;
                struct SliderV *PtrV;
		struct SliderH *PtrH;
                LastListe=Ptr;
                Ptr1=(struct Liste *)Ptr->Pointer;
	        PtrV=(struct SliderV *)Ptr1->PtrV->Pointer;
                PtrH=(struct SliderH *)Ptr1->PtrH->Pointer;
                if (Ptr1->Start==NULL) return;
                if ((KeyCode==XK_Begin) || (KeyCode==XK_Home))
   		{ /* springe zum Anfang der Liste */
   		 Ptr1->Start=Ptr1->Elemente;
   		 PtrV->wert=PtrV->min;
                 Male_Objekt(Ptr);
                 Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind); 
   		}
		if (KeyCode==XK_End)
   		{ /* springe zum Ende der Liste */
   		 struct Element *EPtr;
   		 for (EPtr=Ptr1->Elemente;EPtr!=NULL;EPtr=EPtr->NextPtr)
   		 {
   		  if (EPtr->NextPtr==NULL) break;
   		 }
   		 if (EPtr!=NULL)
   		 {
   		  Ptr1->Start=EPtr;
   		  PtrV->wert=PtrV->max;
                  Male_Objekt(Ptr);
                  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind); 
   		 }
   		}
		if ((KeyCode==XK_Up) || (KeyCode==XK_Prior))
   		{ /* springe -1 der Liste */
   		 if (Ptr1->Start->PrevPtr!=NULL) 
   		 { 
   		  Ptr1->Start=Ptr1->Start->PrevPtr;
   		  PtrV->wert--;
   		  if (PtrV->wert<PtrV->min) PtrV->wert=PtrV->min;
   		  Male_Objekt(Ptr);
   		  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
   		 }
   		}
		if ((KeyCode==XK_Down) || (KeyCode==XK_Next))
   		{ /* springe +1 der Liste */
   		 if (Ptr1->Start->NextPtr!=NULL) 
   		 { 
   		  Ptr1->Start=Ptr1->Start->NextPtr;
   		  PtrV->wert++;
   		  if (PtrV->wert>PtrV->max) PtrV->wert=PtrV->max;
		  Male_Objekt(Ptr);
                  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
   		 }
   		}
		if ((KeyCode==XK_Return) || (KeyCode==XK_KP_Enter)) 
		{ /* Wie klick auf Element => fuehre proc aus ! */
                  struct Element *EPtr;
                  for (EPtr=Ptr1->Elemente;EPtr!=NULL;EPtr=EPtr->NextPtr)
                  { EPtr->Selected=FALSCH; }
                  Ptr1->Start->Selected=WAHR;
                  Male_Objekt(Ptr);
                  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
                  if (LastEingabeListe!=NULL)      
                        {   
                         struct Eingabeliste *EL;    
                         struct Liste *L;    
                         EL=(struct Eingabeliste *)LastEingabeListe->Vater->Pointer;    
                         L=(struct Liste *)EL->ListePtr->Pointer;    
                         SetObjektSichtbar(LastEingabeListe,FALSCH);    
                         LastEingabeListe=NULL;     
                        }

 		  if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; }
		}		
		if (KeyCode==XK_Left)
   		{ /* springe -1  */
   		  PtrH->wert--;
   		  if (PtrH->wert<PtrH->min) PtrH->wert=PtrH->min;
   		  Male_Objekt(Ptr);
   		  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
   		}
		if (KeyCode==XK_Right) 
   		{ /* springe +1  */
   		  PtrH->wert++;
   		  if (PtrH->wert>PtrH->max) PtrH->wert=PtrH->max;
		  Male_Objekt(Ptr);
                  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
   		}
	       }
   	       break;
   case CHECKBOX:
    		if ((KeyCode==XK_Return) || (KeyCode==XK_KP_Space) || (KeyCode==XK_space))
   		{ /* Wie klick auf CheckBox */
                 CheckKlickAreaKind(0,Ptr,Ptr->Size.X+1,Ptr->Size.Y+1);   		 
   		}
   		break;
   case EINGABE:
   	{
   	  struct Eingabe *Ptr1;
   	  char Text[500];
   	  Ptr1=(struct Eingabe *)Ptr->Pointer;
   		if  ((KeyCode==XK_Return))
   		{
   		 if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; } 
   		 return;
   		}
   	        if (KeyCode==XK_Delete)  
   		{
   		 if (strlen((char *)Ptr1->Titel)>0)
   		 { 
                  strcpy(Text,Ptr1->Titel);
                  sprintf(&(Text[Ptr1->Cursor]), "%s",&(Text[Ptr1->Cursor+1]));
                  strcpy(Ptr1->Titel,Text);
   		  Male_Objekt(Ptr);
   		 }
                if (Ptr1->Art==ZAHLEN) 
		 { 
		  Ptr1->wert=0; 
		  sscanf(Ptr1->Titel,"%ld",&(Ptr1->wert)); 
		 }

	        return;
   		}
   		if (KeyCode==XK_BackSpace) 
   		{
   		 if ((strlen(Ptr1->Titel)>0) && (Ptr1->Cursor!=0))
   		 {
		  strcpy(Text,Ptr1->Titel);
		  sprintf(&(Text[Ptr1->Cursor-1]), "%s",&(Text[Ptr1->Cursor]));
		  Ptr1->Cursor--;         
		  if (Ptr1->Cursor<0) Ptr1->Cursor=0;            		 
   		  strcpy(Ptr1->Titel,Text);
   		  Male_Objekt(Ptr);
   		 }
   		  if (Ptr1->Art==ZAHLEN) 
		 { 
		  Ptr1->wert=0; 
		  sscanf(Ptr1->Titel,"%ld",&(Ptr1->wert)); 
		 }
   		 return;
   		}
   		if ((KeyCode==XK_Clear) || (KeyCode==XK_Escape))
   		{
   		 strcpy(Ptr1->Titel,""); 
   		 Ptr1->Cursor=0;
   		 Male_Objekt(Ptr);
   		 if (Ptr1->Art==ZAHLEN) 
		 { 
		  Ptr1->wert=0; 
		  sscanf(Ptr1->Titel,"%ld",&(Ptr1->wert)); 
		 }
   		 return;
   		}
   		if (KeyCode==XK_Right)
   		{
   		 if (strlen(Ptr1->Titel)>Ptr1->Cursor) Ptr1->Cursor++;
   		 Male_Objekt(Ptr);
   		 return;
   		}
   		if (KeyCode==XK_Left)
   		{
   		 if (0<Ptr1->Cursor) Ptr1->Cursor--;
		 Male_Objekt(Ptr);
		 return;
   		}
   		if (KeyCode==XK_End)
   		{
		 Ptr1->Cursor=strlen(Ptr1->Titel);
		 Male_Objekt(Ptr);
		 return;
   		}
   		if (KeyCode==XK_Begin)
   		{
		 Ptr1->Cursor=0;
		 Male_Objekt(Ptr);
		 return;
   		}
   		if (Ptr1->Art==ZAHLEN) 
   		{
   		 if  (!( (KeyCode==XK_0) || (KeyCode==XK_1) || (KeyCode==XK_2) || (KeyCode==XK_3) || (KeyCode==XK_4) ||
	              (KeyCode==XK_5) || (KeyCode==XK_6) || (KeyCode==XK_7) || (KeyCode==XK_8) || (KeyCode==XK_9) || 
	              (KeyCode==XK_minus) || 
	   	      (KeyCode==XK_KP_0) || (KeyCode==XK_KP_1) || (KeyCode==XK_KP_2) || (KeyCode==XK_KP_3) || (KeyCode==XK_KP_4) ||
	              (KeyCode==XK_KP_5) || (KeyCode==XK_KP_6) || (KeyCode==XK_KP_7) || (KeyCode==XK_KP_8) || (KeyCode==XK_KP_9) || 
	              (KeyCode==XK_KP_Subtract))) return;
	         if ((KeyCode==XK_KP_Subtract) || (KeyCode==XK_minus))       
	   	 {
	   	  if (Ptr1->Cursor!=0) return;
	   	  if (Ptr1->Titel[0]=='-') return;
	   	 }
	   		 
   		}
   		strcpy(Text,Ptr1->Titel);
   		sprintf(&(Ptr1->Titel[Ptr1->Cursor]),"%s%s",buffer,&Text[Ptr1->Cursor]);
		Ptr1->Cursor++;
		if (Ptr1->Art==ZAHLEN) 
		{ 
		 Ptr1->wert=0; 
		 sscanf(Ptr1->Titel,"%ld",&(Ptr1->wert)); 
		}
               if (Ptr1->Cursor>strlen(Ptr1->Titel)) Ptr1->Cursor=strlen(Ptr1->Titel);
		Male_Objekt(Ptr);
   		return;	
   		break;
   	}
  
  }
 }
}

void ok1()
{
 
}

void ClearListe(Ptr)
struct Objekt *Ptr;
{
 struct Element *Ptr1,*Ptr3;
 struct Liste *Ptr2;
 struct SliderH *PtrHo;
 struct SliderV *PtrVe;
 
 Ptr2=NULL;
 if (Ptr!=NULL)
 {
  Ptr2=(struct Liste *)Ptr->Pointer;
  Ptr2->Start=NULL; 
  for (Ptr1=Ptr2->Elemente;Ptr1!=NULL;Ptr1=Ptr3)  
  {
   Ptr3=Ptr1->NextPtr;
   free(Ptr1);
  }
  PtrVe=(struct SliderV *)Ptr2->PtrV->Pointer;
  PtrHo=(struct SliderH *)Ptr2->PtrH->Pointer;
  PtrVe->max=1; 
  PtrHo->wert=1;
  PtrHo->min=1;  
  Male_Objekt(Ptr);
  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind); 
 }
 Ptr2->Elemente=NULL;
}


void AddListElement(Ptr,Titel)
struct Objekt *Ptr;
char *Titel;
{
 struct Element *Ptr1;
 struct Liste *Ptr2;
 struct SliderH *PtrHo;
 struct SliderV *PtrVe;
long DeltaX;
 if (Ptr!=NULL)
 {
  Ptr2=(struct Liste *)Ptr->Pointer;
  Ptr1=(struct Element *)malloc(sizeof(struct Element));
  if (Ptr1==NULL) return;
  Ptr1->TextEintrag=(char *)malloc(strlen(Titel)+1);
  strcpy(Ptr1->TextEintrag,Titel);
  Ptr1->XOffset=0;
  Ptr1->Selected=FALSCH;
  Ptr1->NextPtr=Ptr2->Elemente;
  Ptr2->Elemente=Ptr1;
  PtrVe=(struct SliderV *)Ptr2->PtrV->Pointer;
 PtrHo=(struct SliderH *)Ptr2->PtrH->Pointer;
  PtrVe->max++;
  DeltaX=XTextWidth(xfontinfo,Titel,strlen(Titel))+10;

 if (DeltaX>Ptr->Size.dx) if (Titel[0]!=0) if (DeltaX>Ptr2->DeltaX) 
{ 
  Ptr2->DeltaX=DeltaX; 
  Ptr2->Abstand=(0.0+DeltaX-Ptr->Size.dx)/(0.0+strlen(Titel));   
  PtrHo->wert=1;
 PtrHo->max=strlen(Titel);
 PtrHo->min=1;  
}  
Ptr1->PrevPtr=NULL;
  Ptr2->Start=Ptr1;
  if (Ptr1->NextPtr!=NULL) Ptr1->NextPtr->PrevPtr=Ptr1;
 }
if (doo==0)
 { Male_Objekt(Ptr);
  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind); 
  }
 }

void SetMaxSize(x,y,dx,dy)
long x,y,dx,dy;
{
 MaxSize_x=x;
 MaxSize_y=y; 
 MaxSize_dx=dx;
 MaxSize_dy=dy;
}

void ListBoxSliderNotify()
{
 struct SliderV *Ptr1;
 struct Liste  *ListePtr;
 struct Element *EPtr;
 long t,nr;
 if (LastSliderV!=NULL)
 {
 ListePtr=(struct Liste *)LastSliderV->Vater->Pointer;
 EPtr=ListePtr->Elemente;
 Ptr1=(struct SliderV *)ListePtr->PtrV->Pointer;
 nr=Ptr1->wert-Ptr1->min;
 
 for (t=0;;t++)
 {
  if (EPtr==NULL) break;
  if (t==nr)
  {
   ListePtr->Start=EPtr;
   break;
  }
  EPtr=EPtr->NextPtr;
 }
 Male_Objekt(LastSliderV->Vater);
 }
}

void KlickFensterCloseButton()
{
 struct Objekt *Ptr;
 Ptr=LastButton->Vater;
 SetObjektSichtbar(Ptr,FALSCH);
 CheckRepaintArea(Ptr->Size.X,Ptr->Size.Y,Ptr->Size.dx+1,Ptr->Size.dy+1);
 if (Ptr->Proc!=NULL) Ptr->Proc();
}

void BerechneFensterCliping(Ptr)
struct Objekt *Ptr;
{
 /* Gehe rekursiv bis zum letzten Fenster durch */
 struct Objekt *Ptr1;
 struct MyWindow *Ptr2;
 XPoint points[4];
 Region region,region1;  
 
 points[0].x=Ptr->Size.X;  		points[0].y=Ptr->Size.Y;
 points[1].x=Ptr->Size.X+Ptr->Size.dx+1; 	points[1].y=Ptr->Size.Y;
 points[2].x=Ptr->Size.X+Ptr->Size.dx+1; 	points[2].y=Ptr->Size.Y+Ptr->Size.dy+1;
 points[3].x=Ptr->Size.X;  		points[3].y=Ptr->Size.Y+Ptr->Size.dy+1;
 region=XPolygonRegion(points, 4, WindingRule);
 Ptr2=(struct MyWindow *)Ptr->Pointer;
 points[0].x=Ptr2->InnenSize.X;  			points[0].y=Ptr2->InnenSize.Y;
 points[1].x=Ptr2->InnenSize.X+Ptr2->InnenSize.dx+1; 	points[1].y=Ptr2->InnenSize.Y;
 points[2].x=Ptr2->InnenSize.X+Ptr2->InnenSize.dx+1; 	points[2].y=Ptr2->InnenSize.Y+Ptr2->InnenSize.dy+1;
 points[3].x=Ptr2->InnenSize.X;  			points[3].y=Ptr2->InnenSize.Y+Ptr2->InnenSize.dy+1;
 region1=XPolygonRegion(points, 4, WindingRule);
 
 Ptr->region=region;
 if (Ptr->Bruder!=NULL) BerechneFensterCliping(Ptr->Bruder); 
 
 for (Ptr1=ObjektListe;Ptr1!=NULL;Ptr1=Ptr1->Bruder)
 {
  if (Ptr==Ptr1) break;
  if (Ptr1->Sichtbar==WAHR)
  {
   XSubtractRegion(region,Ptr1->region,region);
   XSubtractRegion(region1,Ptr1->region,region1);
  }
 }
 Ptr->region=region;
 XSetRegion(display,Ptr->gc,region);
 if (Ptr->Kind!=NULL) BerechneCliping(Ptr->Kind,region1);
}

void BerechneCliping(Ptr,region_daddy)
struct Objekt *Ptr;
Region region_daddy;
{
 if (Ptr!=NULL)
 {
 XPoint points[4];
 Region region;
 
 points[0].x=Ptr->Size.X;  	        	points[0].y=Ptr->Size.Y;
 points[1].x=Ptr->Size.X+Ptr->Size.dx+1; 	points[1].y=Ptr->Size.Y;
 points[2].x=Ptr->Size.X+Ptr->Size.dx+1; 	points[2].y=Ptr->Size.Y+Ptr->Size.dy+1;
 points[3].x=Ptr->Size.X;  		        points[3].y=Ptr->Size.Y+Ptr->Size.dy+1;
 region=XPolygonRegion(points, 4, WindingRule);
 if (Ptr->Bruder!=NULL) BerechneCliping(Ptr->Bruder,region_daddy);
 /* berechne hier region */  
 XIntersectRegion(region,region_daddy,region);
 if (Ptr->Vater!=NULL) 
 {
  short int w;
  w=1; 
  if (!(((Ptr->Vater->Objekt_Typ==LISTE) || (Ptr->Vater->Objekt_Typ==BILD)) && 
     (( Ptr->Objekt_Typ==SLIDER_H) || (Ptr->Objekt_Typ==SLIDER_V))))
  {  
   if (!((Ptr->Vater->Objekt_Typ==EINGABE) && (Ptr->Objekt_Typ==BUTTON)))
   {
    if (!((Ptr->Vater->Objekt_Typ==EINGABELISTE) && ( (Ptr->Objekt_Typ==BUTTON) || 
    (Ptr->Objekt_Typ==EINGABE) || (Ptr->Objekt_Typ==LISTE) )))
    {
     XIntersectRegion(region,Ptr->Vater->region,region);
     w=0;
    } 
   }
  }
  if (w==1)
  {
   if (Ptr->Vater->Vater!=NULL)
   {
    XIntersectRegion(region,Ptr->Vater->Vater->region,region);   
   }
  }
 }
 
 
 Ptr->region=region;
 XSetRegion(display,Ptr->gc,region);
 if (Ptr->Kind!=NULL) if (Ptr->Sichtbar==WAHR)   BerechneCliping(Ptr->Kind,region_daddy);  
 if (Ptr->Kind!=NULL) if (Ptr->Sichtbar==FALSCH) BerechneCliping(Ptr->Kind,leere_region);
 
 }
}

struct Objekt *Neues_Objekt_Anlegen(Vater,Objekt_Typ,X,Y,dx,dy,sichtbar,Focus,Proc)
struct Objekt *Vater;
short int Objekt_Typ;
long   X,Y,dx,dy;
short int sichtbar,Focus;
int (* Proc)();
{
 struct Objekt *Ptr;
 Ptr=(struct Objekt *)calloc(1,sizeof(struct Objekt));
 if (Ptr==NULL) { fprintf(stderr,"Toolkit warning: Not enough space to alloc new objekt !\n"); return(NULL); }
 Ptr->Size.X    =X;
 Ptr->Size.Y    =Y;
 Ptr->Size.dx   =dx;
 Ptr->Size.dy   =dy;
 Ptr->Proc	=Proc;
 Ptr->Sichtbar  =sichtbar;
 Ptr->Objekt_Typ=Objekt_Typ;
 Ptr->gc	=XCreateGC(display,window, 0, 0);
 XSetFont(display,Ptr->gc,xfontinfo->fid);
 Ptr->Pointer   =NULL;
 Ptr->Fokusliste=NULL; 
 Ptr->Kind      =NULL;
 Ptr->Focus	=Focus;
 Ptr->Bruder    =NULL;
 Ptr->Vater     =NULL;
 if (Vater!=NULL) 
 { /* Dem Vater sein schon exestierendes Kind ist unser Bruder ! */
   /* und wir sind das Kind vom Vater        			 */
   Ptr->Bruder=Vater->Kind;
   Vater->Kind=Ptr;
   Ptr->Vater = Vater;
 } else
 { /* wir sind ein window */
  Ptr->Bruder=ObjektListe;
  ObjektListe=Ptr;
 }
 switch (Objekt_Typ)
 {
  case WINDOW: 
       {
        struct MyWindow *Ptr1;
        Ptr1=(struct MyWindow *)calloc(1,sizeof(struct MyWindow)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new Window !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case MENU: 
       {
        struct Menu *Ptr1;
        Ptr1=(struct Menu *)calloc(1,sizeof(struct Menu)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new Wenu !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }

  case BILD:
       {
        struct Bild *Ptr1;
        Ptr1=(struct Bild *)calloc(1,sizeof(struct Bild)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new Bild !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case SLIDER_V:
       {
        struct SliderV *Ptr1;
        Ptr1=(struct SliderV *)calloc(1,sizeof(struct SliderV)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new slider_v !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case SLIDER_H:
       {
        struct SliderH *Ptr1;
        Ptr1=(struct SliderH *)calloc(1,sizeof(struct SliderH)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new slider_h !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case CHECKBOX:
       {
        struct Checkbox *Ptr1;
        Ptr1=(struct Checkbox *)calloc(1,sizeof(struct Checkbox)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new checkbox !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case BUTTON:
       {
        struct Button *Ptr1;
        Ptr1=(struct Button *)calloc(1,sizeof(struct Button)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new button !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case LISTBUTTON:
       {
        struct Listbutton *Ptr1;
        Ptr1=(struct Listbutton *)calloc(1,sizeof(struct Listbutton)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new list-button !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case KARTEI:
       {
        struct Kartei *Ptr1;
        Ptr1=(struct Kartei *)calloc(1,sizeof(struct Kartei)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new kartei !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case LISTE:
       {
        struct Liste *Ptr1;
        Ptr1=(struct Liste *)calloc(1,sizeof(struct Liste)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new list !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case TEXT:
       {
        struct Text *Ptr1;
        Ptr1=(struct Text *)calloc(1,sizeof(struct Text)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new Text !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case ORDNERLISTE:
       {
        struct Ordnerliste *Ptr1;
        Ptr1=(struct Ordnerliste *)calloc(1,sizeof(struct Ordnerliste)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new ord-list !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case EINGABE:
       {
        struct Eingabe *Ptr1;
        Ptr1=(struct Eingabe *)calloc(1,sizeof(struct Eingabe)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new Eingabe !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case KARTEI_ELEMENT:
       {
        struct KarteiKarte_Element *Ptr1;
        Ptr1=(struct KarteiKarte_Element *)calloc(1,sizeof(struct KarteiKarte_Element)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new KarteiKarte_Element !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }

  case EINGABELISTE:
       {
        struct Eingabeliste *Ptr1;
        Ptr1=(struct Eingabeliste *)calloc(1,sizeof(struct Eingabeliste)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new input-list !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
  case BOX:
       {
        struct Box *Ptr1;
        Ptr1=(struct Box *)calloc(1,sizeof(struct Box)); 
        if (Ptr1==NULL)  { fprintf(stderr,"Toolkit warning: Not enough space to alloc new box !\n"); return(NULL); } 
        Ptr->Pointer=(void *)Ptr1;
        break;
       }
 }   
 return(Ptr);
}

void InstallWindowsToolkit(Titel,x,y,dx,dy,argc,argv)
char *Titel;
long x,y,dx,dy;
int  argc;
char *argv[];
{
 XPoint points[10];
 raised=FALSCH;
 hint.x = x; hint.y = y; hint.width = dx; hint.height = dy; hint.flags = PPosition | PSize;
 display        = XOpenDisplay(myDisplayName);
 screen_number  = DefaultScreen(display);
 cmap           = DefaultColormap(display,screen_number);
 foreground    = BlackPixel(display,screen_number);
 background    = WhitePixel(display,screen_number);
 window 	= XCreateSimpleWindow (display,DefaultRootWindow(display),x,y,dx,dy,5,foreground,background);
 		  XSetStandardProperties(display,window,Titel,Titel,None, argv, argc, &hint);
                  gc=XCreateGC(display,window, 0, 0);
 depth  = DefaultDepth(display,screen_number) ;
 
 
 points[0].x=0;  	points[0].y=0;
 points[1].x=0; 	points[1].y=0;
 points[2].x=0; 	points[2].y=0;
 points[3].x=0;         points[3].y=0;
 leere_region=XPolygonRegion(points, 4, WindingRule);

 
 
MyCursor[0]=XCreateFontCursor(display,XC_top_left_arrow);
MyCursor[1]=XCreateFontCursor(display,XC_sb_h_double_arrow);
MyCursor[2]=XCreateFontCursor(display,XC_sb_h_double_arrow); 
MyCursor[4]=XCreateFontCursor(display,XC_sb_v_double_arrow); 
MyCursor[5]=XCreateFontCursor(display,XC_top_left_corner);  
MyCursor[6]=XCreateFontCursor(display,XC_top_right_corner); 
MyCursor[8]=XCreateFontCursor(display,XC_sb_v_double_arrow); 
MyCursor[9]=XCreateFontCursor(display,XC_bottom_left_corner);  
MyCursor[10]=XCreateFontCursor(display,XC_bottom_right_corner); 
 
 if ((xfontinfo = XLoadQueryFont(display,fontname)) == NULL) { xfontinfo = XQueryFont(display,XGContextFromGC(gc)); }
                  XSetFont(display,gc,xfontinfo->fid);
                  XSelectInput (display,window,
                                                ButtonMotionMask  | ButtonReleaseMask | PointerMotionMask |
                                                ButtonPressMask   | KeyPressMask      | KeyReleaseMask | ExposureMask);

		XParseColor(display,cmap,"Blue",&exact_def);
		XAllocColor(display,cmap,&exact_def);
		color_blue     = exact_def.pixel;
		XParseColor(display,cmap,"SteelBlue",&exact_def);
		XAllocColor(display,cmap,&exact_def); 
		color_lightblue        = exact_def.pixel;
		XParseColor(display,cmap,"yellow",&exact_def);
		XAllocColor(display,cmap,&exact_def);
		color_gelb     = exact_def.pixel;
		XParseColor(display,cmap,"gray",&exact_def);
		exact_def.red   +=5000;
		exact_def.blue  +=5000;
		exact_def.green +=5000;
		XAllocColor(display,cmap,&exact_def);
		color_lightdarkgray     = exact_def.pixel;
		XParseColor(display,cmap,"black",&exact_def);
		XAllocColor(display,cmap,&exact_def);
		color_black    = exact_def.pixel;
		XParseColor(display,cmap,"white",&exact_def);
		XAllocColor(display,cmap,&exact_def);
		color_white    = exact_def.pixel;
		XParseColor(display,cmap,"light gray",&exact_def);
		XAllocColor(display,cmap,&exact_def);
		color_lightgray= exact_def.pixel;
		XParseColor(display,cmap,"gray",&exact_def);
		exact_def.red   -=3000;
		exact_def.blue  -=3000;
		exact_def.green -=3000;
		XAllocColor(display,cmap,&exact_def);
		color_gray= exact_def.pixel;
		XParseColor(display,cmap,"red",&exact_def);
		XAllocColor(display,cmap,&exact_def);
		color_red= exact_def.pixel;

 bilder[1] = XCreatePixmapFromBitmapData(display,window,G1,10,10,color_black,color_lightgray, depth);
 bilder[2] = XCreatePixmapFromBitmapData(display,window,G2,10,10,color_black,color_lightgray, depth); 
 bilder[3] = XCreatePixmapFromBitmapData(display,window,G3,10,10,color_black,color_lightgray, depth); 
 bilder[4] = XCreatePixmapFromBitmapData(display,window,G4,10,10,color_black,color_lightgray, depth); 
 bilder[5] = XCreatePixmapFromBitmapData(display,window,G5,10,10,color_black,color_lightgray, depth); 
 bilder[6] = XCreatePixmapFromBitmapData(display,window,G6,10,10,color_black,color_lightgray, depth); 
}

void MaleWindow(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,tx,ty,z,dx,dy,dx1;
 struct MyWindow *Ptr1;
 
 Ptr1=(struct MyWindow *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 dx1=Ptr1->dx1;
 xx=x+dx;
 yy=y+dy;
 z=strlen(Ptr1->Titel);
 tx=x +((xx-x)>>1)-(XTextWidth(xfontinfo,Ptr1->Titel,z)>>1);
 ty=y+Ptr1->dx1-((dx1)>>1)+((xfontinfo->ascent+xfontinfo->descent)>>1);
 /*XSetForeground (display,       Ptr->gc,color_lightgray);
 XFillRectangle (display,window,Ptr->gc,x,y,dx,dy);
 */
 XSetForeground (display,       Ptr->gc,color_white);
 XDrawLine      (display,window,Ptr->gc,x,y+1,xx-1,y+1);
 XDrawLine      (display,window,Ptr->gc,x+1,y,x+1,yy-1);
 XSetForeground (display,       Ptr->gc,color_gray); 
 XDrawLine      (display,window,Ptr->gc,x+1,yy-1,xx-1,yy-1);                
 XDrawLine      (display,window,Ptr->gc,xx-1,y+1,xx-1,yy);    
 XSetForeground (display,       Ptr->gc,color_black);
 XDrawRectangle (display,window,Ptr->gc,x,y,dx,dy);
  
    
 switch (Ptr1->Typ)
 {
  case SMALLBORDER:  
                     XDrawRectangle (display,window,Ptr->gc,x+8,2+y+(Ptr1->dx1>>1),9,2);
                     XSetForeground (display,       Ptr->gc,color_lightblue);
                     if (ObjektListe==Ptr) XSetForeground (display, Ptr->gc,color_blue);
  		     XFillRectangle (display,window,Ptr->gc,x+2+Ptr1->dx1,y+1+3,2+dx-1-6-Ptr1->dx1,Ptr1->dx1-3);
  		     XSetForeground (display,       Ptr->gc,color_white);
  		     tx=x +((xx-x)>>1)-(XTextWidth(xfontinfo,Ptr1->Titel,z)>>1);
  		     XDrawString    (display,window,Ptr->gc,tx,ty+1,Ptr1->Titel,z);
                     XDrawLine      (display,window,Ptr->gc,x+4,y+1+Ptr1->dx1,xx-3,y+1+Ptr1->dx1);
                     XDrawLine      (display,window,Ptr->gc,xx-3,y+5,xx-3,y+1+Ptr1->dx1);
                     XSetForeground (display,       Ptr->gc,color_gray);
                     XDrawLine      (display,window,Ptr->gc,x+4,y+4,xx-3,y+4);
                     XDrawLine      (display,window,Ptr->gc,x+4,y+5,x+4,y+Ptr1->dx1+3);
                     break;
  
  case NORMALBORDER: 
                     XSetForeground (display,       Ptr->gc,color_gray);
                     XDrawRectangle (display,window,Ptr->gc,x+1,y+1,dx-2,dy-2);
                     XDrawRectangle (display,window,Ptr->gc,x+2,y+2,dx-4,dy-4);
                     XSetForeground (display,       Ptr->gc,color_black);
                     XDrawRectangle (display,window,Ptr->gc,x+3,y+3,dx-6,dy-6);
                     XDrawLine      (display,window,Ptr->gc,x+dx1+1,y,x+dx1+1,y-1+dx1);
                     XDrawLine      (display,window,Ptr->gc,xx-dx1-1,y,xx-dx1-1,y-1+dx1);
                     XDrawLine      (display,window,Ptr->gc,x+dx1,yy,x+dx1,yy-3);
                     XDrawLine      (display,window,Ptr->gc,xx-dx1,yy,xx-dx1,yy-3);
                     XDrawLine      (display,window,Ptr->gc,x,y+dx1,xx,y+dx1);                      
                     XDrawLine      (display,window,Ptr->gc,xx,y+dx1,xx-3,y+dx1);
                     XDrawLine      (display,window,Ptr->gc,x,yy-dx1,x+3,yy-dx1);
                     XDrawLine      (display,window,Ptr->gc,xx,yy-dx1,xx-3,yy-dx1);
                                          
                     XSetForeground (display,       Ptr->gc,color_lightblue);
                     if (ObjektListe==Ptr) XSetForeground (display, Ptr->gc,color_blue);
  		     XFillRectangle (display,window,Ptr->gc,x+2+Ptr1->dx1,y+1+3,2+dx-1-6-2*Ptr1->dx1+2,Ptr1->dx1-4);
  		     XSetForeground (display,       Ptr->gc,color_white);
  		     tx=x +((xx-x)>>1)-(XTextWidth(xfontinfo,Ptr1->Titel,z)>>1);
  		     XDrawString    (display,window,Ptr->gc,tx,ty+1,Ptr1->Titel,z);
	 	    break;
 }
 
}

void MaleBox(Ptr)
struct Objekt *Ptr;
{
 long f,x,y,xx,yy,ty,dx,dy;
 struct Button *Ptr1;
 
 Ptr1=(struct Button *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 xx=x+dx;
 yy=y+dy;
 f=XTextWidth(xfontinfo,Ptr1->Titel,strlen(Ptr1->Titel));
 ty=10;
 y=y+ty;
 if (strlen(Ptr1->Titel)>0)
 {
  XSetForeground (display,Ptr->gc,color_gray);
  XDrawLine (display,window,Ptr->gc,x,y,xx,y);
  XDrawLine (display,window,Ptr->gc,xx-1,y+1,xx-1,yy-1);        
  XDrawLine (display,window,Ptr->gc,xx-1,yy-1,x+1,yy-1);        
  XDrawLine (display,window,Ptr->gc,x,y,x,yy);        
  XSetForeground (display,       Ptr->gc,color_white);    
  XDrawRectangle (display,window,Ptr->gc,x+1,y+1,dx-1,dy-1-ty);        
  XSetForeground (display,Ptr->gc,color_lightgray);
  XDrawLine (display,window,Ptr->gc,x+5,y,x+15+f,y);
  XDrawLine (display,window,Ptr->gc,x+5,y+1,x+15+f,y+1);
  y=y-ty;
  XSetForeground (display,Ptr->gc,color_black);
  XDrawString(display,window,Ptr->gc,x+10,y+15,Ptr1->Titel,strlen(Ptr1->Titel));  
 } else
 {
  XSetForeground (display,Ptr->gc,color_gray);
  XDrawLine (display,window,Ptr->gc,x,y,xx,y);
  XDrawLine (display,window,Ptr->gc,x,y,x,yy);
  XSetForeground (display,Ptr->gc,color_white);
  XDrawLine (display,window,Ptr->gc,x,yy,xx,yy);
  XDrawLine (display,window,Ptr->gc,xx,y,xx,yy);
 }  
}

void MaleEingabeListe(Ptr)
struct Objekt *Ptr;
{
}

void MaleEingabe(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,dx,dy,dx1,m,k;
 struct Eingabe *Ptr1;
 char Prev[400];
 
 Ptr1=(struct Eingabe *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 dx1=dx;
 xx=x+dx;
 yy=y+dy;
 XSetForeground (display,       Ptr->gc,color_white);
 XFillRectangle (display,window,Ptr->gc,x+3,y+3,dx-4,dy-4);
 m=XTextWidth(xfontinfo,Ptr1->Titel,Ptr1->Cursor);
 k=0;
 if ((m+x+4)>(xx-4)) k=k+m-dx+8;
 XSetForeground (display,       Ptr->gc,color_red);
 if (Ptr->Focus==WAHR) XDrawLine      (display,window,Ptr->gc,x+4+m-k,y+4,x+4+m-k,y+dy-4);
 XSetForeground (display,       Ptr->gc,color_black);
 sprintf(Prev,"%s%s",Ptr1->Titel,Ptr1->Suffix);
 XDrawString    (display,window,Ptr->gc,x+4-k,y+dy-4,Prev,strlen(Prev));
 XDrawLine      (display,window,Ptr->gc,x+2,y+2,x+dx-2,y+2);
 XDrawLine      (display,window,Ptr->gc,x+2,y+2,x+2,y-2+dy);
 XSetForeground (display,       Ptr->gc,color_lightgray);
 XDrawLine      (display,window,Ptr->gc,x+dx-1,y+2,x+dx-1,y+dy-1);
 XDrawLine      (display,window,Ptr->gc,x+2,y+dy-1,x+dx-1,y+dy-1);
 XSetForeground (display,       Ptr->gc,color_gray);
 XDrawLine      (display,window,Ptr->gc,x,y,x,y+dy);
 XDrawLine      (display,window,Ptr->gc,x+1,y,x+1,y+dy-1);
 XDrawLine	(display,window,Ptr->gc,x,y,x+dx,y);
 XDrawLine      (display,window,Ptr->gc,x,y+1,x+dx-1,y+1);
 XSetForeground (display,       Ptr->gc,color_white);
 XDrawLine      (display,window,Ptr->gc,x+dx,y+1,x+dx,y+dy);
 XDrawLine      (display,window,Ptr->gc,x+1,y+dy,x+dx,y+dy);
}

void MaleOrdnerListe(Ptr)
struct Objekt *Ptr;
{
}

void MaleText(Ptr)
struct Objekt *Ptr;
{
 struct Text *Ptr1;
Ptr1=(struct Text *)Ptr->Pointer;
XSetForeground(display,Ptr->gc,color_black);
XDrawString(display,window,Ptr->gc,Ptr->Size.X,Ptr->Size.Y+Ptr->Size.dy,Ptr1->Titel,strlen(Ptr1->Titel));
}

void MaleListButton(Ptr)
struct Objekt *Ptr;
{
}

void MaleKartei(Ptr)
struct Objekt *Ptr;
{
 long fx,z,x,y,xx,yy,dx,dy,Spalten,Zeilen,tx,ty,zx,zy;
 long x0,xx0,y0,yy0,uu;
 double Abstandx,Abstandy;
 struct Kartei *Ptr1;
 Ptr1=(struct Kartei *)Ptr->Pointer;
 xx0=0; y0=0; yy0=0;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 fx=5;
 uu=Ptr1->Aktuell % Ptr1->Zeilen;
 xx=x+dx;
 yy=y+dy;
 Zeilen=Ptr1->Spalten;
 Spalten=Ptr1->Zeilen;
 Abstandx=(dx-2*fx*Zeilen+0.0)/(Spalten+0.0);
 Abstandy=16.0;
 zx=Abstandx;
 zy=Abstandy;
 for (ty=0;ty<Zeilen;ty++)
 {
  for (tx=0;tx<Spalten;tx++)
  {
   x0=tx*Abstandx+x+(Zeilen-ty-1)*fx*2;
   xx0=x0+Abstandx;
   y0=ty*Abstandy+y;
   yy0=y0+Abstandy;
   XSetForeground (display,       Ptr->gc,color_lightgray);
   XFillRectangle(display,window,Ptr->gc,x0+fx,y0+fx,zx-fx-fx,zy-fx);
   {
    struct KarteiKarte_Element *Ptr2;
    long ok;
    
    ok=tx+Spalten*Ptr1->Tabelle[ty];
    Ptr2=(struct KarteiKarte_Element *)Ptr1->Kinder[ok]->Pointer;
    ok=(Abstandx/2)-((XTextWidth(xfontinfo,Ptr2->Titel,strlen(Ptr2->Titel)))>>1);
    XSetForeground (display,       Ptr->gc,color_black);
    XDrawString(display,window,Ptr->gc,ok+x0,y0+fx+10,Ptr2->Titel,strlen(Ptr2->Titel));
    if (Ptr->Focus==WAHR) if (uu==tx) if (ty==(Zeilen-1)) 
    { 
     XSetForeground (display,       Ptr->gc,color_red);
     XDrawString(display,window,Ptr->gc,ok+x0,y0+fx+10,Ptr2->Titel,strlen(Ptr2->Titel));
    }
   }
   XSetForeground (display,       Ptr->gc,color_black);
   XDrawLine (display,window,Ptr->gc,x0,yy0,x0,y0+fx);
   XDrawLine (display,window,Ptr->gc,x0,y0+fx,x0+fx,y0);
   XDrawLine (display,window,Ptr->gc,x0+fx,y0,xx0-fx,y0);
   XDrawLine (display,window,Ptr->gc,xx0-fx,y0,xx0,y0+fx);
   XSetForeground (display,       Ptr->gc,color_white);
   XDrawLine (display,window,Ptr->gc,x0+1,yy0,x0+1,y0+fx);
   XDrawLine (display,window,Ptr->gc,x0+1,y0+fx+1,x0+fx+1,y0+1);
   XDrawLine (display,window,Ptr->gc,x0+fx+1,y0+1,xx0-fx-1,y0+1);
   XSetForeground (display,       Ptr->gc,color_gray);
   XDrawLine (display,window,Ptr->gc,xx0-fx-1,y0+1,xx0-1,y0+fx+1);
   XDrawLine (display,window,Ptr->gc,xx0-1,yy0,xx0-1,y0+fx+1);
   /****/
   XSetForeground (display,       Ptr->gc,color_lightgray);
   XDrawLine (display,window,Ptr->gc,x0+2,yy0,x0+2,y0+fx+2);
   XDrawLine (display,window,Ptr->gc,x0+2,y0+fx+2,x0+fx+2,y0+2);
   XDrawLine (display,window,Ptr->gc,x0+fx+2,y0+2,xx0-fx-2,y0+2);
   XDrawLine (display,window,Ptr->gc,xx0-fx-2,y0+2,xx0-2,y0+fx+2);
   XDrawLine (display,window,Ptr->gc,xx0-2,yy0,xx0-2,y0+fx+2);
  }
   yy0-=Abstandy-fx;
   y0=dy-Abstandy*(Zeilen-1)  + yy0-fx;
   XSetForeground (display,       Ptr->gc,color_black); 
   XDrawLine (display,window,Ptr->gc,xx0,yy0,xx0,y0);
   XDrawLine (display,window,Ptr->gc,xx0-fx-fx,y0,xx0,y0);  
   XSetForeground (display,       Ptr->gc,color_gray);
   XDrawLine (display,window,Ptr->gc,xx0-1,yy0,xx0-1,y0-1);  
   XDrawLine (display,window,Ptr->gc,xx0-fx-fx,y0-1,xx0-1,y0-1);
 }
  yy0+=Abstandy;
  XDrawLine (display,window,Ptr->gc,xx0-2,yy0-fx,xx0-2,y0-1);
  yy0-=Abstandy;
  XSetForeground (display,       Ptr->gc,color_black);
  yy0=y+Abstandy*(Zeilen-1)+fx;
  XDrawLine (display,window,Ptr->gc,x,y0,xx0,y0);
  XDrawLine (display,window,Ptr->gc,x,y0,x,yy0);    
  yy0+=Abstandy;
  XSetForeground (display,       Ptr->gc,color_gray);
  XDrawLine (display,window,Ptr->gc,x+1,y0-1,xx0-1,y0-1);  
  XDrawLine (display,window,Ptr->gc,x+2,y0-2,xx0-2,y0-2);  
  XSetForeground (display,       Ptr->gc,color_white);
  XDrawLine (display,window,Ptr->gc,x+1,y0-1,x+1,yy0-fx);
  XDrawLine (display,window,Ptr->gc,x+2,y0-2,x+2,yy0-fx);
  z=yy0-fx;
  /******************* aktuelles feld tx= ... *****************/
   tx=Ptr1->Aktuell % Ptr1->Zeilen;
   ty=Zeilen-1;
   x0=tx*Abstandx+x+(Zeilen-ty-1)*fx*2;
   xx0=x0+Abstandx;
   y0=ty*Abstandy+y;
   yy0=y0+Abstandy;
   XSetForeground (display,       Ptr->gc,color_white);
   XDrawLine (display,window,Ptr->gc,x0+2,yy0,x0+2,y0+fx+2);
   XDrawLine (display,window,Ptr->gc,x0+2,y0+fx+2,x0+fx+2,y0+2);
   XDrawLine (display,window,Ptr->gc,x0+fx+2,y0+2,xx0-fx-2,y0+2);
   XSetForeground (display,       Ptr->gc,color_gray);
   XDrawLine (display,window,Ptr->gc,xx0-fx-2,y0+2,xx0-2,y0+fx+2);
   XDrawLine (display,window,Ptr->gc,xx0-2,yy0,xx0-2,y0+fx+2);
   XSetForeground (display,       Ptr->gc,color_black);
   if (tx==0)
   {
    x0=x+Abstandx;    
    xx0=x+Spalten*Abstandx-1;
    XSetForeground (display,       Ptr->gc,color_black);
    XDrawLine (display,window,Ptr->gc,x0,z,xx0,z);                   
    XSetForeground (display,       Ptr->gc,color_white);
    XDrawLine (display,window,Ptr->gc,x0-2,z+1,xx0-1,z+1);      
    XDrawLine (display,window,Ptr->gc,x0-2,z+2,xx0-2,z+2);            
    XSetForeground(display,       Ptr->gc,color_lightgray);
    x0=Abstandx-4;
    XFillRectangle(display,window,Ptr->gc,x+3,z,x0-1,3);
   } else  
   if (tx==(Spalten-1))
   {
    x0=x;    
    xx0=x+(Spalten-1)*Abstandx+2;
    XSetForeground (display,       Ptr->gc,color_black);
    XDrawLine (display,window,Ptr->gc,x0,z,xx0-2,z);                   
    XSetForeground (display,       Ptr->gc,color_white);
    XDrawLine (display,window,Ptr->gc,x0+1,z+1,xx0,z+1);      
    XDrawLine (display,window,Ptr->gc,x0+2,z+2,xx0,z+2);            
    XSetForeground(display,       Ptr->gc,color_lightgray);
    x0=Abstandx-5;
    XFillRectangle(display,window,Ptr->gc,xx0+1,z,x0,3);
   } else
   {
    x0=x;
    xx0=x+Spalten*Abstandx-1;
    y0=x+tx*Abstandx;
    yy0=x+(tx+1)*Abstandx;
    XSetForeground (display,       Ptr->gc,color_black);
    XDrawLine (display,window,Ptr->gc,x0,z,y0,z);     
    XDrawLine (display,window,Ptr->gc,yy0,z,xx0,z);
    XSetForeground (display,       Ptr->gc,color_white);
    XDrawLine (display,window,Ptr->gc,x0+1,z+1,y0+2,z+1);     
    XDrawLine (display,window,Ptr->gc,yy0-2,z+1,xx0-1,z+1);
    XDrawLine (display,window,Ptr->gc,x0+2,z+2,y0+2,z+2);     
    XDrawLine (display,window,Ptr->gc,yy0-2,z+2,xx0-2,z+2);
    XSetForeground(display,       Ptr->gc,color_lightgray);
    x0=Abstandx-5;
    XFillRectangle(display,window,Ptr->gc,y0+3,z,x0,3);
  }
}

void NotifySliderVFromListBox()
{
 if (LastSliderH!=NULL)
{
 Male_Objekt(LastSliderH->Vater);
}
}

void MaleListe(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,s,dx,dy;
 struct Liste *Ptr1;
 struct Element *Ptr4;
 struct SliderH *PtrH;
 long Abstand;  
 
 Ptr1=(struct Liste *)Ptr->Pointer;
 PtrH=(struct SliderH *)Ptr1->PtrH->Pointer;
 x=Ptr->Size.X;
 
 Abstand=(PtrH->wert-PtrH->min)*Ptr1->Abstand;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 xx=x+dx;
 yy=y+dy;
 
 XSetForeground (display,       Ptr->gc,color_black);
 XDrawRectangle (display,window,Ptr->gc,x,y,dx,dy);
 y=y+13;
 s=0;
 
 for (Ptr4=Ptr1->Start;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
 {
 
  if (Ptr4->Selected==WAHR )
  {
   
   
   XSetForeground (display,       Ptr->gc,color_black);
   XFillRectangle (display,window,Ptr->gc,x+1,y+1-13,dx-1,13);
   XSetForeground (display,       Ptr->gc,color_white);
   XDrawString    (display,window,Ptr->gc,0-Abstand+x+2+Ptr4->XOffset,y-2,Ptr4->TextEintrag,strlen(Ptr4->TextEintrag)); 
  
  } else
  {
   
   
   XSetForeground (display,       Ptr->gc,color_white);
   XFillRectangle (display,window,Ptr->gc,x+1,y+1-13,dx-1,13);
   XSetForeground (display,       Ptr->gc,color_black);
   XDrawString    (display,window,Ptr->gc,0-Abstand+x+2+Ptr4->XOffset,y-2,Ptr4->TextEintrag,strlen(Ptr4->TextEintrag)); 
  }
   
   
  if ((s==0) && (Ptr->Focus==WAHR)) 
  {
    XSetForeground (display,       Ptr->gc,color_red);
    XDrawRectangle (display,window,Ptr->gc,1-Abstand+x+2+Ptr4->XOffset-2,y+1-13,
                    4+XTextWidth(xfontinfo,Ptr4->TextEintrag,strlen(Ptr4->TextEintrag)),13-2);
    s=1;
  }
   
   
  y=y+13;
  if (y>(yy+20)) break; 
 }
  
  y=y-13;
  XSetForeground (display,       Ptr->gc,color_white);
  XFillRectangle (display,window,Ptr->gc,x+1,y,dx-1,yy-y);
  XSetForeground (display,       Ptr->gc,color_black);
  XDrawRectangle (display,window,Ptr->gc,x,Ptr->Size.Y,dx,dy);
 
}

void MaleButton(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,tx,ty,z,dx,dy;
 struct Button *Ptr1;
 Ptr1=(struct Button *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 xx=x+dx;
 yy=y+dy;
 z=strlen(Ptr1->Titel);
 tx=x +((xx-x)>>1)-(XTextWidth(xfontinfo,Ptr1->Titel,z)>>1);
 ty=yy-((yy-y)>>1)+((xfontinfo->ascent+xfontinfo->descent)>>1);
 XSetForeground (display,       Ptr->gc,color_lightgray);
 XFillRectangle (display,window,Ptr->gc,x+2,y+2,dx-5,dy-5);
 if (Ptr1->MenuPtr!=NULL)
 {
  XCopyArea(display,bilder[2],window,Ptr->gc,0,0,10,10,xx-14,yy-13);
 }
 XSetForeground (display,       Ptr->gc,color_black);
 XDrawString    (display,window,Ptr->gc,tx,ty,Ptr1->Titel,z);
 if (Ptr->Focus==WAHR) 
 { XDrawRectangle (display,window,Ptr->gc,x,y,dx,dy); x++; y++; dx--; dy--; dx--; dy--; xx--; yy--;} 
 XDrawRectangle (display,window,Ptr->gc,x,y,dx,dy);
 xx--; yy--; x++; y++;
 XSetForeground (display,       Ptr->gc,color_white);
 XDrawLine      (display,window,Ptr->gc,x,y,xx,y); 
 XDrawLine      (display,window,Ptr->gc,x,y+1,xx-1,y+1);
 XDrawLine      (display,window,Ptr->gc,x,y,x,yy);
 XDrawLine      (display,window,Ptr->gc,x+1,y,x+1,yy-1);
 XSetForeground (display,       Ptr->gc,color_gray); 
 XDrawLine      (display,window,Ptr->gc,x,yy,xx,yy);               
 XDrawLine      (display,window,Ptr->gc,x+1,yy-1,xx-1,yy-1);                
 XDrawLine      (display,window,Ptr->gc,xx,y,xx,yy);    
 XDrawLine      (display,window,Ptr->gc,xx-1,y+1,xx-1,yy);    
 if (Ptr1->Bildnr!=0) XCopyArea(display,bilder[Ptr1->Bildnr],window,Ptr->gc,0,0,10,10,x+2,y+2);
}

void MaleCheckBox(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,tx,ty,z,dx,dy,dx1;
 struct Checkbox *Ptr1;
 
 Ptr1=(struct Checkbox *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 dx1=15;
 xx=x+dx;
 yy=y+dy;
 z=strlen(Ptr1->Titel);
 tx=x+dx1+10;
 ty=y+dx1-((dx1)>>1)+((xfontinfo->ascent+xfontinfo->descent)>>1)-1;
 XSetForeground (display,       Ptr->gc,color_black);
 XDrawString    (display,window,Ptr->gc,tx,ty,Ptr1->Titel,z);
 XDrawLine      (display,window,Ptr->gc,x+2,y+2,x+dx1-2,y+2);
 XDrawLine      (display,window,Ptr->gc,x+2,y+2,x+2,y-2+dx1);
 XSetForeground (display,       Ptr->gc,color_gray);
 XDrawLine      (display,window,Ptr->gc,x,y,x,y+dx1);
 XDrawLine      (display,window,Ptr->gc,x+1,y,x+1,y+dx1-1);
 XDrawLine	(display,window,Ptr->gc,x,y,x+dx1,y);
 XDrawLine      (display,window,Ptr->gc,x,y+1,x+dx1-1,y+1);
 XSetForeground (display,       Ptr->gc,color_white);
 XFillRectangle (display,window,Ptr->gc,x+3,y+3,dx1-4,dx1-4);
 XDrawLine      (display,window,Ptr->gc,x+dx1,y+1,x+dx1,y+dx1);
 XDrawLine      (display,window,Ptr->gc,x+1,y+dx1,x+dx1,y+dx1);
 if (Ptr->Focus==WAHR)
 {
  XSetForeground (display,       Ptr->gc,color_black);    
 } else
 {
  XSetForeground (display,       Ptr->gc,color_lightgray);  
 }
  XDrawRectangle (display,window,Ptr->gc,x+dx1+5,y,dx-dx1-10,dx1);
 if (Ptr1->value==WAHR)
 { /* setzte kreuz */
  XSetForeground (display,       Ptr->gc,color_black);
  XDrawLine      (display,window,Ptr->gc,x+4,y+4,x+dx1-4,y+dx1-4);
  XDrawLine      (display,window,Ptr->gc,x+dx1-4,y+4,x+4,y+dx1-4);            
 }
}

void MaleSliderH(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,tx,z,dx,dy,dx1;
 struct SliderH *Ptr1;
 
 Ptr1=(struct SliderH *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 dx1=15;
 xx=x+dx;
 yy=y+dy;
 XSetForeground (display,       Ptr->gc,color_black);
 XDrawRectangle (display,window,Ptr->gc,x,y,dx,dy);
 XSetForeground (display,       Ptr->gc,color_lightgray);
 XFillRectangle (display,window,Ptr->gc,x+dx1+1,y+1,dx-dx1-dx1-1,dy-1);
 XSetForeground (display,       Ptr->gc,color_black);

 z=(Ptr1->max-Ptr1->min);  
 if (z!=0) 
 { /* male sliderschieber */
  tx=((((dx-dx1-dx1-dx1)+0.0) / (z+0.0))) * (Ptr1->wert-Ptr1->min) + x+dx1;
  XDrawRectangle (display,window,Ptr->gc,tx,y,dx1,dx1);
  x=tx+1;
  xx=x+dx1-2;
  y+=1;
  yy=y+dx1-2;
  XSetForeground (display,       Ptr->gc,color_white);
  XDrawLine      (display,window,Ptr->gc,x,y,xx,y); 
  XDrawLine      (display,window,Ptr->gc,x,y+1,xx-1,y+1);
  XDrawLine      (display,window,Ptr->gc,x,y,x,yy);
  XDrawLine      (display,window,Ptr->gc,x+1,y,x+1,yy-1);
  XSetForeground (display,       Ptr->gc,color_gray); 
  XDrawLine      (display,window,Ptr->gc,x,yy,xx,yy);               
  XDrawLine      (display,window,Ptr->gc,x+1,yy-1,xx-1,yy-1);                
  XDrawLine      (display,window,Ptr->gc,xx,y,xx,yy);    
  XDrawLine      (display,window,Ptr->gc,xx-1,y+1,xx-1,yy);    
 } 
}

void MaleSliderV(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,tx,z,dx,dy,dx1;
 struct SliderV *Ptr1;
 
 Ptr1=(struct SliderV *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 dx1=15;
 xx=x+dx;
 yy=y+dy;
 XSetForeground (display,       Ptr->gc,color_black);
 XDrawRectangle (display,window,Ptr->gc,x,y,dx,dy);
 XSetForeground (display,       Ptr->gc,color_lightgray);
 XFillRectangle (display,window,Ptr->gc,x+1,y+dx1+1,dx-1,dy-dx1-dx1-1);
 XSetForeground (display,       Ptr->gc,color_black);
 
 z=(Ptr1->max-Ptr1->min);  
 if (z!=0) 
 { /* male sliderschieber */
  tx=((((dy-dx1-dx1-dx1)+0.0) / (z+0.0))) * (Ptr1->wert-Ptr1->min) + y+dx1;
  XDrawRectangle (display,window,Ptr->gc,x,tx,dx1,dx1);
  y=tx+1;
  yy=y+dx1-2;
  x+=1;
  xx=x+dx1-2;
  XSetForeground (display,       Ptr->gc,color_white);
  XDrawLine      (display,window,Ptr->gc,x,y,xx,y); 
  XDrawLine      (display,window,Ptr->gc,x,y+1,xx-1,y+1);
  XDrawLine      (display,window,Ptr->gc,x,y,x,yy);
  XDrawLine      (display,window,Ptr->gc,x+1,y,x+1,yy-1);
  XSetForeground (display,       Ptr->gc,color_gray); 
  XDrawLine      (display,window,Ptr->gc,x,yy,xx,yy);               
  XDrawLine      (display,window,Ptr->gc,x+1,yy-1,xx-1,yy-1);                
  XDrawLine      (display,window,Ptr->gc,xx,y,xx,yy);    
  XDrawLine      (display,window,Ptr->gc,xx-1,y+1,xx-1,yy);    

 } 

}

void MaleBild(Ptr)
struct Objekt *Ptr;
{
 long x,y,xx,yy,dx,dy;
 struct Bild *Ptr1;
 
 Ptr1=(struct Bild *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx;
 dy=Ptr->Size.dy;
 xx=x+dx;
 yy=y+dy;
 XSetForeground (display,       Ptr->gc,color_white);
/* XFillRectangle (display,window,Ptr->gc,x+1,y+1,dx-1,dy-1);
*/ XSetForeground (display,       Ptr->gc,color_black);
 XDrawRectangle (display,window,Ptr->gc,x,y,dx,dy);
 if (Ptr1->Proc!=NULL) { Ptr1->Proc();  LastObjekt=Ptr; } /* und repaint-Proc der applikation aufrufen */
}

void MaleMenu(Ptr)
struct Objekt *Ptr;
{
 long t,x,y,dx,dy;
 struct Menu *Ptr1;
 Ptr1=(struct Menu *)Ptr->Pointer;
 x=Ptr->Size.X;
 y=Ptr->Size.Y;
 dx=Ptr->Size.dx+1;
 dy=Ptr->Size.dy;
 XSetForeground (display,       Ptr->gc,color_white);
 XFillRectangle (display,window,Ptr->gc,x,y+1,dx,dy-2);
 XSetForeground (display,       Ptr->gc,color_black);           
 XDrawLine(display,window,Ptr->gc,x,y,dx+x,y);
 XDrawLine(display,window,Ptr->gc,x,dy+y,dx+x,dy+y);
 x=x+10;
 for (t=0;t<30;t++)
 {
  XDrawString(display,window,Ptr->gc,x,y+13,Ptr1->Titel[t],strlen(Ptr1->Titel[t]));
  Ptr1->xx[t]=x;
  x=x+XTextWidth(xfontinfo,Ptr1->Titel[t],strlen(Ptr1->Titel[t]));
  Ptr1->xx1[t]=x;
  x=x+10;
 }
}

void MaleKarteiKarte(Ptr)
struct Objekt *Ptr;
{
  long x,y,dx,dy;
  x=Ptr->Size.X;
  y=Ptr->Size.Y;
  dx=Ptr->Size.dx+1;
  dy=Ptr->Size.dy;
  XSetForeground (display,       Ptr->gc,color_lightgray);
  XFillRectangle (display,window,Ptr->gc,x,y,dx,dy);
}

void SetObjektSichtbar1(Ptr,Wert)
struct Objekt *Ptr;
short int Wert;
{
 if (Ptr!=NULL)
 {
   SetObjektSichtbar1(Ptr->Bruder,Wert);
   SetObjektSichtbar1(Ptr->Kind ,Wert);
   Ptr->Sichtbar=Wert;

   if ((Ptr->Objekt_Typ==EINGABELISTE) && (WAHR==Wert))
   {
    struct Eingabeliste *P;
    P=(struct Eingabeliste *)Ptr->Pointer;
    P->ListePtr->Sichtbar=FALSCH;
   }
  
   if ((Ptr->Objekt_Typ==LISTE) && (WAHR==Wert))
   {
    struct Liste *Ptr1;
    Ptr1=(struct Liste *)Ptr->Pointer;   
    Ptr1->PtrH->Sichtbar=Ptr1->SichtbarH;
    Ptr1->PtrV->Sichtbar=Ptr1->SichtbarV;  
   }
   if ((Ptr->Objekt_Typ==BILD) && (WAHR==Wert))
   {
    struct Bild *Ptr1;
    Ptr1=(struct Bild *)Ptr->Pointer;   
    Ptr1->PtrH->Sichtbar=Ptr1->SichtbarH;
    Ptr1->PtrV->Sichtbar=Ptr1->SichtbarV;  
   }

 }
}

void SetObjektSichtbar(Ptr,Wert)
struct Objekt *Ptr;
short int Wert;
{
  if (Ptr!=NULL)
  {
   
   SetObjektSichtbar1(Ptr->Kind,Wert);
   Ptr->Sichtbar=Wert;
   if ((Ptr->Objekt_Typ==EINGABELISTE) && (WAHR==Wert))
   {
    struct Eingabeliste *P;
    P=(struct Eingabeliste *)Ptr->Pointer;
    P->ListePtr->Sichtbar=FALSCH;
   }
  
   if ((Ptr->Objekt_Typ==LISTE) && (WAHR==Wert))
   {
    struct Liste *Ptr1;
    Ptr1=(struct Liste *)Ptr->Pointer;   
    Ptr1->PtrH->Sichtbar=Ptr1->SichtbarH;
    Ptr1->PtrV->Sichtbar=Ptr1->SichtbarV;  
   }
   if ((Ptr->Objekt_Typ==BILD) && (WAHR==Wert))
   {
    struct Bild *Ptr1;
    Ptr1=(struct Bild *)Ptr->Pointer;   
    Ptr1->PtrH->Sichtbar=Ptr1->SichtbarH;
    Ptr1->PtrV->Sichtbar=Ptr1->SichtbarV;  
   }
  }
  BerechneFensterCliping(ObjektListe);
  CheckRepaintArea(Ptr->Size.X,Ptr->Size.Y,Ptr->Size.dx+1+25,Ptr->Size.dy+1+25);
}

void WechsleKarteiKarte(Ptr,x,y)
struct Objekt *Ptr;
short int x,y;
{
 struct Kartei *Ptr1;
 long Aktuell;
 Ptr1=(struct Kartei *)Ptr->Pointer;
 Aktuell=0;
 if ((x>=Ptr1->Zeilen) || (y>=Ptr1->Spalten)) return;  
 if ((x<0) || (y<0)) return;
 if (Aktuell>49) return;
 if ((Ptr1->Zeilen!=0))
 {
  long ok;
  for (ok=0;ok<49;ok++) if (Ptr1->Kinder[ok]!=NULL) { SetObjektSichtbar1(Ptr1->Kinder[ok]->Kind,FALSCH);  } 
  ok=Ptr1->Tabelle[y];
  Ptr1->Tabelle[y]=Ptr1->Tabelle[Ptr1->Spalten-1];
  Ptr1->Tabelle[Ptr1->Spalten-1]=ok;  
  Ptr1->LastX=x;
  Ptr1->LastY=y;  
  Aktuell = x + ok*Ptr1->Zeilen; 
  SetObjektSichtbar(Ptr1->Kinder[Aktuell],WAHR);
  Ptr1->Aktuell=Aktuell;
  Male_Objekt(Ptr);
  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr1->Kinder[Ptr1->Aktuell]);
 }
}

void Male_Objekt(Ptr)                          
struct Objekt *Ptr;
{ 
 if (Ptr!=NULL)
 { 
  if (Ptr->Sichtbar==WAHR)
  {
   switch(Ptr->Objekt_Typ)
   {
    case KARTEI_ELEMENT: MaleKarteiKarte(Ptr); break;
    case WINDOW:         MaleWindow(Ptr);      break;
    case BOX:            MaleBox(Ptr);         break;
    case EINGABE:        MaleEingabe(Ptr);     break;
    case ORDNERLISTE:    MaleOrdnerListe(Ptr); break;
    case TEXT:           MaleText(Ptr);        break;
    case LISTE:       	 MaleListe(Ptr);       break;
    case KARTEI:         MaleKartei(Ptr);      break;
    case LISTBUTTON:     MaleListButton(Ptr);  break;
    case BUTTON:         MaleButton(Ptr);      break;
    case CHECKBOX:       MaleCheckBox(Ptr);    break;
    case SLIDER_H:       MaleSliderH(Ptr);     break;
    case SLIDER_V:       MaleSliderV(Ptr);     break;
    case BILD:           MaleBild(Ptr);        break;
    case MENU:           MaleMenu(Ptr);        break;
   }
  }
 }
 XFlush(display);
 
}

void Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr)
struct Objekt *Ptr;
{
 if (Ptr!=NULL)
 {
  Male_Objekt(Ptr); 
  if (Ptr->Bruder!=NULL) Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Bruder);
  if (Ptr->Kind!=NULL) if (Ptr->Sichtbar==WAHR)  Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
 }
}     

void CheckRepaintArea(x,y,dx,dy)
long y,x,dx,dy;
{
 struct Objekt *Ptr;
 long xx,yy,X,Y,XX,YY;
 xx=x+dx;
 yy=y+dy;
 XSetForeground(display,gc,color_lightgray );
 XFillRectangle(display,window,gc,x,y,dx,dy);
       
 for (Ptr=ObjektListe;Ptr!=0;Ptr=Ptr->Bruder)
 {
  X=Ptr->Size.X; XX=Ptr->Size.dx+X;
  Y=Ptr->Size.Y; YY=Ptr->Size.dy+Y;
  if (x>X)   X=x;    if (y>Y) Y=y;
  if (yy<YY) YY=yy;  if (xx<XX) XX=xx;
  if (((XX-X)>=0) && ((YY-Y)>=0) && (Ptr->Sichtbar==WAHR))
  {  /* ok, wir müssen einen refresh für dieses Objekt und seine Kinder durchführen */
   Male_Objekt(Ptr);
   if (Ptr->Kind!=NULL) { Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind); }
  }
 }
 XFlush(display);
}

void KlickButtonFromSlider()
{
 if (LastButton->Vater->Objekt_Typ==SLIDER_V)
 { /* slider-v */
  struct SliderV *Ptr1; Ptr1=(struct SliderV *)LastButton->Vater->Pointer;
  if (Ptr1->Ptr_UP ==LastButton) { if (Ptr1->wert<Ptr1->max) Ptr1->wert++; }
  if (Ptr1->Ptr_DOWN==LastButton) { if (Ptr1->wert>Ptr1->min) Ptr1->wert--;
  } MaleSliderV(LastButton->Vater); LastSliderV=LastButton->Vater; if
  (LastButton->Vater->Proc!=NULL) { LastButton->Vater->Proc(); LastObjekt=LastButton->Vater; }
 } else
 { /* Slider-h */
  struct SliderH *Ptr1;
  Ptr1=(struct SliderH *)LastButton->Vater->Pointer;
  if (Ptr1->Ptr_UP  ==LastButton) { if (Ptr1->wert<Ptr1->max) Ptr1->wert++; }
  if (Ptr1->Ptr_DOWN==LastButton) { if (Ptr1->wert>Ptr1->min) Ptr1->wert--; }    
  MaleSliderH(LastButton->Vater);
  LastSliderH=LastButton->Vater;
  if (LastButton->Vater->Proc!=NULL) { LastButton->Vater->Proc(); LastObjekt=LastButton->Vater; }
 }
}
void LoescheFokus(Ptr)
struct Objekt *Ptr;
{
 if (Ptr!=NULL)
 {
  if (Ptr->Bruder!=NULL)  LoescheFokus(Ptr->Bruder);
  if (Ptr->Kind!=NULL)    LoescheFokus(Ptr->Kind);
  if (Ptr->Focus==WAHR)
  {
   Ptr->Focus=FALSCH;
   
   if (Ptr->Sichtbar==WAHR) 
   {
    BerechneFensterCliping(ObjektListe);
    Male_Objekt(Ptr);
   }
  }
 }
}

void SetFocus(Ptr)
struct Objekt *Ptr;
{
 
 LoescheFokus(ObjektListe);
 Ptr->Focus=WAHR;
 Male_Objekt(Ptr); 
 
}

void KlickFromEingabeButton()
{
  struct Objekt *Vater;
  struct Eingabe *Ptr1;
  Vater=LastButton->Vater;
  Ptr1=(struct Eingabe *)Vater->Pointer;
  if (Ptr1->Button_UP==LastButton)
  {
   Ptr1->wert++;   
   sprintf(Ptr1->Titel,"%ld",Ptr1->wert);
  } else
  {
   Ptr1->wert--;
   sprintf(Ptr1->Titel,"%ld",Ptr1->wert);
  }
  Ptr1->Cursor=strlen(Ptr1->Titel);
  SetFocus(Vater);
  Male_Objekt(Vater);
}

void BewegeSlider(Ptr,flag,x1,y1)
struct Objekt *Ptr;
short int flag;
long x1,y1;
{
 long x,y,xx,yy,dx,dy,dx1,dy1,x2,y2,min,max,wert,ty,tx,xz,yz;
 long Posx,Posy,alt;
 alt=0;
 if (flag==1)                
 {
  struct SliderV *Ptr1;
  Ptr1=(struct SliderV *)Ptr->Pointer;
  dx1=1;
  xz=13;
  yz=14;
  dy1=16;
  max=Ptr1->max;
  min=Ptr1->min;
  wert=Ptr1->wert;
 } else
 {
  struct SliderH *Ptr1;
  Ptr1=(struct SliderH *)Ptr->Pointer;
  dx1=16;
  dy1=1;
  xz=14;
  yz=13;
  max=Ptr1->max;
  min=Ptr1->min;
  wert=Ptr1->wert;
 }
  x=Ptr->Size.X+dx1;
  y=Ptr->Size.Y+dy1;
  dx=Ptr->Size.dx-dx1-dx1+1;
  dy=Ptr->Size.dy-dy1-dy1+1;
  xx=x+dx;
  yy=y+dy;
  if (max==min) return;
  tx=((dx+0.0-dx1) / (max-min+0.0)) * (wert-min) + x+1;
  ty=((dy+0.0-dy1) / (max-min+0.0)) * (wert-min) + y+1;     
  if (flag==0) { ty=y; } else { tx=x; } 
  Posx=x1-tx;
  Posy=y1-ty;
  
 XSetFunction(display,Ptr->gc,GXxor);
 XSetForeground(display,Ptr->gc,color_gray);  
 if ((x1>tx) && (x1<(tx+14)) && (y1>ty) && (y1<(ty+14)))
 { /* auf den Slider-Button geklickt */
  XDrawRectangle(display,window,Ptr->gc,tx,ty,xz,yz);
  x2=tx; x1=tx;
  y2=ty; y1=ty;
  for (;1==1;)
  {
   XFlush(display);
   XNextEvent(display,&event);
   event.xbutton.x-=Posx;
   event.xbutton.y-=Posy;
   if (flag==0) if ((event.xbutton.x>=x) && (event.xbutton.x<=(xx-dx1+1))) { x1=event.xbutton.x; } 
   if (flag==1) if ((event.xbutton.y>=y) && (event.xbutton.y<=(yy-dy1+1))) { y1=event.xbutton.y; }
   switch (event.type)
   {
    case ButtonRelease: 
    
    			XSetFunction(display,Ptr->gc,GXcopy);
			if (flag==1)                
 			{
  			 struct SliderV *Ptr1;
  			 Ptr1=(struct SliderV *)Ptr->Pointer;
  			 wert=min+((y1-1-y)/((dy-dy1+0.0)/(max-min+0.0))) ;
                         if (wert<min) wert=min;
                         if (wert>max) wert=max;
			 Ptr1->wert=wert;
 			} else
 			{
  			 struct SliderH *Ptr1;
  			 Ptr1=(struct SliderH *)Ptr->Pointer;
 			 wert=min+((x1-1-x)/((dx-dx1+0.0)/(max-min+0.0))) ;
                         if (wert<min) wert=min;
                         if (wert>max) wert=max;
    		 	 Ptr1->wert=wert;
    		        }
    		        Male_Objekt(Ptr);
                        return; break;
    case MotionNotify:   
                     XDrawRectangle(display,window,Ptr->gc,x2,y2,xz,yz);
                     XFlush(display);
                     if (flag==0) 
                     {
                      wert=min+((x1-1-x)/((dx-dx1+0.0)/(max-min+0.0))) ;
                      x2=x1;
		      /*if (Ptr->Vater->Objekt_Typ==LISTBOX)*/
		      if (alt!=wert)
		      {
		      	 struct SliderH *Ptr1;
  		         alt=wert;
  			 Ptr1=(struct SliderH *)Ptr->Pointer;
                         if (wert<min) wert=min;
                         if (wert>max) wert=max;
    		 	 Ptr1->wert=wert;
    		         
    		         if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; }
		      }
		     }
                     if (flag==1) 
                     { 
                      y2=y1;
                      wert=min+((y1-1-y)/((dy-dy1+0.0)/(max-min+0.0))) ;
                      /*if (Ptr->Vater->Objekt_Typ==LISTBOX) */
                      if (alt!=wert)
                      {
   	                struct SliderV *Ptr1;
  		        alt=wert;
  		        Ptr1=(struct SliderV *)Ptr->Pointer;
                        if (wert<min) wert=min;
                        if (wert>max) wert=max;
		        Ptr1->wert=wert;
                       if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; }                      
                      }
                     }
                     XDrawRectangle(display,window,Ptr->gc,x1,y1,xz,yz);
                     XFlush(display);
                     break;
   }
  } 
 } else
 { /* in den Fuellraum geklickt ! */
  XSetFunction(display,Ptr->gc,GXcopy);
 }
 XSetFunction(display,Ptr->gc,GXcopy);

}

void CheckKlickAufListe(Ptr,x,y)
struct Objekt *Ptr;
long x,y;
{
/* Klick in die Liste */
 long nr,t,nr1;
 struct Element *FirstPtr,*Ptr4;
 struct Liste   *ListePtr;
 struct SliderV *PtrVe;
 
 ListePtr=(struct Liste   *)Ptr->Pointer;
 FirstPtr=ListePtr->Start;
 if (FirstPtr==NULL) return;
 nr=((y-Ptr->Size.Y)/13); 
 for (t=0;nr!=t;t++)
 {
  if (FirstPtr==NULL) break;
  FirstPtr=FirstPtr->NextPtr;
 }
 if (FirstPtr!=NULL)
 {
  for (Ptr4=ListePtr->Elemente;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
  {
   Ptr4->Selected=FALSCH;   
  }
  FirstPtr->Selected=WAHR;
 }
 nr1=nr;

 Male_Objekt(Ptr);
 Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind); 
 for (;;)
 {
  XNextEvent(display,&event);
  switch (event.type)
  {
   case MotionNotify: if ((event.xmotion.x>Ptr->Size.X) && (event.xmotion.x<(Ptr->Size.X+Ptr->Size.dx)))    
   		      {
   		       if ((event.xmotion.y>Ptr->Size.Y) && (event.xmotion.y<(Ptr->Size.Y+Ptr->Size.dy)))
   		       { /* innerhalb der liste */
   			nr=((event.xmotion.y-Ptr->Size.Y)/13);
   			if (nr1!=nr)
   			{ /* aha, bewegt auf neues element */
                         nr1=nr;
			 FirstPtr=ListePtr->Start;
                         for (t=0;nr!=t;t++)
                         {
  			  if (FirstPtr==NULL) break;
  			  FirstPtr=FirstPtr->NextPtr;
 			 }
 			 if (FirstPtr!=NULL)
 			 {
  			  for (Ptr4=ListePtr->Elemente;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
  			  {
   			   Ptr4->Selected=FALSCH;   
  			  }
  			  FirstPtr->Selected=WAHR;
 			 }
   			 Male_Objekt(Ptr);
   			 Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
   			}
   			break;		
   		       } 
    		       if (event.xmotion.y<Ptr->Size.Y)
    		       { /* ueberhalb der liste */
    		        if (ListePtr->Start->PrevPtr!=NULL) 
    		        {
    		         nr1=-1; 
    		         ListePtr->Start=ListePtr->Start->PrevPtr;
    		         PtrVe=(struct SliderV *)ListePtr->PtrV->Pointer;
    		         PtrVe->wert--;
    		         Pause(10);
    		         Male_Objekt(Ptr);
    		         Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
    		         break;
    		        }
    		       }
    		       if (event.xmotion.y>(Ptr->Size.Y+Ptr->Size.dy)) 
   		       { /* unterhalb der liste */
   		        if (ListePtr->Start->NextPtr!=NULL) 
   		        {
   		         nr1=-1;
   		         ListePtr->Start=ListePtr->Start->NextPtr;
                         PtrVe=(struct SliderV *)ListePtr->PtrV->Pointer;
                         PtrVe->wert++;
    		         Pause(10);
    		         Male_Objekt(Ptr);
    		         Male_Objekt_alle_Kinder_und_alle_Brueder(Ptr->Kind);
   		         break;
   		        }
   		       }
   		      } else
   		      { /* rechts oder links ausserhalb der liste */
                       if (nr1!=-1)
                       {
                        nr1=-1;
                        for (Ptr4=ListePtr->Elemente;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
  		        {
   		         Ptr4->Selected=FALSCH;   
  		        }
		        Male_Objekt(Ptr);
   		       }
   		      } 
   	              break;
   case ButtonRelease: /* fertig */
   			return;
   			break;
  } 
 }
}

void MaleMenuItem(Ptr,x,y)
struct Menu_Element *Ptr;
long x,y;
{
 struct Menu_Element *Ptr2;
 long dx,dy;
 long t,g;
 char tt[2],tt1[2];
 tt[0]='*';
 tt[1]=0;
 tt1[0]='>';
 tt1[1]=0;
 t=0; dx=10;
 for (Ptr2=Ptr;Ptr2!=NULL;Ptr2=Ptr2->NextPtr)
 {
  g=XTextWidth(xfontinfo,Ptr2->Titel,strlen(Ptr2->Titel));
  if (dx<g) dx=g;
  t++;
 }
 dy=14*t;
 dx=dx+25;
 if (t>0)
 { /* ok,es gab eintraege */
  XSetForeground(display,gc,color_black);                  
  XDrawRectangle(display,window,gc,x,y,dx,dy+1);         
  t=0;
  for (Ptr2=Ptr;Ptr2!=NULL;Ptr2=Ptr2->NextPtr)
  {
   Ptr2->x=x;
   Ptr2->xx=x+dx;
   Ptr2->y=y+t*14;
   Ptr2->yy=y+t*14+14;
   t++;
   if (Ptr2->Selected==FALSCH) XSetForeground(display,gc,color_white); else  XSetForeground(display,gc,color_black);
   XFillRectangle (display,window,gc,x+1,Ptr2->y+1,dx-1,14);
   XSetForeground(display,gc,color_black);
   if (Ptr2->Art==STRICH) XDrawLine(display,window,gc,x,y+t*14-9,x+dx,y+t*14-9);
   if (Ptr2->Selected==WAHR) XSetForeground(display,gc,color_white); else  XSetForeground(display,gc,color_black);
   if (Ptr2->Disable==WAHR) XSetForeground(display,gc,color_gray);  
   if (Ptr2->Art==EINTRAG) XDrawString(display,window,gc,x+15,y+t*14-1,Ptr2->Titel,strlen(Ptr2->Titel));
   if (Ptr2->Child!=NULL) XDrawString(display,window,gc,x+dx-10,y+t*14-1,tt1,1);
   if (Ptr2->Art==EINTRAG_FLAG) 
   { 
    XDrawString(display,window,gc,x+15,y+t*14-1,Ptr2->Titel,strlen(Ptr2->Titel));
    XSetForeground(display,gc,color_blue);
    if (Ptr2->Flag==WAHR) XDrawString(display,window,gc,x+3,y+t*14-1,tt,1);
   }
  }
    
  
 
 }
}

short int CheckMenuChild(Ptr,x,y,region)
struct Menu_Element *Ptr;
long x,y;
Region region;
{
 XPoint points[4];
 Region my_region,new_region;
 long g,maxX,maxY,backx,backy,backdx,backdy,KeyCode;
 struct  Menu_Element *Ptr4,*Ptr5,*Ptr6;
 XImage *Bild;
 maxX=10; maxY=2;
 Ptr5=NULL;
 for (Ptr4=Ptr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
 {
  Ptr4->Selected=FALSCH;
  if ((Ptr5==NULL) && (Ptr4->Disable==FALSCH) && (Ptr4->Art!=STRICH)) Ptr5=Ptr4;
  g=XTextWidth(xfontinfo,Ptr4->Titel,strlen(Ptr4->Titel))+26;
  if (g>maxX) maxX=g;
  maxY=maxY+14;
 }
  if (Ptr5!=NULL) Ptr5->Selected=WAHR;
  Bild = GetScreen(x,y,x+maxX,y+maxY,&backx,&backy,&backdx,&backdy);
  points[0].x=backx;        points[0].y=backy;
  points[1].x=backx+backdx; points[1].y=backy;
  points[2].x=backx+backdx; points[2].y=backy+backdy;
  points[3].x=backx;        points[3].y=backy+backdy;
  my_region=XPolygonRegion(points, 4, WindingRule);  
  new_region=XPolygonRegion(points, 4, WindingRule);
  XXorRegion(region,my_region,new_region);

  MaleMenuItem(Ptr,x,y);
  XFlush(display);
 
 for (;;)
 {
   XFlush(display);
   XNextEvent(display,&event);
   switch (event.type)
   {
    case Expose: 
                 if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                 if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                 CheckRepaintArea(event.xexpose.x,event.xexpose.y,event.xexpose.width,event.xexpose.height);
                 event.xbutton.x=-1; event.xbutton.y=-1;
                 return(WAHR); 
    case KeyPress:
                                    KeyCode=XLookupKeysym(&(event.xkey),0);
                                    if (KeyCode==XK_Down)
                                    {
                                     Ptr5=NULL;
                                     for (Ptr4=Ptr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if (Ptr4->Selected!=FALSCH) { Ptr5=Ptr4; break; }
                                     }
                                     if (Ptr5==NULL) break;
 				     Ptr5->Selected=FALSCH;
                                     for (Ptr4=Ptr5->NextPtr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if ((Ptr4->Disable==FALSCH) && (Ptr4->Art!=STRICH)) { Ptr5=Ptr4; break; }
                                     }
                                     Ptr5->Selected=WAHR;
                                     MaleMenuItem(Ptr,x,y);
                                     XFlush(display);
                                     break;
                                    }
                                    if (KeyCode==XK_Up)
                                    {
                                     Ptr5=NULL;
                                     for (Ptr4=Ptr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if (Ptr4->Selected!=FALSCH) { Ptr5=Ptr4; break; }
                                     }
                                     if (Ptr5==NULL) break;
 				     Ptr5->Selected=FALSCH;
                                     Ptr6=NULL;
                                     for (Ptr4=Ptr;Ptr4!=Ptr5;Ptr4=Ptr4->NextPtr)
                                     {
                                      if ((Ptr4->Disable==FALSCH) && (Ptr4->Art!=STRICH)) Ptr6=Ptr4;
                                     }
                                     if (Ptr6==NULL) Ptr5->Selected=WAHR;
                                     if (Ptr6!=NULL) Ptr6->Selected=WAHR;
                                     MaleMenuItem(Ptr,x,y); 
                                     XFlush(display);
                                     break;                                    
                                    }
                                    if ((KeyCode==XK_Return) || (KeyCode==XK_KP_Enter))
                                    { /* wenn ein feld aktiv -> fertig */
                                     for (Ptr4=Ptr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if (Ptr4->Selected!=FALSCH) 
                                      { 
                                       if (Ptr4->Art==EINTRAG_FLAG) 
                                       {
                                        if (Ptr4->Flag==WAHR) { Ptr4->Flag=FALSCH; } else  { Ptr4->Flag=WAHR; }
                                        MaleMenuItem(Ptr,x,y); 
                                        XFlush(display);
                                        Pause(250);
                                       }
                                       if (Ptr4->Child!=NULL)
                                       { /* ok, pop des child-fensters ! */ 
                                        if (WAHR==CheckMenuChild(Ptr4->Child,Ptr4->xx+2,Ptr4->y,region))
                                        { /* ok, beende alles */
                                         if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                         if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                         XFlush(display);
                                         return(WAHR);
                                        } else
                                        {    /* bleibe hier */
                                         break; 
                                        }
                                       } else
                                       {
                                        if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                        if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                        XFlush(display);
                                        MProc=Ptr4->Proc;
                                        return(WAHR);
                                       }
                                      }
                                     }
                                    }
                                    if (KeyCode==XK_Left)
                                    {
                                     if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                     if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                     XFlush(display);
                                     return(FALSCH);
                                    }
                                    break;

    case ButtonPress:
          {
            if (XPointInRegion(region,event.xbutton.x,event.xbutton.y))
            { /* ausserhalb , aber im gepopten menu ! */
             if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
             if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
             XFlush(display);
             return(FALSCH);
            } else
            {
             if (XPointInRegion(my_region,event.xbutton.x,event.xbutton.y))
             { /* innerhalb geklickt */
              for (Ptr4=Ptr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr) Ptr4->Selected=FALSCH;
              for (Ptr4=Ptr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
              {
               if ((event.xbutton.y>Ptr4->y) && (event.xbutton.y<Ptr4->yy) && (Ptr4->Disable!=WAHR) && (Ptr4->Art!=STRICH))
               { /* geklicktes element element gefunden */
                if (Ptr4->Art==EINTRAG_FLAG) 
                {
                 if (Ptr4->Flag==WAHR) { Ptr4->Flag=FALSCH; } else  { Ptr4->Flag=WAHR; }
                }
                Ptr4->Selected=WAHR;       
                MaleMenuItem(Ptr,x,y);
                XFlush(display);
                Pause(250);
                break;
               }  
              }
              if (Ptr4==NULL) break;              
              if (Ptr4->Child!=NULL)
              { /* weiteres Pop-child aufrufen */
               if (WAHR==CheckMenuChild(Ptr4->Child,Ptr4->xx+2,Ptr4->y,new_region))
               { /* ok, beende alles */
                if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                XFlush(display);
                return(WAHR);
               } else
               { /* bleibe hier ? */
                if (XPointInRegion(my_region,event.xbutton.x,event.xbutton.y))
                {
                 break;
                } else
                { /* nein gehe weg */
                 if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                 if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                 XFlush(display);
                 return(FALSCH);
                }
               }
              } else
              { /* fertig */
               if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
               if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
               XFlush(display);
               MProc=Ptr4->Proc;
               return(WAHR);
              }
              if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
              if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
              XFlush(display);
              return(WAHR);
             } else
             { /* ganz ausserhalb */
              if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
              if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
              XFlush(display);
              return(WAHR);
             }
            }
          }   
   
   }                                         
 }
}

short int CheckKlickAreaKind(flag,Ptr,x,y)
short int flag;
struct Objekt *Ptr;
long x,y;
{
 long  x1,y1,dx,zx,zy,fx,tx,ty,x0,y0;
 float Abstandx,Abstandy;
 
 if (Ptr==NULL) return(FALSCH);
 if ((flag==1) && (Ptr->Bruder!=NULL)) if (WAHR==CheckKlickAreaKind(flag,Ptr->Bruder,x,y)) return(WAHR);
 if (Ptr->Sichtbar==WAHR) 
 {
  if (Ptr->Kind!=NULL)                  if (WAHR==CheckKlickAreaKind(flag,Ptr->Kind  ,x,y)) return(WAHR);
  if (XPointInRegion(Ptr->region, x, y))
  {
   if (LastEingabeListe!=NULL) 
   {
    struct Eingabeliste *EL;
    struct Liste *L;
    EL=(struct Eingabeliste *)LastEingabeListe->Vater->Pointer;
    L=(struct Liste *)EL->ListePtr->Pointer;

    if ((EL->ButtonPtr!=Ptr) && (Ptr!=L->PtrV) && (Ptr!=L->PtrH) && (Ptr!=LastEingabeListe) && 
       (Ptr!=L->PtrV->Kind) && (Ptr!=L->PtrV->Kind->Bruder) && 
       (Ptr!=L->PtrH->Kind) && (Ptr!=L->PtrH->Kind->Bruder) && (Ptr!=LastEingabeListe->Vater))
    {
     SetObjektSichtbar(LastEingabeListe,FALSCH);
     LastEingabeListe=NULL;
    }
   }
   switch(Ptr->Objekt_Typ)
   {
    case MENU : 
               { XImage *Bild;
                long g,t,backx,KeyCode,backy,backdx,backdy,maxX,maxY;
                Region region;
                XPoint points[4];
                struct Menu *Ptr1;
                struct Menu_Element *Ptr4,*Ptr6,*Ptr5;
                Ptr1=(struct Menu *)Ptr->Pointer;
                for (t=0;t<30;t++)
                {
                 if ((Ptr1->xx[t]<x) && (Ptr1->xx1[t]>x) && (Ptr1->Start[t]!=NULL))
                 {
                   maxX=10; maxY=2;
                   Ptr5=NULL;
                   for (Ptr4=Ptr1->Start[t];Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                   {
                    Ptr4->Selected=FALSCH;
                    if ((Ptr5==NULL) && (Ptr4->Disable==FALSCH) && (Ptr4->Art!=STRICH)) Ptr5=Ptr4;
                    g=XTextWidth(xfontinfo,Ptr4->Titel,strlen(Ptr4->Titel))+26;
                    if (g>maxX) maxX=g;
                    maxY=maxY+14;
                   }
                   if (Ptr5!=NULL) Ptr5->Selected=WAHR;
                   MaleMenu(Ptr);
                   Bild = GetScreen(Ptr1->xx[t],Ptr->Size.Y+17,Ptr1->xx[t]+maxX,Ptr->Size.Y+18+maxY,
                                    &backx,&backy,&backdx,&backdy);
                   points[0].x=backx;        points[0].y=backy;
                   points[1].x=backx+backdx; points[1].y=backy;
                   points[2].x=backx+backdx; points[2].y=backy+backdy;
                   points[3].x=backx;        points[3].y=backy+backdy;
                   region=XPolygonRegion(points, 4, WindingRule);  
                   XSetForeground(display,Ptr->gc,color_black);
                   XFillRectangle (display,window,Ptr->gc,Ptr1->xx[t],Ptr->Size.Y+1,Ptr1->xx1[t]-Ptr1->xx[t],Ptr->Size.dy-2);
                   XSetForeground(display,Ptr->gc,color_white);
                   XDrawString(display,window,Ptr->gc,Ptr1->xx[t],Ptr->Size.Y+13,Ptr1->Titel[t],strlen(Ptr1->Titel[t]));
                   MaleMenuItem(Ptr1->Start[t],Ptr1->xx[t],Ptr->Size.Y+Ptr->Size.dy);
                   XFlush(display);
                   /******* hier abfrage ob maus innerhalb ********/
                   for (;;)
                   {
                    XFlush(display);
                    XNextEvent(display,&event);
                    switch (event.type)
                    {
                     case KeyPress: 
                                    KeyCode=XLookupKeysym(&(event.xkey),0);
                                    if (KeyCode==XK_Down)
                                    {
                                     Ptr5=NULL;
                                     for (Ptr4=Ptr1->Start[t];Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if (Ptr4->Selected!=FALSCH) { Ptr5=Ptr4; break; }
                                     }
                                     if (Ptr5==NULL) break;
 				     Ptr5->Selected=FALSCH;
                                     for (Ptr4=Ptr5->NextPtr;Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if ((Ptr4->Disable==FALSCH) && (Ptr4->Art!=STRICH)) { Ptr5=Ptr4; break; }
                                     }
                                     Ptr5->Selected=WAHR;
                                     MaleMenuItem(Ptr1->Start[t],Ptr1->xx[t],Ptr->Size.Y+Ptr->Size.dy);
                                     XFlush(display);
                                     break;
                                    }
                                    if (KeyCode==XK_Up)
                                    {
                                     Ptr5=NULL;
                                     for (Ptr4=Ptr1->Start[t];Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if (Ptr4->Selected!=FALSCH) { Ptr5=Ptr4; break; }
                                     }
                                     if (Ptr5==NULL) break;
 				     Ptr5->Selected=FALSCH;
                                     Ptr6=NULL;
                                     for (Ptr4=Ptr1->Start[t];Ptr4!=Ptr5;Ptr4=Ptr4->NextPtr)
                                     {
                                      if ((Ptr4->Disable==FALSCH) && (Ptr4->Art!=STRICH)) Ptr6=Ptr4;
                                     }
                                     if (Ptr6==NULL) Ptr5->Selected=WAHR;
                                     if (Ptr6!=NULL) Ptr6->Selected=WAHR;
                                     MaleMenuItem(Ptr1->Start[t],Ptr1->xx[t],Ptr->Size.Y+Ptr->Size.dy);
                                     XFlush(display);
                                     break;                                    
                                    }
                                    if ((KeyCode==XK_Return) || (KeyCode==XK_KP_Enter))
                                    { /* wenn ein feld aktiv -> fertig */
                                     for (Ptr4=Ptr1->Start[t];Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                                     {
                                      if (Ptr4->Selected!=FALSCH) 
                                      { 
                                       if (Ptr4->Art==EINTRAG_FLAG) 
                                       {
                                        if (Ptr4->Flag==WAHR) { Ptr4->Flag=FALSCH; } else  { Ptr4->Flag=WAHR; }
                                        MaleMenuItem(Ptr1->Start[t],Ptr1->xx[t],Ptr->Size.Y+Ptr->Size.dy);
                                        XFlush(display);
                                        Pause(250);
                                       }
                                       if (Ptr4->Child!=NULL)
                                       { /* ok, pop des child-fensters ! */ 
                                        MProc=NULL;
                                        if (WAHR==CheckMenuChild(Ptr4->Child,Ptr4->xx+2,Ptr4->y,region))
                                        { /* ok, beende alles */
                                         if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                         if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                         MaleMenu(Ptr);
                                         XFlush(display);
                                         if (MProc!=NULL) MProc(); 
                                         return(WAHR);
                                        } else
                                        {    /* bleibe hier */
                                         break; 
                                        }
                                       } else
                                       {
                                        if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                        if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                        MaleMenu(Ptr);
                                        XFlush(display);
                                        if (Ptr4->Proc!=NULL) { Ptr4->Proc(); LastObjekt=Ptr; }
                                        return(WAHR);
                                       }
                                      }
                                     }
                                    }
                                    if (KeyCode==XK_Left)
                                    {
                                     if (t>0) if (Ptr1->Start[t-1]!=NULL)
                                     { /* gehe nach links */
                                      if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                      if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                      MaleMenu(Ptr);
                                      CheckKlickAreaKind(flag,Ptr,Ptr1->xx[t-1]+2,y);
                                      return(WAHR);
                                     }
                                    }
                                    if ((KeyCode==XK_Right) && (t<30))
                                    {
                                     if (Ptr1->Start[t+1]!=NULL)
                                     {
                                      if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                      if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                      MaleMenu(Ptr);
                                      CheckKlickAreaKind(flag,Ptr,Ptr1->xx[t+1]+2,y);
                                      return(WAHR);
                                     }
                                    } 
                                    break;
                     case Expose:  if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                                   if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                                   MaleMenu(Ptr);
                                   CheckRepaintArea(event.xexpose.x,event.xexpose.y,event.xexpose.width,event.xexpose.height);
                                   return(WAHR);
                     case ButtonPress:   
                     {
                      /*** button gedrueckt ... innerhalb ? **/
                      if (XPointInRegion(region,event.xbutton.x,event.xbutton.y))                      
                      {
                       /* in der menuliste geklickt ! */
                       for (Ptr4=Ptr1->Start[t];Ptr4!=NULL;Ptr4=Ptr4->NextPtr)
                       {
                        if ((event.xbutton.y>Ptr4->y) && (event.xbutton.y<Ptr4->yy))
                        { /* geklicktes element element gefunden */
                         if (Ptr4->Disable==WAHR) break;
                         if (Ptr4->Art==STRICH) break;
                         if (Ptr4->Art==EINTRAG_FLAG) 
                         {
                          if (Ptr4->Flag==WAHR) { Ptr4->Flag=FALSCH; } else  { Ptr4->Flag=WAHR; }
                         }
                         for (Ptr5=Ptr1->Start[t];Ptr5!=NULL;Ptr5=Ptr5->NextPtr) Ptr5->Selected=FALSCH;              
                         Ptr4->Selected=WAHR;
                         MaleMenuItem(Ptr1->Start[t],Ptr1->xx[t],Ptr->Size.Y+Ptr->Size.dy);
                         XFlush(display);
 			 Pause(250);
                         if (Ptr4->Child!=NULL)
                         { /* ok, pop des child-fensters ! */ 
                          MProc=NULL;
                          if (WAHR==CheckMenuChild(Ptr4->Child,Ptr4->xx+2,Ptr4->y,region))
                          { /* ok, beende alles */
                           if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                           if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                           MaleMenu(Ptr);
                           XFlush(display);
                           if (MProc!=NULL) MProc();
                           return(WAHR);
                          } else
                          { /* bleibe hier */
                           break; 
                          }
                         } else
                         {
                          if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                          if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                          MaleMenu(Ptr);
                          XFlush(display);
                          if (Ptr4->Proc!=NULL) { Ptr4->Proc(); LastObjekt=Ptr; }
                          return(WAHR);
                         }
                        }
                       }
                      }  else
                      { /* ausserhalb !  im menu ? */
                       for (t=0;t<30;t++)
                       {
                        if ((Ptr1->xx[t]<event.xbutton.x) && (Ptr1->xx1[t]>event.xbutton.x) && (Ptr1->Start[t]!=NULL))
                        {
                         if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                         if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                         MaleMenu(Ptr);
                         XFlush(display);
                         CheckKlickAreaKind(flag,Ptr,event.xbutton.x,event.xbutton.y);
                         return(WAHR);
                        }
                       }
                       /* nicht in der menuleiste -> exit */
                       if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);
                       if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                       MaleMenu(Ptr);
                       return(WAHR);
                      }
                      break;
                     }
                    }
                   }        
                   /********* und fertig ! **********/
                  /* if (Bild!=NULL) XPutImage(display,window,gc,Bild,0,0,backx,backy,backdx,backdy);                     
                   if (Bild!=NULL) XDestroyImage(Bild); Bild=NULL;
                   MaleMenu(Ptr);
                   XFlush(display);
                  */
                   break;
                 }
                }
                
                
                
                
                return(WAHR);
               }
               
    case KARTEI: 
    		{	
                        struct Kartei *Ptr1;
                       if (Ptr->Focus==FALSCH) { SetFocus(Ptr); }
			Ptr1=(struct Kartei *)Ptr->Pointer;
		        x1=Ptr->Size.X;
		        y1=Ptr->Size.Y;
		        dx=Ptr->Size.dx;
		        fx=5;
		        zx=20;
		        zy=20;
		        Abstandx=(dx-2*fx*Ptr1->Spalten+0.0)/(Ptr1->Zeilen+0.0);
		        Abstandy=16.0;
 			for (ty=0;ty<(Ptr1->Spalten);ty++)
 			{
 			for (tx=0;tx<(Ptr1->Zeilen);tx++)
   			{
   		          x0=tx*Abstandx+x1+(Ptr1->Spalten-ty-1)*fx*2;
   		          y0=ty*Abstandy+y1;
   		          if ((x>x0) && (y>y0) && (y<(y0+Abstandy)) && (x<(x0+Abstandx)))
   		         { 
	 		   WechsleKarteiKarte(Ptr,tx,ty);
			   if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; }
 			   return(WAHR);
   		         }
   			}
   			}	 
    			 if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; } 
    			 return(WAHR);
   			}
    case EINGABE:     
			if (Ptr->Focus==FALSCH) { SetFocus(Ptr); }
			if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; }         
         	 	return(WAHR);
    case LISTE:      
			LastListe=Ptr;
                        LastObjekt=Ptr;
                        if (Ptr->Focus==FALSCH) { SetFocus(Ptr); }
                        CheckKlickAufListe(Ptr,x,y);
                        if (LastEingabeListe!=NULL)      
                        {   
                         struct Eingabeliste *EL;    
                         struct Liste *L;    
                         EL=(struct Eingabeliste *)LastEingabeListe->Vater->Pointer;    
                         L=(struct Liste *)EL->ListePtr->Pointer;    
                         SetObjektSichtbar(LastEingabeListe,FALSCH);    
                         LastEingabeListe=NULL;     
                        LastObjekt=Ptr;
                        }
                        
			if (Ptr->Proc!=NULL) Ptr->Proc();         
         		return(WAHR);
    case LISTBUTTON:  
			if (Ptr->Focus==FALSCH) { SetFocus(Ptr); }
			if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=Ptr; }        
         		return(WAHR);
    case BUTTON:       { 
    			 long x,y,xx,yy,dx,dy;
                         struct Button *Ptr5;
                         LastObjekt=Ptr;
                         Ptr5=(struct Button *)Ptr->Pointer;
                         if (Ptr->Focus==FALSCH) { SetFocus(Ptr); }
	       	         x=Ptr->Size.X;
			 y=Ptr->Size.Y;
			 dx=Ptr->Size.dx;
			 dy=Ptr->Size.dy;
			 xx=x+dx;
			 yy=y+dy;
			 if (Ptr->Focus==WAHR) { xx--; yy--; x++; y++; }
			 xx--; yy--; x++; y++;
			 XSetForeground (display,       Ptr->gc,color_gray);
			 XDrawLine      (display,window,Ptr->gc,x,y,xx,y);
			 XDrawLine      (display,window,Ptr->gc,x,y+1,xx-1,y+1);
			 XDrawLine      (display,window,Ptr->gc,x,y,x,yy);
			 XDrawLine      (display,window,Ptr->gc,x+1,y,x+1,yy-1);
			 XSetForeground (display,       Ptr->gc,color_white);
			 XDrawLine      (display,window,Ptr->gc,x,yy,xx,yy);
			 XDrawLine      (display,window,Ptr->gc,x+1,yy-1,xx-1,yy-1);
			 XDrawLine      (display,window,Ptr->gc,xx,y,xx,yy);
			 XDrawLine      (display,window,Ptr->gc,xx-1,y+1,xx-1,yy);                           
                         XFlush(display);
                         Pause(250); 
                         if (Ptr5->MenuPtr!=NULL) {  MProc=NULL;
                         CheckMenuChild(Ptr5->MenuPtr,x-2,yy+4,Ptr->region);
                         if (MProc!=NULL) MProc(); }
                         MaleButton(Ptr);

                         XFlush(display);
                         LastButton=Ptr;
			if (Ptr->Proc!=NULL) Ptr->Proc();         
         	        }
         		return(WAHR);
    case CHECKBOX:      { struct Checkbox *Ptr1;
                          LastObjekt=Ptr;
                         Ptr1=(struct Checkbox *)Ptr->Pointer;
                         if (Ptr1->value==WAHR) { Ptr1->value=FALSCH; } else { Ptr1->value=WAHR; }
                         SetFocus(Ptr);
                         MaleCheckBox(Ptr);
                         XFlush(display);
                        }
    			if (Ptr->Proc!=NULL) Ptr->Proc();         
         		return(WAHR);
    case SLIDER_H:    	
			LastSliderH=Ptr;
                         LastObjekt=Ptr;         	
       	                  BewegeSlider(Ptr,0,x,y);
                                                      LastSliderH=Ptr;
    			if (Ptr->Proc!=NULL) Ptr->Proc();
    			return(WAHR);
    case SLIDER_V:      
                        LastObjekt=Ptr;
                        LastObjekt=Ptr;
    			LastSliderV=Ptr;
    			BewegeSlider(Ptr,1,x,y);
                                         LastSliderV=Ptr;
    			if (Ptr->Proc!=NULL) Ptr->Proc();
    			return(WAHR);
    case BILD:      
                        LastObjekt=Ptr;
                        LastBild=Ptr;
    			if (Ptr->Proc!=NULL) Ptr->Proc();
    			return(WAHR);
   } 
  }
 }
 XFlush(display);
 return(FALSCH);
}

void PositionUpdate(Ptr,dx,dy)
struct Objekt *Ptr;
long dx,dy;
{
 if (Ptr!=NULL)
 {
  if (Ptr->Bruder!=NULL) PositionUpdate(Ptr->Bruder,dx,dy);
  if (Ptr->Kind!=NULL)   PositionUpdate(Ptr->Kind  ,dx,dy); 
  Ptr->Size.X+=dx;
  Ptr->Size.Y+=dy;
 } 
}

void BewegeRand(Ptr,X,Y,DX,DY,Posx,Posy,wert)
struct Objekt *Ptr;
long *X,*Y,*DX,*DY,Posx,Posy,wert;
{
 long xx1,yy1,dxx1,dyy1,dx1,dy1,x1,y1,k,z,x,y,dx,dy,xx,yy;
 GC my_gc;
 XGCValues values;
 XEvent event;
 
 x=*X;
 x1=x;
 y=*Y;
 y1=y;
 dx=*DX;
 dy=*DY;
 k=0; z=0;
 dx1=dx;
 dy1=dy;
 dxx1=dx;
 dyy1=dy;
 xx1=x;
 yy1=y;
 /***************/
 values.line_style=LineOnOffDash;
 my_gc=XCreateGC(display,window,GCLineStyle,&values);
 XSetFunction(display,my_gc,GXxor);
 XSetForeground(display,my_gc,color_gray);  
 XDrawRectangle(display,window,my_gc,x,y,dx,dy);
 for (;k==0;)
 {
  XFlush(display);
  XNextEvent(display,&event);
  switch (event.type)
  {
   case ButtonRelease:   
                        k=1;
                        if (z==0) 
                         {  
                           XDrawRectangle(display,window,my_gc,x,y,dx,dy); 
                           XSetFunction(display,my_gc,GXcopy);
                           XFreeGC(display,my_gc);  
                  	   XFlush(display);
                           return;  
                           }
                        break;
   case Expose:         
                        CheckRepaintArea(x,y,dx,dy);
   			XDrawRectangle(display,window,my_gc,x,y,dx,dy);
   			XFlush(display);
   			break;
   case MotionNotify:	event.xbutton.x-=Posx;
			z=1;
   			event.xbutton.y-=Posy;
                        XDrawRectangle(display,window,my_gc,x,y,dx,dy);
   			xx=x+dx;
   			yy=y+dy;
   			dx1=x;
   			dy1=y;
   			if (wert&1) { x=event.xbutton.x; }
   		        if (wert&2) { xx=event.xbutton.x; }
   			if (wert&4) { y=event.xbutton.y; }
   			if (wert&8) { yy=event.xbutton.y; }
   			dx=xx-x;
   			dy=yy-y;
   			if (dy<80) { dy=80; y=dy1; }
   			if (dx<80) { dx=80; x=dx1; }
   			XDrawRectangle(display,window,my_gc,x,y,dx,dy);
			XFlush(display);
   			break;
  }
 }
 
 PositionUpdate(Ptr->Kind,x-Ptr->Size.X,y-Ptr->Size.Y);     
 { 
  struct MyWindow *Ptr4;
  Ptr4=(struct MyWindow *)Ptr->Pointer;
  Ptr4->Ptr_Button1->Size.X=dx+x-20;
  Ptr4->InnenSize.X=x+4;
  Ptr4->InnenSize.Y=y+2;
  Ptr4->InnenSize.dx=dx-8;
  Ptr4->InnenSize.dy=dy-6;
  Ptr->Size.X=x;
  Ptr->Size.Y=y;
  Ptr->Size.dx=dx;
  Ptr->Size.dy=dy;
 }
 XDrawRectangle(display,window,my_gc,x,y,dx,dy);
 XSetFunction(display,my_gc,GXcopy);
 XFreeGC(display,my_gc);
 XFlush(display);
 BerechneFensterCliping(ObjektListe);
 CheckRepaintArea(xx1,yy1,dxx1+1,dyy1+1);
 CheckRepaintArea(x,y,dx,dy);
}


void BewegeFeld(Ptr,X,Y,DX,DY,Posx,Posy)
struct Objekt *Ptr;
long *X,*Y,*DX,*DY,Posx,Posy;
{
 long x1,y1,k,z,x,y,dx,dy;
 GC my_gc;
 XGCValues values;
 XEvent event;
 
 x=*X;
 x1=x;
 y=*Y;
 y1=y;
 dx=*DX;
 dy=*DY;
 k=0; z=0;
 /***************/
 values.line_style=LineOnOffDash;
 my_gc=XCreateGC(display,window,GCLineStyle,&values);
 XSetFunction(display,my_gc,GXxor);
 XSetForeground(display,my_gc,color_gray);  
 XDrawRectangle(display,window,my_gc,x,y,dx,dy);
 for (;k==0;)
 {
  XFlush(display);
  XNextEvent(display,&event);
  switch (event.type)
  {
   case ButtonRelease:   
                        k=1;
                        if (z==0) 
                         {  
                           XDrawRectangle(display,window,my_gc,x,y,dx,dy); 
                           XSetFunction(display,my_gc,GXcopy);
                           XFreeGC(display,my_gc);  
                  	   XFlush(display);
                           return;  
                           }
                        break;
   case Expose:         
                        CheckRepaintArea(x,y,dx,dy);
   			XDrawRectangle(display,window,my_gc,x,y,dx,dy);
   			XFlush(display);
   			break;
   case MotionNotify:	event.xbutton.x-=Posx;
			z=1;
   			event.xbutton.y-=Posy;
                        XDrawRectangle(display,window,my_gc,x,y,dx,dy);
   			x+=event.xbutton.x-x;
   			y+=event.xbutton.y-y;;
   			XDrawRectangle(display,window,my_gc,x,y,dx,dy);
   			XFlush(display);
   			break;
  }
 }
  
 
 XDrawRectangle(display,window,my_gc,x,y,dx,dy);
 PositionUpdate(Ptr->Kind,x-*X,y-*Y);
 { 
  struct MyWindow *Ptr4;
  Ptr4=(struct MyWindow *)Ptr->Pointer;
  Ptr4->InnenSize.X+=x-*X;
  Ptr4->InnenSize.Y+=y-*Y;
 }
 XSetFunction(display,my_gc,GXcopy);
 XFreeGC(display,my_gc);
 XFlush(display);
 *X=x;
 *Y=y;
 *DX=dx;
 *DY=dy;
 BerechneFensterCliping(ObjektListe);
 CheckRepaintArea(x1,y1,dx+1,dy+1);
 CheckRepaintArea(x,y,dx,dy);
}

void SetWindow(Ptr)
struct Objekt *Ptr;
{
 if ((Ptr!=ObjektListe) && (Ptr->Objekt_Typ==WINDOW)) 
   { /* bewege Window in den vordergrund */
    struct Objekt *PtrDaddy,*Ptr2;      
    struct MyWindow *Ptr1;
   Ptr1=(struct MyWindow *)Ptr->Pointer;
    PtrDaddy=NULL;
    for (Ptr2=ObjektListe;Ptr2!=NULL;Ptr2=Ptr2->Bruder)
    {
     if (Ptr==Ptr2) break;
     PtrDaddy=Ptr2;
    }
    Ptr2=ObjektListe;
    ObjektListe=Ptr;
    PtrDaddy->Bruder=Ptr->Bruder;
    Ptr->Bruder=Ptr2;
    if (Ptr->Fokusliste!=NULL) SetFocus(Ptr->Fokusliste->FokusObjekt);         
    
    BerechneFensterCliping(ObjektListe);
    CheckRepaintArea(Ptr2->Size.X,Ptr2->Size.Y,20,Ptr2->Size.dy);
    CheckRepaintArea(Ptr->Size.X,Ptr->Size.Y,Ptr->Size.dx,Ptr->Size.dy);

  }
}

void CheckKlickArea(x,y)
long x,y;
{
 struct Objekt *Ptr;
 for (Ptr=ObjektListe;Ptr!=NULL;Ptr=Ptr->Bruder) 
 {
 if (Ptr->Sichtbar==WAHR) 
 {
  if (XPointInRegion(Ptr->region, x, y))
  {
   short int ok;
  ok=1;
  if (Ptr->Objekt_Typ==WINDOW) ok=CheckKlickAreaKind(1,Ptr->Kind,x,y); 
  if (Ptr->Objekt_Typ!=WINDOW) ok=CheckKlickAreaKind(0,Ptr,x,y); 
  if ((Ptr!=ObjektListe) && (Ptr->Objekt_Typ==WINDOW)) 
   { /* bewege Window in den vordergrund */
    struct Objekt *PtrDaddy,*Ptr2;      
    struct MyWindow *Ptr1;
   Ptr1=(struct MyWindow *)Ptr->Pointer;
    PtrDaddy=NULL;
    for (Ptr2=ObjektListe;Ptr2!=NULL;Ptr2=Ptr2->Bruder)
    {
     if (Ptr==Ptr2) break;
     PtrDaddy=Ptr2;
    }
    Ptr2=ObjektListe;
    ObjektListe=Ptr;
    PtrDaddy->Bruder=Ptr->Bruder;
    Ptr->Bruder=Ptr2;
    if (Ptr->Fokusliste!=NULL) SetFocus(Ptr->Fokusliste->FokusObjekt);         
    
    BerechneFensterCliping(ObjektListe);
    CheckRepaintArea(Ptr2->Size.X,Ptr2->Size.Y,20,Ptr2->Size.dy);
    CheckRepaintArea(Ptr->Size.X,Ptr->Size.Y,Ptr->Size.dx,Ptr->Size.dy);
    if (Ptr1->Typ!=NOBORDER) return;
   }
   if (ok==WAHR) return;
   if ((Ptr->Objekt_Typ==WINDOW))
   { /* Nicht objekt im Window angeklickt */  
    struct MyWindow *Ptr1;
    Ptr1=(struct MyWindow *)Ptr->Pointer;
    if (Ptr1->Typ==NOBORDER)
    {
     /* bewege window */
   BewegeFeld(Ptr,&(Ptr->Size.X),&(Ptr->Size.Y),&(Ptr->Size.dx),
              &(Ptr->Size.dy),event.xbutton.x-Ptr->Size.X,event.xbutton.y-Ptr->Size.Y);
   return;
    }
    if (Ptr1->Typ!=NOBORDER)
    { 	/* im blauen Feld geklickt oder */
        /* am Rand oder innerhalb ......  */
        long A=16;
     if ( ((Ptr1->Typ==NORMALBORDER) && ( (Ptr->Size.X+A+4)<x ) && 
        ( (Ptr->Size.X+Ptr->Size.dx-A-1) > x ) && ( (Ptr->Size.Y+A+4)>y ) ) || 
          ((Ptr1->Typ==SMALLBORDER ) && ( (Ptr->Size.X+A+4)<x ) && 
          ( (Ptr->Size.X+Ptr->Size.dx-1  ) > x ) && ( (Ptr->Size.Y+A+4)>y ) )   ) 
      {
       if ((Ptr->Size.Y+3)<y)
       {
        BewegeFeld(Ptr,&(Ptr->Size.X),&(Ptr->Size.Y),&(Ptr->Size.dx),&(Ptr->Size.dy),
                   event.xbutton.x-Ptr->Size.X,event.xbutton.y-Ptr->Size.Y);
        return;
       }
      }
      if ((Ptr1->Typ==SMALLBORDER) && ((Ptr->Size.X+3)<x) && ((Ptr->Size.X+16)>x) 
         &&  ((Ptr->Size.Y+3)<y) && ((Ptr->Size.Y+21)>y))
      {
       
       SetObjektSichtbar(Ptr,FALSCH);
       BerechneFensterCliping(ObjektListe);
       CheckRepaintArea(Ptr->Size.X,Ptr->Size.Y,Ptr->Size.dx+1,Ptr->Size.dy+1);
       return;
      }
      if (Ptr1->Typ==NORMALBORDER)
      {
       long aha=0;
       long x0,x1,x2,x3,x4,x5,y0,y1,y2,y3,y4,y5;
       x0=Ptr->Size.X;
       x1=x0+3;
       x5=x1+16;
       x3=x0+Ptr->Size.dx;
       x2=x3-3;
       x4=x2-16;
       y0=Ptr->Size.Y;
       y1=y0+3;
       y5=y1+16;
       y3=y0+Ptr->Size.dy;
       y2=y3-3;
       y4=y2-16;
       
       if ((x0<x) && (x1>x) && (y5<y) && (y<y4)) aha=aha | 1 ;
       if ((x0<x) && (x1>x) && (y5>y)) aha=aha | 1 | 4 ; 
       if ((x0<x) && (x1>x) && (y>y4)) aha=aha | 1 | 8 ; 
       if ((x2<x) && (x3>x) && (y5<y) && (y<y4)) aha=aha | 2 ;
       if ((x2<x) && (x3>x) && (y5>y)) aha=aha | 2 | 4 ; 
       if ((x2<x) && (x3>x) && (y>y4)) aha=aha | 2 | 8 ; 
       if ((y0<y) && (y1>y) && (x5<x) && (x<x4)) aha=aha | 4 ;
       if ((y0<y) && (y1>y) && (x5>x))           aha=aha | 4 | 1 ; 
       if ((y0<y) && (y1>y) && (x>x4))           aha=aha | 4 | 2 ; 
       if ((y2<y) && (y3>y) && (x5<x) && (x<x4)) aha=aha | 8 ;
       if ((y2<y) && (y3>y) && (x5>x))           aha=aha | 8 | 1 ; 
       if ((y2<y) && (y3>y) && (x>x4))           aha=aha | 8 | 2 ; 
              
       if (aha!=0) 
       {
        BewegeRand(Ptr,&(Ptr->Size.X),&(Ptr->Size.Y),&(Ptr->Size.dx),&(Ptr->Size.dy),0,0 ,aha);
        return;
       }
      }
    }
    return;
   }
  }
 }
 }
}

void CheckCursor(x,y)
long x,y;
{
 long aha=0;
 long x0,x1,x2,x3,x4,x5,y0,y1,y2,y3,y4,y5;
 struct Objekt   *Ptr;
 struct MyWindow *Ptr1;
 for (Ptr=ObjektListe;Ptr!=NULL;Ptr=Ptr->Bruder)
 {
  if ((Ptr->Objekt_Typ==WINDOW) && (Ptr->Sichtbar==WAHR))
  {
   if (XPointInRegion(Ptr->region, x, y))
   {
   Ptr1=(struct MyWindow *)Ptr->Pointer;
   if (Ptr1->Typ==NORMALBORDER)
      {
       x0=Ptr->Size.X;
       x1=x0+3;
       x5=x1+16;
       x3=x0+Ptr->Size.dx;
       x2=x3-3;
       x4=x2-16;
       y0=Ptr->Size.Y;
       y1=y0+3;
       y5=y1+16;
       y3=y0+Ptr->Size.dy;
       y2=y3-3;
       y4=y2-16;
       
       if ((x0<x) && (x1>x) && (y5<y) && (y<y4)) aha=aha | 1 ;
       if ((x0<x) && (x1>x) && (y5>y)) aha=aha | 1 | 4 ; 
       if ((x0<x) && (x1>x) && (y>y4)) aha=aha | 1 | 8 ; 
       if ((x2<x) && (x3>x) && (y5<y) && (y<y4)) aha=aha | 2 ;
       if ((x2<x) && (x3>x) && (y5>y)) aha=aha | 2 | 4 ; 
       if ((x2<x) && (x3>x) && (y>y4)) aha=aha | 2 | 8 ; 
       if ((y0<y) && (y1>y) && (x5<x) && (x<x4)) aha=aha | 4 ;
       if ((y0<y) && (y1>y) && (x5>x))           aha=aha | 4 | 1 ; 
       if ((y0<y) && (y1>y) && (x>x4))           aha=aha | 4 | 2 ; 
       if ((y2<y) && (y3>y) && (x5<x) && (x<x4)) aha=aha | 8 ;
       if ((y2<y) && (y3>y) && (x5>x))           aha=aha | 8 | 1 ; 
       if ((y2<y) && (y3>y) && (x>x4))           aha=aha | 8 | 2 ; 
       if ((aha!=0) && (cu!=aha))
       {
         XDefineCursor(display,window,MyCursor[aha]);
         XFlush(display);
         cu=aha;
         return;
       }
       if (aha!=0) return;
    }
   }
  }
 } 
 if (cu!=-1) 
 {
  XDefineCursor(display,window,MyCursor[0]);        
  XFlush(display);
  cu=-1;
 }
}

void TakeControl()
{
 XMapRaised(display,window);
 raised=WAHR;
 for (;;)
 {
  XFlush(display);
  XNextEvent(display, &event);
  switch(event.type)
  {
   case ButtonPress:   LastMouseX=event.xbutton.x; LastMouseY=event.xbutton.y; CheckKlickArea(event.xbutton.x,event.xbutton.y); break;
   case KeyRelease:    CheckKeyRelease(); break;
   case KeyPress:      CheckKeyPress(); break;
   case Expose:        CheckRepaintArea(event.xexpose.x,event.xexpose.y,event.xexpose.width,event.xexpose.height); break;
   case MotionNotify:  CheckCursor(event.xmotion.x,event.xmotion.y); break;
  } 
 }
}

void TakeControlUntil(P1,P2,P3,P4,P5,P6)
struct Objekt *P1,*P2,*P3,*P4,*P5,*P6;
{
 long exitnow;
 BerechneFensterCliping(ObjektListe);
 CheckRepaintArea(0,0,1000,1000);
 raised=WAHR;
 LastObjekt=NULL;
 exitnow=0;
 for (;exitnow==0;)
 {
  XFlush(display);
  XNextEvent(display, &event);
  switch(event.type)
  {
   case ButtonPress:   CheckKlickArea(event.xbutton.x,event.xbutton.y); break;
   case KeyRelease:    CheckKeyRelease(); break;
   case KeyPress:      CheckKeyPress(); break;
   case Expose:        CheckRepaintArea(event.xexpose.x,event.xexpose.y,event.xexpose.width,event.xexpose.height); break;
   case MotionNotify:  CheckCursor(event.xmotion.x,event.xmotion.y); break;
  }
  if (LastObjekt==P1) exitnow=1; 
  if (LastObjekt==P2) exitnow=1; 
  if (LastObjekt==P3) exitnow=1; 
  if (LastObjekt==P4) exitnow=1; 
  if (LastObjekt==P5) exitnow=1; 
  if (LastObjekt==P6) exitnow=1; 
 }
}



struct Objekt *CreateButton(Vater,Titel,x,y,dx,dy,sichtbar,Focus,Proc)
struct Objekt 	*Vater;
char          	*Titel;
long 		x,y,dx,dy;
short int sichtbar,Focus;
int (* Proc)();
{
 struct Objekt *Ptr;
 struct Button *Ptr1;
 Ptr=Neues_Objekt_Anlegen(Vater,BUTTON,x,y,dx,dy,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Button *)Ptr->Pointer;
  Ptr1->MenuPtr=NULL;
  Ptr1->Bildnr=0;
  strcpy(Ptr1->Titel,Titel);  
 } 
 return(Ptr);
}

struct Objekt *CreateText(Vater,Titel,x,y,sichtbar)
struct Objekt 	*Vater;
char          	*Titel;
long 		x,y;
short int sichtbar;
{
long dx;
 struct Objekt *Ptr;
 struct Text *Ptr1;
dx=XTextWidth(xfontinfo,Titel,strlen(Titel))+10; 
Ptr=Neues_Objekt_Anlegen(Vater,TEXT,x,y,dx,18,sichtbar,NIEWAHR,NULL);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Text *)Ptr->Pointer;
  strcpy(Ptr1->Titel,Titel);  
 } 
 return(Ptr);
}


struct Objekt *CreateCheckbox(Vater,Titel,x,y,sichtbar,Focus,value,Proc)
struct Objekt 	*Vater;
char          	*Titel;
long 		x,y;
short int sichtbar,Focus,value;
int (* Proc)();
{
 long dx,dy;
 struct Objekt *Ptr;
 struct Checkbox *Ptr1;
 dx=18+10+XTextWidth(xfontinfo,Titel,strlen(Titel))+10;
 dy=18;
 Ptr=Neues_Objekt_Anlegen(Vater,CHECKBOX,x,y,dx,dy,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Checkbox *)Ptr->Pointer;
  Ptr1->value=value;
  strcpy(Ptr1->Titel,Titel);  
 } 
 return(Ptr);
}


struct Objekt *CreateBox(Vater,Titel,x,y,dx,dy,sichtbar)
struct Objekt 	*Vater;
char          	*Titel;
long 		x,y,dx,dy;
short int sichtbar;
{
 struct Objekt *Ptr;
 struct Box *Ptr1;
 Ptr=Neues_Objekt_Anlegen(Vater,BOX,x,y,dx,dy,sichtbar,FALSCH,NULL);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Box *)Ptr->Pointer;
  strcpy(Ptr1->Titel,Titel);  
 } 
 return(Ptr);
}

struct Objekt *CreateKartei(Vater,Karte,x,y,dx,dy,Spalten,Zeilen,sichtbar,Focus,Proc)
struct Objekt   *Vater;
struct Objekt	**Karte;
long            x,y,Zeilen,Spalten,dx,dy;
short int sichtbar,Focus;
int (* Proc)();
{
 struct Objekt *Ptr,*Ptr2;
 struct Kartei *Ptr1;
 Ptr=Neues_Objekt_Anlegen(Vater,KARTEI,x,y,dx,dy,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  long x1,y1,z;
  z=0;
  Ptr1=(struct Kartei *)Ptr->Pointer;
  Ptr1->Zeilen=Spalten;
  Ptr1->Spalten=Zeilen;
  Ptr1->Aktuell=0;
  dy=dy-(Zeilen+1)*16+10-1;
  y=y+Zeilen*16-12+16+1;
  x=x+3;
  dx=dx-(Zeilen+1)*10+4;
  for (y1=0;y1<Spalten;y1++)
  {
   for (x1=0;x1<Zeilen;x1++)
   {
    Ptr2=Neues_Objekt_Anlegen(Ptr,KARTEI_ELEMENT,x,y,dx,dy,FALSCH,FALSCH,Proc); 
    Ptr1->Kinder[z]=Ptr2;
    Karte[z]=Ptr2;
    Ptr1->Tabelle[x1]=Zeilen-x1-1;
    z++;
   }
  }
  Karte[0]->Sichtbar=sichtbar;
  Karte[0]->Focus=Focus;
  WechsleKarteiKarte(Ptr,0,Zeilen-1);
 } 
 
 return(Ptr);
}


struct Objekt *CreateEingabe(Vater,Titel,Art,Suffix,x,y,dx,sichtbar,Focus,Proc)
struct Objekt 	*Vater;
char          	*Titel,*Suffix;
short int Art;
long 		x,y,dx;
short int sichtbar,Focus;
int (* Proc)();

{
 long dy;
 struct Objekt *Ptr;
 struct Eingabe *Ptr1;
 dy=xfontinfo->ascent+xfontinfo->descent+6; 
 Ptr=Neues_Objekt_Anlegen(Vater,EINGABE,x,y,dx,dy,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Eingabe *)Ptr->Pointer;
  Ptr1->Art=Art;
  Ptr1->Cursor=strlen(Titel);
  strcpy(Ptr1->Suffix,Suffix);
  strcpy(Ptr1->Titel,Titel);  
  Ptr1->wert=0;
  if (Art==ZAHLEN)
  {
   Ptr1->Button_UP=CreateButton(Ptr,"",Ptr->Size.X+Ptr->Size.dx+2,Ptr->Size.Y+2,13,7,WAHR,NIEWAHR,KlickFromEingabeButton);
   CreateButton(Ptr,"",Ptr->Size.X+Ptr->Size.dx+2,Ptr->Size.Y+11,13,7,WAHR,NIEWAHR,KlickFromEingabeButton);  
   sprintf(Ptr1->Titel,"%ld",Ptr1->wert);
  }
 } 
 return(Ptr);
}


struct Objekt *CreateEingabeListe(Vater,Titel,x,y,dx,dy,sichtbarH,sichtbarV,Proc)
struct Objekt 	*Vater;
char          	*Titel;
long 		x,y,dx,dy;
short int sichtbarH,sichtbarV;
int (* Proc)();
{
 struct Objekt *Ptr;
 long dy1;
 struct Eingabeliste *Ptr1;
 struct Eingabe *Ptr2;
 dy1=xfontinfo->ascent+xfontinfo->descent+6;
 Ptr=Neues_Objekt_Anlegen(Vater,EINGABELISTE,x,y,dx+18,dy+36,WAHR,NIEWAHR,NULL);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Eingabeliste *)Ptr->Pointer;
  Ptr1->EingabePtr=CreateEingabe(Ptr,"Test",ZEICHEN,"",x,y,dx,WAHR,WAHR,Proc);
  Ptr2=(struct Eingabe *)Ptr1->EingabePtr->Pointer;
  Ptr2->Art=ZEICHEN;
  Ptr2->Cursor=strlen(Titel);
  strcpy(Ptr2->Suffix,"");
  strcpy(Ptr2->Titel,Titel);  
  Ptr2->wert=0;
  Ptr1->ButtonPtr=CreateButton(Ptr,"",x+dx+2,y+2,15,15,WAHR,NIEWAHR,ButtonEingabeListeNotifyProc);
  {
   struct Button *Ptr5;
   Ptr5=(struct Button *)Ptr1->ButtonPtr->Pointer;
   Ptr5->Bildnr=1;
  }
  Ptr1->ListePtr=CreateListbox(Ptr,x,y+21,dx+2,dy,sichtbarV,sichtbarH,FALSCH,WAHR,Proc);
 } 
 return(Ptr);
}



struct Objekt *CreateSliderH(Vater,x,y,dx,min,wert,max,sichtbar,Focus,Proc)
struct Objekt 	*Vater;
long 		x,y,dx,min,max,wert;
short int sichtbar,Focus;
int (* Proc)();
{
 struct Objekt *Ptr;
 struct SliderH *Ptr1;
 struct Button *Ptr5;
 Ptr=Neues_Objekt_Anlegen(Vater,SLIDER_H,x,y,dx,15,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  Ptr1=(struct SliderH *)Ptr->Pointer;
  Ptr1->min=min;
  Ptr1->max=max;
  Ptr1->wert=wert;
  Ptr1->Ptr_DOWN=CreateButton(Ptr,"",Ptr->Size.X,Ptr->Size.Y,15,15,WAHR,NIEWAHR,KlickButtonFromSlider);
  Ptr5=(struct Button *)Ptr1->Ptr_DOWN->Pointer;
  Ptr5->Bildnr=5;
  Ptr1->Ptr_UP=CreateButton(Ptr,"",Ptr->Size.X+Ptr->Size.dx-15,Ptr->Size.Y,15,15,WAHR,NIEWAHR,KlickButtonFromSlider);  
  Ptr5=(struct Button *)Ptr1->Ptr_UP->Pointer;
  Ptr5->Bildnr=4;
 } 
 return(Ptr);
}

struct Objekt *CreateSliderV(Vater,x,y,dx,min,wert,max,sichtbar,Focus,Proc)
struct Objekt 	*Vater;
long 		x,y,dx,min,max,wert;
short int sichtbar,Focus;
int (* Proc)();
{
 struct Objekt *Ptr;
 struct SliderV *Ptr1;

 Ptr=Neues_Objekt_Anlegen(Vater,SLIDER_V,x,y,15,dx,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  struct Button *Ptr5;
  Ptr1=(struct SliderV *)Ptr->Pointer;
  Ptr1->min=min;
  Ptr1->max=max;
  Ptr1->wert=wert;
  Ptr1->Ptr_DOWN=CreateButton(Ptr,"",Ptr->Size.X,Ptr->Size.Y,15,15,WAHR,NIEWAHR,KlickButtonFromSlider);
  {
  struct Button *Ptr5;
  Ptr5=(struct Button *)Ptr1->Ptr_DOWN->Pointer;
  Ptr5->Bildnr=3;
  }
  Ptr1->Ptr_UP=CreateButton(Ptr,"",Ptr->Size.X,Ptr->Size.Y+Ptr->Size.dy-15,15,15,WAHR,NIEWAHR,KlickButtonFromSlider);  
  Ptr5=(struct Button *)Ptr1->Ptr_UP->Pointer;
  Ptr5->Bildnr=2;
 } 
 return(Ptr);
}

short int Check(Seek,Name)
char *Seek,*Name;
{
 int length,t,i;
 if (0==strcmp(Seek,""))    return(1) ;
 if (0==strcmp(Seek,"*"))   return(1) ;
 if (0==strcmp(Seek,"*.*")) return(1) ;
 length=strlen(Name);
 for (t=0;t<length;t++)
 {
  
  if (Seek[t]=='*')
  {
   if (t==strlen(Seek)-1) return(1);
   for (i=t;i<length;i++)
   {
    if (1==Check(&(Seek[t+1]),&(Name[i]))) return(1);
   }
   return(0);
  }
  if (Name[t]!=Seek[t]) return(0);
 }
 return(1);
}

char *GetPath(Ptr)
struct Objekt *Ptr;
{
 struct Liste *P;
 if (Ptr!=NULL)
 {
  P=(struct Liste *)Ptr->Pointer;
  return(P->Pfad);
 }
 return(NULL);
}

void DateiAktuell();
void OrdnerAktuell();



void SetSuchString(Ptr,Such)
struct Objekt *Ptr;
char *Such;
{
 struct Liste *P;
 if (Ptr!=NULL)
 {
  LastListe=Ptr;
  P=(struct Liste *)Ptr->Pointer;
  strcpy(P->SuchString, Such);
  DateiAktuell(Ptr);
 }
}

void SetPath(Ptr,Such)
struct Objekt *Ptr;
char *Such;
{
 struct Liste *P;
 if (Ptr!=NULL)
 {
  P=(struct Liste *)Ptr->Pointer;
  strcpy(P->Pfad, Such);
 if (P->Proc==NULL) { LastListe=Ptr; DateiAktuell();  } else { LastListe=Ptr; OrdnerAktuell(); } 

}
}

void DateiAktuell()
{
 DIR *dir_fd;
 char Name[600];
 struct stat stat_buffer;
 struct dirent *dirent_ptr;
 struct Liste *Ptr;
 if (LastListe!=NULL)
  {
   Ptr=(struct Liste *)LastListe->Pointer;
   dir_fd=opendir(Ptr->Pfad); 
   if (dir_fd!=NULL)
   {

   ClearListe(LastListe);
 
   for (;;)
    {
 
    dirent_ptr=readdir(dir_fd);
     if (dirent_ptr==NULL) break;
     sprintf(Name,"%s%s",Ptr->Pfad,dirent_ptr->d_name);     
     stat(Name,&stat_buffer);
     if (S_ISREG(stat_buffer.st_mode)) 
     {
      doo=1;

      if (Check(Ptr->SuchString,dirent_ptr->d_name)) AddListElement(LastListe,dirent_ptr->d_name);

      doo=0;
     }
   }
    closedir(dir_fd);
   }
  }

 doo=0;
 Male_Objekt(LastListe);
 Male_Objekt_alle_Kinder_und_alle_Brueder(LastListe->Kind); 

}

void OrdnerGo()
{
 struct Liste *Ptr;
 struct Element *P;
 char into[600],a;
  long t;
 Ptr=(struct Liste *)LastListe->Pointer;
 for (P=Ptr->Elemente;P!=NULL;P=P->NextPtr) 
 {
  if (P->Selected==WAHR)
  {
   if ((strcmp(P->TextEintrag,".")==0) || (strcmp(P->TextEintrag,"..")==0)) 
   {  /* und hochgehen */
    if (strlen(Ptr->Pfad)!=1)
    { 
     for (t=strlen(Ptr->Pfad)-2;;t--)
     { 
       a='/';
       if (Ptr->Pfad[t]==a) { Ptr->Pfad[t+1]=0; break; }
     }
    }
   OrdnerAktuell();

    return;
   }
   /* dann eben runtergehen */
    sprintf(into,"%s%s/",Ptr->Pfad,P->TextEintrag);
    strcpy(Ptr->Pfad,into); 
    OrdnerAktuell();
    return;
  } 
 }
}

char *GetSelected(Ptr1)
struct Objekt *Ptr1;
{
 struct Liste *Ptr;
 struct Element *P;
 Ptr=(struct Liste *)LastListe->Pointer;
 for (P=Ptr->Elemente;P!=NULL;P=P->NextPtr) 
 {
  if (P->Selected==WAHR)
  {
    return(P->TextEintrag);
  }
 }
 return(NULL);
}


void OrdnerAktuell()
{
 DIR *dir_fd;
 char Name[600];
 struct stat stat_buffer;
 struct dirent *dirent_ptr;
 struct Liste *Ptr;
 if (LastListe!=NULL)
  {
   Ptr=(struct Liste *)LastListe->Pointer;
   dir_fd=opendir(Ptr->Pfad); 
   if (dir_fd!=NULL)
   {
    ClearListe(LastListe);
    for (;;)
    {
     dirent_ptr=readdir(dir_fd);
     if (dirent_ptr==NULL) break;
     sprintf(Name,"%s%s",Ptr->Pfad,dirent_ptr->d_name);     
     stat(Name,&stat_buffer);
     if (S_ISDIR(stat_buffer.st_mode)) 
     {
      doo=1;
      AddListElement(LastListe,dirent_ptr->d_name);
      doo=0;
     }
   }
    closedir(dir_fd);
    Male_Objekt(LastListe);
    Male_Objekt_alle_Kinder_und_alle_Brueder(LastListe->Kind); 
    if (Ptr->Proc!=NULL) { Ptr->Proc(); LastObjekt=LastListe; }
   } else
   {
    struct Liste *Ptr;
    char a;
    long t;
    Ptr=(struct Liste *)LastListe->Pointer;
    if (strlen(Ptr->Pfad)!=1)
    {
     for (t=strlen(Ptr->Pfad)-2;;t--)
     { 
       a='/';
       if (Ptr->Pfad[t]==a) { Ptr->Pfad[t+1]=0; break; }
     }
    }
   OrdnerAktuell();

   }
  }
}



struct Objekt *CreateOrdnerListbox(Vater,x,y,dx,dy,sichtbarH,sichtbarV,sichtbar,Focus,Proc)
struct Objekt 	*Vater;
long 		x,y,dx,dy;
short int sichtbar,Focus,sichtbarH,sichtbarV;
 int (* Proc)();
{
 struct Objekt *Ptr;
 struct Liste *L;
 Ptr=CreateListbox(Vater,x,y,dx,dy,sichtbarH,sichtbarV,sichtbar,Focus,OrdnerGo); 
 L=(struct Liste *)Ptr->Pointer;
 strcpy(L->Pfad,ANFANGPFAD);
 strcpy(L->SuchString,"*"); 
 L->Proc=Proc;
 LastListe=Ptr;
 OrdnerAktuell();
 return(Ptr);
}

struct Objekt *CreateDateiListbox(Vater,x,y,dx,dy,sichtbarH,sichtbarV,sichtbar,Focus,Proc)
struct Objekt 	*Vater;
long 		x,y,dx,dy;
short int sichtbar,Focus,sichtbarH,sichtbarV;
int (* Proc)();
{
 struct Objekt *Ptr;
 struct Liste *L;
 Ptr=CreateListbox(Vater,x,y,dx,dy,sichtbarH,sichtbarV,sichtbar,Focus,Proc); 
 L=(struct Liste *)Ptr->Pointer;
 strcpy(L->Pfad,ANFANGPFAD);
 strcpy(L->SuchString,"*"); 
 LastListe=Ptr;
 DateiAktuell();
 return(Ptr);
}


struct Objekt *CreateListbox(Vater,x,y,dx,dy,sichtbarH,sichtbarV,sichtbar,Focus,Proc)
struct Objekt 	*Vater;
long 		x,y,dx,dy;
short int sichtbar,Focus,sichtbarH,sichtbarV;
int (* Proc)();
{
 struct Objekt *Ptr;
 struct Liste *Ptr1;
 long g;
 Ptr=Neues_Objekt_Anlegen(Vater,LISTE,x,y,dx,dy,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Liste *)Ptr->Pointer;
  Ptr1->Start=NULL;
 Ptr1->DeltaX=0;
 Ptr1->Proc=NULL;
 Ptr1->Abstand=0.0;
 Ptr1->SichtbarH=sichtbarH;
 Ptr1->SichtbarV=sichtbarV;
 Ptr1->Elemente=NULL;
  g=0;
  if ((sichtbarH==WAHR) && (sichtbarV==WAHR)) g=15;
  Ptr1->PtrH=CreateSliderH(Ptr,x,y+dy,dx,1,1,1,sichtbarH,WAHR,NotifySliderVFromListBox);
  Ptr1->PtrV=CreateSliderV(Ptr,x+dx,y,dy+g,1,1,1,sichtbarV,WAHR,ListBoxSliderNotify);
 } 
 return(Ptr);
}


struct Objekt *CreateBild(Vater,x,y,dx,dy,sichtbarH,sichtbarV,sichtbar,Focus,Proc,Proc_repaint)
struct Objekt 	*Vater;
long 		x,y,dx,dy;
short int sichtbar,Focus,sichtbarH,sichtbarV;
int (* Proc)();
int (* Proc_repaint)();
{
 struct Objekt *Ptr;
 struct Bild *Ptr1;
 long g;

 Ptr=Neues_Objekt_Anlegen(Vater,BILD,x,y,dx,dy,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  Ptr1=(struct Bild *)Ptr->Pointer;
  Ptr1->Proc=Proc_repaint;
  Ptr1->SichtbarH=sichtbarH;
  Ptr1->SichtbarV=sichtbarV;
  g=0;
  if ((sichtbarH==WAHR) && (sichtbarV==WAHR)) g=15;
  Ptr1->PtrH=CreateSliderH(Ptr,x,y+dy,dx,1,1,1,sichtbarH,WAHR,Proc);
  Ptr1->PtrV=CreateSliderV(Ptr,x+dx,y,dy+g,1,1,1,sichtbarV,WAHR,Proc);
 } 
 return(Ptr);
}


struct Objekt *CreateWindow(Typ,Titel,x,y,dx,dy,sichtbar,Focus,Proc)
short int Typ;
char          	*Titel;
long 		x,y,dx,dy;
short int sichtbar,Focus;
int (* Proc)();
{
 struct Objekt *Ptr,*Ptr6;
 struct MyWindow *Ptr1;
 Ptr=Neues_Objekt_Anlegen(NULL,WINDOW,x,y,dx,dy,sichtbar,Focus,Proc);
 if (Ptr!=NULL)
 {
  Ptr1=(struct MyWindow *)Ptr->Pointer;
  strcpy(Ptr1->Titel,Titel);  
  /* Schwarzer Rahmen */
  Ptr1->Typ=Typ;
  Ptr1->InnenSize=Ptr->Size;
  Ptr1->InnenSize.X+=2;
  Ptr1->InnenSize.Y+=2;
  Ptr1->InnenSize.dx-=4;
  Ptr1->InnenSize.dy-=6;
  Ptr1->dx1=0;
  if (Typ==SMALLBORDER)
  {
    Ptr1->dx1=xfontinfo->ascent+xfontinfo->descent+6;
    Ptr1->InnenSize.Y+=Ptr1->dx1;
    Ptr1->InnenSize.dy-=Ptr1->dx1-3;
  } 
  if (Typ==NORMALBORDER)
  {
    Ptr1->dx1=xfontinfo->ascent+xfontinfo->descent+6;
    Ptr1->InnenSize.X+=2;
    Ptr1->InnenSize.dx-=4;
    Ptr1->Ptr_Button1=CreateButton(Ptr,"",x+dx-15-5,y+3,17,16,WAHR,NIEWAHR,NULL);
    {
     struct Button *Ptr5;
     Ptr5=(struct Button *)Ptr1->Ptr_Button1->Pointer;
     Ptr5->Bildnr=3;
    }
    Ptr6=CreateButton(Ptr,"",x+3,y+3      ,17,16,WAHR,NIEWAHR,KlickFensterCloseButton);
    {
     struct Button *Ptr5;
     Ptr5=(struct Button *)Ptr6->Pointer;
     Ptr5->Bildnr=6;
    }
    
  }
 } 
 return(Ptr);
}

struct Objekt *CreateMenu(Vater,T,anz)
struct Objekt *Vater;
unsigned char   *T;
long anz;
{
 struct Objekt *Ptr;
 struct Menu *Ptr1;
 unsigned char Titel[50][100];
 unsigned char *T1;
 long x,y,dx,dy;
 Ptr=NULL;
 if (Vater==NULL)
 {
 x=0;y=0;dx=10000;
 dy=17;
 } else
 {
  long ddy;
  ddy=0;
 if ((Vater->Objekt_Typ!=WINDOW) && (Vater->Objekt_Typ!=KARTEI_ELEMENT)) { return(NULL); }
 if (Vater->Objekt_Typ==WINDOW)
 {
  struct MyWindow *Ptr2;
  Ptr2=(struct MyWindow *)Vater->Pointer;
  if (Ptr2->Typ==NORMALBORDER) ddy=19;
  if (Ptr2->Typ==SMALLBORDER) ddy=21;
  }
  x=Vater->Size.X;
  y=Vater->Size.Y+ddy;
  dx=Vater->Size.dx+2000;
  dy=17;
 }
 Ptr=Neues_Objekt_Anlegen(Vater,MENU,x,y,dx,dy,WAHR,FALSCH,NULL);
 if (Ptr!=NULL)
 {
  long t;
  Ptr1=(struct Menu *)Ptr->Pointer;
  T1=&Titel[0][0];
  for (t=0;t<(anz*100);t++) { *T1=*T; T++; T1++; }
  for (t=0;t<30;t++) { Ptr1->Start[t]=NULL; strcpy(Ptr1->Titel[t],""); }
  t=0;
  for (;;)
  {
  if (t==(anz-1)) break;  
  strcpy(Ptr1->Titel[t],Titel[t]);
  t++;
  }
 } 
 return(Ptr);     
}

void SetKarteiKarteText(Ptr,Titel)
struct Objekt *Ptr;
char *Titel;
{
 struct KarteiKarte_Element *Ptr2;
 Ptr2=(struct KarteiKarte_Element *)Ptr->Pointer;
 strcpy(Ptr2->Titel,Titel);
}

