#ifndef _XRECTEDITOR_INCLUDED
#define _XRECTEDITOR_INCLUDED

///////////////////////////////////////////////
//											 //
// All files in this framework are Copyright //
// of Aleksandras Gluchovas 				 //
// 											 //
// e-mail: alex@nm3.ktu.lt                   //
//											 //
///////////////////////////////////////////////

#include "XObject.h"

class XRectEditor : public XEditor
{
public:
	XRect   mRect;
	XRect   mInitialRect;
	XDim    mMinDim;
	PosT    mWidth;

	wxPen   mPen;
	wxBrush mBrush;
	wxBrush mSecondaryBrush;

	bool    mUseInvertedHints;
	bool    mUseCursors;
	bool    mCanMove;

	// state variables

	XPoint  mDragOrigin;
	bool    mDragStarted;
	bool    mStartFired;
	int     mActiveHandle;
	int     mHandlesVisible;

	bool    mCursorIsSet;

	enum { NO_HANDLE = -1, 
		   TOP_LEFT,
		   RIGHT_BOTTOM,
		   TOP_RIGHT,
		   LEFT_BOTTOM
	     };

	bool IsSelected();

	XRect HandleRect( int handleType );

	XCollection& GetScene();
	bool IsInMultipleSelection();
	void SetEdtCursor( int cursorType );

public:

	XRectEditor( const wxColour& lineColor   = wxColour( 0,0,0 ),
		         const wxColour& handleColor = wxColour( 0,0,0 ),
				 bool  useInvertedHints = FALSE,
				 bool  useCursors       = TRUE,
				 const wxColour& secondaryHandleColor = wxColour( 0,0,220 )
			   );

	virtual void SubjectChanged(bool isInitiator);

	void EnableMove( bool canMove = TRUE );

	void SetMinimalDim(  const XDim& minDim );
	void SetHandleWidth( PosT width );

	virtual void SetShape( XPoly& shape );
	virtual void GetShape( XPoly& shape );

	virtual bool OnMouseDown ( const XPoint& pos );
	virtual bool OnMouseUp   ( const XPoint& pos );
	virtual bool OnMouseMove ( const XPoint& pos );

	virtual bool OnMouseLeave();

	virtual void Draw( wxDC& canvas );

	virtual XRect GetBounds();

	virtual XObject* CloneCopy( bool identical = FALSE );

	// overridden method of XEditor
	virtual bool Contains( const XPoint& point ) ;

protected:
	virtual bool HasMovedEnough( const XPoint& pos1, const XPoint& pos2 );
};

#endif
