当前位置: 首页>>代码示例>>C++>>正文


C++ PView::SetColorProperty方法代码示例

本文整理汇总了C++中PView::SetColorProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ PView::SetColorProperty方法的具体用法?C++ PView::SetColorProperty怎么用?C++ PView::SetColorProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PView的用法示例。


在下文中一共展示了PView::SetColorProperty方法的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
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:101,代码来源:MainWindow.cpp


注:本文中的PView::SetColorProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。