本文整理汇总了C++中PObject::UsesInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ PObject::UsesInterface方法的具体用法?C++ PObject::UsesInterface怎么用?C++ PObject::UsesInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PObject
的用法示例。
在下文中一共展示了PObject::UsesInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
void
MainWindow::AddControl(const BString &type)
{
if (type.CountChars() < 1)
return;
PObjectBroker *broker = PObjectBroker::GetBrokerInstance();
PObject *pobj = broker->MakeObject(type.String());
if (!pobj || !pobj->UsesInterface("PView"))
return;
PView *pview = dynamic_cast<PView*>(pobj);
if (!pview)
return;
BString name(pview->GetType());
name << pview->GetID();
pview->AddProperty(new StringProperty("Name",name.String(),"The name for this view"),0,0);
if (pview->GetType().Compare("PTextControl") == 0)
{
// Create each text control with some more useful defaults for the GUI
pview->SetStringProperty("Text", "Text");
pview->SetStringProperty("Label", "Label");
PArgs in, out;
pview->RunMethod("SetPreferredDivider", in.ListRef(), out.ListRef());
}
FloatValue pw, ph;
pview->GetProperty("PreferredWidth", &pw);
pview->GetProperty("PreferredHeight", &ph);
if (*pw.value > 0.0)
pview->SetFloatProperty("Width",*pw.value);
else
pview->SetFloatProperty("Width",100);
if (*ph.value > 0.0)
pview->SetFloatProperty("Height",*ph.value);
else
pview->SetFloatProperty("Height",100);
// If we have a PWindow selected in the window, we will add the view as a child of the
// selected window. If there is no selection, we will add the item at the end with no
// parent
ObjectItem *item = new ObjectItem(pview);
int32 selection = fListView->FullListCurrentSelection();
if (selection < 0)
fListView->AddItem(item);
ObjectItem *oitem = dynamic_cast<ObjectItem*>(fListView->FullListItemAt(selection));
if (!oitem)
return;
PWindow *pwin = dynamic_cast<PWindow*>(oitem->GetObject());
if (pwin)
{
PArgs args,out;
if (pview->GetType().Compare("PView") == 0 &&
pwin->RunMethod("CountChildren",args.ListRef(),out.ListRef()) == B_OK)
{
int32 count;
if (out.FindInt32("count",&count) == B_OK && count == 0)
{
float winWidth, winHeight;
pwin->GetFloatProperty("Width",winWidth);
pwin->GetFloatProperty("Height",winHeight);
pview->SetFloatProperty("Width",winWidth);
pview->SetFloatProperty("Height",winHeight);
pview->SetIntProperty("HResizingMode",RESIZE_BOTH);
pview->SetIntProperty("VResizingMode",RESIZE_BOTH);
}
pview->SetColorProperty("BackColor",ui_color(B_PANEL_BACKGROUND_COLOR));
}
args.AddInt64("id",item->GetObject()->GetID());
if (pwin->RunMethod("AddChild", args.ListRef(), out.ListRef()) == B_OK)
fListView->AddUnder(item,oitem);
else
fListView->AddItem(item);
}
else
{
if (oitem->GetObject()->UsesInterface("PView"))
{
PView *parent = dynamic_cast<PView*>(oitem->GetObject());
PArgs args,out;
args.AddInt64("id",item->GetObject()->GetID());
if(parent->RunMethod("AddChild", args.ListRef(), out.ListRef()) == B_OK)
fListView->AddUnder(item,oitem);
else
fListView->AddItem(item);
}
else
{
// Not a view or window, so just add it on at the end
//.........这里部分代码省略.........