Example #1
0
status_t
PProgressBar::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;
	
	BStatusBar *backend = (BStatusBar*)fView;

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

	if (str.ICompare("BarColor") == 0)
		((ColorProperty*)prop)->SetValue(backend->BarColor());
	else if (str.ICompare("BarHeight") == 0)
		((FloatProperty*)prop)->SetValue(backend->BarHeight());
	else if (str.ICompare("Label") == 0)
		((StringProperty*)prop)->SetValue(backend->Label());
	else if (str.ICompare("CurrentValue") == 0)
	{
		((FloatProperty*)prop)->SetValue(backend->CurrentValue());
	}
	else if (str.ICompare("MaxValue") == 0)
		((FloatProperty*)prop)->SetValue(backend->MaxValue());
	else if (str.ICompare("Text") == 0)
		((StringProperty*)prop)->SetValue(backend->Text());
	else if (str.ICompare("TrailingLabel") == 0)
		((StringProperty*)prop)->SetValue(backend->TrailingLabel());
	else if (str.ICompare("TrailingText") == 0)
		((StringProperty*)prop)->SetValue(backend->TrailingText());
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

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

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

	return prop->GetValue(value);
}
Example #2
0
status_t
PProgressBar::SetProperty(const char *name, PValue *value, const int32 &index)
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	if (FlagsForProperty(prop) & PROPERTY_READ_ONLY)
		return B_READ_ONLY;
	
	BStatusBar *backend = (BStatusBar*)fView;
	
	BoolValue boolval;
	ColorValue colorval;
	FloatValue floatval;
	IntValue intval;
	PointValue pointval;
	RectValue rectval;
	StringValue stringval;
	
	status_t status = prop->SetValue(value);
	if (status != B_OK)
		return status;

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

	if (str.ICompare("BarColor") == 0)
	{
		prop->GetValue(&colorval);
		backend->SetBarColor(*colorval.value);
	}
	else if (str.ICompare("BarHeight") == 0)
	{
		prop->GetValue(&floatval);
		backend->SetBarHeight(*floatval.value);
	}
	else if (str.ICompare("CurrentValue") == 0)
	{
		prop->GetValue(&floatval);
		float current = backend->CurrentValue();
		backend->Update((*floatval.value) - current);
	}
	else if (str.ICompare("MaxValue") == 0)
	{
		prop->GetValue(&floatval);
		backend->SetMaxValue(*floatval.value);
	}
	else if (str.ICompare("Text") == 0)
	{
		prop->GetValue(&stringval);
		backend->SetText(*stringval.value);
	}
	else if (str.ICompare("TrailingText") == 0)
	{
		prop->GetValue(&stringval);
		backend->SetTrailingText(*stringval.value);
	}
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

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

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

	return prop->GetValue(value);
}