Exemple #1
0
VOID CDUIIconTextItem::PaintForgnd(HDC dc)
{
	CRefPtr<CImageList> pIcon;
	if(m_bExpand)
	{
		pIcon = m_uiData.m_pExpandIcon;
	}
	else
	{
		pIcon = m_uiData.m_pNormalIcon;
	}

	if(pIcon.IsNull() || pIcon->IsNull())
	{
		return;
	}
	
	INT nImageIndex(m_nIconIndex);
	if(nImageIndex >= pIcon->GetItemCount())
	{
		nImageIndex = 0;
	}

	RECT rtIcon = GetIconRect();
	pIcon->DrawInCenter(dc , rtIcon, nImageIndex);
}
Exemple #2
0
VOID CDUIProgressBarBase::PaintForgnd(HDC dc)
{
	RECT rtContent = GetContentRect();
	
	CRefPtr<CImageList> pImage = m_uiData.m_imageBK;
	if(!pImage.IsNull() 
		&& !pImage->IsNull() 
		&& pImage->GetItemCount() >= PROCRSS_BAR_IMAGE_COUNT)
	{
		RECT rtTemp = {0};
		GetProgressRect(rtContent, rtTemp);
		if(!IsRectEmpty(&rtTemp))
		{
			CDUIRenderClip clip2(dc, rtTemp);
			if(IsVertical())
			{
				pImage->VerticalStretch(dc, rtContent, PROCRSS_BAR_IMAGE_FORE);
			}
			else
			{
				pImage->HorizontalStretch(dc, rtContent, PROCRSS_BAR_IMAGE_FORE);
			}
		}
	}
	else
	{
		DUI_ASSERT(FALSE);
	}
}
Exemple #3
0
VOID XmlMenuParseChild(CDUIMenuBuilder* pThis, CDUIXml& xml, CRefPtr<IDUIControl>  pParentControl)
{
	IDUIApp* pDUIApp = DUIGetAppInstance();
	if(pDUIApp == NULL) return;
	
	IDUIControlFactory* pControlFactory = pDUIApp->GetControlFactory();
	if(pControlFactory == NULL) return;
	
	CDUIString strControlName, strAttriName, strAttriValue;
	CRefPtr<IDUIControl> pControl;
	INT nIndex(0);
	while(xml.FindChildElem())
	{
		xml.IntoElem();
		
		strControlName = xml.GetTagName();
		pControl = pControlFactory->NewControl(strControlName);
		if(pControl.IsNull() && pThis->GetCallBack() != NULL)
		{
			pControl = pThis->GetCallBack()->OnBuilderNewControl(strControlName);
		}
		DUI_ASSERT(!pControl.IsNull());
		
		if(!pControl.IsNull())
		{
			DUI_ASSERT(pControl->GetInterface(IMenu) != NULL 
				|| pControl->GetInterface(IMenuItem) != NULL);

			nIndex = 0;
			do 
			{
				strAttriName = xml.GetAttribName(nIndex++);
				if(strAttriName.size() <= 0) break;
				
				strAttriValue = xml.GetAttrib(strAttriName);
				pControl->SetAttribute(strAttriName, strAttriValue);
				
			} while(TRUE);
			
			if(pThis->GetCallBack() != NULL)
			{
				pThis->GetCallBack()->OnAddChildControl(pParentControl, pControl);
			}
			else
			{
				DefAddChildControl(pParentControl, pControl);
			}
			
			
			XmlMenuParseChild(pThis, xml, pControl);
		}
		
		xml.OutOfElem();
	}
}
Exemple #4
0
VOID CDUIIconTextItem::PaintBkgnd(HDC dc)
{
	RECT rtBK = GetBKRect();
	BOOL bFill(FALSE);
	CARGB clrBK;

	CRefPtr<CDUIFrameBK> pFrameBK;
	if(GetStatus() & CONTROL_STATUS_HOVER)
	{
		pFrameBK = GetHoverFrameBK();
		bFill = TRUE;
	}

	if(m_bSelect)
	{
		pFrameBK = GetSelectFrameBK();
		bFill = TRUE;
	}

	if(bFill
		&& !pFrameBK.IsNull()
		&& !pFrameBK->IsEmpty())
	{
		pFrameBK->DrawBK(dc, rtBK);
	}
}
Exemple #5
0
 VOID CDUIAnimation::StopAnimation(INT nAnimationID /*= 0*/)
 {
	 if(m_pControl == NULL) return;

	 if(nAnimationID  != 0)
	 {
		CRefPtr<CAnimationData> pData = GetAnimationByID(nAnimationID);
		if(!pData.IsNull())
		{
			m_pControl->KillTimer(nAnimationID);
			m_arAnimations.erase(std::remove(m_arAnimations.begin(), m_arAnimations.end(), pData)
				, m_arAnimations.end());
			return;
		}
	 }
	else
	{
		INT nCount = m_arAnimations.size();
		for(INT i=0; i<nCount; ++i)
		{
			m_pControl->KillTimer(m_arAnimations[i]->m_nAnimationID);
		}
		m_arAnimations.clear();
	}
 }
Exemple #6
0
BOOL CDUIControlFactory::RegisterControl(const CDUIString& strName,
									  CRefPtr<IDUIControl> pControl)
{
	DUI_ASSERT(!pControl.IsNull());
	DUI_ASSERT(strName.size() > 0);

	if(!pControl.IsNull() && strName.size() > 0)
	{
		m_mapControl.insert(std::make_pair(strName, pControl));

		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
Exemple #7
0
CRefPtr<IDUIMenu> XmlControlParse(CDUIMenuBuilder* pThis, CDUIXml& xml)
{
	IDUIApp* pDUIApp = DUIGetAppInstance();
	if(pDUIApp == NULL) return NULL;
	
	IDUIControlFactory* pControlFactory = pDUIApp->GetControlFactory();
	if(pControlFactory == NULL) return NULL;
	
	if(!xml.FindElem(_T("menu")))
	{
		DUI_ASSERT(FALSE);
		return NULL;
	}
	CRefPtr<IDUIControl> pRootControl = pControlFactory->NewControl(_T("menu"));
	DUI_ASSERT(!pRootControl.IsNull());
	if(pRootControl.IsNull()) return NULL;

	//parse menu attribute
	CDUIString strAttriName, strAttriValue;
	INT nIndex(0);
	do 
	{
		strAttriName = xml.GetAttribName(nIndex++);
		if(strAttriName.size() <= 0) break;
		
		strAttriValue = xml.GetAttrib(strAttriName);
		pRootControl->SetAttribute(strAttriName, strAttriValue);
		
	} while(TRUE);

	XmlMenuParseChild(pThis, xml, pRootControl);

	if(pThis->GetCallBack() != NULL)
	{
		pThis->GetCallBack()->OnBuilderControlCreated(pRootControl);
	}


	IDUIMenu* pMenuRet =  (IDUIMenu*)pRootControl->GetInterface(IMenu);
	DUI_ASSERT(pMenuRet != NULL);

	return pMenuRet;
}
Exemple #8
0
 INT CDUIAnimation::GetCurrentFrame(INT nAnimationID/* = 0*/)
 {
	 CRefPtr<CAnimationData> pData = GetAnimationByID(nAnimationID);
	 if(pData.IsNull())
	 {
		 DUI_ASSERT(FALSE);
		 return -1;
	 }
	
	 return pData->m_nCurFrame;
 }
Exemple #9
0
VOID CDUIIconTextItem::PaintText(HDC dc)
{
	if(m_pParentControl == NULL)
	{
		DUI_ASSERT(FALSE);
		return;
	}

	CRefPtr<CTextStyle> pTextStyle = m_pParentControl->GetTextStyle();
	if(pTextStyle.IsNull()) return;

	CRefPtr<CFontObject> pFont = pTextStyle->GetFont();
	if(pFont.IsNull() || pFont->IsNull()) return;
	HFONT hFont = pFont->GetFont();
	
	if(m_strText.size() > 0)
	{
		RECT rtText = GetTextRect();
		SelectObject(dc, hFont);
		SetBkMode(dc, TRANSPARENT);

		if(GetSelect())
		{
			SetTextColor(dc, pTextStyle->GetSelectColor().GetColor());
		}
		else if(GetStatus() & CONTROL_STATUS_HOVER)
		{
			SetTextColor(dc, pTextStyle->GetHoverColor().GetColor());
		}
		else
		{
			SetTextColor(dc, pTextStyle->GetNormalColor().GetColor());
		}

		CDUIRenderEngine::DrawText(dc, m_strText.c_str()
			, m_strText.size(), &rtText, pTextStyle->GetTextFormat());
	}
}
Exemple #10
0
CRefPtr<IDUIControl> CDUIControlFactory::NewControl(const CDUIString& strName)
{
	CControlMap::iterator itr = m_mapControl.find(strName);
	if(itr == m_mapControl.end())
	{
		CRefPtr<IDUIControl> pPlugin = CreateFromPlugin(strName);
		DUI_ASSERT(!pPlugin.IsNull());
		if(!pPlugin.IsNull())
		{
			RegisterControl(strName, pPlugin);
			return pPlugin->Clone();
		}
		else
		{
			return NULL;
		}
	}
	
	CRefPtr<IDUIControl> pControl = (*itr).second->Clone();
	if(pControl == NULL) return NULL;
	
	return pControl;
}
Exemple #11
0
VOID CDUIProgressBarBase::PaintBkgnd(HDC dc)
{
	RECT rtContent = GetContentRect();
	
	CRefPtr<CImageList> pImage = m_uiData.m_imageBK;
	if(!pImage.IsNull() 
		&& !pImage->IsNull() 
		&& pImage->GetItemCount() >= PROCRSS_BAR_IMAGE_COUNT)
	{
		if(IsVertical())
		{
			pImage->VerticalStretch(dc, rtContent, PROCRSS_BAR_IMAGE_BK);
		}
		else
		{
			pImage->HorizontalStretch(dc, rtContent, PROCRSS_BAR_IMAGE_BK);
		}
	}
	else
	{
		DUI_ASSERT(FALSE);
	}
}
Exemple #12
0
 BOOL CDUIAnimation::StartAnimation(INT nElapse, INT nTotalFrame, INT nAnimationID /*= 0*/, BOOL bLoop/* = FALSE*/)
 {
	CRefPtr<CAnimationData> pData = GetAnimationByID(nAnimationID);
	if(!pData.IsNull() 
		|| nElapse <= 0
		|| nTotalFrame <= 0
		|| m_pControl == NULL)
	{
		DUI_ASSERT(FALSE);
		return FALSE;
	}

	CRefPtr<CAnimationData> pAnimation = new CAnimationData(nElapse, nTotalFrame, nAnimationID, bLoop);
	if(pAnimation.IsNull()) return FALSE;

	if(m_pControl->SetTimer(nAnimationID, nElapse))
	{
		m_arAnimations.push_back(pAnimation);
		return TRUE;
	}

	return FALSE;
 }
Exemple #13
0
 VOID CDUIAnimation::OnAnimationElapse(INT nAnimationID)
 {
	if(m_pControl == NULL) return;

	CRefPtr<CAnimationData> pData = GetAnimationByID(nAnimationID);
	if(pData.IsNull()) return;
	
	INT nCurFrame = pData->m_nCurFrame;
	if(nCurFrame == 0)
	{
		OnAnimationStart(nAnimationID, pData->m_bFirstLoop);
		pData->m_bFirstLoop = FALSE;
	}

	OnAnimationStep(pData->m_nTotalFrame, nCurFrame, nAnimationID);
	
	if(nCurFrame >= pData->m_nTotalFrame)
	{
		OnAnimationStop(nAnimationID);
		if(pData->m_bLoop)
		{
			pData->m_nCurFrame = 0;
		}
		else
		{
			m_pControl->KillTimer(nAnimationID);
			m_arAnimations.erase(std::remove(m_arAnimations.begin(), m_arAnimations.end(), pData)
				, m_arAnimations.end());
			pData = NULL;
		}
	}

	if(!pData.IsNull())
	{
		++(pData->m_nCurFrame);
	}
 }
Exemple #14
0
VOID CDUIControlFactory::CheckControlStyle(CDUIString& strControlName)
{
	CControlMap::iterator itr = m_mapControl.find(strControlName);
	if(itr == m_mapControl.end())
	{
		DUI_ASSERT(FALSE);
		return;
	}

	CRefPtr<IDUIControl> pControl = itr->second;
	DUI_ASSERT(!pControl.IsNull());


	pControl->SetAttribute(_T("control_style"), strControlName);
}
Exemple #15
0
BOOL CDUIProgressBarBase::EstimateSize(SIZE sizeAvaiable, SIZE& sizeRet)
{
	CRefPtr<CImageList> image = m_uiData.m_imageBK;
	if(!image.IsNull() && !image->IsNull())
	{
		sizeRet.cx = image->GetIconWidth();
		sizeRet.cy = image->GetIconHeight();
	}

	sizeRet.cx += (m_rtMargin.left + m_rtMargin.right);
	sizeRet.cy += (m_rtMargin.top + m_rtMargin.bottom);
	
	SIZE sizeFixed = GetFixedSize();
	if(sizeFixed.cx != 0)
	{
		sizeRet.cx = sizeFixed.cx;
	}
	if(sizeFixed.cy != 0)
	{
		sizeRet.cy = sizeFixed.cy;
	}

	return TRUE;
}
Exemple #16
0
VOID CDUITreeViewImpl::OnCreate()
{
	if(m_pVertSB.IsNull())
	{
		CRefPtr<IDUIControl> pNewControl = GetControlFactory()->NewControl(DUI_VERT_SCROLLBAR);
		if(!pNewControl.IsNull())
		{
			m_pVertSB = (IDUIScrollBar*)pNewControl->GetInterface(IScrollBar);
		}
	}
	
	if(!m_pVertSB.IsNull())
	{
		DUI_ASSERT(m_pControlMgr != NULL);
		m_pVertSB->AttachWindow(m_pControlMgr);
		m_pVertSB->SetScrollOwner(this);
	}
	
	//CheckInitGroupStatus();
}
Exemple #17
0
 BOOL CDUIAnimation::SetCurrentFrame(INT nFrame, INT nAnimationID/* = 0*/)
 {
	 CRefPtr<CAnimationData> pData = GetAnimationByID(nAnimationID);
	 if(pData.IsNull())
	 {
		 DUI_ASSERT(FALSE);
		 return FALSE;
	 }

	 if(nFrame >= 0 && nFrame <= pData->m_nTotalFrame)
	 {
		 pData->m_nCurFrame = nFrame;
		 return TRUE;
	 }
	 else
	 {
		 DUI_ASSERT(FALSE);
	 }

	 return FALSE;
 }
Exemple #18
0
VOID CDUIProgressBarBase::SetAttribute(const CDUIString& strName, const CDUIString& strValue)
{
	BOOL bHandled(FALSE);
	if(strName.compare(_T("back_image")) == 0)
	{
		CRefPtr<CImageList> pImage = GetSkinMgr()->GetImage(strValue);
		DUI_ASSERT(!pImage.IsNull() && (pImage->GetItemCount() >= PROCRSS_BAR_IMAGE_COUNT));
		
		CProgressBarUIData data;
		data.m_imageBK = pImage;
		SetUIData(data);

		bHandled = TRUE;
	}
	else if(strName.compare(_T("range")) == 0)
	{
		TCHAR szValue[128] = {0};
		lstrcpyn(szValue, strValue.c_str(), sizeof(szValue) / sizeof(TCHAR) - 1);
		LPTSTR pstr = szValue;
		INT nItem1 = _tcstol(pstr, &pstr, 10);    
		INT nItem2 = _tcstol(pstr + 1, &pstr, 10); 	

		SetRange(nItem1, nItem2);
		bHandled = TRUE;
	}
	else if(strName.compare(_T("pos")) == 0)
	{
		INT nPos = _ttol(strValue.c_str());
		SetPos(nPos);
		bHandled = TRUE;
	}
	

	if(!bHandled)
	{
		theBase::SetAttribute(strName, strValue);
	}
}
Exemple #19
0
 BOOL CDUIAnimation::IsAnimationRunning(INT nAnimationID)
 {
	CRefPtr<CAnimationData> pData = GetAnimationByID(nAnimationID);
	return !pData.IsNull();
 }
Exemple #20
0
CRefPtr<IDUIControl> XmlControlParse(CDUIControlBuilder* pThis, CDUIXml& xml)
{
	IDUIApp* pDUIApp = DUIGetAppInstance();
	if(pDUIApp == NULL) return NULL;
	
	IDUIControlFactory* pControlFactory = pDUIApp->GetControlFactory();
	if(pControlFactory == NULL) return NULL;
	
	if(!xml.FindElem(_T("window")))
	{
		DUI_ASSERT(FALSE);
		return NULL;
	}
	
	//parse window attribute
	CDUIString strAttriName, strAttriValue;
	INT nIndex(0);
	do 
	{
		strAttriName = xml.GetAttribName(nIndex++);
		if(strAttriName.size() <= 0) break;
		
		strAttriValue = xml.GetAttrib(strAttriName);
		if(pThis->GetCallBack() != NULL)
		{
			pThis->GetCallBack()->OnBuilderWindowAttribute(strAttriName, strAttriValue);
		}
		
	} while(TRUE);
	
	//parse child control
	CDUIString strControlName;
	CRefPtr<IDUIControl> pRootControl;
	if(xml.FindChildElem(NULL))
	{
		xml.IntoElem();

		strControlName = xml.GetTagName();
		pRootControl = pControlFactory->NewControl(strControlName);
		if(pRootControl.IsNull() && pThis->GetCallBack() != NULL)
		{
			pRootControl = pThis->GetCallBack()->OnBuilderNewControl(strControlName);
		}
		DUI_ASSERT(!pRootControl.IsNull());

		if(!pRootControl.IsNull())
		{
			nIndex = 0;
			do 
			{
				strAttriName = xml.GetAttribName(nIndex++);
				if(strAttriName.size() <= 0) break;

				strAttriValue = xml.GetAttrib(strAttriName);
				pRootControl->SetAttribute(strAttriName, strAttriValue);
				
			} while(TRUE);

			XmlControlParseChild(pThis, xml, pRootControl);

			if(pThis->GetCallBack() != NULL)
			{
				pThis->GetCallBack()->OnBuilderControlCreated(pRootControl);
			}
		}
		
		xml.OutOfElem();
	}

	return pRootControl;
}
Exemple #21
0
VOID CDUIListBox::AfterRemoveControl(CRefPtr<IDUIControl> pItem)
{
	if(pItem.IsNull()) return;
	
	theBase::AfterRemoveControl(pItem);
}