00001
00058 #ifndef INC_MGUI_TOOLRECTANGLE_H
00059 #define INC_MGUI_TOOLRECTANGLE_H
00060
00061 #ifndef INC_MGUI_TOOLBASE_H
00062 #include <mgui/toolbase.h>
00063 #endif
00064
00065 class POLYLINE;
00066
00067 namespace MGUI {
00068
00069
00071 class TOOL_RECTANGLE : public TOOL_LIMITED {
00072 public:
00073
00074 enum DIRECTION {
00075 DIRECTION_Forward,
00076 DIRECTION_Backward,
00077 DIRECTION_Left,
00078 DIRECTION_Right
00079 };
00080
00081 enum STARTMODE {
00082 STARTMODE_Default = 0,
00083 STARTMODE_CenterlineWidth = 1,
00084 };
00085
00087 explicit TOOL_RECTANGLE (
00088 TOOLCANVAS *canvas
00089 );
00090
00092 virtual ~TOOL_RECTANGLE ();
00093
00096 double GetAngle (
00097 ) const { return (m_angle); }
00098
00100 DPOINT2D GetCenter (
00101 ) const { return (m_extents.GetCenter()); }
00102
00104 const DPOINT2D& GetCorner (
00105 int corner
00106 ) const { return (m_corners[corner]); }
00107
00110 const DPOINT2D* GetCorners (
00111 ) const { return (m_corners); }
00112
00114 void GetCorners (
00115 DPOINT2D rcorners[4]
00116 ) const { for (int i = 0; (i < 4); ++i) rcorners[i] = m_corners[i]; return; }
00117
00119 const DRECT2D& GetExtents (
00120 ) const { return (m_extents); }
00121
00124 const DPOINT2D& GetSize (
00125 ) const { return (m_size); }
00126
00128 void MoveByStep (
00129 DIRECTION direction,
00130 double StepAmtOverride = 0
00131 );
00132
00135 void SetAngleVisible (
00136 bool anglevisible = true,
00137 bool sideanglevisible = false,
00138 int pixels = 0
00139 );
00140
00143 void SetAspect (
00144 double aspect
00145 );
00146
00148 void SetCenterVisible (
00149 bool centervisible = true
00150 );
00151
00154 void SetCorners (
00155 const POLYLINE& corners
00156 );
00157
00159 void SetDftAngle (
00160 double dftangle
00161 );
00162
00164 void SetRectangle (
00165 const DRECT2D& rhs
00166 );
00167
00171 void SetSideMarkerLength (
00172 int lengthoutside
00173 );
00174
00176 void SetStartMode (
00177 STARTMODE StartMode
00178 ) { m_StartMode = StartMode; }
00179
00181 void SetStepByToolDimension (
00182 bool StepByToolDim = true,
00183 double StepAmt = 1.0
00184 ) { m_StepByToolDim = StepByToolDim; m_StepAmt = StepAmt; }
00185
00186 private:
00187 #ifndef GENERATING_DOXYGEN_OUTPUT
00188
00189 enum ZONE {
00190 ZONE_Outside = 0,
00191 ZONE_Inside,
00192 ZONE_Corner0,
00193 ZONE_Corner1,
00194 ZONE_Corner2,
00195 ZONE_Corner3,
00196 ZONE_Side01,
00197 ZONE_Side12,
00198 ZONE_Side23,
00199 ZONE_Side30,
00200 ZONE_Rotate,
00201 ZONE_RotateLeft,
00202 ZONE_RotateRight,
00203 ZONE_RotateSide01,
00204 ZONE_RotateSide23,
00205 ZONE_SetCenter,
00206 ZONE_NoFunction
00207 };
00208 enum ADJUSTMODE {
00209 ADJUSTMODE_Normal,
00210 ADJUSTMODE_Rotate,
00211 ADJUSTMODE_Create2
00212 };
00213
00214
00215 double m_aspect;
00216 bool m_centervisible;
00217 bool m_anglevisible;
00218 bool m_sideanglevisible;
00219 bool m_StepByToolDim;
00220 int m_AngleHandlePixels;
00221 int m_sidemarkerlength;
00222 STARTMODE m_StartMode;
00223 double m_StartSize;
00224
00225 DRECT2D m_extents;
00226 DPOINT2D m_corners[4];
00227 DPOINT2D m_size;
00228 double m_dftangle;
00229 double m_angle;
00230 double m_StepAmt;
00231
00232 ZONE m_PointerZone;
00233 DPOINT2D m_prevpt;
00234 ADJUSTMODE m_AdjustMode;
00235
00237 class MANUAL_RECTANGLE;
00238 friend class MANUAL_RECTANGLE;
00239
00240
00241 void AdjustTool (const DPOINT2D& pt, KEYSTATE keystate, bool firsttime=false);
00242 DPOINT2D ComputeCenter () const;
00243 void ComputePointerZone (const DPOINT2D&);
00244 void Recompute ();
00245 void ResizeTool (const DPOINT2D&);
00246 void RotateTool (const DPOINT2D&);
00247 void StartTool (const DPOINT2D&);
00248 void UpdateCursor (const DPOINT2D&) const;
00249
00250
00251 virtual MANUAL_BASE* v_CreateManualBase ();
00252 virtual bool v_OnKey (MGUI::POINT devpt, KEYCODE keycode, KEYSTATE keystate);
00253 virtual void v_DoDraw ();
00254 virtual void v_DoMove (double dx, double dy, ADJUSTFLAGS flags);
00255 virtual int v_GenerateRegion (REGION2D& region) const;
00256 virtual bool v_OnPointerButtonDown (MGUI::POINT point, POINTERBUTTON button, KEYSTATE keystate);
00257 virtual bool v_OnPointerButtonUp (MGUI::POINT point, POINTERBUTTON button, KEYSTATE keystate);
00258 virtual void v_OnPointerLeave ();
00259 virtual void v_OnPointerMove (MGUI::POINT point, POINTERBUTTON button, KEYSTATE keystate);
00260
00261 virtual void v_OnChangeLimits ();
00262 #endif // GENERATING_DOXYGEN_OUTPUT
00263
00264 };
00265
00266
00267 }
00268
00269
00270 #endif // INC_MGUI_TOOLRECTANGLE_H