Example #1
0
int32_t
PListViewSelect(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	int32 index;
	if (inArgs->FindInt32("index", &index) != B_OK)
		return B_ERROR;

	bool extend;
	if (inArgs->FindBool("extend", &extend) != B_OK)
		return B_ERROR;

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


	backend->Select(index, extend);

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

	return B_OK;
}
Example #2
0
int32_t
PListViewScrollToPoint(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	BPoint pt;
	if (inArgs->FindPoint("pt", &pt) != B_OK)
		return B_ERROR;

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


	backend->ScrollTo(pt);

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

	return B_OK;
}
Example #3
0
int32_t
PListViewRemoveItem(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	int32 index;
	if (args->FindInt32("index", &index) != B_OK)
		return B_ERROR;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	bool outValue = backend->RemoveItems(index, 1);
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	outArgs->MakeEmpty();
	outArgs->AddBool("value", outValue);
	
	return B_OK;
}
Example #4
0
int32_t
PListViewScrollTo(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	float x;
	if (inArgs->FindFloat("x", &x) != B_OK)
		return B_ERROR;

	float y;
	if (inArgs->FindFloat("y", &y) != B_OK)
		return B_ERROR;

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


	backend->ScrollTo(x, y);

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

	return B_OK;
}
Example #5
0
int32_t
PListViewItemFrame(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 index;
	if (inArgs->FindInt32("index", &index) != B_OK)
		return B_ERROR;

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

	BRect outValue1;

	outValue1 = backend->ItemFrame(index);

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

	outArgs->MakeEmpty();

	return B_OK;
}
Example #6
0
int32_t
PListViewDeselectExcept(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	int32 from;
	if (inArgs->FindInt32("from", &from) != B_OK)
		return B_ERROR;

	int32 to;
	if (inArgs->FindInt32("to", &to) != B_OK)
		return B_ERROR;

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


	backend->DeselectExcept(from, to);

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

	return B_OK;
}
Example #7
0
int32_t
PListViewInvoke(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in);
	int32 what;
	if (args->FindInt32("message", &what) != B_OK)
		what = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	if (what >= 0)
	{
		BMessage invMsg(what);
		backend->Invoke(&invMsg);
	}
	else	
		backend->Invoke();
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
Example #8
0
int32_t
PListViewAddItems(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	
	int32 index;
	if (args->FindInt32("index", &index) != B_OK)
		index = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	BList list;
	BString itemName;
	int32 nameIndex = 0;
	while (args->FindString("items", &itemName, nameIndex) == B_OK)
	{
		list.AddItem(new BString(itemName));
		nameIndex++;
	}
	
	bool outValue = true;
	if (list.CountItems() > 0)
	{
		if (index >= 0)
			outValue = backend->AddList(&list, index);
		else
			outValue = backend->AddList(&list);
	}
		
	if (backend->Window())
		backend->Window()->Unlock();
	
	for (int32 i = 0; i < list.CountItems(); i++)
		delete ((BString*)list.ItemAt(i));
	list.MakeEmpty();
	
	outArgs->MakeEmpty();
	outArgs->AddBool("value", outValue);
	
	return B_OK;
}
Example #9
0
status_t
PListView::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;
	
	BListView *backend = (BListView*)fView;
	
	BoolValue boolval;
	CharValue charval;
	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();

	else if (str.ICompare("SelectionMessage") == 0)
	{
		BMessage selMsg(*intval.value);
		backend->SetSelectionMessage(&selMsg);
	}
	else if (str.ICompare("InvocationMessage") == 0)
	{
		BMessage invMsg(*intval.value);
		backend->SetInvocationMessage(&invMsg);
	}
	else if (str.ICompare("SelectionType") == 0)
	{
		prop->GetValue(&intval);
		backend->SetListType((list_view_type)*intval.value);
	}
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

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

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

	return prop->GetValue(value);
}
Example #10
0
int32_t
PListViewScrollToSelection(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	if (backend->Window())
		backend->Window()->Lock();


	backend->ScrollToSelection();

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

	return B_OK;
}
Example #11
0
int32_t
PListViewMoveItem(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 from;
	if (inArgs->FindInt32("from", &from) != B_OK)
		return B_ERROR;

	int32 to;
	if (inArgs->FindInt32("to", &to) != B_OK)
		return B_ERROR;

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

	bool outValue1;

	outValue1 = backend->MoveItem(from, to);

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

	outArgs->MakeEmpty();

	return B_OK;
}
Example #12
0
int32_t
PListViewAddItem(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	BString label;
	if (args->FindString("label", &label) != B_OK)
		label = "";
	
	int32 index;
	if (args->FindInt32("index", &index) != B_OK)
		index = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	bool outValue;
	BStringItem *item = new BStringItem(label.String());
	if (index >= 0)
		outValue = backend->AddItem(item);
	else
		outValue = backend->AddItem(item, index);
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	outArgs->MakeEmpty();
	outArgs->AddBool("value", outValue);
	
	return B_OK;
}
Example #13
0
int32_t
PListViewSwapItems(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 first;
	if (inArgs->FindInt32("first", &first) != B_OK)
		return B_ERROR;

	int32 second;
	if (inArgs->FindInt32("second", &second) != B_OK)
		return B_ERROR;

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

	bool outValue1;

	outValue1 = backend->SwapItems(first, second);

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

	outArgs->MakeEmpty();

	return B_OK;
}
Example #14
0
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);
}