home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / aplusplus-1.01-src.lha / src / amiga / aplusplus-1.01 / include / aplusplus / graphics / DrawArea.h < prev    next >
C/C++ Source or Header  |  1994-05-04  |  5KB  |  118 lines

  1. #ifndef APP_DrawArea_H
  2. #define APP_DrawArea_H
  3. /******************************************************************************
  4.  **
  5.  **    C++ Class Library for the Amiga© system software.
  6.  **
  7.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  8.  **    All Rights Reserved.
  9.  **
  10.  **    $VER: apphome:APlusPlus/graphics/DrawArea.h 1.04 (04.05.94) $
  11.  **    
  12.  ******************************************************************************/
  13.  
  14. extern "C" {
  15. #include <graphics/rastport.h>
  16. #include <graphics/gfxmacros.h>
  17. #include <graphics/clip.h>
  18. #include <graphics/regions.h>
  19. }
  20. #include <APlusPlus/environment/APPObject.h>
  21. #include <APlusPlus/graphics/RectObject.h>
  22. #include <APlusPlus/graphics/FontC.h>
  23.  
  24.  
  25. /******************************************************************************************
  26.       » DrawArea class «     Access to Graphics RastPort and Layer.
  27.  
  28.    The DrawArea class provides all Graphics draw routines and is attached to one already
  29.    existing GWindow. Furthermore, it enhances rastport drawing with Layers clipping.
  30.    The result is that a DrawArea object is rather a clipped draw area within a specified
  31.    rastport than that rastport itself.
  32.    There may be several DrawArea objects created to one single existing RastPort.
  33.    The ClipRegion gets it dimension for the clipping area from the incorporated RectObject.
  34.    Additional clipping can be achieved with the ClipRegion methods: modify the inherited
  35.    ClipRegion and then call setStdClip() to activate your special clipping.
  36.  ******************************************************************************************/
  37.  
  38. #define RECTANGLE  XYVAL MinX,XYVAL MinY,XYVAL MaxX,XYVAL MaxY
  39. class GWindow;
  40. class DrawArea : virtual public RectObject
  41. {
  42.    private:
  43.         GWindow *gWindowPtr;
  44.         struct RastPort *rastPort;
  45.       struct Region *regionPtr, *oldRegion;
  46.       BOOL ownClippingInstalled;
  47.         void removeClip();
  48.         void insertClip();
  49.  
  50.    protected:
  51.       void setGWindow(GWindow *homeWindow);
  52.  
  53.       void setRectangle(RECTANGLE,struct Rectangle& rect);
  54.       BOOL isValid() { return (regionPtr!=NULL && gWindowPtr!=NULL); }
  55.         GWindow *gwindow() { return gWindowPtr; }
  56.             
  57.    public:
  58.       DrawArea(GWindow *homeWindow=NULL);
  59.       /** Sometimes the GWindow is not available when the DrawArea object has to be initialised.
  60.        ** Therefore setGWindow(GWindow*) may be used. Note that you MUST supply a GWindow before 
  61.          ** using any of the draw methods below.
  62.        **/
  63.       virtual ~DrawArea();
  64.  
  65.       struct RastPort   *rp() { return rastPort; }
  66.       struct Layer      *layer() { return rp()->Layer; }
  67.       struct Region     *region() { return regionPtr; }
  68.       
  69.       void adjustStdClip();    // adjust the clipping to the present values of the RectObject
  70.       void setStdClip();        // installs standard clipping on the boundaries of the RectObject
  71.       void resetStdClip();        // reinstall previous clip region    
  72.  
  73.       // use the following methods to create your own clipping areas     
  74.       void andRectRegion(RECTANGLE);
  75.       void orRectRegion(RECTANGLE);
  76.       void xorRectRegion(RECTANGLE);
  77.       void clearRectRegion(RECTANGLE);
  78.  
  79.       void clearRegion();
  80.  
  81.       // drawmode and colors
  82.       void setAPen(UBYTE);    // foreground pen
  83.       void setBPen(UBYTE);    // background pen
  84.       void setOPen(BYTE pen) { SetOPen(rp(),pen); }  // area outline pen
  85.       void setDrMd(UBYTE);    // set drawmode 
  86.         void setDrPt(UWORD p) { SetDrPt(rp(),p); }
  87.  
  88.       /** draw routines according to the graphics library, coords become relative to the
  89.        ** RectObject's upper, left edge.
  90.        **/
  91.       void draw(XYVAL x,XYVAL y);
  92.         // draw a GadTools bevel box
  93.         void drawBevelBox(XYVAL xmin,XYVAL ymin,WHVAL width,WHVAL height,BOOL recessed);
  94.       void drawEllipse(XYVAL x,XYVAL y,WHVAL hr,WHVAL vr);
  95.         
  96.       void move(XYVAL x,XYVAL y);
  97.         void moveTx(XYVAL x,XYVAL y);        
  98.         // places graphic cursor to upper left edge of text render box for subsequent text() calls.
  99.         // considers baseline of the current font set with setFont()
  100.  
  101.       // give a table of RectObject-relative coordinates
  102.       void polyDraw(LONG count,WORD *polyTable);
  103.         
  104.       void rectFill(XYVAL xmin,XYVAL ymin,XYVAL xmax,XYVAL ymax);
  105.       void scrollRaster(LONG dx,LONG dy,XYVAL xmin,XYVAL ymin,XYVAL xmax,XYVAL ymax);
  106.  
  107.         // set the font to use in subsequent text() calls
  108.         void setFont(FontC& font);
  109.       // if you leave out textLength the string will be measured by the method.
  110.       void text(UBYTE *textString,UWORD textLength=0);
  111. };
  112.  
  113. // compute RectObject relative coords into rastport absolute coords.
  114. #define abs_X(x) (iLeft()+(x))
  115. #define abs_Y(y) (iTop()+(y))
  116.  
  117. #endif
  118.