mgui/toolregp.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/toolregp.h
00003  * \brief MGUI::TOOL_REGPOLYGON class definition
00004  *
00005  * \if NODOC
00006  * $Id: toolregp.h_v 1.3 2003/10/03 19:58:19 linux32build!build Exp $
00007  *
00008  * $Log: toolregp.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:58  mju
00016  * Initial revision
00017  *
00018  * \endif
00019 **/
00020 
00021 #ifndef  INC_MGUI_TOOLREGP_H
00022 #define  INC_MGUI_TOOLREGP_H
00023 
00024 #ifndef  INC_MGUI_TOOLBASE_H
00025 #include <mgui/toolbase.h>
00026 #endif
00027 
00028 namespace MGUI {
00029 
00030 
00031 //! "Regular Polygon" tool
00032 class TOOL_REGPOLYGON : public TOOL_BASE {
00033    public:
00034 
00035       //! Constructor.
00036       explicit TOOL_REGPOLYGON (
00037          TOOLCANVAS *canvas
00038          );
00039 
00040       //! Destructor.
00041       virtual ~TOOL_REGPOLYGON ();
00042 
00043       //! Get current rotation angle.
00044       double GetAngle (
00045          ) const { return (m_angle); }
00046 
00047       //! Get center position.
00048       const DPOINT2D& GetCenter (
00049          ) const { return (m_center); }
00050 
00051       //! Get number of segments.
00052       int GetNumSegments (
00053          ) const { return (m_NumSegments); }
00054 
00055       //! Get radius.
00056       double GetRadius (
00057          ) const { return (m_radius); }
00058 
00059       //! Set rotation angle.
00060       void SetAngle (
00061          double newangle
00062          );
00063 
00064       //! Set whether angle indicator is visible.
00065       void SetAngleVisible (
00066          bool anglevisible = true
00067          );
00068 
00069       //! Set center of polygon.
00070       void SetCenter (
00071          const DPOINT2D& center              //!< New center in tool coordinates
00072          );
00073 
00074       //! Set marker type and size.
00075       //! The default marker is MARKER_Plus with a size of 9 pixels.
00076       void SetMarker (
00077          MARKER marker,                      //!< New marker type
00078          UINT16 size = 0                     //!< New marker size, 0 to retain current size
00079          );
00080 
00081       //! Set number of polygon segments.
00082       void SetNumSegments (
00083          int NumSegments                     //!< Number of segments >= 3
00084          );
00085 
00086       //! Set polygon radius (distance from center to vertex).
00087       void SetRadius (
00088          double radius                       //!< Radius is tool units
00089          );
00090 
00091       //! Set allowed radius range
00092       void SetRadiusRange (
00093          double minradius,                   //!< Minimum radius
00094          double maxradius                    //!< Maximum radius, <= 0 for no maximum
00095          );
00096 
00097    private:
00098       #ifndef GENERATING_DOXYGEN_OUTPUT
00099       //! Enumeration constants
00100       enum ZONE {
00101          ZONE_NoFunction = 0,
00102          ZONE_Outside,
00103          ZONE_Inside,
00104          ZONE_Perimeter,
00105          ZONE_SetCenter,
00106          ZONE_Rotate,
00107          };
00108       //! Tool settings
00109       MARKER m_marker;
00110       UINT16 m_markersize;
00111       double m_minradius;                 //!< Minimum radius
00112       double m_maxradius;                 //!< Maximum radius, 0 if no maximum
00113       bool m_anglevisible;                //!< Visibility of rotation angle indicator
00114       //! Tool position values
00115       DPOINT2D m_center;                  //!< Center
00116       double m_radius;                    //!< Distance from center to each vertex
00117       double m_angle;
00118       int m_NumSegments;
00119       //! Values used during interaction
00120       ZONE m_CursorZone;                  //!< Current cursor zone
00121       DPOINT2D m_prevpt;                  //!< Previous point during button-down
00122 
00123       //! Methods
00124       void AdjustTool (const DPOINT2D&, bool firsttime=false);
00125       void ComputeCursorZone (const DPOINT2D&);
00126       void StartTool (const DPOINT2D&);
00127       void UpdateCursor (const DPOINT2D&) const;
00128 
00129       //! TOOL_BASE overrides.
00130       virtual void v_DoDraw (MGD::CONTEXT*);
00131       virtual void v_DoMove (double dx, double dy, ADJUSTFLAGS flags);
00132       virtual int v_GenerateRegion (REGION2D& region) const;
00133       virtual bool v_OnKey (MGUI::POINT point, KEYCODE keycode, KEYSTATE keystate);
00134       virtual void v_OnLButtonDown (MGUI::POINT point, KEYSTATE keystate);
00135       virtual void v_OnMouseMove (MGUI::POINT point, KEYSTATE keystate);
00136       #endif // GENERATING_DOXYGEN_OUTPUT
00137    };
00138 
00139 
00140 }  // End namespace MGUI
00141 
00142 
00143 #endif   // INC_MGUI_TOOLREGP_H

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