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


C++ Style::GetSetters方法代码示例

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


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

示例1:

DeepStyleWalker::DeepStyleWalker (Style **styles, Types *types)
{
	// Create a list of all Setters in the style sorted by their DP.
	// Use the hashtable to ensure that we only take the first setter
	// declared for each DP (i.e. if the BasedOn style and main style
	// have setters for the same DP, we ignore the BasedOn one
	
	// NOTE: This can be pre-computed and cached as once a style is
	// sealed it can never be changed.

	this->offset = 0;
	this->types = types || !styles[0] ? types : styles[0]->GetDeployment ()->GetTypes ();
	this->setter_list = g_ptr_array_new ();

	if (!styles)
		return;

	GHashTable *styles_seen = g_hash_table_new (g_direct_hash, g_direct_equal);
	GHashTable *dps = g_hash_table_new (g_direct_hash, g_direct_equal);

	for (int i = 0; styles[i]; i ++) {
		Style *style = styles[i];
		while (style != NULL) {
			if (g_hash_table_lookup (styles_seen, style))
				continue;

			SetterBaseCollection *setters = style->GetSetters ();
			int count = setters ? setters->GetCount () : 0;
			for (int i = count-1; i >= 0; i--) {
				Value *v = setters->GetValueAt (i);
				if (Value::IsNull (v) || !types->IsSubclassOf (v->GetKind (), Type::SETTER))
					continue;

				Setter *setter = v->AsSetter ();
				Value* dpVal = setter->GetValue (Setter::PropertyProperty);
				if (Value::IsNull (dpVal))
					continue;

				DependencyProperty *prop = dpVal->AsDependencyProperty ();
				if (!g_hash_table_lookup_extended (dps, prop, NULL, NULL)) {
					g_hash_table_insert (dps, prop, setter);
					g_ptr_array_add (setter_list, setter);
				}
			}

			g_hash_table_insert (styles_seen, style, style);
			style = style->GetBasedOn ();
		}
	}
	
	g_hash_table_destroy (dps);
	g_hash_table_destroy (styles_seen);
	g_ptr_array_sort (setter_list, SetterComparer);
}
开发者ID:snorp,项目名称:moon,代码行数:54,代码来源:style.cpp


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