#ifndef _XSELECTIONEDITOR_INCLUDED
#define _XSELECTIONEDITOR_INCLUDED

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

#include "XObject.h"

WX_DEFINE_ARRAY( XPoly*, XPolyListT );

class XSelectionEditor : public XEditor
{
protected:
	XPoint mDragOrigin;
	XPoint mCanvasOrigin;
	XRect  mBounds;
	XRect  mBoundsOriginal;

	bool   mDragStarted;
	bool   mSelectionStarted;
	bool   mSelectionFinished;

	XObject* mpInitialFocus;
	XObject* mpSurroundingObj;

	bool   mStickyMode;
	bool   mRMBScrollOn;

	bool   mScrollStarted;

	wxPen  mPen;

	XPolyListT mShapes;

protected:
	void   FinishTransaction();
	void   ResetSelector();
	void   SaveOriginalShapes();
	inline XCollection& GetCont();

public:
	XSelectionEditor( const wxColour& color = wxColour( 0,0,0 ) );
	virtual ~XSelectionEditor();

	// if sticky mode is on, objects will appeare in multiple
	// selection rect if any part of the object hits the 
	// selection rectangle, otherwise the entire area of object
	// should be convered by this rectangle for the object to 
	// be selected.
	//
	// by default sticky mode is off

	void SetStickyMode( bool stickyModeOn );

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

	virtual bool OnRightClick( const XPoint& pos );

	virtual void NotifyObjectChanged();

	virtual void Draw( wxDC& canvas );

	virtual XRect GetBounds();

	// notifications can behandled by the derived classes

	// specific selectors may remove some objects
	// (filter) from the given selection list, e.g.
	// these can be unselectable objects

	virtual void FilterSelection( XObjListT& lst ) {}
	// called each time the selection is moved
	virtual void OnSelectionDragged( XObjListT& lst ) {}

protected:
	virtual void DrawTrackerRect( wxDC& dc );
};
	
#endif