Exemple #1
0
void CONTEXT_MENU::updateHotKeys()
{
    TOOL_MANAGER* toolMgr = getToolManager();

    for( std::map<int, const TOOL_ACTION*>::const_iterator it = m_toolActions.begin();
            it != m_toolActions.end(); ++it )
    {
        int id = it->first;
        const TOOL_ACTION& action = *it->second;
        int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK;

        if( key )
        {
            int mod = toolMgr->GetHotKey( action ) & MD_MODIFIER_MASK;
            int flags = 0;
            wxMenuItem* item = FindChildItem( id );

            if( item )
            {
                flags |= ( mod & MD_ALT ) ? wxACCEL_ALT : 0;
                flags |= ( mod & MD_CTRL ) ? wxACCEL_CTRL : 0;
                flags |= ( mod & MD_SHIFT ) ? wxACCEL_SHIFT : 0;

                if( !flags )
                    flags = wxACCEL_NORMAL;

                wxAcceleratorEntry accel( flags, key, id, item );
                item->SetAccel( &accel );
            }
        }
    }
}
HTREEITEM BuildTree::InsertViewItem(HTREEITEM hParentItem,char *szPath)
{
	//找到就OK
	char *ps = szPath;
	char *pf(NULL);
	char szTemp[_MAX_PATH];
	pf = strchr(ps,'\\');
	if (pf)
	{
		ZeroMemory(szTemp,_MAX_PATH);
		memcpy(szTemp,ps,(int)(pf - ps));

		HTREEITEM hItem = FindChildItem(hParentItem,szTemp);

		if (!hItem)
		{
			TV_INSERTSTRUCT ti = {0};
			ti.hParent = hParentItem;
			ti.item.mask    = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
			ti.item.lParam  = -1;
			ti.item.iImage  = ICON_FOLDER;
			ti.item.iSelectedImage = ICON_FOLDER;
			ti.item.pszText = szTemp;
			
			hItem = TreeView_InsertItem(s_hWndTV,&ti);
		}

		return InsertViewItem(hItem,pf + 1);
	}
	
	HTREEITEM hItem = FindChildItem(hParentItem,szTemp);

	if (!hItem)
	{
		TV_INSERTSTRUCT ti = {0};
		ti.hParent = hParentItem;
		ti.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
		ti.item.lParam  = -1;
		ti.item.iImage  = ICON_FOLDER;
		ti.item.iSelectedImage = ICON_FOLDER;
		ti.item.pszText = szPath;

		hItem = TreeView_InsertItem(s_hWndTV,&ti);
	}

	return hItem;
}
HTREEITEM BuildTree::FindViewItem(HTREEITEM hParent,const char *szPath)
{
	//找到就OK
	const char *ps = szPath;
	const char *pf(NULL);
	char szTemp[_MAX_PATH];
	pf = strchr(ps,'\\');
	if (pf)
	{
		ZeroMemory(szTemp,_MAX_PATH);
		memcpy(szTemp,ps,(int)(pf - ps));
		
		HTREEITEM hItem = FindChildItem(hParent,szTemp);
		if (hItem)
            return FindViewItem(hItem,pf + 1);
		else 
			return NULL;
	
	}

	return FindChildItem(hParent,szPath);	
}