home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / c / intuitionpp / ipp / crastporthdl.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-05  |  4.6 KB  |  241 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. ///////////////////////////////////////////////////////////////////////////////
  3. ///////////////////                                        ////////////////////
  4. ///////////////////           file : crastporthdl.cc       ////////////////////
  5. ///////////////////                                        ////////////////////
  6. ///////////////////////////////////////////////////////////////////////////////
  7. ///////////////////////////////////////////////////////////////////////////////
  8.  
  9.  
  10. #include <intuition/intuitionbase.h>
  11. #include <graphics/gfxbase.h>
  12. #include <clib/intuition_protos.h>
  13. #include <clib/graphics_protos.h>
  14. #include <string.h>
  15.  
  16.  
  17. #include "ipp/crastporthdl.h"
  18.  
  19.  
  20.  
  21.  
  22. CRastPortHdl :: CRastPortHdl()
  23. {
  24.     raster=NULL;
  25. }
  26.  
  27.  
  28. CRastPortHdl :: CRastPortHdl(struct RastPort *newraster)
  29. {
  30.     raster=newraster;
  31. }
  32.  
  33.  
  34. CRastPortHdl :: ~CRastPortHdl()
  35. {
  36.     rfont.close();
  37. }
  38.  
  39.  
  40. BOOL CRastPortHdl :: hdlon(struct RastPort *newraster)
  41. {
  42.     raster=newraster;
  43.     if (raster) resetfont();
  44.     return hdlison();
  45. }
  46.  
  47.  
  48. void CRastPortHdl :: hdloff()
  49. {
  50.     raster=NULL;
  51. }
  52.  
  53.  
  54. BOOL CRastPortHdl :: hdlison()
  55. {
  56.     return (raster!=NULL);
  57. }
  58.  
  59.  
  60. void CRastPortHdl :: clear()
  61. {
  62.     if (hdlison()) SetRast(raster,background);
  63. }
  64.  
  65. void CRastPortHdl :: setpenpos(int x, int y)
  66. {
  67.     if (hdlison()) Move(raster,(long)x,(long)y);
  68. }
  69.  
  70. void CRastPortHdl :: writepixel(int x, int y)
  71. {
  72.     if (hdlison()) WritePixel(raster,(long)x,(long)y);
  73. }
  74.  
  75. void CRastPortHdl :: drawline(int x1, int y1, int x2, int y2)
  76. {
  77.     if (hdlison())
  78.     {
  79.         Move(raster, x1, y1);
  80.         Draw(raster, x2, y2);
  81.     }
  82. }
  83.  
  84. void CRastPortHdl :: drawlineto(int x, int y)
  85. {
  86.     if (hdlison()) Draw(raster,x,y);
  87. }
  88.  
  89.  
  90. void CRastPortHdl :: writetext(int x, int y, char *text)
  91. {
  92.     if (hdlison())
  93.     {
  94.         Move(raster,x,y);
  95.         Text(raster,(STRPTR)text,strlen(text));
  96.     }
  97. }
  98.  
  99.  
  100. void CRastPortHdl :: writetext(char *text)
  101. {
  102.     if (hdlison()) Text(raster,(STRPTR)text,strlen(text));
  103. }
  104.  
  105.  
  106. void CRastPortHdl :: setfont(STRPTR fontname, UWORD fontsize, UBYTE style, UBYTE flags)
  107. {
  108.     if (rfont.open(fontname, fontsize, style, flags))
  109.         if (hdlison()) SetFont(raster,rfont.font);
  110. }
  111.  
  112.  
  113. void CRastPortHdl :: setfont(struct TextAttr *tattr)
  114. {
  115.     if (rfont.open(tattr->ta_Name,tattr->ta_YSize,tattr->ta_Style,tattr->ta_Flags))
  116.         if (hdlison()) SetFont(raster,rfont.font);
  117. }
  118.  
  119.  
  120. void CRastPortHdl :: resetfont()
  121. {
  122.     if (rfont.isopen())
  123.         if (hdlison()) SetFont(raster,rfont.font);
  124. }
  125.  
  126.  
  127. void CRastPortHdl :: drawrect(int x1, int y1, int x2, int y2)
  128. {
  129.     if (hdlison())
  130.     {
  131.         Move(raster,x1,y1);
  132.         Draw(raster,x1,y2);
  133.         Draw(raster,x2,y2);
  134.         Draw(raster,x2,y1);
  135.         Draw(raster,x1,y1);
  136.     }
  137. }
  138.  
  139. void CRastPortHdl :: drawrectfill(int x1, int y1, int x2, int y2)
  140. {
  141.     if (hdlison()) RectFill(raster,x1,y1,x2,y2);
  142. }
  143.  
  144. void CRastPortHdl :: drawcircle(int x, int y, int radius)
  145. {
  146.     if (hdlison()) DrawEllipse(raster,x,y,radius,radius);
  147. }
  148.  
  149. void CRastPortHdl :: drawellipse(int x, int y, int rx, int ry)
  150. {
  151.     if (hdlison()) DrawEllipse(raster,x,y,rx,ry);
  152. }
  153.  
  154. void CRastPortHdl :: drawimage(struct Image *image, int x, int y)
  155. {
  156.     if (hdlison()) DrawImage(raster,image,x,y);
  157. }
  158.  
  159. void CRastPortHdl :: flood(int x, int y)
  160. {
  161.     if (hdlison()) Flood(raster,1,x,y);
  162. }
  163.  
  164. void CRastPortHdl :: setdrmd(int mode)
  165. {
  166.     if (hdlison()) SetDrMd(raster,mode);
  167. }
  168.  
  169. void CRastPortHdl :: setdrpt(int pattern)
  170. {
  171.     if (hdlison()) SetDrPt(raster,pattern);
  172. }
  173.  
  174. void CRastPortHdl :: setapen(int color)
  175. {
  176.     if (hdlison()) SetAPen(raster,color);
  177.     foreground=color;
  178. }
  179.  
  180. void CRastPortHdl :: setbpen(int color)
  181. {
  182.     if (hdlison()) SetBPen(raster,color);
  183.     background=color;
  184. }
  185.  
  186. int CRastPortHdl :: readpixel(int x, int y)
  187. {
  188.     if (hdlison()) return ReadPixel(raster,x,y);
  189.     else return 0;
  190. }
  191.  
  192.  
  193. void CRastPortHdl :: setrast(int color)
  194. {
  195.     if (hdlison()) SetRast(raster, color); 
  196. }
  197.  
  198. ULONG CRastPortHdl :: setwritemask(ULONG mask)
  199. {
  200.     if (hdlison()) return SetWriteMask(raster, mask);
  201.     else return 0;
  202. }
  203.  
  204. WORD CRastPortHdl :: textlength(STRPTR string, WORD length)
  205. {
  206.     if (hdlison()) return TextLength(raster, string, length);
  207.     else return 0;
  208. }
  209.  
  210. ULONG CRastPortHdl :: asksoftstyle()
  211. {
  212.     if (hdlison()) return AskSoftStyle(raster);
  213.     else return 0;
  214. }
  215.  
  216. ULONG CRastPortHdl :: setsoftstyle(ULONG mask, ULONG enable)
  217. {
  218.     if (hdlison()) return SetSoftStyle(raster, mask, enable);
  219.     else return 0;
  220. }
  221.  
  222. void CRastPortHdl :: cleareol()
  223. {
  224.     if (hdlison()) ClearEOL(raster);
  225. }
  226.  
  227. void CRastPortHdl :: printItext(struct IntuiText *text, WORD x, WORD y)
  228. {
  229.     if (hdlison()) PrintIText(raster, text, x, y);
  230. }
  231.  
  232. void CRastPortHdl :: polydraw(WORD count, WORD *array)
  233. {
  234.     if (hdlison()) PolyDraw(raster, count, array);
  235. }
  236.  
  237. void CRastPortHdl :: scrollraster(WORD dx, WORD dy, WORD xmin, WORD ymin, WORD xmax, WORD ymax)
  238. {
  239.     if (hdlison()) ScrollRaster(raster, dx, dy, xmin, ymin, xmax, ymax);
  240. }
  241.