#ifndef __ToolTableEdit_h
#define __ToolTableEdit_h

#include "ObjTable.h"		// For FCLineColumn.
#include "ToolBaseEdit.h"	// Super class.

#ifdef SUPER_CLASS
#undef SUPER_CLASS
#endif
#define SUPER_CLASS FCToolBaseEdit


/*************************************************************************
 * <_xZkqqHx_iDeOiDiJiDfI_xHqqkZx_>	FCToolTableEdit
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	FCObjTable_xZkqqHx_iCpAjFnCiPfHiClHiCoJiClNiCnPiCmMiDgDiBfLiDiLiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	99.01.22 Fukushiro M. _xZkqqHx_iDfCiDiBiDjDiDgHiNoMjAkM_xHqqkZx_
 *************************************************************************/
class FCToolTableEdit : public SUPER_CLASS
{
protected:
typedef SUPER_CLASS BASE_CLASS;

protected:
	enum Area
	{
		AREA_NONE,				// _xZkqqHx_iDeHiDiKiDeBjGlDiClFiBeC_xHqqkZx_
		AREA_CELL_SEL_LINE,		// _xZkqqHx_iDfKiDiLiNhDiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_CELL_SEL_COLUMN,	// _xZkqqHx_iDfKiDiLjHpBiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_CELL_SEL_ALL,		// _xZkqqHx_jBfDiDfKiDiLiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_CELL_SEL_MATRIX,	// _xZkqqHx_iDfKiDiLiDhNiDgHiDiKiDgCiDeOiDfIiDeHiDiKiDeBiBeC_xHqqkZx_

		AREA_RULED_MOVE_HORZ,	// _xZkqqHx_jAiFjFlNiMhCjApMiInKjDkOiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_RULED_MOVE_VERT,	// _xZkqqHx_jAiCjClMiMhCjApMiInKjDkOiDeHiDiKiDeBiBeC_xHqqkZx_

		AREA_RULED_SEL_HORZ,	// _xZkqqHx_jAiFjFlNiMhCjApMjBeJjBpAiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_RULED_SEL_VERT,	// _xZkqqHx_jAiCjClMiMhCjApMjBeJjBpAiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_RULED_SEL_ALL,		// _xZkqqHx_jBfDiMhCjApMiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_RULED_SEL_MATRIX_HORZ,	// _xZkqqHx_jAiFjFlNiMhCjApMjBeJjBpAiDhNiDgHiDiKiDgCiDeOiDfIiDeHiDiKiDeBiBeC_xHqqkZx_
		AREA_RULED_SEL_MATRIX_VERT,	// _xZkqqHx_jAiCjClMiMhCjApMjBeJjBpAiDhNiDgHiDiKiDgCiDeOiDfIiDeHiDiKiDeBiBeC_xHqqkZx_
	}; // enum Area.

public:
	//----- _xZkqqHx_iDfEiDhFiDeOiDiJiDfIiCmFjEeDiInD_xHqqkZx_ -----
// 06.12.09 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//	virtual void	OnDraw (CDC* pDC);
// 05.07.25 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//	virtual void	OnDraw (CDC* pDC, const DBLRect* pmmrtRgn = NULL, long lRgnSize = 0);
	virtual void	OnObjectProperties ();
	virtual void	Select (CDC* pDC);
	virtual void	DrawSelectMark (CDC* pDC, FCObjDynabase* pObj);
// 05.01.29 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//	virtual void	OnAppendSelectObj (CDC* pDC, FCObjDynabase* pObj);
	virtual void	OnRemoveSelectObj (CDC* pDC, FCObjDynabase* pObj);

	virtual const ObjDynabaseVector& GetSelectLocalObjVector () const;

//----- 05.08.15 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	virtual BOOL	CanDelete () const;
	virtual void	OnDelete (CDC* pDC);
//----- 05.08.15 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

	virtual BOOL	CanObjectTableInsertLine () const;
	virtual void	OnObjectTableInsertLine ();
	virtual BOOL	CanObjectTableAddLine () const;
	virtual void	OnObjectTableAddLine ();
	virtual BOOL	CanObjectTableInsertColumn () const;
	virtual void	OnObjectTableInsertColumn ();
	virtual BOOL	CanObjectTableAddColumn () const;
	virtual void	OnObjectTableAddColumn ();
	virtual BOOL	CanObjectTableDeleteLine () const;
	virtual void	OnObjectTableDeleteLine ();
	virtual BOOL	CanObjectTableDeleteColumn () const;
	virtual void	OnObjectTableDeleteColumn ();
	virtual BOOL	CanObjectTableMergeCell () const;
	virtual void	OnObjectTableMergeCell ();
	virtual BOOL	CanObjectTableSplitCell () const;
	virtual void	OnObjectTableSplitCell ();

	virtual BOOL	CanHandle (const FCObjDynabase* pObj) const;
	virtual BOOL	IsObjectCommandEnable (DWORD dwCmdID) const;

protected:
	//----- _xZkqqHx_iClBiCmMiDeOiDiJiDfIiMmFjHeM_xHqqkZx_ -----
	virtual Area	CheckHitRuled ();
	virtual Area	CheckHitCell ();
	virtual BOOL	IsHitOnSelectedCell () const;
	virtual void	DrawMovingRuled (CDC* pDC) const;
	virtual void	DrawSelectedCell (CDC* pDC, const FCObjTable* pObjTable) const;
	virtual void	ClearCellSelectionInfo ();
	virtual void	SetSelectedObjTable (FCObjTable* pObjTable);
	virtual void	InsertLine (long lLineIndex);
	virtual void	InsertColumn (long lColumnIndex);
	virtual void	DeleteLine (long lLineIndex);
	virtual void	DeleteColumn (long lColumnIndex);

	virtual void	SelectCellTmpMatrix (FCLineColumn cellIndexFrom,
										 FCLineColumn cellIndexUntil);
	virtual void	SelectCellTmpIncluded (FCLineColumn cellIndexFrom,
										 FCLineColumn cellIndexUntil);
	virtual void	SelectRuledTmpMatrix (	BOOL bIsHorz,
											FCFrontSide ruledIndexFrom,
											FCFrontSide ruledIndexUntil);
	virtual void	ClearSelectCellTmp ();
	virtual BOOL	AppendSelectCellTmp (const FCLineColumn& cellIndex);
	virtual void	ClearRuledTmp (BOOL bIsHorz);
	virtual BOOL	AppendSelectRuledTmp (BOOL bIsHorz, const FCFrontSide& ruledIndex);

	virtual void	ClearSelectCell ();
	virtual void	AppendSelectCell (const FCLineColumn& cellIndex);
	virtual void	AppendSelectCell (const set<FCLineColumn>& stCellIndex);
	virtual void	SetSelectCell (const set<FCLineColumn>& stCellIndex);
	virtual void	RemoveSelectCell (const FCLineColumn& cellIndex);
	virtual void	RemoveSelectCell (const set<FCLineColumn>& stCellIndex);

	virtual void	ClearSelectRuled (BOOL bIsHorz);
	virtual void	AppendSelectRuled (BOOL bIsHorz, const FCFrontSide& cellIndex);
	virtual void	AppendSelectRuled (BOOL bIsHorz, const set<FCFrontSide>& stRuledIndex);
	virtual void	SetSelectRuled (BOOL bIsHorz, const set<FCFrontSide>& stRuledIndex);
	virtual void	RemoveSelectRuled (BOOL bIsHorz, const FCFrontSide& cellIndex);
	virtual void	RemoveSelectRuled (BOOL bIsHorz, const set<FCFrontSide>& stRuledIndex);

// 06.06.13 Fukushiro M. 1_xZkqqHx_iNhDjCmHiJmB_xHqqkZx_ ()
	virtual void	TbLocalObjMovedBefore ();

	//----- FCToolBaseFDA_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjHhGiCmJiJjOiClGiCmE_xHqqkZx_ -----
// 06.12.09 Fukushiro M. 1_xZkqqHx_iNhDjCmHiJmB_xHqqkZx_ ()
	virtual void	OnDrawState (CDC* pDC, int iState);
	virtual int		TransFDA (int iState, int iEvent);
	virtual void	StateFDA (int iState, CDC* pDC);

	//----- _xZkqqHx_jBeKiInKiPpDjBnEiPiIjHjNiBgJiDeJiBfLiDgPiBfLiDiJiDeDiDgIiBgK_xHqqkZx_ -----
	virtual void	StateIdle (CDC* pDC);
	//----- _xZkqqHx_jBeKiInKiPpDjBnEiPiIjHjN_xHqqkZx_ -----
	virtual void	StateEnterMoveRuled (CDC* pDC);
	virtual void	StateStartMoveRuled (CDC* pDC);
	virtual void	StateMovingRuled (CDC* pDC);
	virtual void	StateStopMoveRuled (CDC* pDC);
	virtual void	StateExitMoveRuled (CDC* pDC);

	virtual void	StateEnterSelectCell (CDC* pDC);
	virtual void	StateRangeSelectCell (CDC* pDC);
	virtual void	StateRemoveSelectCell (CDC* pDC);
	virtual void	StateAddSelectCell (CDC* pDC);
	virtual void	StateExitSelectCell (CDC* pDC);
	virtual void	StateClearSelectCell (CDC* pDC);
	virtual void	StateMemoryHitInfo (CDC* pDC);
	virtual void	StateAreaSelecting (CDC* pDC);

	//----- FCToolBaseFDA_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjHhGiCmJiJjOiClGiCmE_xHqqkZx_ -----
	virtual int		GetSubMenuIndex () const;

	//----- FCToolBaseEdit_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjFeLjAhL_xHqqkZx_ -----
	virtual void	ResetEditHandleList ();

	//----- FCToolSelectTmpl_xZkqqHx_iCmMiDfEiDhFiDeOiDiJiDfIiCmFjEeDiInD_xHqqkZx_ -----
	virtual BOOL	IsIntersectXXX (XXX_EditObjDynabase, FCObjDynabase* xxx, const DBLPoint& mmpt) const;

protected:
// _xZkqqHx_iClBiCmMiDeOiDiJiDfIiMmFjHeMiCmMjCoIiLgAiBeC_xHqqkZx_
enum
{
	STATE_BEGIN = BASE_CLASS::STATE_END,	// _xZkqqHx_iPpDjBnEiKeKiOgOiBeC_xHqqkZx_
	STATE_ENTER_MOVE_RULED,		// _xZkqqHx_iMhCjApMiInKjDkOjDpMiMpLiBeC_xHqqkZx_
	STATE_START_MOVE_RULED,		// _xZkqqHx_iMhCjApMiInKjDkOiKeKiOgOiBeC_xHqqkZx_
	STATE_MOVING_RULED,			// _xZkqqHx_iMhCjApMiInKjDkOjCiGiBeC_xHqqkZx_
	STATE_STOP_MOVE_RULED,		// _xZkqqHx_iMhCjApMiInKjDkOiPeJjHlJiBeC_xHqqkZx_
	STATE_EXIT_MOVE_RULED,		// _xZkqqHx_iMhCjApMiInKjDkOiPgPiMpLiBeC_xHqqkZx_

	STATE_ENTER_SELECT_CELL,	// _xZkqqHx_jBeJjBpAjDpMiMpLiBeC_xHqqkZx_
	STATE_RANGE_SELECT_CELL,	// _xZkqqHx_jEmNiImNjBeJjBpAiBeC_xHqqkZx_
	STATE_REMOVE_SELECT_CELL,	// _xZkqqHx_jBeJjBpAiJpAiPjMiBeC_xHqqkZx_
	STATE_ADD_SELECT_CELL,		// _xZkqqHx_jCmHiJmBjBeJjBpAiBeC_xHqqkZx_
	STATE_EXIT_SELECT_CELL,		// _xZkqqHx_jBeJjBpAiPgPiMpLiBeC_xHqqkZx_
	STATE_CLEAR_SELECT_CELL,	// _xZkqqHx_jBeJjBpAjBfDiJpAiPjMiBeC_xHqqkZx_
	STATE_CLEAR_SELECT_CELL_2,	// _xZkqqHx_jBeJjBpAjBfDiJpAiPjM_xHqqkZx_2_xZkqqHx_iBeC_xHqqkZx_
	STATE_CLEAR_SELECT_CELL_3,	// _xZkqqHx_jBeJjBpAjBfDiJpAiPjM_xHqqkZx_3_xZkqqHx_iBeC_xHqqkZx_
	STATE_MEMORY_HIT_INFO,		// _xZkqqHx_iDhBiDgCiDgHiPoOjFpBiLeMiJkPiBeC_xHqqkZx_
	STATE_AREA_SELECTING,		// _xZkqqHx_iDeHiDiKiDeBjBeJjBpAjCiGiBeC_xHqqkZx_
	STATE_END,					// _xZkqqHx_iPpDjBnEiPeJjHlJiBeC_xHqqkZx_
};

protected:
	int				m_iStartBtnDown;		// _xZkqqHx_iKeKiOgOiOjOiCmMiJeFiBeFiNlGiDhLiDfOiDjDiDfPiDeFiDjDiBeC_xHqqkZx_
	FCObjTable*		m_pHitObj;				// _xZkqqHx_iDhBiDgCiDgHiClFiClNjFfMjFjEjFgJiBeC_xHqqkZx_
	Area			m_areaHit;				// _xZkqqHx_iDhBiDgCiDgHiClFiClNiDeHiDiKiDeBiBeC_xHqqkZx_
	long			m_lHitFrontRuledIndex;	// _xZkqqHx_iDhBiDgCiDgHiClFiClNiMhCjApMiCmMiOlCjFpLiMpMiDeDiDjDiDgGiDgCiDeOiDfIiBeC_xHqqkZx_
	long			m_lHitSideRuledIndex;	// _xZkqqHx_iDhBiDgCiDgHiClFiClNiMhCjApMiCmMiOlCjAiCjApMjFpLiMpMiDeDiDjDiDgGiDgCiDeOiDfIiBeC_xHqqkZx_

	mmetol			m_mmMovingRuledCoord;

	long			m_lHitLineCellIndex;		// _xZkqqHx_iDhBiDgCiDgHiClFiClNiNhDiBeC_xHqqkZx_
	long			m_lHitColumnCellIndex;		// _xZkqqHx_iDhBiDgCiDgHiClFiClNjHpBiBeC_xHqqkZx_

	FCObjTable*		m_pPrevHitObj;				// _xZkqqHx_jBePiJpBiDhBiDgCiDgHiClFiClNjFjEjFgJiBeC_xHqqkZx_
	Area			m_areaPrevHit;				// _xZkqqHx_jBePiJpBiDhBiDgCiDgHiClFiClNiDeHiDiKiDeBiBeC_xHqqkZx_

	long			m_lPrevHitLineCellIndex;	// _xZkqqHx_jBePiJpBiDhBiDgCiDgHiClFiClNiNhDiBeC_xHqqkZx_STATE_AREA_SELECTING _xZkqqHx_iCmFiOgHjHhAiBeC_xHqqkZx_
	long			m_lPrevHitColumnCellIndex;	// _xZkqqHx_jBePiJpBiDhBiDgCiDgHiClFiClNjHpBiBeC_xHqqkZx_STATE_AREA_SELECTING _xZkqqHx_iCmFiOgHjHhAiBeC_xHqqkZx_

	long			m_lPrevHitFrontRuledIndex;	// _xZkqqHx_jBePiJpBiDhBiDgCiDgHiClFiClNiMhCjApMiCmMiOlCjFpLiMpMiDeDiDjDiDgGiDgCiDeOiDfIiBeC_xHqqkZx_
	long			m_lPrevHitSideRuledIndex;	// _xZkqqHx_jBePiJpBiDhBiDgCiDgHiClFiClNiMhCjApMiCmMiOlCjAiCjApMjFpLiMpMiDeDiDjDiDgGiDgCiDeOiDfIiBeC_xHqqkZx_

	FCObjTable*			m_pSelectedObjTable;	// _xZkqqHx_jBeJjBpAiClDiCoKiClNjFfMjFjEjFgJiBeC_xHqqkZx_

	FCLineColumn		m_lcLastSelectedCell;	// _xZkqqHx_iNmFiMoDiCmJjBeJjBpAiClDiCoKiClNiDfKiDiLiBeC_xHqqkZx_
	set<FCLineColumn>	m_stSelectedCellTmp;	// _xZkqqHx_iIoKiOjOjDeJiCmJjBeJjBpAiClDiCoKiClNiDfKiDiLiBeC_xHqqkZx_
	set<FCLineColumn>	m_stSelectedCell;		// _xZkqqHx_jBeJjBpAiClDiCoKiClNiDfKiDiLiBeC_xHqqkZx_
	ObjDynabaseVector		m_vSelectedCellRuledObj;	// _xZkqqHx_jBeJjBpAiClDiCoKiClNjFjEjFgJiBeC_xHqqkZx_

	FCFrontSide			m_lcLastSelectedHorzRuled;	// _xZkqqHx_iNmFiMoDiCmJjBeJjBpAiClDiCoKiClNjAiFjFlNiMhCjApMiBeC_xHqqkZx_
	set<FCFrontSide>	m_stSelectedHorzRuledTmp;	// _xZkqqHx_iIoKiOjOjDeJiCmJjBeJjBpAiClDiCoKiClNjAiFjFlNiMhCjApMiBeC_xHqqkZx_
	set<FCFrontSide>	m_stSelectedHorzRuled;		// _xZkqqHx_jBeJjBpAiClDiCoKiClNjAiFjFlNiMhCjApMiBeC_xHqqkZx_

	FCFrontSide			m_lcLastSelectedVertRuled;	// _xZkqqHx_iNmFiMoDiCmJjBeJjBpAiClDiCoKiClNjAiCjClMiMhCjApMiBeC_xHqqkZx_
	set<FCFrontSide>	m_stSelectedVertRuledTmp;	// _xZkqqHx_iIoKiOjOjDeJiCmJjBeJjBpAiClDiCoKiClNjAiCjClMiMhCjApMiBeC_xHqqkZx_
	set<FCFrontSide>	m_stSelectedVertRuled;		// _xZkqqHx_jBeJjBpAiClDiCoKiClNjAiCjClMiMhCjApMiBeC_xHqqkZx_
}; // class FCToolTableEdit.

#endif//__ToolTableEdit_h
