home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / chemesthetics_427.lzh / Chemesthetics / Source / Source.LZH / extra.c < prev    next >
C/C++ Source or Header  |  1990-12-06  |  5KB  |  227 lines

  1. #include <stdio.h>
  2. #include <intuition/intuitionbase.h>
  3. #include <graphics/gfxbase.h>
  4. #include <exec/types.h>
  5.  
  6. #define EXIST 0
  7. #define EXECUTE 1
  8. #define WRITE 2
  9. #define READ 4
  10.  
  11. extern char ProgId[],Version[];
  12. extern int Revision;
  13. extern char UserId[],Date[];
  14. void WrConWin();
  15.  
  16. Block(win,col,x1,y1,width,height)         /* Block zeichnen */
  17. struct Window *win;
  18. int col,x1,y1,width,height;
  19. {
  20.   struct RastPort *RP;
  21.   if(width==0 || height ==0) return;
  22.   RP=win->RPort;
  23.   SetDrMd(RP,JAM1);
  24.   SetAPen(RP,col);
  25.   RectFill(RP,x1,y1,x1+width-1,y1+height-1);
  26. }
  27.  
  28. Box(win,col1,col2,x1,y1,width,height)   /*  leere Box mit Rahmen zeichnen */
  29. struct Window *win;
  30. int col1,col2,x1,y1,width,height;
  31. {
  32.   struct RastPort *RP;
  33.   if(width==0 || height==0) return;
  34.   RP=win->RPort;
  35.   SetDrMd(RP,JAM1);
  36.   SetAPen(RP,col1);
  37.   RectFill(RP,x1,y1,x1+width-1,y1+height-1);
  38.   SetAPen(RP,col2);
  39.   RectFill(RP,x1+1,y1+1,x1+width-2,y1+height-2);
  40. }
  41.  
  42. Check_Pathname(Pfadname)
  43. char *Pfadname;
  44. {
  45.   int l;
  46.   l=strlen(Pfadname);
  47.   if (l)
  48.   {
  49.     if(Pfadname[l-1]!=':' && Pfadname[l-1]!='/')
  50.       strcat(Pfadname,"/");
  51.   }
  52. }
  53.  
  54. Cls(win,col)                      /* Bildschirm löschen in Farbe col */
  55. struct Window *win;
  56. int col;
  57. {
  58.   Move(win->RPort,0,0);       /* Rastport in die obere linke Ecke setzen */
  59.   SetRast(win->RPort,col);
  60.   RefreshWindowFrame(win);
  61.   RemakeDisplay();
  62. }
  63.  
  64. Ellipse(win,col,x,y,rx,ry)                 /* Ellipse zeichnen */
  65. struct Window *win;
  66. int col,x,y,rx,ry;
  67. {
  68.   struct RastPort *RP;
  69.   RP=win->RPort;
  70.   SetDrMd(RP,JAM1);
  71.   SetAPen(RP,col);
  72.   DrawEllipse(RP,x,y,rx,ry);
  73. }
  74.  
  75. /* oeffnet CONSOLE-Window f. (Revision-)Messages */
  76.  
  77. int OpenRevWin(size)
  78. char *size;
  79. {
  80.   int window;
  81.   char Str1[180],Str2[190];
  82.   window=open(size,2,0);
  83.   if(window==-1)
  84.     return(-1);
  85.   sprintf(Str1,"%s %s - Revision %d\n\n",ProgId,Version,Revision);
  86.   sprintf(Str2,"latest update by: %s  %s\n\n",UserId,Date);
  87.   WrConWin(window,Str1);
  88.   WrConWin(window,Str2);
  89.   return(window);
  90. }
  91.  
  92. Pixel(win,col,x,y)               /* Punkt setzen */
  93. struct Window *win;
  94. int col,x,y;
  95. {
  96.   struct RastPort *RP;
  97.   RP=win->RPort;
  98.   SetDrMd(RP,JAM1);
  99.   SetAPen(RP,col);
  100.   WritePixel(RP,x,y);
  101. }
  102.  
  103. Print(win,text,col1,col2,xpos,ypos)      /* Ausgabe von Text */
  104. struct Window *win;
  105. char *text;
  106. int col1,col2,xpos,ypos;
  107. {
  108.   int dx=4,width=win->GZZWidth;
  109.   struct RastPort *RP;
  110.  
  111. /*  if((width-strlen(text)*8) < 0) return; */   /* Text zu lang */
  112.   RP=win->RPort;
  113.   SetDrMd(RP,JAM2);
  114.   SetAPen(RP,col1);
  115.   SetBPen(RP,col2);
  116.   if (win->Flags & GIMMEZEROZERO) dx=0;
  117.   if(xpos == -1) xpos=(width-strlen(text)*8)/2+dx;   /* zentriert */
  118.   if(xpos == -2) xpos=width-strlen(text)*8+dx;       /* rechtsbündig */
  119.   Move(RP,xpos,ypos);
  120.   Text(RP,text,strlen(text));
  121. }
  122.  
  123. ReqBlock(req, col, x1, y1, width, height)
  124. struct Requester *req;
  125. int col, x1, y1, width, height;
  126. {
  127.   struct RastPort *RP;
  128.  
  129.   if (width == 0 || height == 0)
  130.     return;
  131.   RP = req->ReqLayer->rp;
  132.   SetDrMd(RP, JAM1);
  133.   SetAPen(RP, col);
  134.   RectFill(RP, x1, y1, x1 + width - 1, y1 + height - 1);
  135. }
  136.  
  137. ReqBox(req,col1,col2,x1,y1,width,height)   /*  leere Box mit Rahmen im
  138.                            Requester zeichnen */
  139. struct Requester *req;
  140. int col1,col2,x1,y1,width,height;
  141. {
  142.   struct RastPort *RP;
  143.   if(width==0 || height==0) return;
  144.   RP=req->ReqLayer->rp;
  145.   SetDrMd(RP,JAM1);
  146.   SetAPen(RP,col1);
  147.   RectFill(RP,x1,y1,x1+width-1,y1+height-1);
  148.   SetAPen(RP,col2);
  149.   RectFill(RP,x1+1,y1+1,x1+width-2,y1+height-2);
  150. }
  151.  
  152. ReqPrint(req,text,col1,col2,xpos,ypos)      /* Ausgabe von Text */
  153. struct Requester *req;
  154. char *text;
  155. int col1,col2,xpos,ypos;
  156. {
  157.   int width=req->Width;
  158.   struct RastPort *RP;
  159.  
  160.   RP=req->ReqLayer->rp;
  161.   SetDrMd(RP,JAM2);
  162.   SetAPen(RP,col1);
  163.   SetBPen(RP,col2);
  164.   if(xpos == -1) xpos=(width-strlen(text)*8)/2;   /* zentriert */
  165.   if(xpos == -2) xpos=width-strlen(text)*8;       /* rechtsbündig */
  166.   Move(RP,xpos,ypos);
  167.   Text(RP,text,strlen(text));
  168. }
  169.  
  170. Shadow(win,text,txtc,shdwc,xpos,ypos)     /* Ausgabe von Text */
  171. struct Window *win;                  /* mit Schatten      */
  172. char *text;
  173. int txtc,shdwc,xpos,ypos;
  174. {
  175.   int dx=4,width=win->GZZWidth;
  176.   struct RastPort *RP;
  177.  
  178.   RP=win->RPort;
  179.   SetDrMd(RP,JAM1);
  180.   SetAPen(RP,shdwc);
  181.   if(win->Flags & GIMMEZEROZERO) dx=0;
  182.   if(xpos==-1) xpos=(width-strlen(text)*8)/2+dx;
  183.   if(xpos==-2) xpos=width-strlen(text)*8+dx;
  184.   Move(RP,xpos+1,ypos+1);
  185.   Text(RP,text,strlen(text));
  186.   SetAPen(RP,txtc);
  187.   Move(RP,xpos,ypos);
  188.   Text(RP,text,strlen(text));
  189. }
  190.  
  191. int strpos(s1,s2)
  192. char *s1,*s2;
  193. {
  194.   register int i;
  195.   int n,pos=0,flag=0;
  196.  
  197.   if(strlen(s2) > strlen(s1)) return -1;
  198.   for(i=0;i<strlen(s1)-strlen(s2)+1;i++)
  199.   {
  200.     n=strncmp(&s1[i],s2,strlen(s2));
  201.     if(n==0)
  202.     {
  203.       pos=i;
  204.       flag=1;
  205.       break;
  206.     }
  207.   }
  208.   if(!flag) pos=-1;
  209.   return pos;
  210. }
  211.  
  212. BOOL TestFile(file)
  213. char *file;
  214. {
  215.   int Erfolg;
  216.   Erfolg=access(file,EXIST);
  217.   if(Erfolg==0) return (TRUE);
  218.   else return (FALSE);
  219. }
  220.  
  221. void WrConWin(win,text)
  222. int win;
  223. char *text;
  224. {
  225.   write(win,text,strlen(text));
  226. }
  227.