Пример #1
0
void duSplitter::DrawObject(HDC hDC)
{
	duRect rectSplitter;
	Plugin_GetRect(this, &rectSplitter);
	rectSplitter.OffsetRect(-rectSplitter.left, -rectSplitter.top);

	DrawByStyle(this, GetStyle(), hDC, &rectSplitter, GetState(), GetText(), GetAlpha());
}
Пример #2
0
void WINAPI duStatic::OnMouseIn(POINT pt)
{
	duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd);
	if (pCtrlManager == NULL)
		return;

	if (m_fShowToolTip)
	{
		pCtrlManager->AddToolTip((LPTSTR)GetText());
	}
	else
	{
		LPCTSTR lpszText = GetText();
		if (lpszText && *lpszText)
		{
			duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP);
			if (pStyleGroup == NULL)
				return;

			int i;
			int nStyleCount = pStyleGroup->GetStyleCount();
			for (i = 0;i < nStyleCount; i++)
			{
				duStyleBase *pStyleBase = pStyleGroup->GetStyle(i);
				if (pStyleBase->GetType() == STYLE_TEXT)
				{
					duTextStyle *pTextStyle = (duTextStyle *)pStyleBase;

					duSize size(0, 0);
					pTextStyle->CalcTextRect(lpszText, &size);

					duRect rcStyle;
					rcStyle.SetRectEmpty();

					duRect rcStatic;
					Plugin_GetRect(this, &rcStatic);
					rcStatic.OffsetRect(-rcStatic.left, -rcStatic.top);

					MakeRect(pTextStyle->GetLeft(), pTextStyle->GetTop(), pTextStyle->GetRight(), pTextStyle->GetBottom(), 
						pTextStyle->GetWidth(), pTextStyle->GetHeight(), &rcStatic, &rcStyle);

					POINT point;
					point.x = size.cx;
					point.y = size.cy;
					if (!rcStyle.PtInRect(point))
					{
						pCtrlManager->AddToolTip((LPTSTR)lpszText);
					}

					break;
				}
			}
		}
	}
}
Пример #3
0
void duSpin::OnMouseDbClick(POINT pt)
{
	duPoint ptSpin(pt);
	
	duRect rcSpin;
	Plugin_GetRect(this, &rcSpin);
	ptSpin.Offset(-rcSpin.left, -rcSpin.top);
	
	if (!m_fReadOnly && ::PtInRect(&m_rcFormat, ptSpin))
		duEdit::OnMouseLDown(pt);
}
Пример #4
0
void duIMPanelNode::DrawObject(HDC hDC)
{
	duRect rcIMPanelNode;
	Plugin_GetRect(this, &rcIMPanelNode);
	rcIMPanelNode.OffsetRect(-rcIMPanelNode.left, -rcIMPanelNode.top);

	duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP);
	if (pStyleGroup)
		pStyleGroup->Draw(hDC, &rcIMPanelNode, GetState(), GetText(), GetAlpha());

}
Пример #5
0
void duTreeCtrl::OnMouseMove(POINT pt)
{
	duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd);
	duRect rcTreeCtrl;
	Plugin_GetRect(this, &rcTreeCtrl);

	duRect rcItem;
	rcItem.SetRectEmpty();
	TreeCtrlItem *pItem = yHitTest(rcTreeCtrl, pt, rcItem);
	if (m_pHot != pItem)
	{
		m_pHot = pItem;
		Plugin_Redraw(this, TRUE);
		if(m_fShowTooltip)
		{
			pCtrlManager->DelToolTip();
			m_fShowTooltip = FALSE;
		}
	}
	
	if (pItem == NULL)
	{
		m_hitCode = tc_hit_empty;
		if(m_fShowTooltip)
		{
			pCtrlManager->DelToolTip();
			m_fShowTooltip = FALSE;
		}
	}
	else
	{
		POINT ptClient(pt);
		ptClient.x -= rcTreeCtrl.left;
		ptClient.y -= rcTreeCtrl.top;
		
		int nLeft = (pItem->nLevel - 1) * m_nIndentWidth;
		duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight);
		if (ItemHasChildren(pItem) && (rcIndent.PtInRect(ptClient)))
			m_hitCode = tc_hit_indent;

		nLeft += (m_nIndentWidth + m_nIndentIconSpace);
		duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight);
		if (rcIcon.PtInRect(ptClient))
			m_hitCode = tc_hit_icon;

		duRect rcText;
		nLeft += (m_nIconWidth + m_nIconTextSpace);
		rcText = rcItem;
		rcText.left = rcItem.left + nLeft;
		if (rcText.PtInRect(ptClient))
			m_hitCode = tc_hit_text;
	}
}
Пример #6
0
void WINAPI duXmlStatic::DrawObject(HDC hDC)
{
	duRect rectStatic;
	Plugin_GetRect(this, &rectStatic);
	rectStatic.OffsetRect(-rectStatic.left, -rectStatic.top);

	duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP);
	if (pStyleGroup)
		pStyleGroup->Draw(hDC, &rectStatic, GetState(), NULL, GetAlpha());
		
	DrawXmlText(hDC);
}
Пример #7
0
TreeCtrlItem * duTreeCtrl::HitTest(LPPOINT lppt)
{
	duRect rcTreeCtrl;
	Plugin_GetRect(this, &rcTreeCtrl);

	duRect rcItem;
	rcItem.SetRectEmpty();
	POINT pt;
	pt.x = lppt->x;
	pt.y = lppt->y;
	TreeCtrlItem *pItem = yHitTest(rcTreeCtrl, pt, rcItem);
	return pItem;
}
Пример #8
0
BOOL WINAPI duListBox::UpdateScroll()
{
	duScroll *pVScroll = (duScroll *)GetPluginByName(m_szVertScroll);
	if (pVScroll == NULL)
		return FALSE;
	
	int nItemCount = GetItemCount();
	int nViewHeight = nItemCount * m_nItemHeight;
	
	duRect rcListBox;
	Plugin_GetRect(this, &rcListBox);
	
	duRect rcVScroll;
	Plugin_GetRect(pVScroll, &rcVScroll);
	
	if (nViewHeight > rcListBox.Height())
	{
		int nPage = rcListBox.Height();

		pVScroll->SetVisible(TRUE);
		pVScroll->SetMaxPos(nViewHeight);
		pVScroll->SetPage(nPage);
		if (pVScroll->GetPos() > (nViewHeight-nPage))
			pVScroll->SetPos(nViewHeight-nPage);

		//pVScroll->SetPosBottom(0);
		pVScroll->Resize(NULL);
		m_nYOffset = pVScroll->GetPos();
		m_fVert = TRUE;
	}
	else
	{
		pVScroll->SetVisible(FALSE);
		m_nYOffset = 0;
		m_fVert = FALSE;
	}
	
	return TRUE;
}
Пример #9
0
void WINAPI duListBox::OnMouseMove(POINT pt)
{
	duRect rcListBox;
	Plugin_GetRect(this, &rcListBox);
	
	pt.x -= rcListBox.left;
	pt.y -= rcListBox.top;

	duPlugin *pScroll = GetPluginByName(m_szVertScroll);

	
	duRect rcItem;
	rcItem.SetRectEmpty();
	if(pScroll != NULL && Plugin_IsVisible(pScroll))
		rcItem.right = rcListBox.Width() - pScroll->GetPosWidth();
	else
		rcItem.right = rcListBox.Width();
	
	rcItem.OffsetRect(0, -m_nYOffset);
	
	int i;
	int nItemCount = GetItemCount();
	ListBoxItem *pItem = NULL;
	for (i = 0;i < nItemCount; i++)
	{
		rcItem.top = rcItem.bottom;
		rcItem.bottom = rcItem.top + m_nItemHeight;
		pItem = m_vtItem[i];
		
		if (rcItem.PtInRect(pt) && m_pHotItem != pItem)
		{
			if (pItem->fDisable)
			{
				m_pHotItem = NULL;
				Plugin_Redraw(this, TRUE);
			}
			else
			{
				m_pHotItem = pItem;
				if (m_pHotItem != m_pSelItem)
					FadeRedraw();
			}
			break;
		}
	}
}
Пример #10
0
void duXmlStatic::DrawXmlText(HDC hDC)
{
	if (m_vtXmlText.size() <= 0)
		return;
	
	duRect rectStatic;
	Plugin_GetRect(this, &rectStatic);
	rectStatic.OffsetRect(-rectStatic.left, -rectStatic.top);
	
	duRect rcLine;
	int nSegMentLeft;
	duRect rcSegMent;
	
	int nLineCount = (int)m_vtLine.size();
	int i;
	int nCurTop = 0;
	int nCurTextIndex = 0;
	for (i = 0;i < nLineCount; i++)
	{
		XMLSTATICLINE *pLine = m_vtLine[i];
		rcLine.SetRectEmpty();
		rcLine.right = rectStatic.Width();
		rcLine.top = nCurTop;
		rcLine.bottom = nCurTop + pLine->nHeight;
		
		int j;
		nSegMentLeft = 0;
		for (j = 0;j < (int)pLine->vtLineSegment.size(); j++)
		{
			XMLSTATICLINESEGMENT *pSegment = pLine->vtLineSegment[j];
			rcSegMent.SetRectEmpty();
			
			rcSegMent.left = nSegMentLeft;
			rcSegMent.right = nSegMentLeft + pSegment->nWidth; 
			rcSegMent.bottom = rcLine.bottom;
			rcSegMent.top = rcSegMent.bottom - pSegment->nHeight;
			
			PaintSegMent(hDC, pSegment, rcSegMent);
			
			nSegMentLeft = rcSegMent.right;
		}
		
		nCurTop += (pLine->nHeight + m_nParagraphSpace);
	}
}
Пример #11
0
void duSplitter::OnMouseLDown(POINT pt)
{
	duPlugin *pFPlugin = GetPluginByName(m_szFName);
	duPlugin *pSPlugin = GetPluginByName(m_szSName);
	
	if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin))
		return;

	duRect rectSplitter;
	Plugin_GetRect(this, &rectSplitter);
	if (rectSplitter.PtInRect(pt))
	{
		m_ptStart = pt;
		m_rectLast.SetRectEmpty();
		m_fTracking = TRUE;
		Plugin_SetState(this, DU_STATE_PRESS);
		Plugin_SetCapture(this);
		Plugin_Redraw(this, TRUE);
	}
}
Пример #12
0
void WINAPI duXmlStatic::OnMouseMove(POINT pt)
{
	duRect rectStatic;
	Plugin_GetRect(this, &rectStatic);
	
	POINT ptStatic(pt);
	ptStatic.x -= rectStatic.left;
	ptStatic.y -= rectStatic.top;
	rectStatic.OffsetRect(-rectStatic.left, -rectStatic.top);
	duRect rcLine;
	duRect rcSegMent;
	int nSegMentLeft = 0;

	int nLineCount = (int)m_vtLine.size();
	int i;
	int nCurTop = 0;
	int nCurTextIndex = 0;
	for (i = 0;i < nLineCount; i++)
	{
		XMLSTATICLINE *pLine = m_vtLine[i];
		rcLine.SetRectEmpty();
		rcLine.right = rectStatic.Width();
		rcLine.top = nCurTop;
		rcLine.bottom = nCurTop + pLine->nHeight;
		
		int j;
		nSegMentLeft = 0;
		for (j = 0;j < (int)pLine->vtLineSegment.size(); j++)
		{
			XMLSTATICLINESEGMENT *pSegment = pLine->vtLineSegment[j];
			rcSegMent.SetRectEmpty();
			
			rcSegMent.left = nSegMentLeft;
			rcSegMent.right = nSegMentLeft + pSegment->nWidth; 
			rcSegMent.bottom = rcLine.bottom;
			rcSegMent.top = rcSegMent.bottom - pSegment->nHeight;
			
			if (rcSegMent.PtInRect(ptStatic))
			{
				if (m_pHotSegMent != pSegment)
				{
					BOOL fNeedRedraw = FALSE;
					if (IsHrefSegment(m_pHotSegMent) || IsHrefSegment(pSegment))
						fNeedRedraw = TRUE;
					
					m_pHotSegMent = pSegment;
					if (fNeedRedraw)
						Plugin_Redraw(this, TRUE);
				}
				return;
			}
			
			nSegMentLeft = rcSegMent.right;
		}
		
		nCurTop += (pLine->nHeight + m_nParagraphSpace);
	}
	
	if (IsHrefSegment(m_pHotSegMent))
	{
		m_pHotSegMent = NULL;
		Plugin_Redraw(this, TRUE);
	}
	else
		m_pHotSegMent = NULL;
}
Пример #13
0
void WINAPI duComboBox::OnMouseLDown(POINT pt)
{
	duPoint ptCombo(pt);
	
	duRect rcCombobox;
	Plugin_GetRect(this, &rcCombobox);
	ptCombo.Offset(-rcCombobox.left, -rcCombobox.top);
	
	if (!m_fReadOnly && ::PtInRect(&m_rcFormat, ptCombo))
		duEdit::OnMouseLDown(pt);
	else
	{
		Plugin_SetState(this, DU_STATE_PRESS);
		Plugin_Redraw(this, TRUE);

		RegisterComboListClass();

		ptCombo.x = rcCombobox.left;
		ptCombo.y = rcCombobox.bottom;
		::ClientToScreen(m_hWnd, &ptCombo);

		HWND hwndDesktop = ::GetDesktopWindow();
		int nWindowHeight = CalcListBoxHeight();
		m_hWndListBox = ::CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST, lpszComboxClassName, _T(""),
			WS_CHILD, ptCombo.x, ptCombo.y, rcCombobox.Width(), nWindowHeight, hwndDesktop, (HMENU)1001,
			(HINSTANCE)::GetModuleHandle(NULL), (LPVOID)this);

		if (m_hWndListBox == NULL)
			return;

		if (nWindowHeight <= 6)
			::SetWindowPos(m_hWndListBox, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE);
		else
		{
			DWORD dwStartTick =::GetTickCount();
			int nWinHeight = 0;
			int nAnimateCount = (nWindowHeight / 5) + 1;
			int i;
			for (i = 0;i < 6; i++)
			{
				nWinHeight += nAnimateCount;
				if (nWinHeight >= nWindowHeight)
					nWinHeight = nWindowHeight;
					
				if (::GetTickCount() - dwStartTick > 200)
				{
					::SetWindowPos(m_hWndListBox, HWND_TOPMOST, 0, 0, rcCombobox.Width(), nWindowHeight, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOMOVE);
					break;
				}
				
				::SetWindowPos(m_hWndListBox, HWND_TOPMOST, 0, 0, rcCombobox.Width(), nWinHeight, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOMOVE);
				::RedrawWindow(m_hWndListBox, NULL, NULL, RDW_UPDATENOW|RDW_INTERNALPAINT);
				::Sleep(40);
			}
		}
		
		HWND hWndOwner = m_hWnd;
		while (::GetWindowLong(hWndOwner, GWL_STYLE) & WS_CHILD)
			hWndOwner = ::GetParent(hWndOwner);
		

		TrackPopup(this, hWndOwner, m_hWndListBox);
		SetEnd(FALSE);
		m_hWndListBox = NULL;

		Plugin_SetState(this, DU_STATE_NORMAL);
		Plugin_Redraw(this, TRUE);
	}
}
Пример #14
0
void duSplitter::MoveHorz(int nDistance)
{
	duPlugin *pFPlugin = GetPluginByName(m_szFName);
	duPlugin *pSPlugin = GetPluginByName(m_szSName);
	duPlugin *pParent = GetParent();
	
	if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin) || !Plugin_IsValid(pParent))
		return;

	duRect rectFirst, rectSplitter, rectSecond, rectParent;
	Plugin_GetRect(pFPlugin, &rectFirst);
	Plugin_GetRect(pSPlugin, &rectSecond);
	Plugin_GetRect(this, &rectSplitter);
	Plugin_GetRect(pParent, &rectParent);
	
	// Move first
	int nFirstWidth = rectFirst.Width() - nDistance;
	int nFirstRight = rectParent.right - (rectFirst.left + nFirstWidth);
 	int nFirstRatio = 0;
	if (rectParent.Width() > 0)
		nFirstRatio = (int)nFirstWidth / (float)rectParent.Width();
	
	int first_HorzType = pFPlugin->GetPosHorzAnchor();
	if (first_HorzType == 0)
		pFPlugin->SetPosWidth(nFirstWidth);
	else if (first_HorzType == 1)
		pFPlugin->SetPosWidth(nFirstRatio);
	else if (first_HorzType == 2)
		pFPlugin->SetPosRight(nFirstRight);
	
	Plugin_Resize(pFPlugin, NULL);

	// Move splitter
	Plugin_GetRect(pFPlugin, &rectFirst);
	int splitter_HorzType = GetPosHorzAnchor();
	if (splitter_HorzType != 0)
	{
		SetPosHorzAnchor(0);
		SetPosWidth(rectSplitter.Width());
	}

	int nSplitterLeft = rectFirst.right - rectParent.left;
	SetPosLeft(nSplitterLeft);
	Plugin_Resize(this, NULL);

	// Move second
	Plugin_GetRect(this, &rectSplitter);
	int nSecondLeft_positive = max(0, rectSplitter.right - rectParent.left);
	int nSecondLeft_negative = min(0, nSecondLeft_positive - rectParent.Width());

	int nSecondWidth = rectSecond.right - rectSplitter.right;
	int nSecondRight = rectParent.right - (rectSplitter.right + nSecondWidth);
	int nSecondRatio = 0;
	if (rectSecond.Width())
		nSecondRatio = (int)nSecondWidth / (float)rectSecond.Width();

	if (pSPlugin->GetPosLeft() < 0)
		pSPlugin->SetPosLeft(nSecondLeft_negative);
	else
		pSPlugin->SetPosLeft(nSecondLeft_positive);

	int second_HorzType = pSPlugin->GetPosHorzAnchor();
	if (second_HorzType == 0)
		pSPlugin->SetPosWidth(nSecondWidth);
	else if (second_HorzType == 1)
		pSPlugin->SetPosWidth(nSecondRatio);
	else if (second_HorzType == 2)
		pSPlugin->SetPosRight(nSecondRight);
	
	Plugin_Resize(pSPlugin, NULL);
	NotifyUser(DUM_SPLITTERMOVED, NULL, NULL);
}
Пример #15
0
void duSplitter::MoveVert(int nDistance)
{
	duPlugin *pFPlugin = GetPluginByName(m_szFName);
	duPlugin *pSPlugin = GetPluginByName(m_szSName);
	duPlugin *pParent = GetParent();
	
	if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin) || !Plugin_IsValid(pParent))
		return;

	duRect rectFirst, rectSplitter, rectSecond, rectParent;
	Plugin_GetRect(pFPlugin, &rectFirst);
	Plugin_GetRect(pSPlugin, &rectSecond);
	Plugin_GetRect(this, &rectSplitter);
	Plugin_GetRect(pParent, &rectParent);

	// Move first
	int nFirstHeight = rectFirst.Height() - nDistance;
	int nFirstBottom = rectParent.bottom - (rectFirst.top + nFirstHeight);
	int nFirstRatio = 0;
	if (rectParent.Height() > 0)
		nFirstRatio = (int) nFirstHeight / (float)rectParent.Height();

	int first_VertType = pFPlugin->GetPosVertAnchor();
	if (first_VertType == 0)
		pFPlugin->SetPosHeight(nFirstHeight);
	else if (first_VertType == 1)
		pFPlugin->SetPosHeight(nFirstRatio);
	else if (first_VertType == 2)
		pFPlugin->SetPosBottom(nFirstBottom);

	Plugin_Resize(pFPlugin, NULL);

	// Move splitter
	Plugin_GetRect(pFPlugin, &rectFirst);
	int splitter_VertType = GetPosVertAnchor();
	if (splitter_VertType != 0)
	{
		SetPosVertAnchor(0);
		SetPosHeight(rectSplitter.Height());
	}

	int nSplitterTop = rectFirst.bottom - rectParent.top;
	SetPosTop(nSplitterTop);
	Plugin_Resize(this, NULL);

	// Move second
	Plugin_GetRect(this, &rectSplitter);

	int nSecondTop_positive = max(0, rectSplitter.bottom - rectParent.top);
	int nSecondTop_negative = min(0, nSecondTop_positive - rectParent.Height());
	int nSecondHeight = rectSecond.bottom - rectSplitter.bottom;
	int nSecondBottom = rectParent.bottom - (rectSplitter.bottom + nSecondHeight);
	int nSecondRatio = 0;
	if (rectSecond.Height())
		nSecondRatio = (int)nSecondHeight / (float)rectSecond.Height();

	if (pSPlugin->GetPosTop() < 0)
		pSPlugin->SetPosTop( nSecondTop_negative );
	else
		pSPlugin->SetPosTop( nSecondTop_positive );

	int second_VertType = pSPlugin->GetPosVertAnchor();
	if (second_VertType == 0)
		pSPlugin->SetPosHeight(nSecondHeight);
	else if (second_VertType == 1)
		pSPlugin->SetPosHeight(nSecondRatio);
	else if (second_VertType == 2)
		pSPlugin->SetPosBottom(nSecondBottom);

	Plugin_Resize(pSPlugin, NULL);
	NotifyUser(DUM_SPLITTERMOVED, NULL, NULL);
}
Пример #16
0
void duSplitter::OnMouseMove(POINT pt)
{
	duPlugin *pFPlugin = GetPluginByName(m_szFName);
	duPlugin *pSPlugin = GetPluginByName(m_szSName);
	
	if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin))
		return;

	if (GetState() == DU_STATE_NORMAL)
	{
		Plugin_SetState(this, DU_STATE_OVER);
		Plugin_Redraw(this, TRUE);
	}

	if (m_fTracking)
	{
		duRect rectFirst;
		Plugin_GetRect(pFPlugin, &rectFirst);
		
		duRect rectSplitter;
		Plugin_GetRect(this, &rectSplitter);
		
		duRect rectSecond;
		Plugin_GetRect(pSPlugin, &rectSecond);
		duRect rectTracking = rectSplitter;

		if (m_fVert)
		{
			int yOffset = pt.y - m_ptStart.y;
			rectTracking.OffsetRect(0, yOffset);

			int nFirstMinY = rectFirst.top + m_nFMinPixel + (m_ptStart.y - rectSplitter.top);
			int nSecondMinY = rectSecond.bottom - m_nSMinPixel - (rectSplitter.bottom - m_ptStart.y);
            if (pt.y >= nFirstMinY && pt.y <= nSecondMinY)
			{
				OnInvertTracker(m_rectLast);
				OnInvertTracker(rectTracking);
				m_rectLast = rectTracking;
			}
			else
			{
				if (pt.y < nFirstMinY && m_rectLast.top != (rectFirst.top + m_nFMinPixel))
				{
					int nSplitterHeight = m_rectLast.Height();
					rectTracking.top = rectFirst.top + m_nFMinPixel;
					rectTracking.bottom = rectTracking.top + nSplitterHeight;
					OnInvertTracker(m_rectLast);
					OnInvertTracker(rectTracking);
					m_rectLast = rectTracking;
				}

				if (pt.y > nSecondMinY && m_rectLast.bottom != (rectSecond.bottom - m_nSMinPixel))
				{
					int nSplitterHeight = m_rectLast.Height();
					rectTracking.bottom = rectSecond.bottom - m_nSMinPixel;
					rectTracking.top = rectTracking.bottom - nSplitterHeight;
					OnInvertTracker(m_rectLast);
					OnInvertTracker(rectTracking);
					m_rectLast = rectTracking;
				}
			}
		}
		else
		{
			int xOffset = pt.x - m_ptStart.x;
			rectTracking.OffsetRect(xOffset, 0);
			int nFirstMinX  = rectFirst.left   + m_nFMinPixel + (m_ptStart.x - rectSplitter.left);
			int nSecondMinX = rectSecond.right - m_nSMinPixel - (rectSplitter.right - m_ptStart.x);
			if (pt.x >= nFirstMinX && pt.x <= nSecondMinX)
			{
				OnInvertTracker(m_rectLast);
				OnInvertTracker(rectTracking);
				m_rectLast = rectTracking;
			}
			else
			{
				if (pt.x < nFirstMinX && m_rectLast.left != (rectFirst.left + m_nFMinPixel))
				{
					int nSplitterWidth = m_rectLast.Width();
					rectTracking.left = rectFirst.left + m_nFMinPixel;
					rectTracking.right = rectTracking.left + nSplitterWidth;
					OnInvertTracker(m_rectLast);
					OnInvertTracker(rectTracking);
					m_rectLast = rectTracking;
				}

				if (pt.x > nSecondMinX && m_rectLast.right != (rectSecond.right - m_nSMinPixel))
				{
					int nSplitterWidth = m_rectLast.Width();
					rectTracking.right = rectSecond.right - m_nSMinPixel;
					rectTracking.left = rectTracking.right - nSplitterWidth;
					OnInvertTracker(m_rectLast);
					OnInvertTracker(rectTracking);
					m_rectLast = rectTracking;
				}
			}
		}
	
		//static int count = 0;

		//if (rectTracking.Height() != 10)
		//{
		//	__asm int 3;

		//_TRACE("[%d] pointClient  (%d, %d)\r\n", count, pointClient.x, pointClient.y);
		//_TRACE("[%d] m_ptStart (%d, %d)\r\n", count, m_ptStart.x, m_ptStart.y);

		//_TRACE("[%d] rectFirst   (%d, %d, %d, %d)\r\n", count, rectFirst.left, rectFirst.top, rectFirst.right, rectFirst.bottom);
		//_TRACE("[%d] rectSecond  (%d, %d, %d, %d)\r\n", count, rectSecond.left, rectSecond.top, rectSecond.right, rectSecond.bottom);
		//_TRACE("[%d] rectTracking(%d, %d, %d, %d,) Width : %d, Height : %d\r\n", 
		//	count, rectTracking.left, rectTracking.top, rectTracking.right, rectTracking.bottom, rectTracking.Width(), rectTracking.Height());

		//	count++;
		//}
	}
}
Пример #17
0
void duXmlStatic::ParseTextParam()
{
	LPCTSTR lpszText = GetText();
	if (lpszText == NULL || *lpszText == 0)
		return;
	
	TiXmlDocument *pXmlDoc = new TiXmlDocument;
	pXmlDoc->Parse(lpszText, NULL);
	
	TiXmlElement *pTextElement = pXmlDoc->FirstChildElement(_T("text"));
	if (pTextElement == NULL)
	{
		delete pXmlDoc;
		return;
	}
	
	Destroy();
	
	m_nParagraphSpace = ReadXmlAttributeInt(pTextElement, _T("ParagraphSpace"));
	ReadXmlAttributeText(pTextElement, _T("Font"), m_szDefaultFont, MAX_NAME);
	m_clrDefault = ReadXmlAttributeColor(pTextElement, _T("Color"));

	TiXmlNode *pChildNode = pTextElement->FirstChild();
	while (pChildNode)
	{
		if (pChildNode->Type() == TiXmlNode::ELEMENT)
		{
			TiXmlElement *pThis = pChildNode->ToElement();
			if (lstrcmpi(pThis->Value(), _T("br")) == 0)
			{
				XMLTEXTHEAD *pBrText = ParseBrText(pThis);
				if (pBrText)
					m_vtXmlText.push_back(pBrText);
			}
			else if (lstrcmpi(pThis->Value(), _T("text")) == 0)
			{
				XMLTEXTHEAD *pFormatText = ParseFormatText(pThis);
				if (pFormatText)
					m_vtXmlText.push_back(pFormatText);
			}
		}
		else if (pChildNode->Type() == TiXmlNode::TEXT)
		{
			TiXmlText *pThis = pChildNode->ToText();
			XMLTEXTHEAD *pNormalText = ParseNormalText(pThis);
			if (pNormalText)
				m_vtXmlText.push_back(pNormalText);
		}
		
		pChildNode = pChildNode->NextSibling();
	}
	
	//////////////////////////////////////////////////////////////////
	duRect rectStatic;
	Plugin_GetRect(this, &rectStatic);
	rectStatic.OffsetRect(-rectStatic.left, -rectStatic.top);
	
	int nTextCount = (int)m_vtXmlText.size();
	int i;
	int nCurrentLineWidth = 0;
	int nMaxHeight = 0;
	
	XMLSTATICLINE *pThisLine = NULL;
	for (i = 0;i < nTextCount; i++)
	{
		XMLTEXTHEAD *pTextHead = m_vtXmlText[i];
		MeasureString(pTextHead);
		
		if (pTextHead->size.cy > nMaxHeight)
			nMaxHeight = pTextHead->size.cy;

		if (pTextHead->enType == BRTEXT)
		{
			XMLSTATICLINESEGMENT *pLineSegment = new XMLSTATICLINESEGMENT;
			pLineSegment->pTextHead = pTextHead;
			pLineSegment->lpString = g_emptyString;
			pLineSegment->nStringWidth = 0;
			pLineSegment->nStringPosInTextHead = 0;
			pLineSegment->nWidth = pTextHead->size.cx;
			pLineSegment->nHeight = pTextHead->size.cy;

			if (pThisLine == NULL)
			{
				pThisLine = new XMLSTATICLINE;
				pThisLine->nWidth = 0;
				pThisLine->nHeight = 0;
				pThisLine->vtLineSegment.clear();
				m_vtLine.push_back(pThisLine);
			}

			pThisLine->nWidth = nCurrentLineWidth;
			pThisLine->nHeight = nMaxHeight;
			pThisLine->vtLineSegment.push_back(pLineSegment);

			pThisLine = NULL;
			nCurrentLineWidth = 0;
		}
		else
		{
			nCurrentLineWidth += pTextHead->size.cx;
			if (nCurrentLineWidth > rectStatic.Width())
			{
				XMLSTATICLINESEGMENT *pLineSegment = MeasureStringBreakPos(pTextHead, 0, nCurrentLineWidth - pTextHead->size.cx, rectStatic.Width());
				if (pLineSegment == NULL)
					_TRACE(_T("Error: pLineSegment is NULL\n"));
				
				if (pThisLine == NULL)
				{
					pThisLine = new XMLSTATICLINE;
					pThisLine->nWidth = 0;
					pThisLine->nHeight = 0;
					pThisLine->vtLineSegment.clear();
					m_vtLine.push_back(pThisLine);
				}

				pThisLine->nWidth = nCurrentLineWidth - pTextHead->size.cx + pLineSegment->nWidth;
				pThisLine->nHeight = nMaxHeight;
				pThisLine->vtLineSegment.push_back(pLineSegment);
				
				nMaxHeight = 0;
				
				int nRemainWidth = nCurrentLineWidth - pThisLine->nWidth;
				XMLSTATICLINESEGMENT *pLineSegment2 = pLineSegment;
				while (nRemainWidth > rectStatic.Width())
				{
					pLineSegment2 = MeasureStringBreakPos(pTextHead, pLineSegment2->nStringPosInTextHead + pLineSegment2->nStringWidth, 0, rectStatic.Width());
					if (pLineSegment2 == NULL)
						_TRACE(_T("Error: pLineSegment2 is NULL\n"));

					pThisLine = new XMLSTATICLINE;
					pThisLine->nWidth = pLineSegment2->nWidth;
					pThisLine->nHeight = pLineSegment2->nHeight;
					pThisLine->vtLineSegment.push_back(pLineSegment2);
					m_vtLine.push_back(pThisLine);

					nRemainWidth -= pLineSegment2->nWidth;
				}
				
				if (pLineSegment2->nStringPosInTextHead + pLineSegment2->nStringWidth < pLineSegment2->pTextHead->strText.length())
				{
					pThisLine = new XMLSTATICLINE;
					XMLSTATICLINESEGMENT *pLineSegment3 = new XMLSTATICLINESEGMENT;
					pLineSegment3->pTextHead = pTextHead;
					pLineSegment3->lpString = pLineSegment2->lpString + pLineSegment2->nStringWidth;
					pLineSegment3->nStringPosInTextHead = pLineSegment2->nStringPosInTextHead + pLineSegment2->nStringWidth ;
					pLineSegment3->nStringWidth = pLineSegment2->pTextHead->strText.length() - pLineSegment3->nStringPosInTextHead;
					pLineSegment3->nWidth = nRemainWidth;
					pLineSegment3->nHeight = pTextHead->size.cy;
					pThisLine->vtLineSegment.push_back(pLineSegment3);
					pThisLine->nWidth = 0;
					pThisLine->nHeight = 0;
					
					nMaxHeight = pTextHead->size.cy;
					m_vtLine.push_back(pThisLine);
				}

				nCurrentLineWidth = nRemainWidth;
			}
			else
			{
				XMLSTATICLINESEGMENT *pLineSegment = new XMLSTATICLINESEGMENT;
				pLineSegment->pTextHead = pTextHead;
				pLineSegment->lpString = pTextHead->strText.c_str();
				pLineSegment->nStringWidth = pTextHead->strText.length();
				pLineSegment->nStringPosInTextHead = 0;
				pLineSegment->nWidth = pTextHead->size.cx;
				pLineSegment->nHeight = pTextHead->size.cy;
				
				if (pThisLine == NULL)
				{
					pThisLine = new XMLSTATICLINE;
					pThisLine->nWidth = 0;
					pThisLine->nHeight = 0;
					m_vtLine.push_back(pThisLine);
				}
				
				pThisLine->vtLineSegment.push_back(pLineSegment);
			}
		}
	}
	
	if (pThisLine->nHeight == 0)
		pThisLine->nHeight = nMaxHeight;

	delete pXmlDoc;
}
Пример #18
0
void duTreeCtrl::DrawObject(HDC hDC)
{
	duRect rcTreeCtrl;
	Plugin_GetRect(this, &rcTreeCtrl);
	rcTreeCtrl.OffsetRect(-rcTreeCtrl.left, -rcTreeCtrl.top);

	BITMAPINFO bmInfo;
	BYTE *pBits;

	HDC hMemDC = ::CreateCompatibleDC(hDC);
	InitBitmapInfo(&bmInfo, rcTreeCtrl.Width(), rcTreeCtrl.Height());
	HBITMAP hBmp = ::CreateDIBSection(hDC, &bmInfo, DIB_RGB_COLORS,(void**)&pBits, 0, 0);
	HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, hBmp);

	BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
	::AlphaBlend(hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf);


	duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP);
	if (pStyleGroup)
		pStyleGroup->Draw(hMemDC, &rcTreeCtrl, GetState(), NULL, GetAlpha());
	
	int nOffsetY = 0;
	TreeCtrlItem *pFirstVisible = GetFirstVisibleItem(nOffsetY);
	if (pFirstVisible == NULL || pFirstVisible == m_pRoot)
		return;
		
	duRect rcClient = _GetClientRect();
	
	POINT ptView = GetViewPoint();
	duFont *pFont = (duFont *)GetResObj(m_szFont, DU_RES_FONT);
	
	duSize sizeView;
	GetViewSize(&sizeView);
	
	int nDrawHeight = -nOffsetY;
	TreeCtrlItem *pItem = pFirstVisible;
	while (pItem)
	{
		duRect rcItem;
		
		rcItem.left   = -ptView.x;
		rcItem.right  = rcClient.right;
		rcItem.top    = nDrawHeight;
		rcItem.bottom = rcItem.top + m_nItemHeight;

		UINT uItemState = DU_STATE_NORMAL;
		if (pItem == m_pHot)
			uItemState = DU_STATE_OVER;
		
		if (pItem == m_pSelect)
			uItemState = DU_STATE_PRESS;
		
		DrawByStyle(this, m_szItemStyle, hMemDC, &rcItem, uItemState, NULL, GetAlpha());

		// draw indent[-+]
		int nLeft = (pItem->nLevel - 1) * m_nIndentWidth;
		duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight);
		if (ItemHasChildren(pItem))
		{
			UINT nIndentState = pItem->fExpand ? DU_STATE_NORMAL : DU_STATE_CHECKED;
			DrawByStyle(this, m_szIndentStyle, hMemDC, &rcIndent, nIndentState, NULL, GetAlpha());
		}

		// draw icon
		nLeft += (m_nIndentWidth + m_nIndentIconSpace);
		duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight);
		duImage *pIcon = (duImage *)GetResObj(pItem->strImage.c_str(), DU_RES_IMAGE);
		if (pIcon)
			DrawNormal(hMemDC, rcIcon.left, rcIcon.top, rcIcon.Width(), rcIcon.Height(), pIcon, 0, 0, GetAlpha());

		// draw text
		duRect rcText;
		nLeft += (m_nIconWidth + m_nIconTextSpace);
		rcText = rcItem;
		rcText.left = rcItem.left + nLeft;
		if (pItem->strText.length() > 0)
			DrawText32Bpp(hMemDC, pFont, m_clrText, pItem->strText.c_str(), pItem->strText.length(), &rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE, GetAlpha());

		if (nDrawHeight - nOffsetY > rcTreeCtrl.Height())
			break;

		nDrawHeight += m_nItemHeight;
		pItem = GetNextVisibleItem(pItem);
	}

	::AlphaBlend(hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf);

	::SelectObject(hMemDC, hOldBitmap);
	::DeleteObject(hBmp);
	::DeleteDC(hMemDC);
}
Пример #19
0
void duLEDTimer::DrawObject(HDC hDC)
{
	duRect rcLEDTimer;
	Plugin_GetRect(this, &rcLEDTimer);
	rcLEDTimer.OffsetRect(-rcLEDTimer.left, -rcLEDTimer.top);

	duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP);
	if (pStyleGroup)
	    pStyleGroup->Draw(hDC, &rcLEDTimer, GetState(), NULL, GetAlpha());

	duImage *pImage = (duImage *)GetResObj(m_szImageFont, DU_RES_IMAGE);
	if (pImage == NULL)
		return;
		
	LPCTSTR lpszText = GetText();
	int nImageWidth = pImage->GetWidth();
	int nImageHeight = pImage->GetHeight();
	int nTextLength = _tcslen(lpszText);
	int nFontWidth = nImageWidth / 12;
	
	HDC hMemDC = ::CreateCompatibleDC(hDC);
	HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, pImage->GetBitmap());
	BLENDFUNCTION bf = {AC_SRC_OVER, 0, GetAlpha(), AC_SRC_ALPHA};
	
	int i;
	int xDst = 0, yDst = 0;
	int xSrc;
	for (i = 0;i < nTextLength; i++)
	{
		xSrc = 0;
		switch (lpszText[i])
		{
		case '1':
			xSrc = 0;
			break;
		case '2':
			xSrc = nFontWidth;
			break;
		case '3':
			xSrc = nFontWidth * 2;
			break;
		case '4':
			xSrc = nFontWidth * 3;
			break;
		case '5':
			xSrc = nFontWidth * 4;
			break;
		case '6':
			xSrc = nFontWidth * 5;
			break;
		case '7':
			xSrc = nFontWidth * 6;
			break;
		case '8':
			xSrc = nFontWidth * 7;
			break;
		case '9':
			xSrc = nFontWidth * 8;
			break;
		case '0':
			xSrc = nFontWidth * 9;
			break;
		case ':':
			xSrc = nFontWidth * 10;
			break;
		case '-':
			xSrc = nFontWidth * 11;
			break;

		default:
			xSrc = 0;
			break;
		}

		::AlphaBlend(hDC, xDst, 0, nFontWidth, nImageHeight, hMemDC, xSrc, 0, nFontWidth, nImageHeight, bf);
		xDst += nFontWidth;
	}

	::SelectObject(hMemDC, hOldBitmap);
	::DeleteDC(hMemDC);
}
Пример #20
0
static LRESULT WINAPI ComboListBox_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	duComboBox *pComboBox = NULL;
	
	if (uMsg == WM_NCCREATE)
	{
		LPCREATESTRUCT lpCS = (LPCREATESTRUCT)lParam;
		pComboBox = (duComboBox *)lpCS->lpCreateParams;
		if (!Plugin_IsValid(pComboBox))
			return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
		
		::SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pComboBox);
	}
	
	pComboBox = (duComboBox *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
	if (!pComboBox || !Plugin_IsValid(pComboBox))
		return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
	
	switch (uMsg)
	{
		case WM_CREATE:
		{
			duCtrlManager *pCtrlManager = GetCtrlManager(pComboBox->GetHwnd());
			if (pCtrlManager == NULL)
				break;
				
			duWindowManager *pWinManager = pCtrlManager->GetWindowManager();
			if (pWinManager == NULL)
				break;
			
			WindowManager_Attach(pWinManager, hWnd, pComboBox->m_szWindow);
			duCtrlManager *pNewCtrlManager = GetCtrlManager(hWnd);
			if (pNewCtrlManager == NULL)
				return -1;

			duWindow *pWindow = (duWindow *)pNewCtrlManager->GetPluginByName(pComboBox->m_szWindow);
			if (pWindow == NULL)
				return -1;

			duRect rcWindow;
			::GetWindowRect(hWnd, &rcWindow);
			pWindow->SetPosWidth(rcWindow.Width());
			pWindow->SetPosHeight(rcWindow.Height());
			pWindow->Resize(NULL);
			
			duListBox *pListBox = (duListBox *)pNewCtrlManager->GetPluginByName(pComboBox->m_szListBox);
			if (!Plugin_IsValid(pListBox))
				return -1;
			
			pListBox->SetComboBoxListBox(TRUE);
			vector<ListBoxItem *> &vtListBoxItem = pListBox->GetItemVector();

			int nItemCount = (int)pComboBox->GetItemCount();
			int i;
			ListBoxItem *pItem = NULL;
			for (i = 0; i < nItemCount; i++)
			{
				pItem = pComboBox->GetItem(i);
				ListBoxItem *pNewItem = new ListBoxItem;
				
				if (pItem->uIconX == LISTBOX_DEFAULT_VALUE)
					pNewItem->uIconX = pListBox->m_nItemIconX;
				else
					pNewItem->uIconX = pItem->uIconX;
			
				if (pItem->uIconY == LISTBOX_DEFAULT_VALUE)
					pNewItem->uIconY = pListBox->m_nItemIconY;
				else
					pNewItem->uIconY = pItem->uIconY;

				if (pItem->uIconWidth == LISTBOX_DEFAULT_VALUE)
					pNewItem->uIconWidth = pListBox->m_nItemIconWidth;
				else
					pNewItem->uIconWidth = pItem->uIconWidth;

				if (pItem->uIconHeight == LISTBOX_DEFAULT_VALUE)
					pNewItem->uIconHeight = pListBox->m_nItemIconHeight;
				else
					pNewItem->uIconHeight = pItem->uIconHeight;
				
				pNewItem->szIcon = pItem->szIcon;
				pNewItem->szText = pItem->szText;
				pNewItem->fDisable = pItem->fDisable;
				
				vtListBoxItem.push_back(pNewItem);
			}
			
			Plugin_SetFocus(pListBox, TRUE);
		}
		break;

		case WM_DIRECTUI_NOTIFY:
		{
			duPlugin *pPlugin = (duPlugin *)wParam;
			duNotify *pNotify = (duNotify *)lParam;

			if ((lstrcmpi(pPlugin->GetName(), pComboBox->m_szListBox) == 0) && (pNotify->uMsg == DUM_LBSELCHANGED))
			{
				duCtrlManager *pCtrlManager = GetCtrlManager(hWnd);
				if (pCtrlManager == NULL)
					return 0;

				duListBox *pListBox = (duListBox *)pCtrlManager->GetPluginByName(pComboBox->m_szListBox);
				if (pListBox == NULL)
					return 0;

				LPCTSTR lpszText = pListBox->GetItemText(pNotify->lParam);
				pComboBox->m_nCurSel = (int)pNotify->lParam;
				pComboBox->SetText(lpszText);
				pComboBox->SetEnd(TRUE);

				pComboBox->NotifyUser(DUM_COMBOSELCHANGE, pNotify->lParam, NULL);
			}
		}
		break;

		case WM_LBUTTONDOWN:
		{
			POINT pt;
			pt.x = GET_X_LPARAM(lParam);
			pt.y = GET_Y_LPARAM(lParam);

			duCtrlManager *pCtrlManager = GetCtrlManager(hWnd);
			if (pCtrlManager == NULL)
				return 0;

			duListBox *pListBox = (duListBox *)pCtrlManager->GetPluginByName(pComboBox->m_szListBox);
			if (pListBox == NULL)
				return 0;

			duScroll *pScroll = pListBox->GetVertScrollBar();
			if (pScroll == NULL)
			{
				pComboBox->SetEnd(TRUE);
				return 0;
			}

			duRect rcScroll;
			Plugin_GetRect(pScroll, &rcScroll);
			if (!rcScroll.PtInRect(pt))
				pComboBox->SetEnd(TRUE);
		}
		break;

		default:
			return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
	
	return 0;
}