Esempio n. 1
0
const char* IPropertySet::GetSTRING(const void* pData, int nIndex)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return NULL;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_STRING);
	if(pInfo->GetType()!=PROPERTY_TYPE_STRING) return NULL;
	return (const char*)pData + pInfo->GetOffset();
}
Esempio n. 2
0
unsigned int IPropertySet::GetDWORD(const void* pData, int nIndex)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return -1;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_DWORD);
	if(pInfo->GetType()!=PROPERTY_TYPE_DWORD) return -1;
	return *((unsigned int*)((char*)pData + pInfo->GetOffset()));
}
Esempio n. 3
0
float IPropertySet::GetFLOAT(const void* pData, int nIndex)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return -1;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT);
	if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return -1;
	return *((float*)((char*)pData + pInfo->GetOffset()));
}
Esempio n. 4
0
bool IPropertySet::SetValue(void* pData, int nIndex, char Value)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return false;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_CHAR);
	if(pInfo->GetType()!=PROPERTY_TYPE_CHAR) return false;
	*((char*)((char*)pData + pInfo->GetOffset())) = Value;
	return true;
}
Esempio n. 5
0
bool IPropertySet::SetValue(void* pData, int nIndex, const char* Value)
{
	assert(nIndex>=0 && nIndex<PropertyCount());
	if(nIndex<0 || nIndex>=PropertyCount()) return false;
	IProperty* pInfo = GetProperty(nIndex);
	assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT);
	if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return false;
	unsigned int len = strlen(Value);
	assert(len<=pInfo->GetSize());
	if(len>pInfo->GetSize()) return false;
	memcpy((char*)pData+pInfo->GetOffset(), Value, len+1);
	return true;
}
Esempio n. 6
0
int IPropertySet::GetPropertyIndex(const char* pName)
{
	for(int i=0; i<PropertyCount(); i++) {
		if(strcmp(pName, GetProperty(i)->GetName())==0) return i;
	}
	return -1;
}
Esempio n. 7
0
String TPropertyHandler::GetAllNamesValues(TComponent* comp)
{
	String list;
	TStringList *tempList = new TStringList;
	try
	{
		tempList->Sorted = true;

		PTypeInfo TypeInfo = (PTypeInfo)comp->ClassInfo();
		PPropInfo* PropList = new TPropList;
		GetPropInfos(TypeInfo, (PPropList)PropList);

		String data;
		for (int i=0; i < PropertyCount(comp); i++)
		{
			String prName = String(PropList[i]->Name);
			if (PropIsType(comp, prName, tkMethod)) continue; // Skip events.
			if (IsClass(comp, prName))
			{	data = GetClassNamesValues(comp, prName); }
			else data = BuildNameValue(comp, prName);
			if (!data.IsEmpty()) tempList->Append( data );
		}

		delete[] PropList;
		list = tempList->Text;
	}
	__finally
	{
		delete tempList;
	}
	return list;
}
Esempio n. 8
0
String TPropertyHandler::GetClassNamesValues(TComponent* comp, String prName)
{
	TObject *subObj = (TObject *)GetOrdProp(comp, prName);
	if (subObj == NULL) return ""; // In case the prop-value is empty (like Action).

/*  TObject* subObj is needed to find out if the subprop points to
	another Component (like ActiveControl).
	If it is only the value of that property is returned (ie.: "CheckBox1").
	If it is a class like Font all of the props+values of
	comp->Font are returned. */

	if (dynamic_cast<TComponent*>(subObj))
	{   // Find out if subObj points to another Component by casting.
		return prName + "=" + GetValue((TComponent*)subObj,"Name");
	}

/*  subObj does not point to another Component, but we can convert
	it to a TComponent* subComp so it can be used te get the subProps+values.
	This sounds weird but don't forget that a TFont encapsulated in a TForm
	becomes a descendant of TForm, which is a descendant of TComponent!! */

	TComponent* subComp = (TComponent*)subObj;

	TStringList *tempList = new TStringList;
	String temp;
	try
	{
		PTypeInfo TypeInfo = (PTypeInfo)subComp->ClassInfo();
		PPropInfo* PropList = new TPropList;
		GetPropInfos(TypeInfo, (PPropList)PropList);

		tempList->Sorted = true;
		for (int i=0; i < PropertyCount(subComp); i++)
		{
			String subProp = String(PropList[i]->Name);
			tempList->Add(
				prName + "." + subProp
				+ "=" + GetPropValue(subComp, subProp, true) );
		}

		delete[] PropList;

		temp = tempList->Text;
		// Remove trailing carriage-returns:
		int cr = temp.LastDelimiter("\r");
		if (cr) temp.Delete(cr, 2);
	}
	__finally
	{
		delete tempList;
	}

	return temp;
}
Esempio n. 9
0
/*virtual*/ void CPropertyBase::GetPropertyValue(long Index, DWORD Phase, double T, double P, MPropertyValue & Value)
  {
  if (Index<0 || Index>=PropertyCount())
    {
    CString S;
    S.Format("%s Index %i not Valid", DefinedPropertyMapName(), Index);
    throw MMdlException(0, (LPCTSTR)S);
    }
  CString S;
  S.Format("%s Index %i Unknown Error", DefinedPropertyMapName(), Index);
  throw MMdlException(0, S);
  };
Esempio n. 10
0
/*virtual*/ void CPropertyBase::PutPropertyValue(long Index, MPropertyValue & Value)
  {
  if (Index<0 || Index>=PropertyCount())
    {
    CString S;
    S.Format("%s Index %i not Valid", DefinedPropertyMapName(), Index);
    throw MMdlException(0, (LPCTSTR)S);
    }
  if (!PropertyMap()[Index]->Settable())
    {
    CString S;
    S.Format("%s Index %i not Settable", DefinedPropertyMapName(), Index);
    throw MMdlException(0, S);
    }
  CString S;
  S.Format("%s Index %i Unknown Error", DefinedPropertyMapName(), Index);
  throw MMdlException(0, S);
  };
Esempio n. 11
0
int TPropertyHandler::PropertyCount()
{
	if (!DefaultComponentExists()) return -1;
	return PropertyCount(FDefaultComponent);
}