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


C++ Property::IsEditable方法代码示例

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


在下文中一共展示了Property::IsEditable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: selection

// SetTo
void
PropertyListView::SetTo(PropertyObject* object)
{
	// try to do without rebuilding the list
	// it should in fact be pretty unlikely that this does not
	// work, but we keep being defensive
	if (fPropertyObject && object &&
		fPropertyObject->ContainsSameProperties(*object)) {
		// iterate over view items and update their value views
		bool error = false;
		for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) {
			Property* property = object->PropertyAt(i);
			if (!item->AdoptProperty(property)) {
				// the reason for this can be that the property is
				// unkown to the PropertyEditorFactory and therefor
				// there is no editor view at this item
				fprintf(stderr, "PropertyListView::_SetTo() - "
								"property mismatch at %ld\n", i);
				error = true;
				break;
			}
			if (property)
				item->SetEnabled(property->IsEditable());
		}
		// we didn't need to make empty, but transfer ownership
		// of the object
		if (!error) {
			// if the "adopt" process went only halfway,
			// some properties of the original object
			// are still referenced, so we can only
			// delete the original object if the process
			// was successful and leak Properties otherwise,
			// but this case is only theoretical anyways...
			delete fPropertyObject;
		}
		fPropertyObject = object;
	} else {
		// remember scroll pos, selection and focused item
		BPoint scrollOffset = ScrollOffset();
		BList selection(20);
		int32 focused = -1;
		for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) {
			if (item->IsSelected())
				selection.AddItem((void*)i);
			if (item->IsFocused())
				focused = i;
		}
		if (Window())
			Window()->BeginViewTransaction();
		fSuspendUpdates = true;

		// rebuild list
		_MakeEmpty();
		fPropertyObject = object;

		if (fPropertyObject) {
			// fill with content
			for (int32 i = 0; Property* property = fPropertyObject->PropertyAt(i); i++) {
				PropertyItemView* item = new PropertyItemView(property);
				item->SetEnabled(property->IsEditable());
				_AddItem(item);
			}
			_LayoutItems();

			// restore scroll pos, selection and focus
			SetScrollOffset(scrollOffset);
			for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) {
				if (selection.HasItem((void*)i))
					item->SetSelected(true);
				if (i == focused)
					item->MakeFocus(true);
			}
		}

		if (Window())
			Window()->EndViewTransaction();
		fSuspendUpdates = false;

		SetDataRect(_ItemsRect());
	}

	_UpdateSavedProperties();
	_CheckMenuStatus();
	Invalidate();
}
开发者ID:mariuz,项目名称:haiku,代码行数:86,代码来源:PropertyListView.cpp


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