home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / krcls012.zip / KrClass / include / krgobj.hpp < prev    next >
Text File  |  1997-02-04  |  5KB  |  139 lines

  1. // Kroni's Classes: Verschiedene Grafikobjekte
  2. // (c) 1997 Wolfgang Kronberg
  3. // file: krgobj.hpp
  4.  
  5. // **********************************************************************************************************
  6. //
  7. // defines these classes:
  8. //
  9. //   KrGLine                 Draw a line using an arbitrary coordinate system
  10. //   KrGString               Draw a string using an arbitrary alignment and an arbitrary coordinate system
  11. //   KrGBox                  Draw a rectangular Box using an arbitrary color and an arbitrary coord. sys.
  12. //   KrFrame                 Map coordinate system into rectangle part of itself
  13. //   KrAntiFrame             Cancels previous KrFrame
  14. //
  15. // defines no global symbols for private use.
  16. //
  17. // **********************************************************************************************************
  18.  
  19.  
  20. #ifndef __KRGOBJ_HPP__
  21. #define __KRGOBJ_HPP__
  22.  
  23.  
  24. #include "krcstran.hpp"
  25.  
  26. #include <igline.hpp>                            // IGLine
  27. #include <igrect.hpp>                            // IGRectangle
  28. #include <igstring.hpp>                          // IGString
  29.  
  30.  
  31. class KrGLine : public IGLine                    // Object to draw lines
  32. {
  33.  
  34. public:
  35.  
  36.   KrGLine (KrCoordSystemTranslator & translator, const KrPoint & startingPoint, const KrPoint & endPoint);
  37.                                                  // Translator may be changed after contruction, but not
  38.                                                  //   its address
  39.   virtual KrGLine & drawOn (IGraphicContext & graphicContext);
  40.                                                  // This will do the actual drawing
  41.  
  42. private:
  43.  
  44.   KrPoint start, end;                            // Startpoint and endpoint of line
  45.   KrCoordSystemTranslator * trans;               // Pointer to the associated translator
  46.  
  47. };
  48.  
  49.  
  50.  
  51. class KrGString : public IGString                // Object to display text at an arbitrary point
  52. {
  53.  
  54. public:
  55.  
  56.   KrGString (KrCoordSystemTranslator & translator, const IString & text, const KrPoint & positionPoint);
  57.                                                  // Translator may be changed after contruction, but not
  58.                                                  //   its address
  59.   virtual KrGString & drawOn (IGraphicContext & graphicContext);
  60.                                                  // This will do the actual drawing
  61.   void setAlignment (const KrAlignment & al = KrAlignment());
  62.                                                  // Set alignment of the text relative to positionPoint
  63.   KrAlignment & alignment ();                    // Get the current alignment
  64.  
  65. private:
  66.  
  67.   KrPoint stringPosition;                        // Position of text on the screen
  68.   KrCoordSystemTranslator * trans;               // Pointer to the associated translator
  69.   KrAlignment align;                             // Alignment data structure
  70.  
  71. };
  72.  
  73.  
  74.  
  75. class KrGBox : public IGRectangle                // Object to draw solid boxes
  76. {
  77.  
  78. public:
  79.  
  80.   KrGBox (KrCoordSystemTranslator & translator, const KrRectangle & aRectangle, const IColor & aColor);
  81.                                                  // Translator may be changed after contruction, but not
  82.                                                  //   its address
  83.   virtual KrGBox & drawOn (IGraphicContext & graphicContext);
  84.                                                  // This will do the actual drawing
  85.  
  86. private:
  87.  
  88.   KrRectangle rectangle;                         // Area of box
  89.   IColor color;                                  // Color of the box
  90.   KrCoordSystemTranslator * trans;               // Pointer to the associated translator
  91.  
  92. };
  93.  
  94.  
  95.  
  96. class KrFrame : public IGraphic                  // Object to define a frame
  97. {
  98.  
  99. public:
  100.  
  101.   KrFrame (KrCoordSystemTranslator & translator, const KrPoint & p, double scale);
  102.                                                  // Construct frame with low/left corner at p which has
  103.                                                  //   edges "scale" times as long as the original window
  104.   virtual KrFrame & drawOn (IGraphicContext & graphicContext);
  105.                                                  // This will be called from a graphics list and activate
  106.                                                  //   the frame
  107.   KrPoint & basePoint ();                        // Returns low/left corner of frame
  108.   double scale ();                               // Returns scale relative to original window
  109.  
  110. private:
  111.  
  112.   KrPoint bPoint;                                // Data field for low/left corner of frame
  113.   double dScale;                                 // Data field for scale relative to original window
  114.   KrCoordSystemTranslator * trans;               // Translator to be called to realize the frame
  115.  
  116. };
  117.  
  118.  
  119.  
  120. class KrAntiFrame : public IGraphic              // Object to remove the previous frame
  121. {
  122.  
  123. public:
  124.  
  125.   KrAntiFrame (KrCoordSystemTranslator & translator);
  126.                                                  // Removes the most recently activated frame
  127.   virtual KrAntiFrame & drawOn (IGraphicContext & graphicContext);
  128.                                                  // This will be called from a graphics list and remove
  129.                                                  //   the frame
  130. private:
  131.  
  132.   KrCoordSystemTranslator * trans;               // Translator to be called to remove the frame
  133.  
  134. };
  135.  
  136.  
  137. #endif
  138.  
  139.