/****************************************************************************************************

		PropertiesClient.cpp
		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Arnaud
		Date:	12/2/2004

****************************************************************************************************/

#include "PropertiesClient.h"

#include "I3DShModule.h"

#include "MCCountedPtrHelper.h"
#include "Modeler.h"
#include "HierarchyPublicDefs.h"


TPropertiesClient::TPropertiesClient(	IPropertiesModule*		inPropertiesModule,
										TModeler*				inModeler)
: TBasicPropertiesClient(inPropertiesModule)
{
	fModeler= inModeler;
}


TPropertiesClient::~TPropertiesClient()
{
}

	
void TPropertiesClient::Create(	IPropertiesModule*		inPropertiesModule,
								TModeler*				inModeler,
								TPropertiesClient**		outClient)
{
	TMCCountedCreateHelper<TPropertiesClient> result(outClient);
	result = new TPropertiesClient(inPropertiesModule, inModeler);
}

void TPropertiesClient::Hydrate		()
{
	ThrowIfNil(fPropertiesModule);
	fPropertiesModule->GetThisModule()->Hydrate();
}

void TPropertiesClient::Dehydrate	()
{
	ThrowIfNil(fPropertiesModule);
	fPropertiesModule->GetThisModule()->Dehydrate();
}

void TPropertiesClient::Activate	()
{
	ThrowIfNil(fPropertiesModule);
	fPropertiesModule->SetCurrentClient(this);
	fPropertiesModule->GetThisModule()->Hydrate();
	fPropertiesModule->GetThisModule()->Activate();
}

void TPropertiesClient::Deactivate	()
{
	ThrowIfNil(fPropertiesModule);
	fPropertiesModule->GetThisModule()->Deactivate();
	fPropertiesModule->SetCurrentClient(NULL);
}


void TPropertiesClient::GetExtraTabs(TMCClassArray<TPropertyTab>& extraTabs)
{
	TBasicPropertiesClient::GetExtraTabs(extraTabs);
	extraTabs.AddElem( TPropertyTab(kRID_ModuleFamilyID, kHierModuleID, kObjectsPartNodeID,	kHierarchyModulePublicStrings, kHierModuleObjectsString) );
}

void TPropertiesClient::GetPreferedSplit(int32& outPreferedSize, boolean& outForTopPart)
{
	outPreferedSize = 300;
	outForTopPart	= false;

	if (MCVerify(fModeler))
	{
		TModelerPrefs* prefs= fModeler->GetModelerPrefs();
		if (MCVerify(prefs))
		{
			outPreferedSize= prefs->fPreferedSplitSize;
		}
	}
}


void TPropertiesClient::StorePreferedSplit(int32 inPreferedSize)
{
	if (MCVerify(fModeler))
	{
		TModelerPrefs* prefs= fModeler->GetModelerPrefs();
		if (MCVerify(prefs))
		{
			prefs->fPreferedSplitSize= inPreferedSize;
		}
	}
}