KeyRequestWindow::KeyRequestWindow() : BWindow(BRect(50, 50, 100, 100), B_TRANSLATE("Unlock keyring"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), fRequestView(NULL), fDoneSem(-1), fResult(B_ERROR) { fDoneSem = create_sem(0, "keyring unlock dialog"); if (fDoneSem < 0) return; BLayout* layout = new(std::nothrow) BGroupLayout(B_HORIZONTAL); if (layout == NULL) return; SetLayout(layout); fRequestView = new(std::nothrow) KeyRequestView(); if (fRequestView == NULL) return; layout->AddView(fRequestView); }
static BLayoutItem* layout_item_for(BView* view) { BLayout* layout = view->Parent()->GetLayout(); int32 index = layout->IndexOfView(view); return layout->ItemAt(index); }
//cast operator BView* StringView::operator BView*() { if (fView) return fView; fView = new BGroupView(B_HORIZONTAL); BLayout* layout = fView->GroupLayout(); fLabelItem = layout->AddView(fLabel); fTextItem = layout->AddView(fText); return fView; }
/*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); } }