////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2001.
// -------------------------------------------------------------------------
//  File name:   BrushTool.h
//  Version:     v1.00
//  Created:     11/1/2002 by Timur.
//  Compilers:   Visual C++ 6.0
//  Description: Terrain modification tool.
// -------------------------------------------------------------------------
//  History:
//
////////////////////////////////////////////////////////////////////////////

#ifndef __BrushTool_h__
#define __BrushTool_h__

#if _MSC_VER > 1000
#pragma once
#endif

#include "..\EditTool.h"

//////////////////////////////////////////////////////////////////////////
class CBrushTool : public CEditTool
{
	DECLARE_DYNCREATE(CBrushTool)
public:
	CBrushTool();


	//////////////////////////////////////////////////////////////////////////
	// CEditTool overrides.
	//////////////////////////////////////////////////////////////////////////
	virtual void BeginEditParams( IEditor *ie,int flags );
	virtual void EndEditParams();

	virtual void Display( DisplayContext &dc );
	virtual bool MouseCallback( CViewport *view,EMouseEvent event,CPoint &point,int flags );

	// Key down.
	virtual bool OnKeyDown( CViewport *view,uint nChar,uint nRepCnt,uint nFlags );
	virtual bool OnKeyUp( CViewport *view,uint nChar,uint nRepCnt,uint nFlags );	
	//////////////////////////////////////////////////////////////////////////

protected:
	virtual ~CBrushTool();
	// Delete itself.
	void DeleteThis() { delete this; };
	
private:
	void NewBrush( CViewport *view,CPoint point );
	void StretchBrush( CViewport* view,CPoint point );
	void CalcLastBrushSize();
	void SetObjectCursor( CViewport *view,CBaseObject *hitObj );
	bool CheckVirtualKey( int virtualKey );

	// Specific mouse events handlers.
	bool OnLButtonDown( CViewport *view,UINT nFlags,CPoint point );
	bool OnLButtonUp( CViewport *view,UINT nFlags,CPoint point );
	bool OnMouseMove( CViewport *view,UINT nFlags,CPoint point );

	//! Operation modes of this viewport.
	enum BrushOpMode
	{
		BrushNoMode = 0,
		BrushMoveMode,
		BrushCreateMode,
		BrushStretchMode,
	};

	
	IEditor *m_IEditor;

	//////////////////////////////////////////////////////////////////////////
	//! Bounds of last selected brush or selection.
	BBox m_lastBrushBounds;

	//! Current brush tool operation mode.
	BrushOpMode m_mode;
	bool m_bMouseCaptured;
	CPoint m_mouseDownPos;
	CBaseObject *m_pMouseOverObject;

	//////////////////////////////////////////////////////////////////////////
	// Cursors.
	//////////////////////////////////////////////////////////////////////////
	HCURSOR m_hDefaultCursor;
	HCURSOR m_hHitCursor;
	HCURSOR m_hMoveCursor;
	HCURSOR m_hSelectionPlusCursor;
	HCURSOR m_hSelectionMinusCursor;
	HCURSOR m_hCurrCursor;
};


#endif // __BrushTool_h__
