Ejemplo n.º 1
0
void CXTPTaskPanelGroup::OnAnimate(int nStep)
{
	if (nStep < 1)
	{
		m_rcGroupCurrent = m_rcGroupTarget;
	}
	else
	{
		MOVETO(m_rcGroupCurrent.top, m_rcGroupTarget.top, nStep);
		MOVETO(m_rcGroupCurrent.bottom, m_rcGroupTarget.bottom, nStep);
	}

	if (!IsDirty() && m_bExpanding)
	{
		m_bExpanding = FALSE;
		m_pPanel->NotifyOwner(XTP_TPN_GROUPEXPANDED, (LPARAM)this);
	}

	for (int i = 0; i < GetItemCount(); i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);

		pItem->OnAnimate(nStep);
	}
}
Ejemplo n.º 2
0
CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::HitTest(CPoint pt, CRect* lpRect) const
{
	if (!IsExpanded())
		return NULL;

	int nOffset = m_pPanel->GetScrollOffset() - m_nCaptionHeight - m_rcGroupCurrent.top + GetScrollOffsetPos();
	pt.y += nOffset;

	for (int i = 0; i < GetItemCount(); i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);
		CRect rcItem = pItem->GetItemRect();

		if (rcItem.PtInRect(pt) && pItem->IsVisible())
		{
			if (lpRect)
			{
				rcItem.OffsetRect(0, -nOffset);
				*lpRect = rcItem;
			}
			return pItem;
		}
	}
	return NULL;
}
Ejemplo n.º 3
0
void CXTPTaskPanelGroup::RepositionScrollOffset()
{
	int nItemCount = GetItemCount();
	int nLastVisibleItem = m_pItems->GetNextVisibleIndex(nItemCount, -1);

	int nScrollOffset = min(GetOffsetItem(), nLastVisibleItem);

	if (nScrollOffset > 0)
	{
		CRect rcItem(GetAt(nLastVisibleItem)->GetItemRect());

		int nTopMargin = GetPaintManager()->GetGroupInnerMargins(this).top;

		while ((nScrollOffset > 0) && ((rcItem.bottom - GetAt(nScrollOffset - 1)->GetItemRect().top + nTopMargin
			< m_nExpandedClientHeight) || !GetAt(nScrollOffset - 1)->IsVisible()))
		{
			nScrollOffset--;
		}
	}
	SetOffsetItem(nScrollOffset, FALSE);

	for (int i = 0; i < nItemCount; i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);

		if (pItem->IsItemFocused() || (pItem->IsItemSelected() && GetTaskPanel()->m_bSelectItemOnFocus))
		{
			EnsureVisible(pItem, FALSE);
			break;
		}
	}
}
Ejemplo n.º 4
0
bool CMainFrame::_CreateMeshPanel( CImageList& imageList, Ogre::StringVectorPtr& meshNames )
{
	if (!m_resourceSelector.Create(WS_CHILD|WS_VISIBLE, CRect(200,100,400,300), this, IDS_ResourceSelector))
		return false;

	m_resourceSelector.SetOwner(this);
	m_resourceSelector.SetIconSize(CSize(MESH_ICON_SIZE, MESH_ICON_SIZE));
	CXTPTaskPanelGroup* pGroup = m_resourceSelector.AddGroup(IDS_ResourceSelector_Mesh);

	int itemCount = imageList.GetImageCount();
 	m_resourceSelector.GetImageManager()->SetImageList(imageList.Detach(), 0);
	
	for (int i=0; i<itemCount; ++i)
	{
		std::wstring meshname(Utility::EngineToUnicode(meshNames->at(i)));
		meshname.erase(meshname.length()-5);
		// Add folder entries
		CXTPTaskPanelGroupItem* pItem = pGroup->AddLinkItem(i, 0);
		pItem->SetIconIndex(i);
		pItem->SetCaption(meshname.c_str());
	}
					
	m_resourceSelector.SetBehaviour(xtpTaskPanelBehaviourList);
	m_resourceSelector.SetSelectItemOnFocus(TRUE);
	m_resourceSelector.SetMultiColumn(TRUE);
	m_resourceSelector.SetColumnWidth(RES_SELECTOR_COLUMN_WIDTH);
	m_resourceSelector.GetAt(0)->SetExpanded(TRUE);
	//拖拽支持
	m_resourceSelector.AllowDrag(xtpTaskItemAllowDragCopyOutsideControl);

	return true;
}
Ejemplo n.º 5
0
CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::AddControlItem(HWND hWnd)
{
	CXTPTaskPanel::CRepositionContext context(m_pPanel);

	CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)m_pItems->Add(new CXTPTaskPanelGroupItem(), 0);
	pItem->SetControlHandle(hWnd);

	return pItem;
}
Ejemplo n.º 6
0
CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::AddTextItem(LPCTSTR strText)
{
	CXTPTaskPanel::CRepositionContext context(m_pPanel);

	CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)m_pItems->Add(new CXTPTaskPanelGroupItem(), 0);
	pItem->SetCaption(strText);

	return pItem;
}
Ejemplo n.º 7
0
void CXTPTaskPanelGroup::SetSelectedItem(CXTPTaskPanelGroupItem* pSelectedItem)
{
	int nCount = GetItemCount();

	for (int i = 0; i < nCount; i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);
		pItem->SetItemSelected(pSelectedItem == pItem);
	}
}
Ejemplo n.º 8
0
CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::AddLinkItem(UINT nID, int nImage)
{
	CXTPTaskPanel::CRepositionContext context(m_pPanel);

	CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)m_pItems->Add(new CXTPTaskPanelGroupItem(), nID);
	pItem->SetIconIndex(nImage);
	pItem->SetType(xtpTaskItemTypeLink);

	return pItem;
}
Ejemplo n.º 9
0
BOOL CXTPTaskPanelGroup::IsScrollButtonEnabled(BOOL bScrollButtonUp) const
{
	CXTPTaskPanelGroupItem* pLastVisibleItem = (CXTPTaskPanelGroupItem*)m_pItems->GetLastVisibleItem();

	if (pLastVisibleItem == NULL)
		return FALSE;

	if (bScrollButtonUp)
		return m_nScrollOffset != 0;

	CRect rcItem(pLastVisibleItem->GetItemRect());

	return rcItem.bottom - GetScrollOffsetPos() > m_rcGroupTarget.Height() - m_nCaptionHeight;
}
Ejemplo n.º 10
0
void CXTPTaskPanelGroup::EnsureVisible(CXTPTaskPanelGroupItem* pItem, BOOL bUpdateScrollButtons /*= TRUE*/)
{
	if (m_pPanel->IsExplorerBehaviour() || GetItemCount() == 0 || !IsExpanded())
		return;

	if (!pItem || pItem->GetItemGroup() != this || !pItem->IsVisible())
		return;

	int nIndex = pItem->GetIndex();

	if (m_nScrollOffset > nIndex)
	{
		SetOffsetItem(nIndex, bUpdateScrollButtons);
		return;
	}

	CRect rcItem(pItem->GetItemRect());
	if (rcItem.bottom - GetScrollOffsetPos() > m_nExpandedClientHeight)
	{
		int nTopMargin = GetPaintManager()->GetGroupInnerMargins(this).top;
		if (rcItem.top - GetScrollOffsetPos() <= nTopMargin)
			return;

		int nScrollOffset = m_nScrollOffset + 1;
		for (; nScrollOffset <= nIndex; nScrollOffset++)
		{
			CXTPTaskPanelGroupItem* pItemScroll = GetAt(nScrollOffset);
			if (!pItemScroll || !pItemScroll->IsVisible())
				continue;

			int nScrollOffsetPos = pItemScroll->GetItemRect().top - nTopMargin;

			if (rcItem.bottom - nScrollOffsetPos <= m_nExpandedClientHeight)
				break;

			if (rcItem.top - nScrollOffsetPos <= nTopMargin)
				break;
		}
		SetOffsetItem(nScrollOffset, bUpdateScrollButtons);
	}
}
Ejemplo n.º 11
0
LRESULT CMainFrame::OnResPanelNotify( WPARAM wParam, LPARAM lParam )
{
	switch(wParam) {
	case XTP_TPN_CLICK:
		{
			CXTPTaskPanelGroupItem* pItem = (CXTPTaskPanelGroupItem*)lParam;
			TRACE(_T("Click Event: pItem.Caption = %s, pItem.ID = %i\n"), pItem->GetCaption(), pItem->GetID());
		}
		break;

	case XTP_TPN_RCLICK:
		{
			CXTPTaskPanelItem* pItem = (CXTPTaskPanelItem*)lParam;
			TRACE(_T("RClick Event: pItem.Caption = %s, pItem.ID = %i\n"), pItem->GetCaption(), pItem->GetID());

		}
		break;
	}

	return 0;
}
Ejemplo n.º 12
0
int CXTPTaskPanelGroup::GetOffsetItem() const
{
	if (m_nScrollOffset == 0)
		return 0;

	if (m_nScrollOffset < GetItemCount())
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(m_nScrollOffset);

		if (pItem->IsVisible())
			return m_nScrollOffset;

		int nScrollOffset = m_pItems->GetNextVisibleIndex(m_nScrollOffset, +1);

		if (nScrollOffset != -1)
			return nScrollOffset;

		nScrollOffset = m_pItems->GetNextVisibleIndex(m_nScrollOffset, -1);
		if (nScrollOffset != -1)
			return nScrollOffset;
	}

	return 0;
}
Ejemplo n.º 13
0
void CXTPTaskPanelGroup::RepositionAutoHeightControls(int nHeightOffset)
{
	if (GetItemLayout() == xtpTaskItemLayoutImages)
		return;

	int nCount = 0, i, nTotalHeight = 0, nItemCount = GetItemCount(), nOffset = 0;

	for (i = 0; i < nItemCount; i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);
		if (pItem->IsAutoHeight() && pItem->IsVisible())
		{
			nCount++;
			nTotalHeight += max(1, pItem->GetSize().cy);
		}
	}

	if (nCount == 0)
		return;

	for (i = 0; i < nItemCount; i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);
		pItem->m_rcItem.OffsetRect(0, nOffset);

		if (pItem->IsAutoHeight() && pItem->IsVisible())
		{
			int nItemHeight = max(1, pItem->GetSize().cy);
			int nItemHeightOffset = nCount > 1 ? (int)(nItemHeight* nHeightOffset / nTotalHeight) : nHeightOffset;

			nCount--;
			nTotalHeight -= nItemHeight;
			nHeightOffset -= nItemHeightOffset;

			pItem->m_rcItem.bottom += nItemHeightOffset;
			nOffset += nItemHeightOffset;
		}
	}


}
Ejemplo n.º 14
0
// 加载Toolbox配置文件
BOOL CVciOwm::LoadToolbox(LPCTSTR lpszToolboxFile)
{
	if(GetFileAttributes(lpszToolboxFile) == 0xFFFFFFFF)
	{
		return FALSE;
	}

	CXmlParser parser;
	if(parser.Open(lpszToolboxFile))
	{
		DEBUG_OUTF(LOG_LEVEL_ERROR, "Load toolbox file %s fail!", lpszToolboxFile);
		return FALSE;
	}

	CString strImagePath = theApp.GetModulePath();

	BOOL bRet = TRUE;
	DOMNode* pNode = parser.GetRootNode();

	// 加载图片资源
	DOMNode* pImageNode = parser.GetChildNode(pNode, "image");
	while (pImageNode != NULL)
	{
		CString strIconFile = strImagePath + "\\" + parser.GetNodeAttribute(pImageNode, "file");
		int nImageId = atoi(parser.GetNodeAttribute(pImageNode, "id"));

		// 加载单个图片
		if(!theApp.SetToolboxIcon(strIconFile, nImageId))
		{
			bRet = FALSE;
		}

		pImageNode = parser.GetNextNode(pImageNode, "image");
	}

	DOMNode* pImageListNode = parser.GetChildNode(pNode, "imagelist");
	while (pImageListNode != NULL)
	{
		CString strBmpFile = strImagePath + "\\" + parser.GetNodeAttribute(pImageListNode, "file");
		CString strIDs = parser.GetNodeText(pImageListNode);
		CUIntArray auID;
		int nPos = strIDs.Find(",");
		while(nPos != -1)
		{
			auID.Add(atoi(strIDs.Left(nPos)));
			strIDs.Delete(0, nPos+1);
			nPos = strIDs.Find(",");
		}
		auID.Add(atoi(strIDs));

		// 加载图片列表
		if(!theApp.SetToolboxIcons(strBmpFile, &auID))
		{
			bRet = FALSE;
		}

		pImageListNode = parser.GetNextNode(pImageListNode, "imagelist");
	}

	// 加载控件组和控件
	DOMNode* pGroupNode = parser.GetChildNode(pNode, "group");
	while (pGroupNode != NULL)
	{
		CString strGroupName = parser.GetNodeAttribute(pGroupNode, "name");
		int nGroupId = atoi(parser.GetNodeAttribute(pGroupNode, "id"));
		BOOL bExpand = (parser.GetNodeAttribute(pGroupNode, "expand") == "true");
		CXTPTaskPanelGroup* pFolderClass = theApp.CreateToolboxGroup(nGroupId, strGroupName);

		// 加载控件
		DOMNode* pItemNode = parser.GetChildNode(pGroupNode, "control");
		while (pItemNode != NULL)
		{
			CString strControlName = parser.GetNodeAttribute(pItemNode, "name");
			int nControlImageId = atoi(parser.GetNodeAttribute(pItemNode, "image-id"));
			CXTPTaskPanelGroupItem* pItem = pFolderClass->AddLinkItem(nControlImageId, nControlImageId);
			pItem->SetCaption(theApp.StripMnemonics(strControlName));

			pItemNode = parser.GetNextNode(pItemNode, "control");
		}

		pFolderClass->SetExpanded(bExpand);

		pGroupNode = parser.GetNextNode(pGroupNode, "group");
	}

	parser.Close();

	return TRUE;
}
Ejemplo n.º 15
0
void CXTPTaskPanelGroup::OnCalcClientHeight(CDC* pDC, CRect rc)
{
	CXTPTaskPanelPaintManager* pPaintManager = GetPaintManager();
	CRect rcMarginsOuter = pPaintManager->GetGroupOuterMargins(this);
	CRect rcMarginsInner = pPaintManager->GetGroupInnerMargins(this);

	rc.DeflateRect(rcMarginsOuter);
	CRect rcItems(rc);

	rcItems.DeflateRect(rcMarginsInner);
	m_nItemsInRow = 1;
	int nItemCount = GetItemCount();

	if (GetItemLayout() == xtpTaskItemLayoutImages)
	{
		CSize szIcon = GetItemIconSize();
		CRect rcInnerMargins(pPaintManager->m_rcImageLayoutIconPadding);
		CSize szButton(szIcon.cx + rcInnerMargins.right + rcInnerMargins.left,
			szIcon.cy + rcInnerMargins.top + rcInnerMargins.bottom);

		int nRowIcons = max(1, rcItems.Width() / szButton.cx), x = 0, y = 0;
		BOOL bWrap = FALSE;

		for (int i = 0; i < nItemCount; i++)
		{
			CXTPTaskPanelGroupItem* pItem = GetAt(i);

			if (!pItem->IsVisible())
				continue;

			if (bWrap)
			{
				x = 0;
				y++;
				bWrap = FALSE;
			}

			CRect rcItem(CPoint(rcItems.left + x * szButton.cx, rcItems.top + y * szButton.cy), szButton);
			pItem->OnReposition(rcItem);

			if (++x == nRowIcons)
				bWrap = TRUE;
		}
		rcItems.bottom = rcItems.top + rcMarginsInner.bottom + szButton.cy * (y + 1);
		m_nItemsInRow = nRowIcons;

		SetOffsetItem(m_nScrollOffset);
	}
	else
	{
		BOOL bMultiColumn = m_pPanel->IsMultiColumn();
		int nRowHeight = 0;
		CRect rcItemOuterMargins(0, 0, 0, 0);
		int nColumnWidth = m_pPanel->GetColumnWidth();
		ASSERT(nColumnWidth > 0);
		int x = 0;
		BOOL bWrap = FALSE;

		int nRowIcons = max(1, rcItems.Width() / nColumnWidth);

		for (int i = 0; i < nItemCount; i++)
		{
			CXTPTaskPanelGroupItem* pItem = GetAt(i);

			if (!pItem->IsVisible())
				continue;

			if (bMultiColumn)
			{
				if (bWrap)
				{
					rcItems.top += nRowHeight;

					nRowHeight = 0;
					x = 0;
					bWrap = FALSE;
				}

				CRect rcItem = pItem->OnReposition(CRect(rcItems.left + x * nColumnWidth, rcItems.top, rcItems.left + (x + 1) * nColumnWidth, rcItems.bottom));


				rcItemOuterMargins = pPaintManager->GetItemOuterMargins(pItem);

				nRowHeight = max(nRowHeight, rcItem.Height() + rcItemOuterMargins.bottom);

				if (++x == nRowIcons)
					bWrap = TRUE;
			}
			else
			{
				CRect rcItem = pItem->OnReposition(rcItems);
				rcItems.top = rcItem.bottom + pPaintManager->GetItemOuterMargins(pItem).bottom;
			}
		}
		if (bMultiColumn)
		{
			rcItems.top += nRowHeight;
			m_nItemsInRow = nRowIcons;
		}
		rcItems.bottom = rcItems.top + rcMarginsInner.bottom;
	}

	int nMinClientHeight = GetMinimumClientHeight();
	if (rcItems.bottom - rc.top < nMinClientHeight)
		rcItems.bottom = rc.top + nMinClientHeight;

	m_nExpandedClientHeight = rcItems.bottom - rc.top;

	m_nCaptionHeight = pPaintManager->DrawGroupCaption(pDC, this, FALSE);
}