void wxGxContentView::OnSelectionChanged(wxGxSelectionEvent& event)
{
	if(event.GetInitiator() == GetId())
		return;

    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(m_pSelection->GetLastSelectedObjectId());
	if(!pGxObject || m_nParentGxObjectID == pGxObject->GetId())
		return;

	wxBusyCursor wait;
	//reset
	ResetContents();
	m_nParentGxObjectID = pGxObject->GetId();

	wxGxObjectContainer* pObjectContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);
	if(pObjectContainer == NULL || !pObjectContainer->HasChildren())
		return;

	wxGxObjectList ObjectList = pObjectContainer->GetChildren();
    wxGxObjectList::iterator iter;
    for (iter = ObjectList.begin(); iter != ObjectList.end(); ++iter)
    {
        wxGxObject *current = *iter;
		AddObject(current);
    }

    SORTDATA sortdata = {m_bSortAsc, m_currentSortCol};
	SortItems(GxObjectCVCompareFunction, (long)&sortdata);
	SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1);
}
void wxGISToolExecuteView::OnSelectionChanged(wxGxSelectionEvent& event)
{
    if(event.GetInitiator() == GetId())
        return;
    long nSelId = m_pSelection->GetLastSelectedObjectId();
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(nSelId);

    wxBusyCursor wait;
    //reset
    ResetContents();
    m_nParentGxObjectId = nSelId;

    wxGxObjectContainer* pObjContainer =  wxDynamicCast(pGxObject, wxGxObjectContainer);
    if(pObjContainer == NULL)
        return;
    if(!pObjContainer->HasChildren())
        return;

    wxGxObjectList ObjectList = pObjContainer->GetChildren();
    wxGxObjectList::iterator iter;
    for (iter = ObjectList.begin(); iter != ObjectList.end(); ++iter)
    {
        wxGxObject *current = *iter;
        AddObject(current);
    }

    SortItems(GxTaskCompareFunction, 0);
    //wxListCtrl::Refresh();
}
void wxTreeViewComboPopup::OnSelectionChanged(wxGxSelectionEvent& event)
{
	if(event.GetInitiator() == GetId())
		return;

    long nSelID = m_pSelection->GetLastSelectedObjectId();
	wxTreeItemId ItemId = m_TreeMap[nSelID];
	if(ItemId.IsOk())
	{
		SelectItem(ItemId);
	}
	else
	{
        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(nSelID);
		wxGxObject* pParentGxObj = pGxObject->GetParent();
		while(pParentGxObj)
		{
			wxTreeItemId ItemId = m_TreeMap[pParentGxObj->GetId()];
			if(ItemId.IsOk())
			{
				Expand(ItemId);
				break;
			}
			else
				pParentGxObj = pParentGxObj->GetParent();
		}
		OnSelectionChanged(event);
	}
    //set combo text
    wxString sText = GetStringValue();
    m_combo->SetText(sText);
}
Beispiel #4
0
void wxGxTreeViewBase::OnSelectionChanged(wxGxSelectionEvent& event)
{
	if(event.GetInitiator() == GetId())
		return;

    long nSelId = m_pSelection->GetLastSelectedObjectId();
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(nSelId);
    if(pGxObject == NULL)
        return;

	wxTreeItemId ItemId = m_TreeMap[nSelId];
	if(ItemId.IsOk())
	{
		//granted event fireing
		if(wxTreeCtrl::GetSelection() == ItemId)
			UpdateGxSelection();
		else
			wxTreeCtrl::SelectItem(ItemId, true);
		SetFocus();
	}
	else
	{
		wxGxObject* pParentGxObj = pGxObject->GetParent();
        //check if parent has no visible children
        wxGxObjectContainer* pGxObjectContainer = wxDynamicCast(pParentGxObj, wxGxObjectContainer);
		if(pGxObjectContainer && !pGxObjectContainer->AreChildrenViewable())
        {
            wxTreeItemId ParentItemId = m_TreeMap[pParentGxObj->GetId()];
            //granted event fireing
            if(wxTreeCtrl::GetSelection() == ParentItemId)
                UpdateGxSelection();
            else
                wxTreeCtrl::SelectItem(ParentItemId, true);
            SetFocus();
        }

		while(pParentGxObj)
		{
			wxTreeItemId ItemId = m_TreeMap[pParentGxObj->GetId()];
			if(ItemId.IsOk())
			{
                wxTreeCtrl::SetItemHasChildren(ItemId);
				wxTreeCtrl::Expand(ItemId);
				break;
			}
			else
				pParentGxObj = pParentGxObj->GetParent();
		}
		OnSelectionChanged(event);
	}
}