コード例 #1
0
ファイル: PListView.cpp プロジェクト: HaikuArchives/PDesigner
status_t
PListView::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BListView *backend = (BListView*)fView;

	if (backend->Window())
		backend->Window()->Lock();

	if (str.ICompare("PreferredWidth") == 0)
	{
		if (backend->CountItems() == 0)
			((FloatProperty*)prop)->SetValue(100);
		else
		{
			float pw, ph;
			backend->GetPreferredSize(&pw, &ph);
			if (pw < 10)
				pw = 100;
			if (ph < 10)
				ph = 30;
			((FloatProperty*)prop)->SetValue(pw);
		}
	}
	else if (str.ICompare("ItemCount") == 0)
		((IntProperty*)prop)->SetValue(backend->CountItems());
	else if (str.ICompare("SelectionMessage") == 0)
		((IntProperty*)prop)->SetValue(backend->SelectionCommand());
	else if (str.ICompare("PreferredHeight") == 0)
	{
		if (backend->CountItems() == 0)
			((FloatProperty*)prop)->SetValue(30);
		else
		{
			float pw, ph;
			backend->GetPreferredSize(&pw, &ph);
			if (pw < 10)
				pw = 100;
			if (ph < 10)
				ph = 30;
			((FloatProperty*)prop)->SetValue(ph);
		}
	}
	else if (str.ICompare("InvocationMessage") == 0)
		((IntProperty*)prop)->SetValue(backend->InvocationCommand());
	else if (str.ICompare("SelectionType") == 0)
		((EnumProperty*)prop)->SetValue(backend->ListType());
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

		return PView::GetProperty(name, value, index);
	}

	if (backend->Window())
		backend->Window()->Unlock();

	return prop->GetValue(value);
}