Exemplo n.º 1
0
void CAttributeHistoryNode::Refresh()
{
 	GenerateDispText();
	WTL::CTreeItem parent = GetParent();
	parent.Expand(TVE_COLLAPSE | TVE_COLLAPSERESET);
	parent.Expand();
}
Exemplo n.º 2
0
LRESULT MFTreeView::OnItemExpanding(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
{
   bool result = true; // TRUE == Dont Expand/collapse
   LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)pnmh;

   MFTreeViewItem* pItem = (MFTreeViewItem*)(pnmtv->itemNew.lParam);
   if (pItem)
   {
      if (pnmtv->action == TVE_COLLAPSE)
      {
         // TODO: Make this a recursive algorithm incase we have open subnodes.
         WTL::CTreeItem item(pnmtv->itemNew.hItem, this);
         WTL::CTreeItem child = item.GetChild();
         while (!child.IsNull())
         {
            MFTreeViewItem* pChild = (MFTreeViewItem*)child.GetData();
            child.SetData(NULL);
            if (pChild)
            {
               delete pChild;
            }
            child = GetNextSiblingItem(child);
         }

         SendMessage(m_hWnd, TVM_EXPAND, TVE_COLLAPSE | TVE_COLLAPSERESET, (LPARAM) pnmtv->itemNew.hItem);

         result = false;
      }
      else if (pnmtv->action == TVE_EXPAND && pItem->HasChildren())
      {
         HTREEITEM hPrevItem = pnmtv->itemNew.hItem;
         std::vector<MFTreeViewItem*> children = pItem->GetChildren();
         for (unsigned int i = 0; i < children.size(); ++i)
         {
            TVINSERTSTRUCT tvis = { 0 };
            tvis.hParent = pnmtv->itemNew.hItem;
            tvis.hInsertAfter = pItem->SortChildren() ? TVI_SORT : hPrevItem;
            tvis.item.mask = TVIF_CHILDREN | TVIF_PARAM | TVIF_TEXT;
            tvis.item.pszText = LPSTR_TEXTCALLBACK;
            //tvis.item.iImage = nImage;
            //tvis.item.iSelectedImage = nSelectedImage;
            //tvis.item.state = nState;
            //tvis.item.stateMask = nStateMask;
            tvis.item.cChildren = I_CHILDRENCALLBACK;
            tvis.item.lParam = (LPARAM) children[i];

            hPrevItem = InsertItem(&tvis);
         }
         result = false;
      }
   }
   return result ? TRUE : FALSE;
}
Exemplo n.º 3
0
int GetNodeIndex(CTreeNode *node)
{
	int index = 0;
	CTreeNode *parent = node->GetParentNode();
	if ( parent )
	{
		for (WTL::CTreeItem ti = parent->GetChild(); ti != NULL; ti = ti.GetNextSibling())
		{
			if ( ti == *node )
				return index;
			index++;
		}
	}
	return -1;
}
Exemplo n.º 4
0
LRESULT MFTreeView::OnKeydown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) {
	int x = 9;
	TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*)pnmh;

	if (pTVKeyDown->wVKey == VK_F2) {

		WTL::CTreeItem item = GetDropHilightItem();
		if (item.IsNull()) {
			item = GetSelectedItem();
		}
		MFTreeViewItem* pItem = (MFTreeViewItem*)item.GetData();
		if (pItem == NULL) 
			return 0;

		pItem->HandleMenuCmd(4 /*CMD_RENAME*/, item);		
	}
	return 0;
}
LRESULT CRepositoryFilterView::OnBnClickedButtonCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
    if (m_Root)
    {
        std::_tstring attrs;
        WTL::CTreeItem item = *m_Root;
        while(item)
        {
            if (CComQIPtr<CAttributeNode> node = reinterpret_cast<CTreeNode *>(item.GetData()))
            {
                if (!attrs.empty())
                    attrs += _T("\r\n");
                attrs += node->GetAttribute()->GetQualifiedLabel();
            }
            item = m_Tree.GetNextItem(item, TVGN_EX_ALL);
        }
        SetClipboard(attrs);
    }
    return 0;
}
Exemplo n.º 6
0
//  CTreeNode Helper Functions  ---
CTreeNode * Locate(const CModuleHelper & modHelper, CTreeNode * root, unsigned int depth)
{
	if (depth >= modHelper.GetQualifiedDepth())
		return false;

	root->Expand();
	for (WTL::CTreeItem itr = root->GetChild(); itr != NULL; itr = itr.GetNextSibling())
	{
		CString text;
		itr.GetText(text);
		if (_tcsicmp(modHelper.GetQualifiedLabel(depth), text) == 0)
		{
			if (depth == modHelper.GetQualifiedDepth() - 1)
			{
				return reinterpret_cast<CTreeNode *>(itr.GetData());
			}
			return Locate(modHelper, reinterpret_cast<CTreeNode *>(itr.GetData()), depth + 1);
		}
	}
	return NULL;
}
Exemplo n.º 7
0
LRESULT MFTreeView::OnRClick(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled)
{
   HMENU ctxMenu = CreatePopupMenu();

   WTL::CTreeItem item = GetDropHilightItem();
   if (item.IsNull())
   {
      item = GetSelectedItem();
   }
   MFTreeViewItem* pItem = (MFTreeViewItem*)item.GetData();

   if (pItem == NULL)
   {
      DestroyMenu(ctxMenu);
      return 0;
   }

   unsigned int nextID = pItem->AppendMenuCmd(ctxMenu, 1, item);

   if (GetMenuItemCount(ctxMenu) > 0)
   {
      AppendMenu(ctxMenu, MF_SEPARATOR, 0, NULL);
   }
   unsigned int refreshID = nextID++;
   nextID = AppendMenu(ctxMenu, MF_STRING, refreshID, _T("Refresh"));

   if (GetMenuItemCount(ctxMenu) == 0)
   {
      DestroyMenu(ctxMenu);
      return 0;
   }

   POINT pos;
   GetCursorPos(&pos);

   int command = TrackPopupMenuEx(ctxMenu, TPM_NONOTIFY | TPM_RETURNCMD, pos.x, pos.y, pnmh->hwndFrom, NULL);

   if (!pItem->HandleMenuCmd(command, item))
   {
      if (command == refreshID)
      {
         WTL::CTreeItem parent = item.GetParent();
         parent.Expand(TVE_COLLAPSE | TVE_COLLAPSERESET);
         parent.Expand();
      }
   }

   DestroyMenu(ctxMenu);

   return 1;
}