Esempio n. 1
0
int wxSTEditorTreeCtrl::DeleteItem(const wxTreeItemId& id_, bool delete_empty,
                                   int levels, const wxTreeItemId& topId)
{
    int n = 0;
    wxTreeItemId id = id_;

    if (!id)
        return 0;
    else if (!delete_empty)
    {
        if (id == m_notePageId) m_notePageId = wxTreeItemId();

        Delete(id);
        n++;
    }
    else
    {
        // back up the tree and delete all parents that have no other children
        wxTreeItemId parentId_last;
        wxTreeItemId parentId = GetItemParent(id);
        wxTreeItemId rootId = GetRootItem();
        if (id == m_notePageId) m_notePageId = wxTreeItemId();
        Delete(id);
        n++;

        while( parentId && (parentId != rootId) && (parentId != topId) &&
               ((n <= levels) || (levels == -1)))
        {
            unsigned int child_count = GetChildrenCount(parentId, false);

            if (child_count <= 1)
            {
                // verify that if a single child that it's not a file
                if (child_count == 1)
                {
                    wxTreeItemIdValue cookie;
                    wxTreeItemId childId = GetFirstChild(parentId, cookie);
                    wxSTETreeItemData* itemData = (wxSTETreeItemData*)GetItemData(childId);
                    if (itemData && (itemData->m_page_num != -1))
                        break;
                }

                // no other children in this node, try next parent
                parentId_last = parentId;
                parentId = GetItemParent(parentId);
                n++;
            }
            else
                break;
        }

        if (parentId_last)
        {
            if (parentId_last == m_notePageId) m_notePageId = wxTreeItemId();
            Delete(parentId_last);
        }
    }

    return n;
}
Esempio n. 2
0
wxString CLocalTreeView::GetDirFromItem(wxTreeItemId item)
{
	const wxString separator = wxFileName::GetPathSeparator();
	wxString dir;
	while (item)
	{
#ifdef __WXMSW__
		if (item == m_desktop)
		{
			wxChar path[MAX_PATH + 1];
			if (SHGetFolderPath(0, CSIDL_DESKTOPDIRECTORY, 0, SHGFP_TYPE_CURRENT, path) != S_OK)
			{
				if (SHGetFolderPath(0, CSIDL_DESKTOP, 0, SHGFP_TYPE_CURRENT, path) != S_OK)
				{
					wxMessageBox(_("Failed to get desktop path"));
					return _T("/");
				}
			}
			dir = path;
			if (dir.Last() != separator)
				dir += separator;
			return dir;
		}
		else if (item == m_documents)
		{
			wxChar path[MAX_PATH + 1];
			if (SHGetFolderPath(0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, path) != S_OK)
			{
				wxMessageBox(_("Failed to get 'My Documents' path"));
				return _T("/");
			}
			dir = path;
			if (dir.Last() != separator)
				dir += separator;
			return dir;
		}
		else if (item == m_drives)
			return _T("/");
		else if (GetItemParent(item) == m_drives)
		{
			wxString text = GetItemText(item);
			int pos = text.Find(_T(" "));
			if (pos == -1)
				return text + separator + dir;
			else
				return text.Left(pos) + separator + dir;
		}
		else
#endif
		if (item == GetRootItem())
			return _T("/") + dir;

		dir = GetItemText(item) + separator + dir;

		item = GetItemParent(item);
	}

	return separator;
}
Esempio n. 3
0
void               P3DPlantModelTreeCtrl::OnSetStemModelWingsClick
                                      (wxCommandEvent     &event)
 {
  P3DBranchModel                      *BranchModel;
  P3DBranchModel                      *ParentBranchModel;
  const P3DStemModelTube              *ParentStemModel;
  P3DStemModel                        *StemModel;
  P3DBranchingAlg                     *BranchingAlg;
  wxTreeItemId                         ParentId;

  ParentId = GetItemParent(GetSelection());

  if (!ParentId.IsOk())
   {
    return;
   }

  ParentBranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(ParentId)))->GetBranchModel();
  ParentStemModel   = dynamic_cast<const P3DStemModelTube*>(ParentBranchModel->GetStemModel());

  if (ParentStemModel == 0)
   {
    return;
   }

  BranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(GetSelection())))->GetBranchModel();

  StemModel    = new P3DStemModelWings(ParentStemModel);
  BranchingAlg = new P3DBranchingAlgWings();

  unsigned int SubBranchIndex;
  wxTreeItemId ItemId;
  wxTreeItemId ParentItemId;

  SubBranchIndex = 0;
  ItemId         = GetSelection();
  ParentItemId   = GetItemParent(ItemId);

  while ((ItemId = GetPrevSibling(ItemId)).IsOk())
   {
    SubBranchIndex++;
   }

  P3DApp::GetApp()->ExecEditCmd
   (new ChangeStemModelCommand
         (ParentBranchModel,
          SubBranchIndex,
          BranchModel,
          StemModel,
          BranchingAlg,
          this,
          BranchPanel));
 }
Esempio n. 4
0
bool DirectoryTree::IsAncestorOf(wxTreeItemId tidPutativeAncestor, wxTreeItemId tid)
  {
  wxLogTrace(DIRECTORYTREE_EVENTS, wxT("IsAncestorOf(%u, %u)"), (int) tidPutativeAncestor, (int) tid);
  wxTreeItemId tidParent = GetItemParent(tid);
  while(tidParent.IsOk())
    {
    wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tParent: %u"), (int) tidParent);
    if(tidParent == tidPutativeAncestor)
      return true;
    tidParent = GetItemParent(tidParent);
    }
  return false;
  }
wxTreeItemId ComponentTreeCtrl::get_CompId(wxTreeItemId itemid)
{ /* returns the ItemId of the ComponentPackage */
 
	
	while (GetItemParent(itemid)!=GetRootItem())
	{
		itemid=GetItemParent(itemid);
		
	}

	return itemid;

}
Esempio n. 6
0
void               P3DPlantModelTreeCtrl::OnRemoveStemClick
                                      (wxCommandEvent     &event)
 {
  P3DBranchModel  *BranchModel;
  P3DBranchModel  *ParentBranchModel;
  wxTreeItemId     ParentId;
  wxTreeItemId     ItemId;
  wxTreeItemId     CurrItemId;
  unsigned int     SubBranchIndex;

  ItemId   = GetSelection();
  ParentId = GetItemParent(ItemId);

  if (!ParentId.IsOk())
   {
    return;
   }

  SubBranchIndex = 0;

  CurrItemId = ItemId;

  while (CurrItemId.IsOk())
   {
    SubBranchIndex++;
    CurrItemId = GetPrevSibling(CurrItemId);
   }

  ParentBranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(ParentId)))->GetBranchModel();

  P3DApp::GetApp()->ExecEditCmd
   (new P3DRemoveStemCommand(ParentBranchModel,SubBranchIndex - 1,this));
 }
Esempio n. 7
0
void wxTreeListCtrl::UpdateItemParentStateRecursively(wxTreeListItem item)
{
    wxCHECK_RET( item.IsOk(), "Invalid item" );

    wxASSERT_MSG( HasFlag(wxTL_3STATE), "Can only be used with wxTL_3STATE" );

    for ( ;; )
    {
        wxTreeListItem parent = GetItemParent(item);
        if ( parent == GetRootItem() )
        {
            // There is no checked state associated with the root item.
            return;
        }

        // Set parent state to the state of this item if all the other children
        // have the same state too. Otherwise make it indeterminate.
        const wxCheckBoxState stateItem = GetCheckedState(item);
        CheckItem(parent, AreAllChildrenInState(parent, stateItem)
                            ? stateItem
                            : wxCHK_UNDETERMINED);

        // And do the same thing with the parent's parent too.
        item = parent;
    }
}
Esempio n. 8
0
CServerPath CRemoteTreeView::GetPathFromItem(const wxTreeItemId& item) const
{
	std::list<wxString> segments;

	wxTreeItemId i = item;
	while (i != GetRootItem())
	{
		const CItemData* const pData = (const CItemData*)GetItemData(i);
		if (pData)
		{
			CServerPath path = pData->m_path;
			for (std::list<wxString>::const_iterator iter = segments.begin(); iter != segments.end(); ++iter)
			{
				if (!path.AddSegment(*iter))
					return CServerPath();
			}
			return path;
		}

		segments.push_front(GetItemText(i));
		i = GetItemParent(i);
	}

	return CServerPath();
}
bool CocaSystemTree::moveDown( const coca::INode& node )
{
    wxTreeItemId id = findId( node );
    if ( !id.IsOk() ) { return false; }

    wxTreeItemId parentId = GetItemParent( id );
    if ( !parentId.IsOk() ) { return false; }

    wxTreeItemId nextId = GetNextSibling( id );
    if ( !nextId.IsOk() ) { return false; }

    // ready to move
    bool wasSelected = ( id == GetSelection() );

    Delete( id );
    id = InsertItem( parentId, nextId,
                         EditorTools::getName( node ), EditorTools::getImageIndex( node ),
                         -1, new ItemData( node ) );
    COCA_ASSERT( id.IsOk() );
    SetItemTextColour( id, EditorTools::getTextColour( node ) );

    addChildren( node, id );

    if ( wasSelected ) { SelectItem( id ); }

    return true;
}
Esempio n. 10
0
void               P3DPlantModelTreeCtrl::OnSetStemModelQuadClick
                                      (wxCommandEvent     &event)
 {
  P3DBranchModel                      *BranchModel;
  P3DStemModel                        *StemModel;

  BranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(GetSelection())))->GetBranchModel();

  StemModel = P3DApp::GetApp()->CreateStemModelQuad();

  unsigned int SubBranchIndex;
  wxTreeItemId ItemId;
  wxTreeItemId ParentItemId;

  SubBranchIndex = 0;
  ItemId         = GetSelection();
  ParentItemId   = GetItemParent(ItemId);

  while ((ItemId = GetPrevSibling(ItemId)).IsOk())
   {
    SubBranchIndex++;
   }

  P3DApp::GetApp()->ExecEditCmd
   (new ChangeStemModelCommand
         (GetBranchModelByItemId(ParentItemId),
          SubBranchIndex,
          BranchModel,
          StemModel,
          (ParentItemId == GetRootItem()) ?
           (P3DBranchingAlg*)new P3DBranchingAlgBase() :
           (P3DBranchingAlg*)new P3DBranchingAlgStd(),
          this,
          BranchPanel));
 }
Esempio n. 11
0
wxTreeItemId PHPFileLayoutTree::TryGetPrevItem(wxTreeItemId item)
{
    wxCHECK_MSG(item.IsOk(), wxTreeItemId(), wxT("invalid tree item"));

    // find out the starting point
    wxTreeItemId prevItem = GetPrevSibling(item);
    if(!prevItem.IsOk()) {
        prevItem = GetItemParent(item);
        if(prevItem == GetRootItem()) {
            return wxTreeItemId();
        }
    }

    // from there we must be able to navigate until this item
    while(prevItem.IsOk()) {

        ScrollTo(prevItem);

        if(!IsVisible(prevItem)) {
            return wxTreeItemId();
        }

        const wxTreeItemId nextItem = GetNextVisible(prevItem);
        if(!nextItem.IsOk() || nextItem == item) return prevItem;

        prevItem = nextItem;
    }

    return wxTreeItemId();
}
Esempio n. 12
0
void SessionTreeControl::removeSession( std::string address )
{
    wxTreeItemId item = findSession( rootID, address );
    if ( !item.IsOk() )
    {
        gravUtil::logWarning( "SessionTreeControl::removeObject: "
                "item %s not found?\n", address.c_str() );
        return;
    }

    SessionType type;
    wxTreeItemId parent = GetItemParent( item );

    if ( parent == videoNodeID )
        type = VIDEOSESSION;
    else if ( parent == audioNodeID )
        type = AUDIOSESSION;
    else if ( parent == availableVideoNodeID )
        type = AVAILABLEVIDEOSESSION;
    else
    {
        gravUtil::logError( "SessionTreeControl::removeObject: "
                    "cannot remove %s - invalid tree\n", address.c_str() );
        return;
    }

    if ( sessionManager->removeSession( address, type ) )
        Delete( item );
    else
    {
        gravUtil::logError( "SessionTreeControl::removeObject: "
                        "removal of %s failed \n", address.c_str() );
        // TODO throw GUI error dialog
    }
}
Esempio n. 13
0
void wxTreeViewComboPopup::OnMouseClick(wxMouseEvent& event)
{
    m_bClicked = true;
    wxTreeItemId ItemId = GetSelection();
	if(ItemId.IsOk())
    {
        if(m_PrewItemId.IsOk())
        {
            CollapseAllChildren(GetItemParent(m_PrewItemId));
        }
        if(ItemId != GetRootItem())
        {
            CollapseAllChildren(ItemId);
        }
        else
        {
            CollapseAll();
            Expand(GetRootItem());
        }

	    wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(ItemId);
	    if(pData != NULL)
	    {
            SelectItem(ItemId);
		    m_pSelection->Select(pData->m_nObjectID, false, GetId());
            m_PrewItemId = ItemId;
	    }
    }
    Dismiss();

    event.Skip(true);
}
Esempio n. 14
0
void CppSymbolTree::AdvanceSelection(bool forward)
{
    wxTreeItemId item = GetSelection();
    if (!item.IsOk()) {
        return;
    }

    wxTreeItemId nextItem;
    if (forward) {
        nextItem = GetNextVisible(item);
        if ( !nextItem.IsOk() ) {
            // we could not get the next visible, try the next sibling
            nextItem = GetNextSibling(item);
            if ( !nextItem.IsOk() ) {
                // we are the last child... try the sibling of our parent
                wxTreeItemId parent = GetItemParent(item);
                if ( !parent.IsOk() ) {
                    return;
                }
                nextItem = GetNextSibling(parent);
            }
        }
        
    } else {
        nextItem = TryGetPrevItem(item);
    }

    if (nextItem.IsOk()) {
        SelectItem(nextItem);
    }
}
Esempio n. 15
0
void wxSpinTreeCtrl::addToTree(spin::ReferencedNode *n)
{
    wxTreeItemId nodeInTree = GetTreeItem(n);
    if (nodeInTree)
    {
        // If node is already in the tree, we check to see if the parent has
        // changed. If it has, we remove it first
        wxTreeItemId parentTreeItem = GetTreeItem(n->getParent());
        if (parentTreeItem == GetItemParent(nodeInTree))
        {
            // the parent in the tree is already correct, so we don't need to do
            // anything
            std::cout << "Warning (wxSpinTreeCtrl::addToTree). Node " << n->getID() << " already exists in tree." << std::endl;
        }
        else
        {
            // The node in the tree has the wrong parent, so we need to first
            // remove the node from the tree, before we can add it to the proper
            // parent.
            Freeze();
            Delete(nodeInTree);
            Thaw();
        }
    }

    wxTreeItemId parentTreeItem = GetTreeItem(n->getParent());
    if (parentTreeItem)
        addToTree(n,parentTreeItem);
    else
        addToTree(n,GetRootItem());
}
Esempio n. 16
0
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);
}
Esempio n. 17
0
bool CLocalTreeView::CheckSubdirStatus(wxTreeItemId& item, const wxString& path)
{
	wxTreeItemIdValue value;
	wxTreeItemId child = GetFirstChild(item, value);

	static const wxLongLong size(-1);

#ifdef __WXMAC__
	// By default, OS X has a list of servers mounted into /net,
	// listing that directory is slow.
	if (GetItemParent(item) == GetRootItem() && (path == _T("/net") || path == _T("/net/")))
	{
			CFilterManager filter;

			const int attributes = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
			if (!filter.FilenameFiltered(_T("localhost"), path, true, size, true, attributes))
			{
				if (!child)
					AppendItem(item, _T(""));
				return true;
			}
	}
#endif

	if (child)
	{
		if (GetItemText(child) != _T(""))
			return false;

		CTreeItemData* pData = (CTreeItemData*)GetItemData(child);
		if (pData)
		{
			bool wasLink;
			int attributes;
			enum CLocalFileSystem::local_fileType type;
			if (path.Last() == CLocalFileSystem::path_separator)
				type = CLocalFileSystem::GetFileInfo(path + pData->m_known_subdir, wasLink, 0, 0, &attributes);
			else
				type = CLocalFileSystem::GetFileInfo(path + CLocalFileSystem::path_separator + pData->m_known_subdir, wasLink, 0, 0, &attributes);
			if (type == CLocalFileSystem::dir)
			{
				CFilterManager filter;
				if (!filter.FilenameFiltered(pData->m_known_subdir, path, true, size, true, attributes))
					return true;
			}
		}
	}

	wxString sub = HasSubdir(path);
	if (sub != _T(""))
	{
		wxTreeItemId subItem = AppendItem(item, _T(""));
		SetItemData(subItem, new CTreeItemData(sub));
	}
	else if (child)
		Delete(child);

	return true;
}
Esempio n. 18
0
wxTreeItemId
SamplesTreeCtrl::getSpeaker( const wxTreeItemId &speech ) const
{
	wxTreeItemId parentItem = GetItemParent( speech );
	while ( true )
	{
		if ( parentItem.IsOk() )
		{
			if ( GetItemData( parentItem ) == NULL )
				return parentItem;
		}
		else
			return parentItem;

		parentItem = GetItemParent( parentItem );
	}
}
Esempio n. 19
0
void ctlCheckTreeView::SetParentImage(wxTreeItemId node, int newimage)
{
	if (node.IsOk())
	{
		SetItemImage(node, newimage);
		SetParentImage(GetItemParent(node), newimage);
	}
}
Esempio n. 20
0
wxTreeItemId CConfigTree::FindNextItemId(wxTreeItemId treeItemId, const wxString& text,
    bool checkFirst, bool matchCase, bool matchWord)
{
    wxString ctext(text);
    if (!matchCase) {
        ctext.MakeLower();
    }

    wxTreeItemId found;
    wxTreeItemId id;
    wxTreeItemId currentId = treeItemId;
    CConfigItem *item = NULL;
    wxTreeItemIdValue dummy;

    while (currentId.IsOk()) {
        if (checkFirst) {
            CTreeItemData *data = (CTreeItemData *)GetItemData(currentId);
            if (data) {
                if ((item = data->GetConfigItem()) != NULL) {
                    wxString name = item->GetName();
                    wxString brief = item->GetBriefDescription();
                    wxString desc = item->GetDescription();

                    if (!matchCase) {
                        name.MakeLower();
                        brief.MakeLower();
                        desc.MakeLower();
                    }
                    if (CUtils::FindString(name, ctext, matchWord) ||
                        CUtils::FindString(brief, ctext, matchWord) ||
                        CUtils::FindString(desc, ctext, matchWord)) {
                        found = currentId;
                        break;
                    }
                }
            }
        }
        checkFirst = true;

        id = GetFirstChild(currentId, dummy);
        if (!id.IsOk()) {
            id = GetNextSibling(currentId);
            if (!id.IsOk()) {
                wxTreeItemId parentId = currentId;
                do {
                    parentId = GetItemParent(parentId);
                    if (!parentId.IsOk()) {
                        break;
                    }
                    id = GetNextSibling(parentId);
                } while (!id.IsOk());
            }
        }
        currentId = id;
    }
    return found;
}
void PartitioningTreeCtrl::onregister_at_name_service(wxCommandEvent& event)
{

	// opens dialog
	// request full scoped Naming Context name to register at
	wxString ns_name = wxGetTextFromUser("Enter a name for registering at Name Service","Register at NameService",
	"", this,-1,-1,TRUE);
	wxString text="NameService: ";
	text.Append(ns_name);

	// add name to tree
	wxTreeItemId itemid = AppendItem(GetSelection(),text,
		TreeCtrlIcon_Folder,TreeCtrlIcon_FolderSelected,NULL);
	Expand(GetRootItem());
	Refresh();
	ItemTyp itype;
	itype.itemid=itemid;
	itype.type=registration;
	itype.usagename=ns_name;

	itemtypes.push_back(itype);

	// add information to instance or port

	ElementType etype=GetType(GetSelection());
	
	if (etype==inst) {
		// get instance
		Instantiation curr_instance = get_Instantiation(GetSelection());

		// add register Info to instance
		curr_instance.component_registration = ns_name;
		replace_Instantiation(curr_instance);				

	}

	if (etype==facet) {
		// get instance
		Instantiation curr_instance = get_Instantiation(GetItemParent(GetSelection()));


		// create new facet-registration
		PartitioningTreeCtrl::ItemTyp  facet_item = GetItemInfo(GetSelection());
		FacetRegistration fr;
		fr.facet_name = facet_item.usagename;
		fr.ns_name = ns_name;
		// add register Info to instance
		
		curr_instance.facet_registrations.push_back(fr);

		replace_Instantiation(curr_instance);				

	}


}
Esempio n. 22
0
bool svSymbolTree::IsSelectedItemIncludeFile()
{
    wxTreeItemId item = GetSelection();
    if(item.IsOk() == false || item == GetRootItem()) return false;

    wxTreeItemId parent = GetItemParent(item);
    if(parent.IsOk() == false || parent == GetRootItem()) return false;

    return GetItemText(parent) == INCLUDE_FILES_NODE_TEXT;
}
Esempio n. 23
0
void               P3DPlantModelTreeCtrl::OnAppendBranchNewClick
                                      (wxCommandEvent     &event)
 {
  P3DBranchModel                      *ParentBranchModel;
  P3DBranchModel                      *ChildBranchModel;

  ParentBranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(GetSelection())))->GetBranchModel();

  ChildBranchModel = new P3DBranchModel();

  ChildBranchModel->SetName
   (GenerateClonedBranchName
     (P3DApp::GetApp()->GetModel(),ParentBranchModel).c_str());

  P3DStemModelTube *StemModel = P3DApp::GetApp()->CreateStemModelTube();
  unsigned int      Level     = 0;

  for (wxTreeItemId ItemId  = GetSelection();
                    ItemId != GetRootItem();
                    ItemId  = GetItemParent(ItemId))
   {
    Level++;
   }

  if      (Level == 0)
   {
    StemModel->SetProfileResolution(P3DApp::GetApp()->GetModelPrefs().TubeCrossSectResolution[0]);
   }
  else if (Level == 1)
   {
    StemModel->SetProfileResolution(P3DApp::GetApp()->GetModelPrefs().TubeCrossSectResolution[1]);
   }
  else
   {
    StemModel->SetProfileResolution(P3DApp::GetApp()->GetModelPrefs().TubeCrossSectResolution[2]);
   }

  ChildBranchModel->SetStemModel(StemModel);

  if (GetSelection() == GetRootItem())
   {
    ChildBranchModel->SetBranchingAlg(new P3DBranchingAlgBase());
   }
  else
   {
    ChildBranchModel->SetBranchingAlg(P3DApp::GetApp()->CreateBranchingAlgStd());
   }

  ChildBranchModel->SetMaterialInstance(P3DApp::GetApp()->CreateMatInstanceStd());

  P3DApp::GetApp()->ExecEditCmd
   (new AppendBranchCommand(ParentBranchModel,ChildBranchModel,this));
 }
Esempio n. 24
0
void               P3DPlantModelTreeCtrl::OnSetStemModelGMeshClick
                                      (wxCommandEvent     &event)
 {
  wxTreeItemId                         ItemId;
  wxTreeItemId                         ParentItemId;
  P3DBranchModel                      *BranchModel;
  P3DBranchModel                      *NewBranchModel;
  P3DStemModelGMesh                   *StemModel;
  int                                  PluginIndex;
  const P3DPluginInfoVector           &GMeshPlugins = P3DApp::GetApp()->GetGMeshPlugins();
  unsigned int                         SubBranchIndex;

  PluginIndex = event.GetId() - wxID_GMESH_PLUGIN_FIRST;

  if ((PluginIndex < 0) || (PluginIndex >= GMeshPlugins.size()))
   {
    return;
   }

  ItemId       = GetSelection();
  ParentItemId = GetItemParent(ItemId);

  BranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(ItemId)))->GetBranchModel();

  P3DGMeshData *MeshData = P3DPlugLuaRunGMeshGenerator(GMeshPlugins[PluginIndex].GetFileName());

  if (MeshData == 0)
   {
    return;
   }

  StemModel = new P3DStemModelGMesh();
  StemModel->SetMeshData(MeshData);

  SubBranchIndex = 0;

  while ((ItemId = GetPrevSibling(ItemId)).IsOk())
   {
    SubBranchIndex++;
   }

  P3DApp::GetApp()->ExecEditCmd
   (new ChangeStemModelCommand
         (GetBranchModelByItemId(ParentItemId),
          SubBranchIndex,
          BranchModel,
          StemModel,
          (ParentItemId == GetRootItem()) ?
           (P3DBranchingAlg*)new P3DBranchingAlgBase() :
           (P3DBranchingAlg*)new P3DBranchingAlgStd(),
          this,
          BranchPanel));
 }
Esempio n. 25
0
void WatchWindow::OnBeginLabelEdit(wxTreeEvent& event)
{
    
    if (GetItemParent(event.GetItem()) == m_root)
    {
        m_editing = true;
    }    
    else
    {
        event.Veto();
    }
        
}
Esempio n. 26
0
void V4StudioTree::OnEndDrag(wxTreeEvent& event)
{
    wxTreeItemId itemSrc = m_draggedItem, itemDst = event.GetItem(), dstParentItem = GetItemParent(itemDst);
    m_draggedItem = (wxTreeItemId)0l;

	V4StudioTreeItemData *srcData = (V4StudioTreeItemData *)GetItemData(itemSrc);
	GF_FieldInfo srcField;
	srcData->GetField(&srcField);
	// Removal of the src item from its parent field
	switch (srcField.fieldType) {
	case GF_SG_VRML_SFNODE:
		if (* (GF_Node **) srcField.far_ptr) {}
		break;
	case GF_SG_VRML_MFNODE:
		{
			GF_List *nodes = (* (GF_List **) srcField.far_ptr);
			gf_list_rem(nodes, srcData->GetPosition());
		}
		break;
	default:
		break;
	}

	GF_Node *srcNode = srcData->GetNode();
	GF_FieldInfo dstField;
	V4StudioTreeItemData *dstData = (V4StudioTreeItemData *)GetItemData(itemDst);
	dstData->GetField(&dstField);
	// Addition of the src item prior to the dest item
	switch (dstField.fieldType) {
	case GF_SG_VRML_SFNODE:
		if (* (GF_Node **) dstField.far_ptr) {}
		break;
	case GF_SG_VRML_MFNODE:
		{
			GF_List *nodes = (* (GF_List **) dstField.far_ptr);
			gf_list_insert(nodes, srcNode, dstData->GetPosition());
			gf_node_dirty_set(dstData->GetNode(), 0, 1);
		}
		break;
	default:
		break;
	}

	GF_Node *dstParentNode = dstData->GetNodeParent();
	
	Delete(itemSrc);
	AddNodesToItem(dstParentItem, srcNode, dstData->GetFieldIndex(), dstData->GetPosition());
	V4StudioFrame *mainFrame = (V4StudioFrame *)GetParent();
	mainFrame->UpdateSelection(srcNode,dstData->GetNodeParent());
	mainFrame->Update();
}
Esempio n. 27
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;
	}
}
Esempio n. 28
0
void CLocalTreeView::OnMenuDelete(wxCommandEvent& event)
{
	if (!m_contextMenuItem.IsOk())
		return;

	wxString path = GetDirFromItem(m_contextMenuItem);

	CLocalPath local_path(path);
	if (!local_path.HasParent() || !local_path.IsWriteable())
		return;

	if (!CLocalFileSystem::RecursiveDelete(path, this))
		wxGetApp().DisplayEncodingWarning();

	wxTreeItemId item = GetSelection();
	while (item && item != m_contextMenuItem)
		item = GetItemParent(item);

	if (!item)
	{
		if (GetItemParent(m_contextMenuItem) == GetSelection())
			m_pState->RefreshLocal();
		else
			Refresh();
		return;
	}

	if (path.Last() == wxFileName::GetPathSeparator())
		path.RemoveLast();
	int pos = path.Find(wxFileName::GetPathSeparator(), true);
	if (pos < 1)
		path = _T("/");
	else
		path = path.Left(pos);

	m_pState->SetLocalDir(path);
	Refresh();
}
Esempio n. 29
0
wxArrayString wxSTEditorTreeCtrl::GetItemPath(const wxTreeItemId& id_)
{
    wxArrayString pathArray;

    wxTreeItemId rootId = GetRootItem();
    if (!rootId)
        return pathArray;

    for (wxTreeItemId id = id_; id && (id != rootId); id = GetItemParent(id))
    {
        pathArray.Insert(GetItemText(id), 0);
    }

    return pathArray;
}
Esempio n. 30
0
void DirectoryTree::RemoveItem(const wxString& sPath)
  {
  // Find the item
  wxTreeItemId tidToWastebin = GetItemFromPath(sPath, false);
  if(!tidToWastebin.IsOk())
    {
    wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tNothing to remove."));
    return;
    }
  
  wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetItemFromPath('%s') returned %u"), sPath.c_str(), (int) tidToWastebin);
	// Sort out the new selection
  wxTreeItemId tidSelection = GetSelection();
  if(!tidSelection.IsOk())
    // FIXME: Should throw exception
    return;

  wxTreeItemId tidNewSelection;
  if(tidSelection == tidToWastebin)
    tidNewSelection = GetItemParent(tidSelection);
  else
    {
		// If we are in or below the path, climb up to directory above
    bool bIsParent = IsAncestorOf(tidToWastebin, tidSelection);
    wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tIsAncestorOf() returned %u"), bIsParent);
    if(bIsParent)
      tidNewSelection = GetItemParent(tidSelection);
    }

  // Remove item
  Delete(tidToWastebin);

  // Re select if necessary
  if(tidNewSelection.IsOk())
    DoSelection(tidNewSelection);
	}