Esempio n. 1
0
void wxTreeViewComboPopup::AddTreeItem(wxGxObject* pGxObject, wxTreeItemId hParent)
{
	if(NULL == pGxObject)
		return;
	wxGxObjectContainer* pContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);
	if(NULL == pContainer)
		return;

    if (m_TreeMap[pGxObject->GetId()].IsOk())
    {
        return;
    }

	IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pGxObject);
	wxIcon icon;
	if(pObjUI != NULL)
		icon = pObjUI->GetSmallImage();

	int pos(wxNOT_FOUND);
	if(icon.IsOk())
    {
        for(size_t i = 0; i < m_IconsArray.size(); ++i)
        {
            if(m_IconsArray[i].oIcon.IsSameAs(icon))
            {
                pos = m_IconsArray[i].iImageIndex;
                break;
            }
        }
        if(pos == wxNOT_FOUND)
        {
            pos = m_TreeImageList.Add(icon);
            ICONDATA myicondata = {icon, pos};
            m_IconsArray.push_back(myicondata);
        }
    }
	else
		pos = 0;//0 col img, 1 - col img

	wxGxTreeItemData* pData = new wxGxTreeItemData(pGxObject->GetId(), pos, false);

    wxString sName;
    if(m_pCatalog->GetShowExt())
        sName = pGxObject->GetName();
    else
        sName = pGxObject->GetBaseName();


	wxTreeItemId NewTreeItem = AppendItem(hParent, sName, pos, -1, pData);
	m_TreeMap[pGxObject->GetId()] = NewTreeItem;

	if(pContainer->AreChildrenViewable())
		SetItemHasChildren(NewTreeItem);

//	SortChildren(hParent);
	wxTreeCtrl::Refresh();
}
Esempio n. 2
0
bool wxGxContentView::AddObject(wxGxObject* const pObject)
{
    wxCriticalSectionLocker locker(m_CritSectCont);
    if(pObject == NULL)
		return false;

    //check doubles
	for(long i = 0; i < GetItemCount(); ++i)
	{
		LPITEMDATA pItemData = (LPITEMDATA)GetItemData(i);
		if(pItemData == NULL)
			continue;
        if(pItemData->nObjectID == pObject->GetId())
			return false;
    }

    //wxLogDebug(wxT("wxGxContentView::AddObject %d '%s'"), pObject->GetId(), pObject->GetFullName());
    IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pObject);
	wxIcon icon_small, icon_large;
	if(pObjUI != NULL)
	{
		icon_small = pObjUI->GetSmallImage();
		icon_large = pObjUI->GetLargeImage();
	}

	int pos = GetIconPos(icon_small, icon_large);

	LPITEMDATA pData = new _itemdata;
	pData->nObjectID = pObject->GetId();
	pData->iImageIndex = pos;

    wxString sName;
    if(m_pCatalog->GetShowExt())
        sName = pObject->GetName();
    else
        sName = pObject->GetBaseName();

	wxString sType = pObject->GetCategory();

	long ListItemID = InsertItem(0, sName, pos);
	if(m_current_style == enumGISCVReport)
	{
		SetItem(ListItemID, 1, sType);
        IGxDataset* pDSet = dynamic_cast<IGxDataset*>(pObject);
        if(pDSet)
        {
            wxCriticalSectionLocker locker(m_CritSectFillMeta);
            m_anFillMetaIDs.Add(pObject->GetId());
        }
	}
	SetItemPtrData(ListItemID, (wxUIntPtr) pData);

    return true;
}
Esempio n. 3
0
void wxGxTreeViewBase::AddRoot(wxGxObject* pGxObject)
{
	if(NULL == pGxObject)
		return;
	IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pGxObject);
	wxIcon icon;
	if(pObjUI != NULL)
		icon = pObjUI->GetSmallImage();
	int pos(-1);
	if(icon.IsOk())
		pos = m_TreeImageList.Add(icon);

	wxGxTreeItemData* pData = new wxGxTreeItemData(pGxObject->GetId(), pos, false);

	wxTreeItemId wxTreeItemIdRoot = wxTreeCtrl::AddRoot(pGxObject->GetName(), pos, -1, pData);
	m_TreeMap[pGxObject->GetId()] = wxTreeItemIdRoot;

	wxTreeCtrl::SetItemHasChildren(wxTreeItemIdRoot);
	wxTreeCtrl::Expand(wxTreeItemIdRoot);

	wxTreeCtrl::SortChildren(wxTreeItemIdRoot);
	wxTreeCtrl::Refresh();
}
Esempio n. 4
0
void wxGxContentView::OnObjectChanged(wxGxCatalogEvent& event)
{
    //wxLogDebug(wxT("ContentView Object %d Change"), event.GetObjectID());
    if(event.GetObjectID() == m_nParentGxObjectID)
	{
        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
		wxGxObjectContainer* pObjectContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);
		if(pObjectContainer != NULL)
		{
			wxBusyCursor wait;
			if(GetItemCount() > 0 && !pObjectContainer->HasChildren())
			{
			    ResetContents();
			}
			else if(GetItemCount() == 0 && pObjectContainer->HasChildren())
			{
				RefreshAll();
				return;
			}
		}
	}

    bool bItemsHaveChanges = false;

	for(long i = 0; i < GetItemCount(); ++i)
	{
		LPITEMDATA pItemData = (LPITEMDATA)GetItemData(i);
		if(pItemData == NULL)
			continue;
		if(pItemData->nObjectID != event.GetObjectID())
			continue;

        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
		IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pGxObject);
		wxIcon icon_small, icon_large;
		if(pObjUI != NULL)
		{
			icon_small = pObjUI->GetSmallImage();
			icon_large = pObjUI->GetLargeImage();
		}

        bool bChangeIcon = false;
        int pos = GetIconPos(icon_small, icon_large);
        bChangeIcon = pItemData->iImageIndex != pos;
		pItemData->iImageIndex = pos;

		wxString sName;
		if(m_pCatalog->GetShowExt())
			sName = pGxObject->GetName();
		else
			sName = pGxObject->GetBaseName();

		wxString sType = pGxObject->GetCategory();

        if (GetItemText(i, 0) != sName)
        {
		    SetItem(i, 0, sName, pos);
            if (m_currentSortCol == 0)
            {
                bItemsHaveChanges = true;
            }
        }
        else if(bChangeIcon)
        {
            SetItemImage(i, pos);
        }

        if(m_current_style == enumGISCVReport)
	    {
            if (GetItemText(i, 1) != sType)
            {
		        SetItem(i, 1, sType);
                if (m_currentSortCol == 1)
                {
                    bItemsHaveChanges = true;
                }
            }
            IGxDataset* pDSet = dynamic_cast<IGxDataset*>(pGxObject);
            if(pDSet)
            {
                if (pDSet->IsMetadataFilled())
                {
                    if (pDSet->GetSize() > 0)
                        SetItem(i, 2, wxFileName::GetHumanReadableSize(pDSet->GetSize()));
                    if (pDSet->GetModificationDate().IsValid())
                        SetItem(i, 3, pDSet->GetModificationDate().Format());
                }
                else
                {
                    wxCriticalSectionLocker locker(m_CritSectFillMeta);
                    m_anFillMetaIDs.Add(pGxObject->GetId());
                }
            }
	    }
	}

    if(bItemsHaveChanges)
    {
        SORTDATA sortdata = {m_bSortAsc, m_currentSortCol};
	    SortItems(GxObjectCVCompareFunction, (long)&sortdata);
    	SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1);
    }

//	wxListCtrl::Refresh();

}
Esempio n. 5
0
void wxGxTreeViewBase::OnObjectChanged(wxGxCatalogEvent& event)
{
	wxTreeItemId TreeItemId = m_TreeMap[event.GetObjectID()];
	if(TreeItemId.IsOk())
	{
		wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(TreeItemId);
		if(pData != NULL)
		{
            wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
			IGxObjectUI* pGxObjectUI = dynamic_cast<IGxObjectUI*>(pGxObject);
			wxGxObjectContainer* pGxObjectContainer = dynamic_cast<wxGxObjectContainer*>(pGxObject);
            IGxObjectTreeAttr* pGxObjectAttr = dynamic_cast<IGxObjectTreeAttr*>(pGxObject);
			if(pGxObjectUI != NULL)
			{
                wxString sName;
                if(m_pCatalog->GetShowExt())
                    sName = pGxObject->GetName();
                else
                    sName = pGxObject->GetBaseName();

                if(pGxObjectAttr && pGxObjectAttr->ShowCount())
                {
                    sName.Append(wxString::Format(wxT(" [%d]"), pGxObjectAttr->GetCount()));
                }

				wxIcon icon = pGxObjectUI->GetSmallImage();

                int pos(wxNOT_FOUND);
				if(icon.IsOk())
                {
                    for(size_t i = 0; i < m_IconsArray.size(); ++i)
                    {
                        if(m_IconsArray[i].oIcon.IsSameAs(icon))
                        {
                            pos = m_IconsArray[i].iImageIndex;
                            break;
                        }
                    }
                    if(pos == wxNOT_FOUND)
                    {
                        pos = m_TreeImageList.Add(icon);
                        ICONDATA myicondata = {icon, pos};
                        m_IconsArray.push_back(myicondata);
                    }
                    SetItemImage(TreeItemId, pos);
					//m_TreeImageList.Replace(pData->m_smallimage_index, icon);
                }
				SetItemText(TreeItemId, sName);
				if(pGxObjectContainer != NULL)
				{
					wxBusyCursor wait;
					bool bItemHasChildren = pGxObjectContainer->HasChildren();
					if(ItemHasChildren(TreeItemId) && !bItemHasChildren)
					{						
						CollapseAndReset(TreeItemId);
						pData->m_bExpandedOnce = false;
                        UpdateGxSelection();
					}
					SetItemHasChildren(TreeItemId, bItemHasChildren && pGxObjectContainer->AreChildrenViewable());
				}
                
                if(pGxObjectAttr)
                {
                    SetItemBold(TreeItemId, pGxObjectAttr->IsBold());
                    SetItemTextColour(TreeItemId, pGxObjectAttr->GetColor());                    
                }
				//wxTreeCtrl::Refresh();
			}
		}
	}
}
Esempio n. 6
0
void wxGxTreeViewBase::AddTreeItem(wxGxObject* pGxObject, wxTreeItemId hParent)
{
	if(NULL == pGxObject)
		return;

    wxTreeItemId TreeItemId = m_TreeMap[pGxObject->GetId()];
	if(TreeItemId.IsOk())
        return;

	IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pGxObject);
	wxIcon icon;
	if(pObjUI != NULL)
		icon = pObjUI->GetSmallImage();

	int pos(wxNOT_FOUND);
	if(icon.IsOk())
    {
        for(size_t i = 0; i < m_IconsArray.size(); ++i)
        {
            if(m_IconsArray[i].oIcon.IsSameAs(icon))
            {
                pos = m_IconsArray[i].iImageIndex;
                break;
            }
        }
        if(pos == wxNOT_FOUND)
        {
            pos = m_TreeImageList.Add(icon);
            ICONDATA myicondata = {icon, pos};
            m_IconsArray.push_back(myicondata);
        }
    }
	else
		pos = 0;//m_ImageListSmall.Add(m_ImageListSmall.GetIcon(2));//0 col img, 1 - col img

	wxGxTreeItemData* pData = new wxGxTreeItemData(pGxObject->GetId(), pos, false);
    
    IGxObjectTreeAttr* pGxObjectAttr = dynamic_cast<IGxObjectTreeAttr*>(pGxObject);

    wxString sName;
    if(m_pCatalog->GetShowExt())
        sName = pGxObject->GetName();
    else
        sName = pGxObject->GetBaseName();

    if(pGxObjectAttr && pGxObjectAttr->ShowCount())
    {
        sName.Append(wxString::Format(wxT(" [%d]"), pGxObjectAttr->GetCount()));
    }


	wxTreeItemId NewTreeItem = AppendItem(hParent, sName, pos, wxNOT_FOUND, pData);
	m_TreeMap[pGxObject->GetId()] = NewTreeItem;

	wxGxObjectContainer* pContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);//dynamic_cast<IGxObjectContainer*>(pGxObject);
	if(pContainer != NULL)
    {
		if(pContainer->AreChildrenViewable())
			SetItemHasChildren(NewTreeItem);
    }

    if(pGxObjectAttr)
    {
        SetItemBold(NewTreeItem, pGxObjectAttr->IsBold());
        SetItemTextColour(NewTreeItem, pGxObjectAttr->GetColor());                    
    }

    //SortChildren(hParent);
	wxTreeCtrl::Refresh();
}