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


C++ CL_DomElement::has_attribute方法代码示例

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


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

示例1: on_set_options

void CL_FileDialog_Generic::on_set_options(const CL_DomElement &options)
{
	if (options.has_attribute("file"))
		set_file(options.get_attribute("file"), false);

	if (options.has_attribute("filter"))
		set_filter(options.get_attribute("filter"), false);

	if (options.has_attribute("show_hidden"))
		show_hidden = CL_String::to_bool(options.get_attribute("show_hidden"));

	read_dir();
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:13,代码来源:filedialog_generic.cpp

示例2: on_set_options

void CL_Component_Generic::on_set_options(const CL_DomElement &options)
{
	int x = 0, y = 0, width = 0, height = 0;

	if (options.has_attribute("x")) x = CL_String::to_int(options.get_attribute("x"));
	if (options.has_attribute("y")) y = CL_String::to_int(options.get_attribute("y"));
	if (options.has_attribute("width"))  width = CL_String::to_int(options.get_attribute("width"));
	if (options.has_attribute("height")) height = CL_String::to_int(options.get_attribute("height"));

	owner->set_position(CL_Rect(x, y, x + width, y + height));

	if (options.has_attribute("visible")) owner->show(CL_String::to_bool(options.get_attribute("visible")));
	if (options.has_attribute("enabled")) owner->enable(CL_String::to_bool(options.get_attribute("enabled")));
	if (options.has_attribute("tab_id")) owner->set_tab_id(CL_String::to_int(options.get_attribute("tab_id")));

	owner->update();
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:17,代码来源:component_generic.cpp

示例3: on_set_options

void CL_Button_Silver::on_set_options(const CL_DomElement &options)
{
	if (options.has_attribute("surface_up"))
		set_surface_up(new CL_Surface(options.get_attribute("surface_up"), resources), true);
	if (options.has_attribute("surface_down"))
		set_surface_down(new CL_Surface(options.get_attribute("surface_down"), resources), true);
	if (options.has_attribute("surface_disabled"))
		set_surface_disabled(new CL_Surface(options.get_attribute("surface_disabled"), resources), true);
	if (options.has_attribute("surface_highlighted"))
		set_surface_highlighted(new CL_Surface(options.get_attribute("surface_highlighted"), resources), true);
	if (options.has_attribute("font"))
		set_font(new CL_Font(options.get_attribute("font"), resources), true);
	if (options.has_attribute("font_disabled"))
		set_font_disabled(new CL_Font(options.get_attribute("font_disabled"), resources), true);
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:15,代码来源:button_silver.cpp

示例4: load_polylist

void CL_Collada_Triangles_Impl::load_polylist(CL_DomElement &polylist_element, bool contains_vcount, std::vector<CL_Collada_Source> &sources, CL_Collada_Vertices &vertices, std::vector<CL_Collada_Material> &library_materials)
{
	name = polylist_element.get_attribute("name");

	// Find material	
	if (polylist_element.has_attribute("material"))
	{
		CL_String material_name = polylist_element.get_attribute("material");

			std::vector<CL_Collada_Material>::size_type size, cnt;
			size = library_materials.size();
			for (cnt=0; cnt< size; cnt++)
			{
				if (library_materials[cnt].get_id() == material_name)
				{
					material = library_materials[cnt];
					break;
				}
			}
	
		if (material.is_null())
			throw CL_Exception("Unable to find material");

	}

	triangle_count = polylist_element.get_attribute_int("count", 0);

	load_inputs(polylist_element, sources, vertices);

	if (contains_vcount)
	{
		CL_DomElement vcount_element = polylist_element.named_item("vcount").to_element();
		if (!vcount_element.is_null())
			validate_vcount(vcount_element);
	}

	CL_DomElement primitive_element = polylist_element.named_item("p").to_element();
	if (!primitive_element.is_null())
		load_primitive(primitive_element);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:40,代码来源:collada_triangles.cpp

示例5: main

int ConsoleProgram::main(const std::vector<CL_String> &args)
{
	// Setup clanCore:
	CL_SetupCore setup_core;

	// Initialize the ClanLib display component
	CL_SetupDisplay setup_display;

	// Create a console Window if one does not exist:
	CL_ConsoleWindow console_window("Console", 80, 600);

try
{	
	//получение параметра запуска
	for (std::vector<CL_String>::const_iterator iter_args = args.begin(); iter_args != args.end(); ++iter_args)
		CL_Console::write_line( *iter_args );

	//получение имени директории для сохранения
	CL_String workDirectoryName;
	if (args.size() > 1)
	{
		//полное имя рабочей директории
		workDirectoryName = args[1];
		//конвертирование из CP-1251 в UTF-8 имени рабочей директории
		workDirectoryName = decode(workDirectoryName);
	}
	else
	{
		//получение полного пути к текущему каталогу
		workDirectoryName = CL_Directory::get_current();
	}

	CL_Console::write_line("workDirectoryName: %1", workDirectoryName);
	//получение имени последней директории
	CL_String locationName = CL_PathHelp::remove_trailing_slash(workDirectoryName);
	locationName = CL_PathHelp::get_filename(locationName);
	CL_Console::write_line("locationName: %1", locationName);

	CL_String tempDir = CL_PathHelp::add_trailing_slash(workDirectoryName) + "temp\\";
	CL_DirectoryScanner directoryScanner;
	directoryScanner.scan(tempDir, "*.export");
	while (directoryScanner.next())
	{
		//имя обрабатываемого файла
		CL_String fileName;

		if (directoryScanner.is_directory())
			continue;
		//получение полного имени файла экспорта
		fileName = directoryScanner.get_pathname();
		//конвертирование из CP-1251 в UTF-8
		fileName = decode(fileName);
		CL_Console::write_line("find: %1", fileName);

		//открытие XML файла
		CL_File fileXML;
		bool is_opened = fileXML.open(fileName);
		if( !is_opened )
			return PrintError( CL_String("Can't open file: ") + fileName );

		//Создание объекта DOM парсера
		CL_DomDocument document(fileXML);
		//получение root узла
		CL_DomElement root = document.get_document_element();
		if( root.get_local_name() != "resources")
		{
			CL_Console::write_line("Root name can't be: %1", root.get_local_name().c_str());
			return PrintError("");
		}

		//цикл по потомкам "resources"
		for (CL_DomNode cur = root.get_first_child(); !cur.is_null(); cur = cur.get_next_sibling())
		{
			//загрузка только спрайтов
			if (cur.get_node_name() != "sprite")
				continue;

			CL_DomElement element = cur.to_element();

			//проверка на обязательные параметры
			if (!element.has_attribute("name"))
				return PrintError("Error: can't find parametr \"name\"");

			CL_DomString name = element.get_attribute("name");
			int x = element.get_attribute_int("x");
			int y = element.get_attribute_int("y");
			//добавление спрайта
			sprites.push_back( S_Sprite(name, CL_Vec2i(x, y) ) );

			//цикл по "image" (формирование списка имен файлов)
			for (CL_DomNode cur_image = cur.get_first_child(); !cur_image.is_null(); cur_image = cur_image.get_next_sibling())
			{
				//загрузка только image
				if (cur_image.get_node_name() != "image")
					continue;
				
				CL_DomElement element_image = cur_image.to_element();
				CL_DomString file = element_image.get_attribute("file");
				
				//конвертирование из CP-1251 в UTF-8 имени файла изображения
//.........这里部分代码省略.........
开发者ID:ermachkov,项目名称:bmgui,代码行数:101,代码来源:main.cpp

示例6: on_set_options

void CL_Label_Generic::on_set_options(const CL_DomElement &options)
{
	if (options.has_attribute("text"))
		text = options.get_attribute("text");
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:5,代码来源:label_generic.cpp

示例7: if

void CL_GUIXMLLoaderVersion_1_0::load(CL_DomElement &element, CL_GUIComponent *parent)
{
	CL_DomElement e = element.get_first_child().to_element();

	dialog_width = 0;
	dialog_height = 0;

	while (e.is_element())
	{
		CL_String tag = e.get_tag_name();
		CL_GUIComponent *new_comp = 0;

		if (tag == "button")
		{
			CL_PushButton *co = new CL_PushButton(parent);
			if (e.has_attribute("text"))
				co->set_text(e.get_attribute("text"));
			new_comp = co;
		}
		else if (tag == "checkbox")
		{
			CL_CheckBox *co = new CL_CheckBox(parent);
			if (e.has_attribute("text"))
				co->set_text(e.get_attribute("text"));
			new_comp = co;
		}
		else if (tag == "radiobutton")
		{
			CL_RadioButton *co = new CL_RadioButton(parent);
			if (e.has_attribute("text"))
				co->set_text(e.get_attribute("text"));
			if (e.has_attribute("group"))
				co->set_group_name(e.get_attribute("group"));
			new_comp = co;
		}
		else if (tag == "label")
		{
			CL_Label *co = new CL_Label(parent);
			if (e.has_attribute("text"))
				co->set_text(e.get_attribute("text"));
			new_comp = co;
		}
		else if (tag == "toolbar")
		{
			CL_ToolBar *co = new CL_ToolBar(parent);
			new_comp = co;
		}
		else if (tag == "progressbar")
		{
			CL_ProgressBar *co = new CL_ProgressBar(parent);
			new_comp = co;
		}
		else if (tag == "lineedit")
		{
			CL_LineEdit *co = new CL_LineEdit(parent);
			if (e.has_attribute("text"))
				co->set_text(e.get_attribute("text"));
			new_comp = co;
		}
		else if (tag == "slider")
		{
			CL_Slider *co = new CL_Slider(parent);
			co->set_min(CL_StringHelp::text_to_int(e.get_attribute("min")));
			co->set_max(CL_StringHelp::text_to_int(e.get_attribute("max")));
			co->set_tick_count(CL_StringHelp::text_to_int(e.get_attribute("ticks")));
			co->set_page_step(CL_StringHelp::text_to_int(e.get_attribute("page_step")));
			new_comp = co;
		}
		else if (tag == "listview")
		{
			CL_ListView *co = new CL_ListView(parent);
			CL_ListViewHeader *header = co->get_header();

			std::vector<CL_DomNode> columns_nodes = e.select_nodes("listview_header/listview_column");
			for(size_t i = 0; i < columns_nodes.size(); ++i)
			{
				CL_DomElement column_element = columns_nodes[i].to_element();
				CL_String id = column_element.get_attribute("col_id");
				CL_String caption = column_element.get_attribute("caption");
				int width = column_element.get_attribute_int("width");

				CL_ListViewColumnHeader column = header->create_column(id, caption);
				column.set_width(width);
				header->append(column);
			}

			new_comp = co;
		}
		else if (tag == "tab")
		{
			CL_Tab *co = new CL_Tab(parent);
			new_comp = co;

			CL_DomElement tab_child = e.get_first_child().to_element();
			while (tab_child.is_element())
			{
				if (tab_child.get_tag_name() == "tabpage")
				{
					CL_String label = tab_child.get_attribute("label", "Error: NO LABEL!");
					int id = CL_StringHelp::text_to_int(tab_child.get_attribute("id", "0"));
//.........这里部分代码省略.........
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:101,代码来源:gui_xml_loader_version_1_0.cpp


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