00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00032 class TOOL_RECTANGLE : public TOOL_LIMITED {
00033 public:
00034
00035
00036 explicit TOOL_RECTANGLE (
00037 TOOLCANVAS *canvas
00038 );
00039
00040
00041 virtual ~TOOL_RECTANGLE ();
00042
00043
00044 TOOL_RECTANGLE& operator= (
00045 const DRECT2D& rhs
00046 );
00047
00048
00049
00050 double GetAngle (
00051 ) const { return (m_angle); }
00052
00053
00054 DPOINT2D GetCenter (
00055 ) const { return (m_extents.GetCenter()); }
00056
00057
00058 const DPOINT2D& GetCorner (
00059 int corner
00060 ) const { return (m_corners[corner]); }
00061
00062
00063
00064 const DPOINT2D* GetCorners (
00065 ) const { return (m_corners); }
00066
00067
00068 void GetCorners (
00069 DPOINT2D rcorners[4]
00070 ) const { for (int i = 0; (i < 4); ++i) rcorners[i] = m_corners[i]; return; }
00071
00072
00073 const DRECT2D& GetExtents (
00074 ) const { return (m_extents); }
00075
00076
00077
00078 const DPOINT2D& GetSize (
00079 ) const { return (m_size); }
00080
00081
00082
00083 void SetAspect (
00084 double aspect
00085 );
00086
00087 protected:
00088
00089 #ifdef DOCONLY // For documentation purposes only.
00090
00091 virtual void v_OnNotifyChange (
00092 CHANGESEQ changeseq,
00093 CHANGETYPE changetype
00094 );
00095 #endif
00096
00097 private:
00098 #ifndef GENERATING_DOXYGEN_OUTPUT
00099
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
00114 double m_aspect;
00115
00116 DRECT2D m_extents;
00117 DPOINT2D m_corners[4];
00118 DPOINT2D m_size;
00119 double m_angle;
00120
00121 ZONE m_CursorZone;
00122 DPOINT2D m_prevpt;
00123 UINT8 m_AdjustMode;
00124
00125
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
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
00141 virtual void v_OnChangeLimits ();
00142 #endif // GENERATING_DOXYGEN_OUTPUT
00143
00144 };
00145
00146
00147 }
00148
00149
00150 #endif // INC_MGUI_TOOLRECT_H