home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / MultiDesktop / gfx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-27  |  13.4 KB  |  902 lines

  1. /* Grafik-Funktionen */
  2. #include "multiwindows.h"
  3.  
  4. extern struct ExecBase         *SysBase;
  5. extern struct MultiWindowsBase *MultiWindowsBase;
  6.  
  7. extern UWORD INewWidth(),INewHeight();
  8.  
  9. /* ---- TmpRas erstellen */
  10. BOOL CreateTmpRas(we)
  11.  struct WindowEntry *we;
  12. {
  13.  UBYTE *plane;
  14.  ULONG  w,h,v;
  15.  
  16.  if(we->TmpRas!=NULL) { we->TmpRasCount++; return(TRUE); }
  17.  w=we->Screen->Width;
  18.  h=we->Screen->Height;
  19.  v=w/8*h;
  20.  
  21.  plane=AllocRaster(w,h);
  22.  if(plane==NULL)
  23.   {
  24.    ErrorL(1110,"CreateTmpRas(): Not enough chip memory for raster!");
  25.    SetError(MERR_NoMemory);
  26.    return(FALSE);
  27.   }
  28.  BltClear(plane,v,0);
  29.  
  30.  we->TmpRas=InitTmpRas(&we->TmpRasBuffer,plane,v);
  31.  we->TmpRasCount=1;
  32.  if(!we->Iconify) we->RastPort->TmpRas=we->TmpRas;
  33.  
  34.  return(TRUE);
  35. }
  36.  
  37. /* ---- TmpRas entfernen */
  38. void DeleteTmpRas(we)
  39.  struct WindowEntry *we;
  40. {
  41.  we->TmpRasCount--;
  42.  if(we->TmpRasCount==0)
  43.   {
  44.    FreeRaster(we->TmpRas->RasPtr,we->Screen->Width,we->Screen->Height);
  45.    we->TmpRas=NULL;
  46.    if(!we->Iconify) we->RastPort->TmpRas=NULL;
  47.   }
  48. }
  49.  
  50. /* ---- AreaInfo erstellen */
  51. BOOL CreateAreaInfo(we,count)
  52.  struct WindowEntry *we;
  53.  ULONG               count;
  54. {
  55.  UBYTE *table;
  56.  
  57.  if(we->AreaInfo!=NULL) return(TRUE);
  58.  
  59.  table=ALLOC2(count*5);
  60.  if(table==NULL)
  61.   {
  62.    ErrorL(1111,"CreateAreaInfo(): Not enough memory for buffer!");
  63.    SetError(MERR_NoMemory);
  64.    return(FALSE);
  65.   }
  66.  
  67.  InitArea(&we->AreaInfoBuffer,table,count);
  68.  we->AreaInfo=&we->AreaInfoBuffer;
  69.  we->AreaInfoTable=table;
  70.  if(!we->Iconify) we->RastPort->AreaInfo=we->AreaInfo;
  71.  
  72.  return(TRUE);
  73. }
  74.  
  75. /* ---- AreaInfo entfernen */
  76. void DeleteAreaInfo(we)
  77.  struct WindowEntry *we;
  78. {
  79.  if(we->AreaInfo!=NULL)
  80.   {
  81.    if(!we->Iconify) we->RastPort->AreaInfo=NULL;
  82.    we->AreaInfo=NULL;
  83.    FREE2(we->AreaInfoTable);
  84.    we->AreaInfoTable=NULL;
  85.   }
  86. }
  87.  
  88. /* ---- Aktuellen RastPort ermitteln */
  89. struct RastPort *GetRP()
  90. {
  91.  struct WindowEntry *we;
  92.  
  93.  WE;
  94.  if(we==NULL) return(NULL);
  95.  return(we->RastPort);
  96. }
  97.  
  98. /* ---- Zeichenstifte */
  99. void SetFgPen(pen)
  100.  UBYTE pen;
  101. {
  102.  struct RastPort *rp;
  103.  
  104.  rp=GetRP();
  105.  if(rp) SetAPen(rp,pen);
  106. }
  107.  
  108. /* ---- Zeichenstifte */
  109. void SetOlPen(pen)
  110.  UBYTE pen;
  111. {
  112.  struct RastPort *rp;
  113.  
  114.  rp=GetRP();
  115.  if(rp) SetOPen(rp,pen);
  116. }
  117.  
  118. /* ---- Zeichenstifte */
  119. void SetBgPen(pen)
  120.  UBYTE pen;
  121. {
  122.  struct RastPort *rp;
  123.  
  124.  rp=GetRP();
  125.  if(rp) SetBPen(rp,pen);
  126. }
  127.  
  128. /* ---- Zeichenstifte */
  129. void SetPens(ap,bp)
  130.  UBYTE ap,bp;
  131. {
  132.  struct RastPort *rp;
  133.  
  134.  rp=GetRP();
  135.  if(rp)
  136.   {
  137.    SetAPen(rp,ap);
  138.    SetBPen(rp,bp);
  139.   }
  140. }
  141.  
  142. /* ---- Zeichenstifte */
  143. void SetFgDrawInfoPen(c)
  144.  UBYTE c;
  145. {
  146.  struct WindowEntry *we;
  147.  struct RastPort    *rp;
  148.  
  149.  WE;
  150.  if(we==NULL) return;
  151.  rp=we->RastPort;
  152.  if(rp) SetAPen(rp,we->DrawInfo->dri_Pens[c]);
  153. }
  154.  
  155. /* ---- Zeichenstifte */
  156. void SetBgDrawInfoPen(c)
  157.  UBYTE c;
  158. {
  159.  struct WindowEntry *we;
  160.  struct RastPort    *rp;
  161.  
  162.  WE;
  163.  if(we==NULL) return;
  164.  rp=we->RastPort;
  165.  if(rp) SetBPen(rp,we->DrawInfo->dri_Pens[c]);
  166. }
  167.  
  168. /* ---- Zeichenstifte */
  169. void SetOlDrawInfoPen(c)
  170.  UBYTE c;
  171. {
  172.  struct WindowEntry *we;
  173.  struct RastPort    *rp;
  174.  
  175.  WE;
  176.  if(we==NULL) return;
  177.  rp=we->RastPort;
  178.  if(rp) SetOPen(rp,we->DrawInfo->dri_Pens[c]);
  179. }
  180.  
  181. /* ---- Zeichenstifte */
  182. UBYTE GetFgPen()
  183. {
  184.  struct RastPort *rp;
  185.  
  186.  rp=GetRP();
  187.  if(rp) return(rp->FgPen);
  188.  return(0);
  189. }
  190.  
  191. /* ---- Zeichenstifte */
  192. UBYTE GetBgPen()
  193. {
  194.  struct RastPort *rp;
  195.  
  196.  rp=GetRP();
  197.  if(rp) return(rp->BgPen);
  198.  return(0);
  199. }
  200.  
  201. /* ---- Zeichenstifte */
  202. UBYTE GetOlPen()
  203. {
  204.  struct RastPort *rp;
  205.  
  206.  rp=GetRP();
  207.  if(rp) return(rp->AOlPen);
  208.  return(0);
  209. }
  210.  
  211. /* ---- Zeichenmodus */
  212. void SetDrawMode(mode)
  213.  UWORD mode;
  214. {
  215.  struct RastPort *rp;
  216.  
  217.  rp=GetRP();
  218.  if(rp) SetDrMd(rp,mode);
  219. }
  220.  
  221. /* ---- Pattern */
  222. void SetLinePattern(pattern)
  223.  UWORD pattern;
  224. {
  225.  struct RastPort *rp;
  226.  
  227.  rp=GetRP();
  228.  if(rp) SetDrPt(rp,pattern);
  229. }
  230.  
  231. /* ---- Pattern */
  232. void SetMonoPattern(pattern,lines)
  233.  UWORD lines;
  234. {
  235.  struct RastPort *rp;
  236.  
  237.  rp=GetRP();
  238.  if(rp)
  239.    SetAfPt(rp,pattern,lines);
  240. }
  241.  
  242. /* ---- Pattern */
  243. void SetColorPattern(pattern,lines)
  244.  UWORD lines;
  245. {
  246.  struct RastPort *rp;
  247.  
  248.  rp=GetRP();
  249.  if(rp)
  250.    SetAfPt(rp,pattern,-lines);
  251. }
  252.  
  253. /* ---- Pattern */
  254. void SetWriteMask(mask)
  255.  UWORD mask;
  256. {
  257.  struct RastPort *rp;
  258.  
  259.  rp=GetRP();
  260.  if(rp) SetWrMsk(rp,mask);
  261. }
  262.  
  263. /* ---- Zeichenmodus */
  264. UWORD GetDrawMode()
  265. {
  266.  struct RastPort *rp;
  267.  
  268.  rp=GetRP();
  269.  if(rp) return(rp->DrawMode);
  270.  return(0);
  271. }
  272.  
  273. /* ---- Fontstil */
  274. void SetStyle(style)
  275.  UBYTE style;
  276. {
  277.  UWORD               gfxStyles;
  278.  struct RastPort    *rp;
  279.  struct WindowEntry *we;
  280.  
  281.  WE;
  282.  if(we==NULL) return;
  283.  rp=we->RastPort;
  284.  if(rp)
  285.   {
  286.    gfxStyles=0;
  287.    if(style & ST_BOLD) gfxStyles=FSF_BOLD;
  288.    if(style & ST_ITALIC) gfxStyles=FSF_ITALIC;
  289.    if(style & ST_UNDERLINED) gfxStyles=FSF_UNDERLINED;
  290.    we->GfxStyle=style;
  291.    SetSoftStyle(rp,gfxStyles,AskSoftStyle(rp));
  292.   }
  293. }
  294.  
  295. /* ---- Fontstil */
  296. BOOL SetWindowFont(name,height)
  297.  UBYTE *name;
  298.  UWORD  height;
  299. {
  300.  struct RastPort    *rp;
  301.  struct WindowEntry *we;
  302.  struct TextFont    *font;
  303.  
  304.  WE;
  305.  if(we==NULL) return;
  306.  rp=we->RastPort;
  307.  if(rp)
  308.   {
  309.    font=CacheFont(name,height);
  310.    if(font)
  311.     {
  312.      if(we->WindowFont)
  313.       {
  314.        Forbid();
  315.        we->WindowFont->tf_Accessors--;
  316.        Permit();
  317.       }
  318.      we->WindowFont=font;
  319.      Forbid();
  320.      we->WindowFont->tf_Accessors++;
  321.      Permit();
  322.      SetFont(rp,font);
  323.      return(TRUE);
  324.     }
  325.   }
  326.  return(FALSE);
  327. }
  328.  
  329. /* ---- Fontstil */
  330. UBYTE GetStyle()
  331. {
  332.  struct WindowEntry *we;
  333.  
  334.  WE;
  335.  if(we==NULL) return(0);
  336.  return(we->GfxStyle);
  337. }
  338.  
  339. /* ---- Koordinaten korrigieren */
  340. void NewXY(xPtr,yPtr)
  341.  WORD *xPtr,*yPtr;
  342. {
  343.  struct WindowEntry *we;
  344.  
  345.  WE;
  346.  if(we==NULL) return;
  347.  if(we->GfxFlags==GFXF_NEWXY)
  348.   {
  349.    *xPtr=INewX(we,*xPtr);
  350.    *yPtr=INewY(we,*yPtr);
  351.   }
  352.  *xPtr+=we->InnerLeftEdge;
  353.  *yPtr+=we->InnerTopEdge;
  354. }
  355.  
  356. /* ---- Zeichenfunktion */
  357. void Plot(x,y)
  358.  WORD x,y;
  359. {
  360.  struct RastPort *rp;
  361.  
  362.  rp=GetRP();
  363.  if(rp)
  364.   {
  365.    NewXY(&x,&y);
  366.    Move(rp,x,y);
  367.    WritePixel(rp,x,y);
  368.   }
  369. }
  370.  
  371. /* ---- Zeichenfunktion */
  372. void MoveTo(x,y)
  373.  WORD x,y;
  374. {
  375.  struct RastPort *rp;
  376.  
  377.  rp=GetRP();
  378.  if(rp)
  379.   {
  380.    NewXY(&x,&y);
  381.    Move(rp,x,y);
  382.   }
  383. }
  384.  
  385. /* ---- Zeichenfunktion */
  386. void DrawTo(x,y)
  387.  WORD x,y;
  388. {
  389.  struct RastPort *rp;
  390.  
  391.  rp=GetRP();
  392.  if(rp)
  393.   {
  394.    NewXY(&x,&y);
  395.    Draw(rp,x,y);
  396.   }
  397. }
  398.  
  399. /* ---- Zeichenfunktion */
  400. void Line(x1,y1,x2,y2)
  401.  WORD x1,y1,x2,y2;
  402. {
  403.  struct RastPort *rp;
  404.  
  405.  rp=GetRP();
  406.  if(rp)
  407.   {
  408.    NewXY(&x1,&y1);
  409.    NewXY(&x2,&y2);
  410.    Move(rp,x1,y1);
  411.    Draw(rp,x2,y2);
  412.   }
  413. }
  414.  
  415. /* ---- Zeichenfunktion */
  416. void Ellipse(x,y,a,b)
  417.  WORD x,y,a,b;
  418. {
  419.  struct RastPort    *rp;
  420.  struct WindowEntry *we;
  421.  
  422.  WE;
  423.  if(we==NULL) return;
  424.  rp=we->RastPort;
  425.  if(rp)
  426.   {
  427.    NewXY(&x,&y);
  428.    DrawEllipse(rp,x,y,INewWidth(we,a),INewHeight(we,b));
  429.   }
  430. }
  431.  
  432. /* ---- Zeichenfunktion */
  433. void Circle(x,y,a)
  434.  WORD x,y,a;
  435. {
  436.  struct RastPort    *rp;
  437.  struct WindowEntry *we;
  438.  
  439.  WE;
  440.  if(we==NULL) return;
  441.  rp=we->RastPort;
  442.  if(rp)
  443.   {
  444.    NewXY(&x,&y);
  445.    DrawEllipse(rp,x,y,
  446.                INewWidth(we,a),
  447.                (WORD)((FLOAT)INewHeight(we,a)*we->AspectY));
  448.   }
  449. }
  450.  
  451. /* ---- Zeichenfunktion */
  452. void Rectangle(x1,y1,x2,y2)
  453.  WORD x1,y1,x2,y2;
  454. {
  455.  struct RastPort *rp;
  456.  
  457.  rp=GetRP();
  458.  if(rp)
  459.   {
  460.    NewXY(&x1,&y1);
  461.    NewXY(&x2,&y2);
  462.    Move(rp,x1,y1);
  463.    Draw(rp,x2,y1);
  464.    Draw(rp,x2,y2);
  465.    Draw(rp,x1,y2);
  466.    Draw(rp,x1,y1);
  467.   }
  468. }
  469.  
  470. /* ---- Zeichenfunktion */
  471. void FilledRectangle(x1,y1,x2,y2)
  472.  WORD x1,y1,x2,y2;
  473. {
  474.  WORD             h;
  475.  struct RastPort *rp;
  476.  
  477.  rp=GetRP();
  478.  if(rp)
  479.   {
  480.    if(y2>y1) { h=y2; y2=y1; y1=h; }
  481.    if(x2>x1) { h=x2; x2=x1; x1=h; }
  482.    NewXY(&x1,&y1);
  483.    NewXY(&x2,&y2);
  484.    Move(rp,x1,y1);
  485.    Draw(rp,x2,y1);
  486.    Draw(rp,x2,y2);
  487.    Draw(rp,x1,y2);
  488.    Draw(rp,x1,y1);
  489.   }
  490. }
  491.  
  492. /* ---- Polygon zeichnen */
  493. void DrawPolygon(array,count)
  494.  UWORD *array;
  495.  ULONG  count;
  496. {
  497.  UWORD              *mem;
  498.  ULONG               i;
  499.  struct RastPort    *rp;
  500.  struct WindowEntry *we;
  501.  
  502.  WE;
  503.  rp=GetRP();
  504.  if(rp)
  505.   {
  506.    if(we->GfxFlags & GFXF_NEWXY)
  507.     {
  508.      mem=AllocVec(count*4+8,MEMF_ANY);
  509.      if(mem!=NULL)
  510.       {
  511.        CopyMemQuick(array,mem,count*4);
  512.        for(i=0;i<(count*2);i+=2)
  513.          NewXY(&mem[i],&mem[i+1]);
  514.        FreeVec(mem);
  515.        PolyDraw(rp,count,mem);
  516.       }
  517.      else
  518.        NoMemory();
  519.     }
  520.    else
  521.      PolyDraw(rp,count,array);
  522.   }
  523. }
  524.  
  525. /* ---- Zeichenfunktion */
  526. void Paint(x,y)
  527.  WORD x,y;
  528. {
  529.  BOOL                bool;
  530.  struct RastPort    *rp;
  531.  struct WindowEntry *we;
  532.  
  533.  WE;
  534.  if(we==NULL) return;
  535.  rp=we->RastPort;
  536.  if(rp)
  537.   {
  538.    bool=CreateTmpRas(we);
  539.    if(bool)
  540.     {
  541.      NewXY(&x,&y);
  542.      Flood(rp,1,x,y);
  543.      DeleteTmpRas(we);
  544.     }
  545.   }
  546. }
  547.  
  548. /* ---- Korrektion einschalten */
  549. void CorrectionOn()
  550. {
  551.  struct WindowEntry *we;
  552.  WE;
  553.  if(we) we->GfxFlags=GFXF_NEWXY;
  554. }
  555.  
  556. /* ---- Korrektion ausschalten */
  557. void CorrectionOff()
  558. {
  559.  struct WindowEntry *we;
  560.  WE;
  561.  if(we) we->GfxFlags=GFXF_OLDXY;
  562. }
  563.  
  564. /* ---- Text()-Funktion mit Outline-Druck */
  565. void OutlineText(rp,x,y,text,style)
  566.  struct RastPort *rp;
  567.  UWORD            x,y;
  568.  UBYTE           *text;
  569.  UBYTE            style;
  570. {
  571.  WORD a,b;
  572.  
  573.  if(style & ST_OUTLINE)
  574.   {
  575.    SetDrMd(rp,JAM1);
  576.    for(a=-1;a<=1;a++) {
  577.      for(b=-1;b<=1;b++) {
  578.        Move(rp,x+a,y+b);
  579.        Text(rp,text,strlen(text));
  580.     }}
  581.    SetAPen(rp,0);
  582.   }
  583.  Move(rp,x,y);
  584.  Text(rp,text,strlen(text));
  585. }
  586.  
  587. /* ---- Textausgabe */
  588. void Print(x,y,text)
  589.  WORD   x,y;
  590.  UBYTE *text;
  591. {
  592.  UBYTE               bgpen,fgpen;
  593.  UWORD               spacing;
  594.  struct WindowEntry *we;
  595.  struct RastPort    *rp;
  596.  
  597.  WE;
  598.  if(we==NULL) return;
  599.  rp=we->RastPort;
  600.  if(rp)
  601.   {
  602.    NewXY(&x,&y);
  603.    BackupRP(we);
  604.    spacing=rp->TxSpacing;
  605.  
  606.    rp->TxSpacing=we->TextSpacing;
  607.    if(we->GfxStyle & ST_WIDE)
  608.     {
  609.      rp->TxSpacing=rp->TxSpacing+(((UWORD)TextLength(rp,"A",1))/2);
  610.     }
  611.    if(we->GfxStyle & ST_SHADOW)
  612.     {
  613.      bgpen=rp->BgPen;
  614.      fgpen=rp->FgPen;
  615.      SetAPen(rp,bgpen);
  616.      SetBPen(rp,0);
  617.      SetDrMd(rp,JAM1);
  618.      OutlineText(rp,x+(UWORD)((FLOAT)2*we->FactorX),
  619.                     y+(UWORD)((FLOAT)2*we->FactorY),
  620.                     text,we->GfxStyle);
  621.      SetAPen(rp,fgpen);
  622.      OutlineText(rp,x,y,text,we->GfxStyle);
  623.     }
  624.    else
  625.      OutlineText(rp,x,y,text,we->GfxStyle);
  626.  
  627.    rp->TxSpacing=spacing;
  628.    RestoreRP(we);
  629.   }
  630. }
  631.  
  632. /* ---- Zeichenstifte */
  633. UBYTE GetPixel(x,y)
  634.  WORD x,y;
  635. {
  636.  struct RastPort *rp;
  637.  
  638.  rp=GetRP();
  639.  if(rp)
  640.   {
  641.    NewXY(&x,&y);
  642.    return(ReadPixel(rp,x,y));
  643.   }
  644.  return(0);
  645. }
  646.  
  647. /* ---- Textabstand */
  648. void SetTextSpacing(spacing)
  649.  WORD spacing;
  650. {
  651.  struct WindowEntry *we;
  652.  
  653.  WE;
  654.  if(we)
  655.    we->TextSpacing=spacing;
  656. }
  657.  
  658. /* ---- Textabstand */
  659. WORD GetTextSpacing(spacing)
  660.  WORD spacing;
  661. {
  662.  struct WindowEntry *we;
  663.  
  664.  WE;
  665.  if(we) return(we->TextSpacing);
  666.  return(0);
  667. }
  668.  
  669. /* ---- Area-Initialisierung */
  670. struct RastPort *AInit()
  671. {
  672.  BOOL                bool;
  673.  struct WindowEntry *we;
  674.  
  675.  WE;
  676.  if(we==NULL) return(0L);
  677.  if((we->TmpRas)&&(we->AreaInfo)) return(we->RastPort);
  678.  
  679.  if(we->TmpRas==NULL)
  680.   {
  681.    bool=CreateTmpRas(we);
  682.    if(bool==FALSE) return(0L);
  683.   }
  684.  
  685.  if(we->AreaInfo==NULL)
  686.   {
  687.    bool=CreateAreaInfo(we,200);
  688.    if(bool==FALSE) return(0L);
  689.   }
  690.  
  691.  return(we->RastPort);
  692. }
  693.  
  694. /* ---- Zeichenfunktion */
  695. void AMoveTo(x,y)
  696.  WORD x,y;
  697. {
  698.  struct RastPort    *rp;
  699.  
  700.  rp=AInit();
  701.  if(rp)
  702.   {
  703.    NewXY(&x,&y);
  704.    AreaMove(rp,x,y);
  705.   }
  706. }
  707.  
  708. /* ---- Zeichenfunktion */
  709. void ADrawTo(x,y)
  710.  WORD x,y;
  711. {
  712.  struct RastPort    *rp;
  713.  
  714.  rp=AInit();
  715.  if(rp)
  716.   {
  717.    NewXY(&x,&y);
  718.    AreaDraw(rp,x,y);
  719.   }
  720. }
  721.  
  722. /* ---- Zeichenfunktion */
  723. void ADrawPolygon(array,count)
  724.  UWORD *array;
  725.  ULONG  count;
  726. {
  727.  struct RastPort *rp;
  728.  ULONG            i;
  729.  WORD             x,y;
  730.  
  731.  rp=AInit();
  732.  if(rp)
  733.   {
  734.    for(i=0;i<(count*2);i+=2)
  735.     {
  736.      x=array[i]; y=array[i+1];
  737.      NewXY(&x,&y);
  738.      if(i==0)
  739.        AreaMove(rp,x,y);
  740.      else
  741.        AreaDraw(rp,x,y);
  742.     }
  743.    AreaEnd(rp);
  744.   }
  745. }
  746.  
  747. /* ---- Zeichenfunktion */
  748. void AEllipse(x,y,a,b)
  749.  WORD x,y,a,b;
  750. {
  751.  struct RastPort    *rp;
  752.  
  753.  rp=AInit();
  754.  if(rp)
  755.   {
  756.    NewXY(&x,&y);
  757.    AreaEllipse(rp,x,y,a,b);
  758.   }
  759. }
  760.  
  761. /* ---- Zeichenfunktion */
  762. void ACircle(x,y,a,b)
  763.  WORD x,y,a,b;
  764. {
  765.  struct RastPort    *rp;
  766.  struct WindowEntry *we;
  767.  
  768.  WE;
  769.  rp=AInit();
  770.  if(rp)
  771.   {
  772.    NewXY(&x,&y);
  773.    AreaEllipse(rp,x,y,
  774.                INewWidth(we,a),
  775.                (WORD)((FLOAT)INewHeight(we,a)*we->AspectY));
  776.   }
  777. }
  778.  
  779. /* ---- Zeichenfunktion */
  780. void AEnd()
  781. {
  782.  struct RastPort    *rp;
  783.  
  784.  rp=AInit();
  785.  if(rp) AreaEnd(rp);
  786. }
  787.  
  788. /* ---- Area-Linien darstellen */
  789. void ShowAreaLines()
  790. {
  791.  struct RastPort *rp;
  792.  
  793.  rp=GetRP();
  794.  if(rp) rp->Flags |= AREAOUTLINE;
  795. }
  796.  
  797. /* ---- Area-Linien nicht darstellen */
  798. void HideAreaLines()
  799. {
  800.  struct RastPort *rp;
  801.  
  802.  rp=GetRP();
  803.  if(rp) rp->Flags &= ~AREAOUTLINE;
  804. }
  805.  
  806. /* ---- Palette setzen */
  807. void SetPalette(num,r,g,b)
  808.  UWORD num;
  809.  UBYTE r,g,b;
  810. {
  811.  struct WindowEntry *we;
  812.  
  813.  WE;
  814.  if(we)
  815.   {
  816.    if(!we->Iconify)
  817.      SetRGB4(we->ViewPort,num,r>>4,g>>4,b>>4);
  818.   }
  819. }
  820.  
  821. /* ---- Palette setzen */
  822. void SetGreyScale(num,r,g,b)
  823.  UWORD num;
  824.  UBYTE r,g,b;
  825. {
  826.  UWORD               grey;
  827.  struct WindowEntry *we;
  828.  
  829.  WE;
  830.  if(we)
  831.   {
  832.    if(!we->Iconify)
  833.     {
  834.      grey=(((UWORD)r+(UWORD)g+(UWORD)b)/3)>>4;
  835.      SetRGB4(we->ViewPort,num,grey,grey,grey);
  836.     }
  837.   }
  838. }
  839.  
  840. /* ---- Palette setzen */
  841. void SetGrey(num,grey)
  842.  UWORD num;
  843.  UBYTE grey;
  844. {
  845.  struct WindowEntry *we;
  846.  
  847.  WE;
  848.  if(we)
  849.   {
  850.    if(!we->Iconify)
  851.      SetRGB4(we->ViewPort,num,grey>>4,grey>>4,grey>>4);
  852.   }
  853. }
  854.  
  855. /* ---- Palette ermitteln */
  856. void GetPalette(num,r,g,b)
  857.  UWORD  num;
  858.  UBYTE *r,*g,*b;
  859. {
  860.  ULONG               color;
  861.  struct WindowEntry *we;
  862.  
  863.  WE;
  864.  if(we)
  865.   {
  866.    if(!we->Iconify)
  867.     {
  868.      color=GetRGB4(we->ViewPort->ColorMap,num);
  869.      *r=((color & 0x0f00)>>8) << 4;
  870.      *g=((color & 0x00f0)>>4) << 4;
  871.      *b=(color & 0x000f) << 4;
  872.     }
  873.    else
  874.      *r=*g=*b=0;
  875.   }
  876. }
  877.  
  878. /* ---- Palette ermitteln */
  879. UBYTE GetGrey(num)
  880.  UWORD num;
  881. {
  882.  ULONG               color;
  883.  UBYTE               r,g,b,grey;
  884.  struct WindowEntry *we;
  885.  
  886.  grey=0,
  887.  WE;
  888.  if(we)
  889.   {
  890.    if(!we->Iconify)
  891.     {
  892.      color=GetRGB4(we->ViewPort->ColorMap,num);
  893.      r=((color & 0x0f00)>>8);
  894.      g=((color & 0x00f0)>>4);
  895.      b=(color & 0x000f);
  896.      grey=((r+g+b)/3)<<4;
  897.     }
  898.   }
  899.  return(grey);
  900. }
  901.  
  902.