Exemple #1
0
CString CStatisticsTree::GetText(bool onlyVisible, HTREEITEM theItem, int theItemLevel, bool firstItem)
{
	bool bPrintHeader = firstItem;
	HTREEITEM hCurrent;
	if (theItem == NULL)
	{
		hCurrent = GetRootItem(); // Copy All Vis or Copy All
	}
	else
	{
		if (bPrintHeader && (!ItemHasChildren(theItem) || !IsExpanded(theItem)))
			bPrintHeader = false;
		hCurrent = theItem;
	}

	CString	strBuffer;
	if (bPrintHeader)
		strBuffer.Format(_T("eMule v%s %s [%s]\r\n\r\n"), theApp.m_strCurVersionLong, GetResString(IDS_SF_STATISTICS) ,thePrefs.GetUserNick());

	while (hCurrent != NULL)
	{
		for (int i = 0; i < theItemLevel; i++)
			strBuffer += _T("   ");
		strBuffer += GetItemText(hCurrent);
		if (bPrintHeader || !firstItem)
			strBuffer += _T("\r\n");
		if (ItemHasChildren(hCurrent) && (!onlyVisible || IsExpanded(hCurrent)))
			strBuffer += GetText(onlyVisible, GetChildItem(hCurrent), theItemLevel+1, false);
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
		if (firstItem && theItem != NULL)
			break; // Copy Selected Branch was used, so we don't want to copy all branches at this level.  Only the one that was selected.
	}
	return strBuffer;
}
VectorTreeItemId BFBackupTree::GetTaskItems (wxTreeItemId idParent, bool bGoDeep /*= true*/)
{
    VectorTreeItemId vec;

    wxTreeItemId idCurr;
    wxTreeItemIdValue idCookie;

    if (ItemHasChildren(idParent))
    {
        for (idCurr = GetFirstChild(idParent, idCookie);
             idCurr.IsOk();
             idCurr = GetNextChild(idParent, idCookie))
        {
            if (ItemHasChildren(idCurr) == bGoDeep)
            {
                VectorTreeItemId vecSub(GetTaskItems(idCurr, true));

                for (ItVectorTreeItemId it = vecSub.begin();
                     it != vecSub.end();
                     it++)
                {
                    vec.push_back(*it);
                }
            }
            else
            {
                if (IsTask(idCurr))
                    vec.push_back(idCurr);
            }
        }
    }

    return vec;
}
Exemple #3
0
void ctlTree::NavigateTree(int keyCode)
{
	switch(keyCode)
	{
		case WXK_LEFT:
			{
				//If tree item has children and is expanded, collapse it, otherwise select it's parent if has one
				wxTreeItemId currItem = GetSelection();

				if (ItemHasChildren(currItem) && IsExpanded(currItem))
				{
					Collapse(currItem);
				}
				else
				{
					wxTreeItemId parent = GetItemParent(currItem);
					if (parent.IsOk())
					{
						SelectItem(currItem, false);
						SelectItem(parent, true);
					}
				}
			}
			break;
		case WXK_RIGHT:
			{
				//If tree item do not have any children ignore it,
				//otherwise  expand it if not expanded, and select first child if already expanded
				wxTreeItemId currItem = GetSelection();

				if(ItemHasChildren(currItem))
				{
					if (!IsExpanded(currItem))
					{
						Expand(currItem);
					}
					else
					{
						wxCookieType cookie;
						wxTreeItemId firstChild = GetFirstChild(currItem, cookie);
						SelectItem(currItem, false);
						SelectItem(firstChild, true);
					}
				}
			}
			break;
		default:
			wxASSERT_MSG(false, _("Currently handles only right and left arrow key, other keys are working"));
			break;
	}
}
void svSymbolTree::BuildTree(const wxFileName& fn)
{
    TagEntryPtrVector_t newTags;
    ITagsStoragePtr db = TagsManagerST::Get()->GetDatabase();
    if ( !db ) {
        return;
    }
    
    db->SelectTagsByFile(fn.GetFullPath(), newTags);
    if ( TagsManagerST::Get()->AreTheSame(newTags, m_currentTags) )
        return;
    
    wxWindowUpdateLocker locker(this);
    SymbolTree::BuildTree(fn, &newTags);
    
    // Request from the parsing thread list of include files
    ++m_uid;
    
    ParseRequest *req = new ParseRequest(this);
    req->setFile(fn.GetFullPath());
    req->setType(ParseRequest::PR_PARSE_INCLUDE_STATEMENTS);
    req->_uid = m_uid; // Identifies this request
    ParseThreadST::Get()->Add( req );
    
    wxTreeItemId root = GetRootItem();
    if( root.IsOk() && ItemHasChildren(root) ) {
        wxTreeItemIdValue cookie;
        wxTreeItemId child = GetFirstChild(root, cookie);
        while ( child.IsOk() ) {
            Expand(child);
            child = GetNextChild(root, cookie);
        }
    }
}
Exemple #5
0
HTREEITEM CMyTreeCtrl::FindItem( HTREEITEM hItem, DWORD dwData, bool f )
{
	if( hItem == (HTREEITEM)NULL )
		return (HTREEITEM)NULL;

	PSrvrData pSrvrData	= (PSrvrData)GetItemData( hItem );
	if( f == true ) {
		if( pSrvrData->dwId == dwData )
			return hItem;
	}
	else {
		if( pSrvrData->dpid == dwData )
			return hItem;
	}

	if( TRUE == ItemHasChildren( hItem ) )
	{
		HTREEITEM hFind		= FindItem( GetChildItem( hItem ), dwData, f );
		if( hFind != (HTREEITEM)NULL )
			return hFind;
		return FindItem( GetNextSiblingItem( hItem ), dwData, f );
	}
	else
	{
		return FindItem( GetNextSiblingItem( hItem ), dwData, f );
	}
}
Exemple #6
0
void CMyTreeCtrl::PostEnumItem( HTREEITEM hItem, bool f, PENUMITEM pEnumItem )
{
	if( hItem == (HTREEITEM)NULL )
		return;

	if( f == true )
		pEnumItem	= new ENUMITEM;

	PSrvrData pData		= (PSrvrData)GetItemData( hItem );
	ASSERT( pData );
	if( pData->dwId < MAX_ID )
		pEnumItem->m_ahEnumItem[pEnumItem->m_uSizeofEnumItem++]		= hItem;

	if( TRUE == ItemHasChildren( hItem ) )
	{
		if( f == false )
			PostEnumItem( GetNextSiblingItem( hItem ), false, pEnumItem );
		PostEnumItem( GetChildItem( hItem ), false, pEnumItem );
	}
	else
	{
		if( f == false )
			PostEnumItem( GetNextSiblingItem( hItem ), false, pEnumItem );
	}

	if( f == true )
	{
		m_lspEnumItem.push_back( pEnumItem );
	}
}
Exemple #7
0
void CMyTreeCtrl::EnumItem( HTREEITEM hItem, bool f )
{
	if( hItem == (HTREEITEM)NULL )
		return;

	if( f == true ) {
		m_uSizeofEnumItem	= 0;
		m_uIndexofEnumItem	= 0;
	}

	PSrvrData pData		= (PSrvrData)GetItemData( hItem );
	ASSERT( pData );
	if( pData->dwId < MAX_ID )
		m_ahEnumItem[m_uSizeofEnumItem++]	= hItem;

	if( TRUE == ItemHasChildren( hItem ) )
	{
		if( f == false )
			EnumItem( GetNextSiblingItem( hItem ), false );
		EnumItem( GetChildItem( hItem ), false );
	}
	else
	{
		if( f == false )
			EnumItem( GetNextSiblingItem( hItem ), false );
	}
}
wxTreeItemId wxSpinTreeCtrl::GetTreeItem(const char *nodeId, wxTreeItemId idParent, wxTreeItemIdValue cookie)
{
    if (! idParent.IsOk())
        return NULL;

    wxSpinTreeItemData *treeData = (wxSpinTreeItemData*)GetItemData(idParent);
    if (treeData && treeData->m_pNode.valid())
    {
        if (strcmp(treeData->m_pNode->id->s_name, nodeId) == 0)
        {
            return idParent;
        }
    }

    if (ItemHasChildren(idParent))
    {
        wxTreeItemId child;
        for (child = GetFirstChild(idParent, cookie); child.IsOk(); child = GetNextChild(idParent, cookie))
        {
            wxTreeItemId targetItem = GetTreeItem(nodeId, child, cookie);
            if (targetItem.IsOk())
                return targetItem;
        }
    }
    return GetTreeItem(nodeId, GetNextSibling(idParent), cookie);
}
Exemple #9
0
void wxGxTreeViewBase::OnObjectRefreshed(wxGxCatalogEvent& event)
{
	wxTreeItemId TreeItemId = m_TreeMap[event.GetObjectID()];
	if(TreeItemId.IsOk())
	{
		wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(TreeItemId);
		if(pData != NULL)
		{
			if(pData->m_bExpandedOnce)
			{
                //deleted via refresh
				//DeleteChildren(TreeItemId);
				pData->m_bExpandedOnce = false;
				Expand(TreeItemId);
			}
            else
            {
                wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
			    wxGxObjectContainer* pGxObjectContainer = dynamic_cast<wxGxObjectContainer*>(pGxObject);
				wxBusyCursor wait;
			    if(pGxObjectContainer && pGxObjectContainer->HasChildren() && !ItemHasChildren(TreeItemId))
                {
                    SetItemHasChildren(TreeItemId);
                }
            }
		}
	}
}
wxTreeItemId BFBackupTree::FindItemByPath (wxTreeItemId idStart, const wxString& strPath)
{
    wxTreeItemId            idCurr, idLast;
    wxTreeItemIdValue       idCookie;
    wxString                str;

    // check start item
    if (HasPath(idStart, strPath))
        return idStart;

    if (ItemHasChildren(idStart))
    {
        for (idCurr = GetFirstChild(idStart, idCookie);
             idCurr.IsOk();
             idCurr = GetNextChild(idStart, idCookie))
        {
            idLast = FindItemByPath(idCurr, strPath);

            if (idLast.IsOk())
                return idLast;
        }
    }

    return wxTreeItemId();
}
Exemple #11
0
BOOL CDirTreeCtrl::AddSubDirAsItem1(HTREEITEM hParent)
{
	CString strPath,strFileName;
	HTREEITEM hChild;
	//---------------------去除该父项下所有的子项------------   // 因为有dummy项,并且有时子目录再次打开,或子目录会刷新等,因此必须去除。
	while ( ItemHasChildren(hParent))  {
		hChild = GetChildItem(hParent);
		DeleteItem( hChild );
	}    //-----------------------装入该父项下所有子项--------------  
	strPath = GetFullPath(hParent);

	CString strSearchCmd = strPath;
	if( strSearchCmd.Right( 1 ) != _T( "\\" ))
		strSearchCmd += _T( "\\" );

	strSearchCmd += _T( "*.*" );
	CFileFind find;
	BOOL bContinue = find.FindFile( strSearchCmd );
	while ( bContinue )  {
		bContinue = find.FindNextFile();
		strFileName = find.GetFileName();

		 if(!find.IsHidden() && ! find.IsDots() && find.IsDirectory() )
		 {
			 hChild = AddItem( hParent, strFileName );
		 }

		if ( !find.IsHidden() && ! find.IsDots() && !find.IsDirectory() )   {
			InsertItem( strFileName, 0, 0, hParent );
		}
    }

    return TRUE; 
}
Exemple #12
0
//------------------------------------------------------------------------------
wxTreeItemId OutputTree::FindItem(wxTreeItemId parentId, const wxString &name)
{
   #if DEBUG_OUTPUT_TREE
   MessageInterface::ShowMessage
      ("OutputTree::FindItem() parentId=%s, name=%s\n",
       GetItemText(parentId).c_str(), name.c_str());
   #endif
   
   wxTreeItemId itemId;
   
   if (ItemHasChildren(parentId))
   {
      wxString itemText;
      wxTreeItemIdValue cookie;
      wxTreeItemId childId = GetFirstChild(parentId, cookie);
      
      while (childId.IsOk())
      {
         itemText = GetItemText(childId);
         if (itemText == name)
            return childId;
         
         childId = GetNextChild(parentId, cookie);
      }
   }
   
   return itemId;
}
Exemple #13
0
wxTreeItemId SessionTreeControl::findSession( wxTreeItemId root,
                                                std::string address )
{
    wxTreeItemIdValue temp; // unused var, needed in getchild
    wxTreeItemId targetItem;
    wxTreeItemId current = GetFirstChild( root, temp );

    while ( current.IsOk() )
    {
        wxString text = GetItemText( current );
        std::string target = std::string( text.char_str() );
        if ( target.compare( address ) == 0 )
            return current;

        if ( ItemHasChildren( current ) )
        {
            targetItem = findSession( current, address );
            if ( targetItem.IsOk() )
                return targetItem;
        }
        current = GetNextChild( root, temp );
    }

    wxTreeItemId none;
    return none; // return default value if not found
}
Exemple #14
0
void KGTreeCtrl::SortTree(HTREEITEM hTreeItem)
{
	HTREEITEM hSubItem = NULL;
	if (!hTreeItem)
	{
		hTreeItem = GetRootItem();
//		hTreeItem = GetChildItem(TVI_ROOT);
		KG_PROCESS_ERROR(hTreeItem);
		SortChildren(NULL);
	}
	hSubItem = hTreeItem;
	SortChildren(hSubItem);
	HTREEITEM BrotherItem = hSubItem;
	if (ItemHasChildren(hSubItem))
	{
		hSubItem = GetChildItem(hSubItem);
		SortTree(hSubItem);
	}
	hSubItem = GetNextSiblingItem(BrotherItem);
	KG_PROCESS_ERROR(hSubItem);

	SortTree(hSubItem);
Exit0:
	return ;
}
Exemple #15
0
void MyGameTreeCtrl::DClickTreeItem( HTREEITEM htree)
{
	if(ItemHasChildren(htree))
		return ;
	m_iCurItem = GetItemData(htree);
	SearchTreeItem( htree );
}
Exemple #16
0
// Recursively sort the entire tree
void CMultiSelTreeCtrl::SortTree(HTREEITEM topNode/*=NULL*/, HTREEITEM parentNode/*=NULL*/)
{
	HTREEITEM item;

	// Sort things at the this level
	if (parentNode && (m_SortByExtension || m_SortByResolveStat 
					|| m_SortByAction    || m_SortByFilename))
	{
		TVSORTCB tvsortcb;
		tvsortcb.hParent = topNode;
		tvsortcb.lParam = (m_SortByResolveStat ? 2 : 0) + (m_SortByExtension ? 1 : 0) 
						+ (m_SortByFilename ? 8 : 0)    + (m_SortByAction ? 4 : 0);
		tvsortcb.lpfnCompare = SortTreeCB;
		SortChildrenCB(&tvsortcb);
	}
	else 
		SortChildren(topNode);

	// Get the first item at this level
	if(topNode == NULL)
		item=GetNextItem(TVI_ROOT, TVGN_ROOT);
	else
		item=GetChildItem(topNode);   // Get first child

	// Recurse all items that have children
	while(item != NULL)
	{
		if(ItemHasChildren(item))
			SortTree(item, topNode);
		item=GetNextSiblingItem(item);
	}
}
BOOL COXTreeItem::SortChildren(int nCol/*=0*/, 
							   BOOL bOnlyChildren/*=TRUE*/, 
							   BOOL bAscending/*=TRUE*/, 
							   PFNTVCOMPARE lpfnCompare/*=NULL*/, 
							   LPARAM lParam/*=NULL*/)
{
	if(!ItemHasChildren())
	{
		return TRUE;
	}

	BOOL bNotDone = TRUE;
	while (bNotDone)
	{      
		bNotDone = FALSE;	
		COXTreeItem* xti=pxFirstChild;
		BOOL bFirstChild=TRUE;
		while(xti && xti->pxNext)
		{
			BOOL bResult;
			if(lpfnCompare==NULL)
			{
				bResult=Compare(xti,nCol,bAscending);
			}
			else
			{
				bResult=lpfnCompare(xti->m_tvi.lParam,xti->pxNext->m_tvi.lParam,lParam)*
					(bAscending ? 1 : -1)>0 ? TRUE : FALSE;
			}
			bNotDone|=bResult;
			if(bResult)
			{
				Swap(xti);
				if(bFirstChild)
				{
					pxFirstChild=xti->pxPrev;
				}
				xti=xti->pxPrev;
			}
			xti=xti->pxNext;
			bFirstChild=FALSE;
		}
	}

	if(!bOnlyChildren)
	{
		COXTreeItem* xti=pxFirstChild;
		while(xti)
		{
			if(xti->ItemHasChildren())
			{
				xti->SortChildren(nCol,bOnlyChildren,bAscending,
					lpfnCompare,lParam);
			}
			xti=xti->pxNext;
		}
	}

	return TRUE;
}
Exemple #18
0
// Recursively sorts a node and its children using an application
// specific sorting function
void CMyTreeCtrl::SortNodeAndChildren(HTREEITEM hItem, PFNTVCOMPARE lpfnCompare)
{
	// Create the sorting structure
	TVSORTCB sort;
	sort.hParent=hItem;
	sort.lParam=0;
	sort.lpfnCompare=lpfnCompare;

	// Sort the node
	SortChildrenCB(&sort);

	// Determine if this item has children
	if (ItemHasChildren(hItem))
	{
		// Get the first child item
		HTREEITEM hChild=GetChildItem(hItem);

		// Sort the child
		SortNodeAndChildren(hChild, lpfnCompare);

		// Sort the rest of the children
		HTREEITEM hSibling=GetNextSiblingItem(hChild);
		while (hSibling)
		{
			SortNodeAndChildren(hSibling, lpfnCompare);
			hSibling=GetNextSiblingItem(hSibling);
		}
	}
}
Exemple #19
0
void CViewTree::OnLButtonDblClk(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	//::MessageBox(NULL,_T("双击ViewTree"),_T("OK"),MB_OK);
	HTREEITEM  temp = this->GetSelectedItem();
	HTREEITEM parentitem = GetParentItem(temp);
	if (!ItemHasChildren(temp)){
		CString str = GetItemText(temp);
		CString parentname = GetItemText(parentitem);
		char path[256] ;
		GetCurrentDirectory(256,path);
		
		//CString pathstring = path;
		CString pathstring = workspace;
		// 根据根目录设置路径
		if (parentname.Left(4) == "SPIN"){
			pathstring.Append("\\spin\\");
		}
		if (parentname.Left(4) == "Effe"){
			pathstring.Append("\\piez\\");
		}
		//::MessageBox(NULL,_T(pathstring+str),_T("OK"),MB_OK);
		if (str.Right(3)==_T("bmp")){
			((CPMPApp *)AfxGetApp())->m_pBmpDocTemplate->OpenDocumentFile(pathstring+str);
		}else{
			// 其他格式一律用文本编辑器打开
			((CPMPApp *)AfxGetApp())->m_pTxtDocTemplate->OpenDocumentFile(pathstring+str);
		}
	}
	CTreeCtrl::OnLButtonDblClk(nFlags, point);
}
void CCheckBoxTree::vSetCheckParent(HTREEITEM hItem)
{
    if(hItem == nullptr)
    {
        return;
    }

    HTREEITEM hParentItem = GetParentItem(hItem);
    HTREEITEM hChildItem;
    BOOL bAllChecked = TRUE;
    if( ItemHasChildren(hParentItem))
    {
        hChildItem = GetChildItem(hParentItem);
        while(hChildItem)
        {
            if(!bIsItemChecked(hChildItem))
            {
                bAllChecked = FALSE;
                break;
            }
            hChildItem = GetNextSiblingItem(hChildItem);
        }
    }
    BOOL fCheck=0;
    vSetCheck(hParentItem, bAllChecked);
    vSetCheckParent(hParentItem);
    vSetCheckChildren(hParentItem,!fCheck);
}
void SkillObjectTree::OnEndDrag(wxTreeEvent& event)
{
	wxTreeItemId itemSrc = m_draggedItem,
		itemDst = event.GetItem();
	m_draggedItem = (wxTreeItemId)0l;

	// where to copy the item?
	if ( itemDst.IsOk() && !ItemHasChildren(itemDst) )
	{
		// copy to the parent then
		itemDst = GetItemParent(itemDst);
	}

	if ( !itemDst.IsOk() )
	{
		wxLogMessage(wxT("OnEndDrag: can't drop here."));

		return;
	}

	wxString text = GetItemText(itemSrc);
	wxLogMessage(wxT("OnEndDrag: '%s' copied to '%s'."),
		text.c_str(), GetItemText(itemDst).c_str());

	// just do append here - we could also insert it just before/after the item
	// on which it was dropped, but this requires slightly more work... we also
	// completely ignore the client data and icon of the old item but could
	// copy them as well.
	//
	// Finally, we only copy one item here but we might copy the entire tree if
	// we were dragging a folder.
	//int image = wxGetApp().ShowImages() ? TreeCtrlIcon_File : -1;
	//AppendItem(itemDst, text, image);
}
wxTreeItemId PHPFileLayoutTree::RecurseSearch(const wxTreeItemId& item, const wxString& word)
{
    if(!item.IsOk()) return wxTreeItemId();

    if(item != GetRootItem()) {
        wxString curtext = GetItemText(item);
        curtext.MakeLower();

        if(curtext.StartsWith(word)) {
            return item;
        }
    }

    if(ItemHasChildren(item)) {
        wxTreeItemIdValue cookie;
        wxTreeItemId child = GetFirstChild(item, cookie);
        while(child.IsOk()) {
            wxTreeItemId selection = RecurseSearch(child, word);
            if(selection.IsOk()) {
                return selection;
            }
            child = GetNextChild(item, cookie);
        }
    }
    return wxTreeItemId();
}
void CDragDropTreeCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
    CTreeCtrl::OnMouseMove(nFlags, point);

    if (m_bDragging && m_pImageList != NULL)
    {
        // Stop the scroll timer if it's running.
        KillTimer(1);

        // Erase the old drag image and draw a new one.
        m_pImageList->DragMove(point);

        // Highlight the drop target if the cursor is over an item.
        HTREEITEM hItem = HighlightDropTarget(point);

        // Modify the cursor to provide visual feedback to the user.
        // Note: It's important to do this AFTER the call to DragMove.
        ::SetCursor(hItem == NULL ?
                    AfxGetApp()->LoadStandardCursor(IDC_NO) :
                    (HCURSOR) ::GetClassLongPtr(m_hWnd, GCLP_HCURSOR));

        // Set a timer if the cursor is at the top or bottom of the window,
        // or if it's over a collapsed item.
        CRect rect;
        GetClientRect(rect);
        int cy = rect.Height();

        if ((point.y >= 0 && point.y <= m_nScrollMargin) ||
            (point.y >= cy - m_nScrollMargin && point.y <= cy) ||
            (hItem != NULL && ItemHasChildren(hItem) &&
            !IsItemExpanded(hItem)))

            SetTimer(1, m_nDelayInterval, NULL);
    }
}
//-----------------------------------------------------------------------------
// Purpose: Returns the tree item in the given subtree associated with the given
//			visgroup, NULL if none.
//-----------------------------------------------------------------------------
HTREEITEM CGroupList::FindVisGroupItemRecursive(HTREEITEM hItem, CVisGroup *pVisGroup)
{
    if (hItem)
    {
        CVisGroup *pVisGroupCheck = (CVisGroup *)GetItemData(hItem);
        if (pVisGroupCheck == pVisGroup)
        {
            return hItem;
        }

        if (ItemHasChildren(hItem))
        {
            HTREEITEM hChildItem = GetChildItem(hItem);
            while (hChildItem != NULL)
            {
                HTREEITEM hFoundItem = FindVisGroupItemRecursive(hChildItem, pVisGroup);
                if (hFoundItem)
                {
                    return hFoundItem;
                }

                hChildItem = GetNextItem(hChildItem, TVGN_NEXT);
            }
        }
    }

    return NULL;
}
Exemple #25
0
// This takes a string and uses it to set the expanded or
// collapsed state of the tree items.
int CStatisticsTree::ApplyExpandedMask(CString theMask, HTREEITEM theItem, int theStringIndex)
{
	HTREEITEM	hCurrent;

	if (theItem == NULL) {
		hCurrent = GetRootItem();
		SetRedraw(false);
		ExpandAll(true);
		m_bExpandingAll = true;
	}
	else
		hCurrent = theItem;

	while (hCurrent != NULL && theStringIndex < theMask.GetLength())
	{
		if (ItemHasChildren(hCurrent) && IsBold(hCurrent)) {
			if (theMask.GetAt(theStringIndex) == '0') Expand(hCurrent, TVE_COLLAPSE);
			theStringIndex++;
			theStringIndex = ApplyExpandedMask(theMask, GetChildItem(hCurrent), theStringIndex);			
		}
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
	}
	if (theItem == NULL) {
		SetRedraw(true);
		m_bExpandingAll = true;
	}
	return theStringIndex;
}
Exemple #26
0
// This returns a string of 1's and 0's indicating
// which parent items are expanded.  Only saves the
// bold items.
CString CStatisticsTree::GetExpandedMask(HTREEITEM theItem)
{
	HTREEITEM	hCurrent;
	CString		tempMask;

	tempMask.Empty();

	if (theItem == NULL)
		hCurrent = GetRootItem();
	else
		hCurrent = theItem;

	while (hCurrent != NULL)
	{
		if (ItemHasChildren(hCurrent) && IsBold(hCurrent)) {
			if (IsExpanded(hCurrent))
				tempMask += "1";
			if (!IsExpanded(hCurrent))
				tempMask += "0";
			tempMask += GetExpandedMask(GetChildItem(hCurrent));
		}
		hCurrent = GetNextItem(hCurrent, TVGN_NEXT);
	}
	return tempMask;
}
Exemple #27
0
// Returns the number of children of this group
int CCWTreeCtrl::CountChildren(HTREEITEM hStartItem) const
{
  // Walk the Tree!
  int num = 0;
  if (hStartItem != NULL && ItemHasChildren(hStartItem)) {
    HTREEITEM hChildItem = GetChildItem(hStartItem);
    while (hChildItem != NULL) {
      if (ItemHasChildren(hChildItem)) {
        num += CountChildren(hChildItem);
      } else {
        num++;
      }
      hChildItem = GetNextSiblingItem(hChildItem);
    }
  }
  return num;
}
Exemple #28
0
//----------------------------------------
void CFieldsTreeCtrl::OnBeginDrag( wxTreeEvent &event )
{

  if (ItemHasChildren(event.GetItem()))
  {
    event.Veto();
    return;
  }

  CFieldsTreeItemData* itemData = dynamic_cast<CFieldsTreeItemData*>(GetItemData(event.GetItem()));
  if (itemData == NULL)
  {
    event.Veto();
    return;
  }

  CField* field = itemData->GetField();
  if (field == NULL)
  {
    event.Veto();
    return;
  }

  //event.Allow();

  // start drag operation
  CDndField* dndField = new CDndField();
//  dndField->AddField(field);
  dndField->m_field  = field;

  CDndFieldDataObject dndFieldDataObject(dndField);

  wxDropSource source(dndFieldDataObject, this, wxDROP_ICON(dnd_copy),
                     wxDROP_ICON(dnd_move), wxDROP_ICON(dnd_none));

  //source.DoDragDrop(wxDrag_DefaultMove); // Effectuer l'opération de D&D
  source.DoDragDrop(); // Effectuer l'opération de D&D

  event.Skip();


/*
  wxDropSource source(textData, this,
                      wxDROP_ICON(dnd_copy),
                      wxDROP_ICON(dnd_move),
                      wxDROP_ICON(dnd_none));
                      */
  /*
  wxDropSource source(textData, this);

  //int flags = 0;

  wxDragResult result = source.DoDragDrop();
  */

}
Exemple #29
0
void CCWTreeCtrl::CollapseBranch(HTREEITEM hItem)
{
  // Courtesy of Zafir Anjumfrom www.codeguru.com
  if (ItemHasChildren(hItem)) {
    Expand(hItem, TVE_COLLAPSE);
    hItem = GetChildItem(hItem);
    do {
      CollapseBranch(hItem);
    } while((hItem = GetNextSiblingItem(hItem)) != NULL);
  }
}
Exemple #30
0
void duTreeCtrl::OnMouseMove(POINT pt)
{
	duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd);
	duRect rcTreeCtrl;
	Plugin_GetRect(this, &rcTreeCtrl);

	duRect rcItem;
	rcItem.SetRectEmpty();
	TreeCtrlItem *pItem = yHitTest(rcTreeCtrl, pt, rcItem);
	if (m_pHot != pItem)
	{
		m_pHot = pItem;
		Plugin_Redraw(this, TRUE);
		if(m_fShowTooltip)
		{
			pCtrlManager->DelToolTip();
			m_fShowTooltip = FALSE;
		}
	}
	
	if (pItem == NULL)
	{
		m_hitCode = tc_hit_empty;
		if(m_fShowTooltip)
		{
			pCtrlManager->DelToolTip();
			m_fShowTooltip = FALSE;
		}
	}
	else
	{
		POINT ptClient(pt);
		ptClient.x -= rcTreeCtrl.left;
		ptClient.y -= rcTreeCtrl.top;
		
		int nLeft = (pItem->nLevel - 1) * m_nIndentWidth;
		duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight);
		if (ItemHasChildren(pItem) && (rcIndent.PtInRect(ptClient)))
			m_hitCode = tc_hit_indent;

		nLeft += (m_nIndentWidth + m_nIndentIconSpace);
		duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight);
		if (rcIcon.PtInRect(ptClient))
			m_hitCode = tc_hit_icon;

		duRect rcText;
		nLeft += (m_nIconWidth + m_nIconTextSpace);
		rcText = rcItem;
		rcText.left = rcItem.left + nLeft;
		if (rcText.PtInRect(ptClient))
			m_hitCode = tc_hit_text;
	}
}