#include "ExportEngineerpch.h"
#include "EngineerDialogHook.h"
#include <DgnPlatform\DgnPlatform.r.h>

using namespace Bentley;
extern BindingValue g_binding;

ListCell*			listModel_getEditCell
(
	const MSDialogP   	db,			//	=>	Dialog that contains ComboBox or ListBox
	RawItemHdr*			rItem,		//	=>	Reference to  ComboBox or ListBox
	int* rowIndex,
	int* colIndex
)
{
	ListModel*		pListModel = NULL;
	ListCell*		pCell = NULL;
	DialogItem*		pContainer = rItem->diP;
	int				row = -1,
		col = -1,
		status = -1;

	switch (pContainer->type)
	{
	case RTYPE_ListBox:
	{
		pListModel = mdlDialog_listBoxGetListModelP(rItem);
		status = mdlDialog_listBoxGetEditCell(&row, &col, rItem);
		*rowIndex = row;
		*colIndex = col;
		if (SUCCESS == status)
		{
			pCell = mdlListModel_getCellAtIndexes(pListModel, row, col);
		}
		else
		{
			printf("  mdlDialog_listBoxGetEditCell() failed\n");
		}
		break;
	}
	}
	return pCell;
}
/** --------------------------------------------------------------------+
|																		|
|	function name:	listModel_getListBoxEditCell						|
|																		|
|	description:	A ListCell is contained by a ListModel that is 		|
|					contained by a ListBox.  The ListModel contains		|
|					an array of ListCell objects.	A reference to the	|
|					currently-selected ListCell is often required to	|
|					obtain or update the ListCell's contents.			|
|																		|
|	note:			If the ListBox is transient you can't use			|
|					you can't use this function							|
|																		|
|	usage:			ListCell *pCell = NULL;								|
|					pCell	= listModel_getListBoxEditCell	(db, LBOX);	|
|																		|
|	returns:		Non-const reference to a ListCell on success		|
|																		|
+--------------------------------------------------------------------- */
ListCell*			listModel_getListBoxEditCell
(
	const MSDialogP   	db,			//	=>	Dialog box that contains our ListBox
	ULong 				nIDListBox,	//	=>	Resource ID of the ListBox
	int* rowIndex,
	int* colIndex
)
{
	DialogItem*		pLBox = mdlDialog_itemGetByTypeAndId((MSDialogP)db, RTYPE_ListBox, nIDListBox, 0);

	return (NULL == pLBox) ? NULL : listModel_getEditCell(db, pLBox->rawItemP,rowIndex,colIndex);
}

//双击ListBox产生编辑框，此编辑框的钩函数
void EditCellHook
(
	DialogItemMessage *dimP
)
{
	dimP->msgUnderstood = TRUE;
	switch (dimP->messageType)
	{
	case DITEM_MESSAGE_CREATE:
	{
		
	}
	break;
	case DITEM_MESSAGE_FOCUSOUT:
	{
		
	}
	break;
	default:
		dimP->msgUnderstood = FALSE;
		break;
	}
}
//按工程做法分类ListBox，编辑“构造做法”列产生下拉列表框，此下拉列表框的钩函数
void EditComboxHook
(
	DialogItemMessage* dimP
)
{
	
	switch (dimP->messageType)
	{
	case DITEM_MESSAGE_CREATE:
	{
		
		
		break;
	}
	case DITEM_MESSAGE_STATECHANGED:
	{
		
		break;
	}
	case DITEM_MESSAGE_DESTROY:
	{
		break;
	}
	default:
		dimP->msgUnderstood = FALSE;
		break;
	}
}
//标签列表钩函数
void TagPageList_ExportEngineer_Hook
(
	DialogItemMessage       *dimP
)
{
	dimP->msgUnderstood = TRUE;
	switch (dimP->messageType)
	{
	case DITEM_MESSAGE_STATECHANGED:
		
		break;
	default:
		dimP->msgUnderstood = FALSE;
		break;
	}
}
//ListBox钩函数
void CellListlingHook
(
	DialogItemMessage       *dimP
)
{
	dimP->msgUnderstood = TRUE;
	switch (dimP->messageType)
	{
	case DITEM_MESSAGE_CREATE:
	{
	}
	break;
	case DITEM_MESSAGE_DESTROY:
	{

	}
	break;
	case DITEM_MESSAGE_BUTTON:
	{
	}
	break;
	default:
		dimP->msgUnderstood = FALSE;
		break;
	}
	return;
}

void ToggleBtnDeleteBlank
(
	DialogItemMessage* dimP
)
{
	dimP->msgUnderstood = TRUE;
	switch (dimP->messageType)
	{
	case DITEM_MESSAGE_CREATE:
	{
		//初始时不勾选“删除空白行”
		g_binding.deleteBlank = 0;
	}
	break;
	case DITEM_MESSAGE_STATECHANGED:
	{
	}
	break;
	default:
		dimP->msgUnderstood = FALSE;
		break;
	}
	return;
}


//“导出”按钮钩函数
void ExportHook
(
	DialogItemMessage       *dimP
)
{
	dimP->msgUnderstood = TRUE;
	switch (dimP->messageType)
	{
	case DITEM_MESSAGE_BUTTON:
	{
	}
	break;
	default:
		dimP->msgUnderstood = FALSE;
		break;
	}
	return;
}
