//
//	Copyright © 2006 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#include "StdHeaders.h"

#include "ColorPopupCtrl.h"

#include "Dialog.h"

using namespace VectorWorks::VWUI;

VWColorPopupCtrl::VWColorPopupCtrl(TControlID id)
: VWControl( id )
{
}

VWColorPopupCtrl::~VWColorPopupCtrl()
{
}

bool VWColorPopupCtrl::CreateControl(VWDialog* pDlg)
{
	::GS_CreateColorPopup( gCBP, pDlg->GetControlID(), fControlID );
	return VWControl::CreateControl( pDlg );
}

RGBColor VWColorPopupCtrl::GetSelectedColor() const
{
	short		colorIndex;
	::GS_GetColorChoice( gCBP, fpParentDlg->GetControlID(), fControlID, colorIndex );

	RGBColor	color;
	//ECO_REVISIT_VML Replace GS_ColorIndexToRGB call with new ColorRef-based call when available.
	::GS_ColorIndexToRGB( gCBP, DemoteTo<ColorRef>(kSteve, colorIndex), color );
	return color;
}

void VWColorPopupCtrl::SetSelectedColor(const RGBColor& color)
{
	ColorRef		colorIndex;
	::GS_RGBToColorIndex( gCBP, color, colorIndex );

	::GS_SetColorChoice( gCBP, fpParentDlg->GetControlID(), fControlID, colorIndex );
}
