void TW_CALL UiPropertyGrid::SetCallbackPropertyDropdown( const void* value, void* clientData )
{
	SceneManager::Property* property ( reinterpret_cast<SceneManager::Property*>(clientData) );
	bool treest= property->SetValue( *(const int*)value );
	GetParentPanel(property)->UpdatePropertyList();
	GetParentPanel(property)->RefreshPropertyGrid();
}
void UiPropertyGrid::ClearTextureCallback( void* propertyData )
{
	SceneManager::Property* textureProperty ( reinterpret_cast<SceneManager::Property*>(propertyData) );
	std::string nullString;
	textureProperty->SetValue(nullString);

	UiPropertyGrid* currentPropertyGrid( GetParentPanel(textureProperty) );
	currentPropertyGrid->UpdatePropertyList();
	currentPropertyGrid->RefreshPropertyGrid();

}
void TW_CALL UiPropertyGrid::SetCallbackPropertyVector3f( const void* value, void* clientData )
{
	SceneManager::Property* property ( reinterpret_cast<SceneManager::Property*>(clientData) );
	
	glm::vec3 vector3;
	vector3.x = ((float*)value)[0];
	vector3.y = ((float*)value)[1];
	vector3.z = ((float*)value)[2];
	property->SetValue( vector3 );
	GetParentPanel(property)->UpdatePropertyList();
}
void TW_CALL UiPropertyGrid::SetCallbackPropertyQuat( const void* value, void* clientData )
{
	SceneManager::Property* property ( reinterpret_cast<SceneManager::Property*>(clientData) );

	glm::quat quaternion;
	quaternion.x = ((float*)value)[0];
	quaternion.y = ((float*)value)[1];
	quaternion.z = ((float*)value)[2];
	quaternion.w = ((float*)value)[3];
	property->SetValue( quaternion );
	GetParentPanel(property)->UpdatePropertyList();
}
void UiPropertyGrid::CreateTextureCallback( void* propertyData )
{
	SceneManager::Property* textureProperty ( reinterpret_cast<SceneManager::Property*>(propertyData) );

	std::vector<std::string> extensionList;
	extensionList.push_back("*.bmp; *.png");
	std::string filePath( UiUtilities::DisplayOpenFileDialog(extensionList) );
	if ( filePath != "" )
	{
		textureProperty->SetValue(filePath);
		UiPropertyGrid* currentPropertyGrid( GetParentPanel(textureProperty) );
		if ( currentPropertyGrid )
		{
			currentPropertyGrid->UpdatePropertyList();
			currentPropertyGrid->RefreshPropertyGrid();
		}
	}

}
//**************************************************************************
void CBCGPRibbonBackstageViewItemForm::OnAfterChangeRect (CDC* pDC)
{
	SetLayoutReady(FALSE);

	CBCGPBaseRibbonElement::OnAfterChangeRect(pDC);

	if (m_rect.IsRectEmpty ())
	{
		if (m_pWndForm->GetSafeHwnd () != NULL)
		{
			m_pWndForm->ShowWindow (SW_HIDE);
		}
		return;
	}

	BOOL bForceAdjustLocations = FALSE;

	if (m_pWndForm == NULL)
	{
		if ((m_pWndForm = OnCreateFormWnd()) == NULL)
		{
			return;
		}

		SetLayoutReady(FALSE);
		bForceAdjustLocations = TRUE;

		if (m_Watermark.GetImageWell() != NULL)
		{
			BOOL bMirror = FALSE;

			if (GetParentWnd()->GetExStyle () & WS_EX_LAYOUTRTL)
			{
				if (!m_bImageMirror)
				{
					m_bImageMirror = TRUE;
					bMirror = TRUE;
				}
			}
			else if (m_bImageMirror)
			{
				m_bImageMirror = FALSE;
				bMirror = TRUE;
			}

			if (bMirror)
			{
				m_Watermark.Mirror();
				OnChangeVisualManager();
			}
		}
	}

	CRect rectWindow = m_rect;
	CRect rectWatermark(0, 0, 0, 0);

	if (m_sizeWaterMark != CSize(0, 0))
	{
		int xWatermark = max(rectWindow.Width(), m_sizeDlg.cx) - m_sizeWaterMark.cx;
		int yWatermark = max(rectWindow.Height(), m_sizeDlg.cy) - m_sizeWaterMark.cy;

		rectWatermark = CRect(CPoint(xWatermark, yWatermark), m_sizeWaterMark);
	}

	OnSetBackstageWatermarkRect(rectWatermark);

	m_pWndForm->SetWindowPos (NULL, 
		rectWindow.left, rectWindow.top,
		rectWindow.Width (), rectWindow.Height () + 1,
		SWP_NOZORDER | SWP_NOACTIVATE);

	if (!m_pWndForm->IsWindowVisible())
	{
		m_pWndForm->ShowWindow (SW_SHOWNOACTIVATE);
	}

	SetLayoutReady();

	if (bForceAdjustLocations)
	{
		CBCGPRibbonPanel* pParentPanel = GetParentPanel();
		if (pParentPanel != NULL && pParentPanel->GetParentMenuBar()->GetSafeHwnd() != NULL)
		{
			CRect rectPanel;
			pParentPanel->GetParentMenuBar()->GetClientRect(rectPanel);

			pParentPanel->GetParentMenuBar()->PostMessage(WM_SIZE, MAKEWPARAM(rectPanel.Width(), rectPanel.Height()));
		}
	}

	m_pWndForm->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);
}
void TW_CALL UiPropertyGrid::SetCallbackPropertyString( const void* value, void* clientData )
{
	SceneManager::Property* property ( reinterpret_cast<SceneManager::Property*>(clientData) );
	property->SetValue( *(const std::string*)value );
	GetParentPanel(property)->UpdatePropertyList();
}