Example #1
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 #2
0
int32_t
PTextViewCut(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;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in);
	
	uint64 id = 0;
	if (inArgs->FindInt64("clipid", (int64*)&id) != B_OK)
		return B_ERROR;
	
	PObject *obj = BROKER->FindObject(id);
	if (!obj || obj->GetType().ICompare("PClipboard") != 0)
		return B_BAD_DATA;
	
	PClipboard *clip = dynamic_cast<PClipboard*>(obj);
	
	if (backend->Window())
		backend->Window()->Lock();
	
	backend->Cut(clip->GetBackend());
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
Example #3
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 #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
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 #6
0
int32_t
PTextViewInsert(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;
	
	BTextView *backend = (BTextView*)parent->GetView();


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

	BString text;
	if (inArgs->FindString("text", &text) != B_OK)
		return B_ERROR;

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

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


	backend->Insert(text.String(), length);

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

	return B_OK;
}
Example #7
0
int32_t
PTextViewLineAtOffset(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;
	
	BTextView *backend = (BTextView*)parent->GetView();


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

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

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

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

	int32 outValue1;

	outValue1 = backend->LineAt(offset);

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

	outArgs->MakeEmpty();

	return B_OK;
}
Example #8
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 #9
0
int32_t
PTextViewHighlight(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;
	
	BTextView *backend = (BTextView*)parent->GetView();


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

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

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

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


	backend->Highlight(start, end);

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

	return B_OK;
}
Example #10
0
int32_t
PTextViewGetSelection(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;
	
	BTextView *backend = (BTextView*)parent->GetView();


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

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

	int32 outValue1;
	int32 outValue2;

	backend->GetSelection(&outValue1, &outValue2);

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

	outArgs->MakeEmpty();
	outArgs->AddInt32("start", outValue1);
	outArgs->AddInt32("end", outValue2);

	return B_OK;
}
Example #11
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 #12
0
int32_t
PTextViewDisallowChars(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;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in);
	BString string;
	if (inArgs->FindString("chars", &string) != B_OK)
		return B_ERROR;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	for (int32 i = 0; i < string.CountChars(); i++)
	{
		char c = string.ByteAt(i);
		if (c)
			backend->DisallowChar(c);
	}
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
Example #13
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 #14
0
int32_t
PMenuItemSubmenu(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;
	
	BMenuItem *backend = (BMenuItem*)parent->GetView();
	
	PArgs *outArgs = static_cast<PArgs*>(out);
	outArgs->MakeEmpty();
	
	BMenu *menu = backend->Menu();
	
	PMenuBackend *menuBackend = static_cast<PMenuBackend*>(menu);
	if (menuBackend)
	{
		PMenu *pmenu = static_cast<PMenu*>(menuBackend->GetOwner());
		outArgs->AddInt64("id", pmenu->GetID());
	}
	else
		outArgs->AddInt64("id", 0);
	
	return B_OK;
}
Example #15
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 #16
0
int32_t
PTextViewSetInsets(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;
	
	BTextView *backend = (BTextView*)parent->GetView();


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

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

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

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

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

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


	backend->SetInsets(left, top, right, bottom);

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

	return B_OK;
}
Example #17
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 #18
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 #19
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 #20
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 #21
0
int32_t
PTextViewGetInsets(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;
	
	BTextView *backend = (BTextView*)parent->GetView();


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

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

	float outValue1;
	float outValue2;
	float outValue3;
	float outValue4;

	backend->GetInsets(&outValue1, &outValue2, &outValue3, &outValue4);

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

	outArgs->MakeEmpty();
	outArgs->AddFloat("left", outValue1);
	outArgs->AddFloat("top", outValue2);
	outArgs->AddFloat("right", outValue3);
	outArgs->AddFloat("bottom", outValue4);

	return B_OK;
}
Example #22
0
int32_t
PTextViewGetText(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;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	outArgs->MakeEmpty();
	
	if (backend->Window())
		backend->Window()->Lock();
	
	int32 start, length;
	if (inArgs->FindInt32("start", &start) != B_OK ||
		inArgs->FindInt32("length", &length) != B_OK)
		return B_ERROR;
	
	char *buffer = new char[length + 1];
	
	backend->GetText(start, length, buffer);
	
	outArgs->AddString("text", buffer);
	
	delete [] buffer;
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}