mgui/toolrect.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/toolrect.h
00003  * \brief MGUI::TOOL_RECTANGLE class definitions
00004  *
00005  * \if NODOC
00006  * $Id: toolrect.h_v 1.3 2003/10/03 19:58:19 linux32build!build Exp $
00007  *
00008  * $Log: toolrect.h_v $
00009  * Revision 1.3  2003/10/03 19:58:19  linux32build!build
00010  * Doxygen
00011  *
00012  * Revision 1.2  2003/09/15 13:49:32  fileserver!dwilliss
00013  * Doxygen
00014  *
00015  * Revision 1.1  2003/01/10 23:08:50  mju
00016  * Initial revision
00017  *
00018  * \endif
00019 **/
00020 
00021 #ifndef  INC_MGUI_TOOLRECT_H
00022 #define  INC_MGUI_TOOLRECT_H
00023 
00024 #ifndef  INC_MGUI_TOOLBASE_H
00025 #include <mgui/toolbase.h>
00026 #endif
00027 
00028 namespace MGUI {
00029 
00030 
00031 //! Rectangle tool class.
00032 class TOOL_RECTANGLE : public TOOL_LIMITED {
00033    public:
00034 
00035       //! Constructor.
00036       explicit TOOL_RECTANGLE (
00037          TOOLCANVAS *canvas
00038          );
00039 
00040       //! Destructor.
00041       virtual ~TOOL_RECTANGLE ();
00042 
00043       //! Assigment from DRECT2D.
00044       TOOL_RECTANGLE& operator= (
00045          const DRECT2D& rhs                  //!< Rectangle in tool coordinates to assign from
00046          );
00047 
00048       //! Get rotation angle.
00049       //! @return Rotation angle in RADIANS.
00050       double GetAngle (
00051          ) const { return (m_angle); }
00052 
00053       //! Get center of rectangle in tool coordinates.
00054       DPOINT2D GetCenter (
00055          ) const { return (m_extents.GetCenter()); }
00056 
00057       //! Get coordinates of specified corner.
00058       const DPOINT2D& GetCorner (
00059          int corner                          //!< Corner number (0-3)
00060          ) const { return (m_corners[corner]); }
00061 
00062       //! Get coordinates of all rectangle corners.
00063       //! @return Array of 4 corner coordinates.
00064       const DPOINT2D* GetCorners (
00065          ) const { return (m_corners); }
00066 
00067       //! Copy corner coordinates into specified array.
00068       void GetCorners (
00069          DPOINT2D rcorners[4]                //!< Array to contain corner coordinates
00070          ) const { for (int i = 0; (i < 4); ++i) rcorners[i] = m_corners[i]; return; }
00071 
00072       //! Get extents of tool.
00073       const DRECT2D& GetExtents (
00074          ) const { return (m_extents); }
00075 
00076       //! Get current rectangle size.
00077       //! @return Size in tool coordinates before rotation.
00078       const DPOINT2D& GetSize (
00079          ) const { return (m_size); }
00080 
00081       //! Set aspect ratio for rectangle.
00082       //! Setting the aspect ratio to a value <= 0 removes the aspect constraint.
00083       void SetAspect (
00084          double aspect                          //!< Aspect ratio X/Y
00085          );
00086 
00087    protected:
00088 
00089    #ifdef DOCONLY // For documentation purposes only.
00090       //! Called when change made to tool position, shape, size, etc.
00091       virtual void v_OnNotifyChange (
00092          CHANGESEQ changeseq,                //!< Sequence
00093          CHANGETYPE changetype               //!< Type
00094          );
00095    #endif
00096 
00097    private:
00098       #ifndef GENERATING_DOXYGEN_OUTPUT
00099       //! Enumeration constants
00100       enum ZONE {
00101          ZONE_Outside = 0,
00102          ZONE_Inside,
00103          ZONE_Corner0,
00104          ZONE_Corner1,
00105          ZONE_Corner2,
00106          ZONE_Corner3,
00107          ZONE_Side01,
00108          ZONE_Side12,
00109          ZONE_Side23,
00110          ZONE_Side30,
00111          ZONE_NoFunction
00112          };
00113       //! Tool settings
00114       double m_aspect;                    //!< Aspect ratio, proportional if > 0
00115       //! Tool position values
00116       DRECT2D m_extents;                  //!< Position (extents if rotated)
00117       DPOINT2D m_corners[4];              //!< Corner coordinates
00118       DPOINT2D m_size;                    //!< Current size
00119       double m_angle;                     //!< Rotation angle
00120       //! Values used during interaction
00121       ZONE m_CursorZone;                  //!< Current cursor zone
00122       DPOINT2D m_prevpt;                  //!< Previous point during button-down
00123       UINT8 m_AdjustMode;                 //!< Adjustment mode, 2=rotate, 1=everything else
00124 
00125       //! Methods
00126       void AdjustTool (const DPOINT2D&, bool firsttime=false);
00127       void ComputeCursorZone (const DPOINT2D&);
00128       void Recompute ();
00129       void ResizeTool (const DPOINT2D&);
00130       void RotateTool (const DPOINT2D&);
00131       void StartTool (const DPOINT2D&);
00132       void UpdateCursor () const;
00133 
00134       //! TOOL_BASE overrides.
00135       virtual void v_DoDraw (MGD::CONTEXT*);
00136       virtual void v_DoMove (double dx, double dy, ADJUSTFLAGS flags);
00137       virtual int v_GenerateRegion (REGION2D& region) const;
00138       virtual void v_OnLButtonDown (MGUI::POINT point, KEYSTATE keystate);
00139       virtual void v_OnMouseMove (MGUI::POINT point, KEYSTATE keystate);
00140       //! TOOL_LIMITED overrides.
00141       virtual void v_OnChangeLimits ();
00142       #endif // GENERATING_DOXYGEN_OUTPUT
00143 
00144    };
00145 
00146 
00147 }  // End namespace MGUI
00148 
00149 
00150 #endif   // INC_MGUI_TOOLRECT_H

Generated on Thu Aug 12 06:18:29 2004 for TNTsdk by doxygen 1.3.4-20031026