示例#1
0
unsigned uie::menu_hook_impl::win32_build_menu_recur(HMENU menu,uie::menu_node_ptr parent,unsigned base_id,unsigned max_id)//menu item identifiers are base_id<=N<base_id+max_id (if theres too many items, they will be clipped)
{
	if (parent.is_valid() && parent->get_type()==menu_node_t::type_popup)
	{
		pfc::string8_fast_aggressive temp,name;
		temp.prealloc(32);
		name.prealloc(32);
		unsigned child_idx,child_num = parent->get_children_count();
		unsigned new_base = base_id;
		for(child_idx=0;child_idx<child_num;child_idx++)
		{
			menu_node_ptr child;
			parent->get_child(child_idx, child);
			if (child.is_valid())
			{
				unsigned displayflags=0;
				child->get_display_data(name, displayflags);
				if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;temp.reset();}
				menu_node_t::type_t type = child->get_type();
				if (type==menu_node_t::type_popup)
				{
					HMENU new_menu = CreatePopupMenu();
					uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(displayflags),(UINT)new_menu,name);
					new_base = win32_build_menu_recur(new_menu,child,new_base,max_id);
				}
				else if (type==menu_node_t::type_separator)
				{
					uAppendMenu(menu,MF_SEPARATOR,0,0);
				}
				else if (type==menu_node_t::type_command)
				{
					unsigned id = new_base;
					if (id>=0 && (max_id<0 || id<max_id))
					{
						uAppendMenu(menu,MF_STRING | flags_to_win32(displayflags),new_base,name);
						if (displayflags & menu_node_t::state_radio)
							set_menu_item_radio(menu, new_base);
					}
					new_base++;
				}
			}
		}
		return new_base;
	}
	return base_id;
}
示例#2
0
void contextmenu_manager::win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id)//menu item identifiers are base_id<=N<base_id+max_id (if theres too many items, they will be clipped)
{
	if (parent!=0 && parent->get_type()==contextmenu_item_node::TYPE_POPUP)
	{
		pfc::string8_fastalloc temp;
		t_size child_idx,child_num = parent->get_num_children();
		for(child_idx=0;child_idx<child_num;child_idx++)
		{
			contextmenu_node * child = parent->get_child(child_idx);
			if (child)
			{
				const char * name = child->get_name();
				if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;}
				contextmenu_item_node::t_type type = child->get_type();
				if (type==contextmenu_item_node::TYPE_POPUP)
				{
					HMENU new_menu = CreatePopupMenu();
					uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(child->get_display_flags()),(UINT_PTR)new_menu,name);
					win32_build_menu(new_menu,child,base_id,max_id);
				}
				else if (type==contextmenu_item_node::TYPE_SEPARATOR)
				{
					uAppendMenu(menu,MF_SEPARATOR,0,0);
				}
				else if (type==contextmenu_item_node::TYPE_COMMAND)
				{
					int id = child->get_id();
					if (id>=0 && (max_id<0 || id<max_id))
					{
						const unsigned flags = child->get_display_flags();
						const UINT ID = base_id+id;
						uAppendMenu(menu,MF_STRING | flags_to_win32(flags),ID,name);
						if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) CheckMenuRadioItem(menu,ID,ID,ID,MF_BYCOMMAND);
					}
				}
			}
		}
	}
}
示例#3
0
void menu_manager::win32_build_menu(HMENU menu,menu_node * parent,int base_id,int max_id)//menu item identifiers are base_id<=N<base_id+max_id (if theres too many items, they will be clipped)
{
	if (parent!=0 && parent->get_type()==menu_node::TYPE_POPUP)
	{
		string8_fastalloc temp;
		int child_idx,child_num = parent->get_num_children();
		for(child_idx=0;child_idx<child_num;child_idx++)
		{
			menu_node * child = parent->get_child(child_idx);
			if (child)
			{
				const char * name = child->get_name();
				if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;}
				menu_node::type type = child->get_type();
				if (type==menu_node::TYPE_POPUP)
				{
					HMENU new_menu = CreatePopupMenu();
					uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(child->get_display_flags()),(UINT)new_menu,name);
					win32_build_menu(new_menu,child,base_id,max_id);
				}
				else if (type==menu_node::TYPE_SEPARATOR)
				{
					uAppendMenu(menu,MF_SEPARATOR,0,0);
				}
				else if (type==menu_node::TYPE_COMMAND)
				{
					int id = child->get_id();
					if (id>=0 && (max_id<0 || id<max_id))
					{
						uAppendMenu(menu,MF_STRING | flags_to_win32(child->get_display_flags()),base_id+id,name);
					}
				}
			}
		}
	}
}