Esempio n. 1
0
void CPropertiesWnd::OnPropAdditem()
{
	if (!IsComboType())
	{
		return;
	}

	CMFCPropertyGridProperty *pProp = m_wndPropList.FindItemByData(PROP_DATA_ITEMS);
	if (pProp)
	{
		CMFCPropertyGridProperty* pPropItem = new CMFCPropertyGridProperty(_T("ITEM"), 0, TRUE);
		pProp->AddSubItem(pPropItem);
		pProp->Expand(TRUE);

		CMFCPropertyGridProperty* pPropChild = new CMFCPropertyGridProperty(_T("VALUE"), (COleVariant)_T(""));
		pPropItem->AddSubItem(pPropChild);

		pPropChild = new CMFCPropertyGridProperty(_T("SHORT"), (COleVariant)_T(""));
		pPropItem->AddSubItem(pPropChild);

		pPropChild = new CMFCPropertyGridProperty(_T("PREVIEW"), (COleVariant)_T(""));
		pPropItem->AddSubItem(pPropChild);
		pPropItem->Expand(TRUE);
	}
}
Esempio n. 2
0
void CFileView::OnGroupAddprop()
{
	HTREEITEM hGroupItem = GetSelectItemGroup();
	ASSERT(hGroupItem != NULL);

	CMFCPropertyGridProperty* pPropGroup = new CMFCPropertyGridProperty(_T("PROPERTY"));
	CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("NAME"), (COleVariant)_T("New"));
	pPropGroup->AddSubItem(pProp);

	pProp = new CMFCPropertyGridProperty(_T("TYPE"), (COleVariant)_T("Combo"), _T(""), PROP_DATA_TYPE);
	pProp->AddOption(_T("Combo"));
	pProp->AddOption(_T("Number"));
	pProp->AddOption(_T("Text"));
	pProp->AllowEdit(FALSE);
	pPropGroup->AddSubItem(pProp);

	pProp = new CMFCPropertyGridProperty(_T("VALUE"), (COleVariant)_T("No"));
	pPropGroup->AddSubItem(pProp);

	pProp = new CMFCPropertyGridProperty(_T("ITEMS"), PROP_DATA_ITEMS, TRUE);
	pPropGroup->AddSubItem(pProp);

	CString strValues[2] = { _T("Yes"), _T("No") };
	for (int i = 0; i < 2; i++)
	{
		CMFCPropertyGridProperty* pPropItem = new CMFCPropertyGridProperty(_T("ITEM"), 0, TRUE);
		pProp->AddSubItem(pPropItem);
		pProp->Expand(TRUE);

		CMFCPropertyGridProperty* pPropChild = new CMFCPropertyGridProperty(_T("VALUE"), (COleVariant)strValues[i]);
		pPropItem->AddSubItem(pPropChild);

		pPropChild = new CMFCPropertyGridProperty(_T("SHORT"), (COleVariant)_T(""));
		pPropItem->AddSubItem(pPropChild);

		pPropChild = new CMFCPropertyGridProperty(_T("PREVIEW"), (COleVariant)_T(""));
		pPropItem->AddSubItem(pPropChild);
		pPropItem->Expand(TRUE);
	}

	HTREEITEM hItem = m_wndFileView.InsertItem(_T("New"), 2, 2, hGroupItem);
	m_wndFileView.SetItemData(hItem, (DWORD_PTR)pPropGroup);

	if (hGroupItem)
	{
		m_wndFileView.Expand(hGroupItem, TVE_EXPAND);
		m_wndFileView.SelectItem(hItem);
	}
}
Esempio n. 3
0
void CReflectiveUI::BuildUIForObject(CMFCPropertyGridProperty* root, RTTIObject* pObject, const char* szName )
{
	CMFCPropertyGridProperty* pRoot = new CMFCPropertyGridProperty(szName);
	if (root)
	{
		root->AddSubItem( pRoot );
	}
	else
	{
		m_pGrid->AddProperty(pRoot);
	}

	std::vector<BaseProperty*> Properties;
	pObject->GetRTTI()->EnumProperties( Properties );

	for ( size_t i = 0; i < Properties.size(); i++ )
	{
		switch ( Properties[i]->GetTypeID() )
		{
		case eptBool:
			{
				AddPropertyToGrid<bool>(pRoot, pObject, Properties[i]);
				break;
			}
		case eptByte:
			{
				AddPropertyToGrid<char>(pRoot, pObject, Properties[i]);
				break;
			}
		case eptInt:
			{
				AddPropertyToGrid<int>(pRoot, pObject, Properties[i]);
				break;
			}
		case eptShort:
			{
				AddPropertyToGrid<short>(pRoot, pObject, Properties[i]);
				break;
			}
		case eptLong :
			{
				AddPropertyToGrid<long>(pRoot, pObject, Properties[i]);
				break;
			}
		case eptPtr:
			{
				TypedProperty<RTTIObject*>* pTypedProperty = (TypedProperty<RTTIObject*>*)Properties[i];
				BuildUIForObject(pRoot
					, pTypedProperty->GetValue( pObject )
					, pTypedProperty->GetName().c_str()
					);
				break;
			}
		case eptOgreReal:
			{
				AddPropertyToGrid<Ogre::Real>(pRoot, pObject, Properties[i]);
				break;
			}
		case eptOgreString:
			{
				AddPropertyToGrid_AsString<Ogre::String>(pRoot, pObject, Properties[i]);
				break;
			}
		case eptOgreVector2:
			{
				AddPropertyToGrid_AsString<Ogre::Vector2>(pRoot, pObject, Properties[i]);
			}
			break;
		case eptOgreVector3:
			{
				AddPropertyToGrid_AsString<Ogre::Vector3>(pRoot, pObject, Properties[i]);
			}
			break;
		case eptOgreVector4:
			{
				AddPropertyToGrid_AsString<Ogre::Vector4>(pRoot, pObject, Properties[i]);
			}
			break;
		case eptOgreColorValue:
			{
				TypedProperty<Ogre::ColourValue>* pTypedProperty = (TypedProperty<Ogre::ColourValue>*)Properties[i];
				Ogre::ColourValue val = pTypedProperty->GetValue(pObject);

				CMFCPropertyGridProperty* pGrid = new CMFCPropertyGridColorProperty(
					pTypedProperty->GetName().c_str()
					, val.getAsRGBA()
					, 0
					, pTypedProperty->GetDescription().c_str()
					);

				pRoot->AddSubItem( pGrid );

				CReflectiveUI::SPropertyObject PO(Properties[i], pObject);
				_GridPropertyMap[pGrid] = PO;
			}
			break;
		case eptOgreQuaternion:
			{
				AddPropertyToGrid_AsString<Ogre::Quaternion>(pRoot, pObject, Properties[i]);
			}
			break;
		case eptOgreMatrix3:
			{
				AddPropertyToGrid_AsString<Ogre::Matrix3>(pRoot, pObject, Properties[i]);
			}
			break;
		case eptOgreMatrix4:
			{
				AddPropertyToGrid_AsString<Ogre::Matrix4>(pRoot, pObject, Properties[i]);
			}
			break;
		};
	}

	pRoot->Expand();
}