Ejemplo n.º 1
0
static BLayoutItem*
layout_item_for(BView* view)
{
	BLayout* layout = view->Parent()->GetLayout();
	int32 index = layout->IndexOfView(view);
	return layout->ItemAt(index);
}
Ejemplo n.º 2
0
/*static*/ void
BLayoutUtils::_GetLayoutTreeDump(BLayoutItem* item, int level,
	bool isViewLayout, BString& _output)
{
	if (BViewLayoutItem* viewItem = dynamic_cast<BViewLayoutItem*>(item)) {
		_GetLayoutTreeDump(viewItem->View(), level, _output);
		return;
	}

	BString indent;
	indent.SetTo(' ', level * 2);

	if (item == NULL) {
		_output << indent << "<null item>\n";
		return;
	}

	BLayout* layout = dynamic_cast<BLayout*>(item);
	BRect frame = item->Frame();
	BSize min = item->MinSize();
	BSize max = item->MinSize();
	BSize preferred = item->PreferredSize();
	if (isViewLayout) {
		_output << indent << BString().SetToFormat("  [layout %p (%s)]\n",
			layout, typeid(*layout).name());
	} else {
		_output << indent << BString().SetToFormat("item %p (%s):\n",
			item, typeid(*item).name());
	}
	_output << BString().SetToFormat(
		"%s  frame: (%f, %f, %f, %f)\n"
		"%s  min:   (%f, %f)\n"
		"%s  max:   (%f, %f)\n"
		"%s  pref:  (%f, %f)\n",
		indent.String(), frame.left, frame.top, frame.right, frame.bottom,
		indent.String(), min.width, min.height,
		indent.String(), max.width, max.height,
		indent.String(), preferred.width, preferred.height);

	if (layout == NULL)
		return;

	int32 count = layout->CountItems();
	for (int32 i = 0; i < count; i++) {
		_output << indent << "  ---\n";
		_GetLayoutTreeDump(layout->ItemAt(i), level + 1, false, _output);
	}
}