Example #1
0
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);
}
Example #2
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());
}
Example #3
0
bool wxSpinTreeCtrl::SelectNode(spin::ReferencedNode* pNode)
{
    // there should always be at least one node (the scene root). If not, return
    // because this is a problem.
    if (GetCount() == 0)
        return false;

    // if pNode is NULL, we select the scene root
    if (! pNode)
    {
        SelectItem(GetRootItem());
        UpdatePropGrid();
    }

    // if the node is already selected, don't do anything
    if (pNode == GetSelectedNode())
        return true;

    wxTreeItemId id = GetTreeItem(pNode);
    if (id)
    {
        SelectItem(id);
        UpdatePropGrid();
        return true;
    }
    // couldn't find the node, so return false
    return false;
}
Example #4
0
BOOL CMySuperGrid::OnItemLButtonDown(LVHITTESTINFO& ht)
{
	if(ht.iItem!=-1)
	{
#ifdef _WHAT_EVER_
		CTreeItem*pSelItem = GetTreeItem(ht.iItem);
		if(pSelItem!=NULL)
		{	
			CItemInfo* pInfo = GetData(pSelItem);
			if((ht.iSubItem==0) && (pInfo->GetItemText()==CString(_T("Hello World"))))
			{
				AfxMessageBox("no can do buddy");
				return 0;
			}

			for(int i=0;i<pInfo->GetItemCount(); i++)
			{
				if(i==ht.iSubItem-1)
				{
					CString str=pInfo->GetSubItem(i);
					if(str == CString(_T("Ethan Hunt"))) 
					{
						AfxMessageBox("Tom Cruise\nliked him in a few good men");
						return 0;
					}
				}
			}
		}
#endif
	}
	return 1;
}
Example #5
0
//HOWTO: 
void CMySuperGrid::HowToInsertItemsAfterTheGridHasBeenInitialized(int nIndex, const CString& str)
{
	CTreeItem *pSelItem = GetTreeItem(nIndex);
	if(pSelItem != NULL)
	{
		SetRedraw(0);
		BOOL bUpdate = FALSE;
		if(!IsCollapsed(pSelItem))
			bUpdate = TRUE;//Children are expanded, want to see update right away if not no visual update

		CItemInfo* lpRelative = new CItemInfo();
		lpRelative->SetItemText(str);
		lpRelative->AddSubItemText(_T("I am"));
		lpRelative->AddSubItemText(_T("now"));
		lpRelative->AddSubItemText(_T("going to insert"));
		lpRelative->AddSubItemText(_T("some items"));

		CTreeItem* pParent = InsertItem(pSelItem, lpRelative, bUpdate);
		for(int i=0; i < GetNumCol(); i++)
		{
			CItemInfo* lpItemInfo = new CItemInfo();
			CString strItem;
			strItem.Format(_T("Item %d"), i);
			//add items text
			lpItemInfo->SetItemText(strItem);
			//add subitem text
			for(int y=0;y < GetNumCol()-1; y++) 
			{
				CString str;
				str.Format(_T("SubItem %d of %s"), y, lpItemInfo->GetItemText());
				lpItemInfo->AddSubItemText(str);
			}
			//set combobox in last col
			lpItemInfo->SetControlType(lpItemInfo->CONTROLTYPE::combobox, GetNumCol()-2);
			CStringList list;
			for(int x = 0; x < 3; x++)
			{
				CString str;
				str.Format("ListItem %d",x);
				list.AddTail(str);
			}
			lpItemInfo->SetListData(GetNumCol()-2, &list);

			InsertItem(pParent, lpItemInfo);
		}
		SetRedraw(1);
		InvalidateRect(NULL);
		UpdateWindow();
	}
}
Example #6
0
ecConfigItem *ecConfigItem::NextSibling() const
{ 
    ecConfigTreeCtrl* treeCtrl = wxGetApp().GetTreeCtrl();

    wxTreeItemId hChild=treeCtrl->GetNextSibling(GetTreeItem());
    if (hChild)
    {
        ecTreeItemData* data = (ecTreeItemData*) wxGetApp().GetTreeCtrl()->GetItemData(hChild);
        wxASSERT(data);

        return data->GetConfigItem();
    }
    else
        return NULL;
}
Example #7
0
void wxSpinTreeCtrl::removeNode(const char *id)
{
    // if the node to be removed is currently selected, then select NULL (root)
    spin::ReferencedNode* n = GetSelectedNode();
    if (n && strcmp(n->id->s_name,id)==0)
    {
        SelectNode(NULL);
    }
    // We need to find the node based on the string id provided:
    wxTreeItemId nodeInTree = GetTreeItem(id);
    if (nodeInTree)
    {
        Freeze();
        Delete(nodeInTree);
        Thaw();
    }
}
Example #8
0
ecConfigItem *ecConfigItem::FirstChild() const
{ 
    ecConfigTreeCtrl* treeCtrl = wxGetApp().GetTreeCtrl();

#if wxCHECK_VERSION(2, 6, 0)
		wxTreeItemIdValue cookie;
#else
        long cookie;
#endif
    wxTreeItemId hChild=treeCtrl->GetFirstChild(GetTreeItem(), cookie);
    if (hChild)
    {
        ecTreeItemData* data = (ecTreeItemData*) wxGetApp().GetTreeCtrl()->GetItemData(hChild);
        wxASSERT(data);

        return data->GetConfigItem();
    }
    else
        return NULL;
}
Example #9
0
int CVICALLBACK OpenProjectConfirm (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			int i, checked;
/*			for (i = 0; i < projectlist.number; i++)
			{
				IsListItemChecked(panel_open,OPPANEL_TREE_ProjectList,i,&checked);
				if (checked)
				{
					MessagePopup("Number of Projects","checked");
					operatingproject = projectlist.projects[i];
					break;
				}
			}*/
			GetTreeItem(panel_open,OPPANEL_TREE_ProjectList,VAL_ALL,0,0,VAL_NEXT_PLUS_SELF,VAL_SELECTED,&i);
			if (i == -1)
			{
				MessagePopup("打开时出错!","请选中某项后再点击打开按钮");
				return -1;
			}
			if (state_open == 1)
			{
				operatingproject = projectlist.projects[i];
				getDetails(&operatingproject);
				openproject();
			}
			else
			{
				operatinggroupnum = i+1;
				openmeasuregroup();
			}
			HidePanel (panel_open);
			state_open = 0;
			DisplayPanel (panel_main);
			break;
	}
	return 0;
}
Example #10
0
//override called when OnLButtondown
void CMySuperGrid::OnControlLButtonDown(UINT nFlags, CPoint point, LVHITTESTINFO& ht)
{
	//now I am sure I added a combobox some where, so check for this control
	CTreeItem*pSelItem = GetTreeItem(ht.iItem);
	if(pSelItem!=NULL)
	{	
		CItemInfo* pInfo = GetData(pSelItem);
		CItemInfo::CONTROLTYPE ctrlType;
		if(pInfo->GetControlType(ht.iSubItem-1, ctrlType))
		{	
			if(ctrlType==pInfo->CONTROLTYPE::combobox) 
			{
					CStringList* list=NULL;
					pInfo->GetListData(ht.iSubItem-1, list);
					CComboBox * pList = ShowList(ht.iItem, ht.iSubItem, list);
			}
		}								
		/*
		else //activate default edit control
			CSuperGridCtrl::OnControlLButtonDown(nFlags, point, ht);
		*/
	}
}
Example #11
0
BOOL CMySuperGrid::OnVkReturn()
{
	BOOL bResult=FALSE;
	int iItem = GetNextItem( -1, LVNI_ALL | LVNI_SELECTED);
	if( GetCurSubItem() != -1 && iItem != -1)
	{
		CTreeItem*pSelItem = GetTreeItem(iItem);
		if(pSelItem!=NULL)
		{	
			CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
			int iSubItem = Header_OrderToIndex(pHeader->m_hWnd, GetCurSubItem());
			CItemInfo* pInfo = GetData(pSelItem);
			CItemInfo::CONTROLTYPE ctrlType;
			if(pInfo->GetControlType(iSubItem-1, ctrlType))
			{	
				switch(ctrlType)
				{
					/*put in your own control here*/
					case pInfo->CONTROLTYPE::datecontrol:break;
					case pInfo->CONTROLTYPE::spinbutton:break;
					case pInfo->CONTROLTYPE::dropdownlistviewwhatevercontrol:break;
					case pInfo->CONTROLTYPE::combobox: 
						{

							CStringList* list=NULL;
							pInfo->GetListData(iSubItem-1, list);
							CComboBox * pList = ShowList(iItem, iSubItem, list);
							bResult=TRUE; //I'll handle it from here
						}break;
					default:break;
				}
			}
		}
	}
	return bResult;
}
Example #12
0
// Unload (a package)
bool ecConfigItem::Unload()
{
    bool rc=FALSE;
    CdlPackage package=dynamic_cast<CdlPackage>(GetCdlItem());
    wxASSERT(package);
    ecConfigToolDoc* pDoc=wxGetApp().GetConfigToolDoc();

    // Remove its objects from the view to prevent any painting problems
    ecTreeItemData* data = (ecTreeItemData*) wxGetApp().GetTreeCtrl()->GetItemData(GetTreeItem());
    wxASSERT(data);

    // I _think_ we should do this to stop 'this' from being deleted when we delete the item.
    // But, in that case, where do we delete this item?
    // Perhaps should store them in an array in the document, as per the MFC tool.
    data->SetConfigItem(NULL);

    wxGetApp().GetTreeCtrl()->Delete(GetTreeItem());

#if wxCHECK_VERSION(2, 6, 0)
    wxNode* node = pDoc->GetItems().GetFirst();
    while (node)
    {
        ecConfigItem* item = wxDynamicCast(node->GetData(), ecConfigItem);
        if (package == item->GetOwnerPackage() && item != this)
        {
            item->SetTreeItem(wxTreeItemId()); // Make sure we can't attempt to paint it
            item->SetCdlItem(NULL); // Make sure we can't access stale data
            delete item; // Delete the item itself
        }
        node = node->GetNext();
    }
#else
    wxNode* node = pDoc->GetItems().First();
    while (node)
    {
        ecConfigItem* item = wxDynamicCast(node->Data(), ecConfigItem);
        if (package == item->GetOwnerPackage() && item != this)
        {
            item->SetTreeItem(wxTreeItemId()); // Make sure we can't attempt to paint it
            item->SetCdlItem(NULL); // Make sure we can't access stale data
            delete item; // Delete the item itself
        }
        node = node->Next();
    }
#endif

    const wxString strMacroName(GetMacro());
    //TRACE (wxT("Unloading package %s\n"), strMacroName);
    try {
        pDoc->GetCdlConfig()->unload_package (package);
        rc=TRUE;
    }
    catch (CdlStringException exception) {
        wxString msg;
        wxString exceptionMsg(exception.get_message ().c_str ());
        msg.Printf(wxT("Error unloading package %s:\n\n%s"), (const wxChar*) strMacroName, (const wxChar*) exceptionMsg );
        wxMessageBox(msg);
    }
    catch (...) {
        wxString msg;
        msg.Printf(wxT("Error unloading package %s"), (const wxChar*) strMacroName);
        wxMessageBox(msg);
    }
    m_treeItem=wxTreeItemId();   // Make sure we can't attempt to paint it
    m_CdlItem=NULL; // Make sure we can't access stale data
    return rc;
}
BOOL CTreeListCtrl::DeleteItem( int nItem )
{
   return DeleteItem(GetTreeItem(nItem));
}
CString CTreeListCtrl::GetItemText( int nItem, int nSubItem )
{
   return GetItemText(GetTreeItem(nItem), nSubItem);
}
Example #15
0
wxTreeItemId wxSpinTreeCtrl::GetTreeItem(const char *nodeId)
{
    return GetTreeItem(nodeId, GetRootItem());
}
Example #16
0
/*
wxTreeItemId wxSpinTreeCtrl::GetTreeItem(spin::ReferencedNode* pNode, wxTreeItemId idParent, wxTreeItemIdValue cookie)
{
    return GetTreeItem(pNode->id->s_name, idParent, cookie);
}
*/
wxTreeItemId wxSpinTreeCtrl::GetTreeItem(spin::ReferencedNode* pNode)
{
    return GetTreeItem(pNode->id->s_name);
}