#include <common/elastic.hpp>

GUIWindow &ElasticControl::controlWindow(void)
{
  return *this;
}

HWND ElasticControl::createControl(const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,GUIWindow &parentWindow,int controlID)
{
	ElasticControl::createControl(0,className,windowName,dwStyle,initRect,parentWindow,controlID);
	return *this;
}

HWND ElasticControl::createControl(DWORD extendedStyle,const String &className,const String &windowName,DWORD dwStyle,const Rect &initRect,GUIWindow &parentWindow,int controlID)
{
	mlpParentWindow=&parentWindow;
	parentWindow.insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
	Control::createControl(extendedStyle,className,windowName,dwStyle,initRect,parentWindow,controlID);
	initControl(parentWindow);
	return *this;
}

HWND ElasticControl::assumeControl(GUIWindow &parentWindow,HWND hControlWnd,UINT controlID)
{
  mlpParentWindow=&parentWindow;
	parentWindow.insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
	Control::assumeControl(hControlWnd,controlID);
	initControl(parentWindow);
	return *this;
}

HWND ElasticControl::createControl(DWORD /*extendedStyle*/,const String &/*className*/,const String &/*windowName*/,DWORD /*dwStyle*/,const Rect &/*initRect*/,HWND /*hParent*/,int /*controlID*/)
{ // no implementation
	return (HWND)0;
}

HWND ElasticControl::createControl(const String &/*className*/,const String &/*windowName*/,DWORD /*dwStyle*/,const Rect &/*initRect*/,HWND /*hParentWnd*/,int /*controlID*/)
{  // no implementation
	return (HWND)0;
}

CallbackData::ReturnType ElasticControl::sizeHandler(CallbackData &someCallbackData)
{
	if(!mlpParentWindow)return (CallbackData::ReturnType)FALSE;
  moveControl(*mlpParentWindow,someCallbackData.loWord(),someCallbackData.hiWord());
	return (CallbackData::ReturnType)FALSE;
}
