Ejemplo n.º 1
0
LRESULT HandleCustomDraw(UINT ctrlid, NMCSBCUSTOMDRAW *nm)
{
	RECT *rc;
	CustomDrawTable *cdt;
	UINT code = NM_CUSTOMDRAW;

	UNREFERENCED_PARAMETER(ctrlid);

	// inserted buttons do not use PREPAINT etc..
	if(nm->nBar == SB_INSBUT)
	{
		CoolSB_DrawProc(nm->hdc, nm->uItem, nm->uState, &nm->rect);
		return CDRF_SKIPDEFAULT;
	}

	if(!fCustomDraw) return CDRF_DODEFAULT;

	if(nm->dwDrawStage == CDDS_PREPAINT)
	{
		if(fCustomDraw)
			return CDRF_SKIPDEFAULT;
		else
			return CDRF_DODEFAULT;
	}

	if(nm->dwDrawStage == CDDS_POSTPAINT)
	{
		
	}

	//the sizing gripper in the bottom-right corner
	if(nm->nBar == SB_BOTH)	
	{
		RECT *rc = &nm->rect;
		
		StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top,
			hdcSkin, 100, 100, 18, 18, SRCCOPY);
				
		return CDRF_SKIPDEFAULT;
	}
	else if(nm->nBar == SB_HORZ)
	{
		rc = &nm->rect;

		if(nm->uState == CDIS_HOT)	
			cdt = &cdt_horz_hot[nm->uItem];
		else if(nm->uState == CDIS_SELECTED) 
			cdt = &cdt_horz_active[nm->uItem];
		else				   
			cdt = &cdt_horz_normal[nm->uItem];
		
		if(nm->uItem == HTSCROLL_THUMB)
		{
			StretchBlt(nm->hdc, rc->left,   rc->top, 9, rc->bottom-rc->top, hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
			cdt++;
			StretchBlt(nm->hdc, rc->left+9, rc->top, (rc->right-rc->left)-18, rc->bottom-rc->top, hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
			cdt++;
			StretchBlt(nm->hdc, rc->left+(rc->right-rc->left)-9, rc->top, 9, rc->bottom-rc->top, hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
			return CDRF_SKIPDEFAULT;
		}

	}
	else if(nm->nBar == SB_VERT)
	{
		rc = &nm->rect;

		if(nm->uState == CDIS_HOT)		
			cdt = &cdt_vert_hot[nm->uItem];
		else if(nm->uState == CDIS_SELECTED)  
			cdt = &cdt_vert_active[nm->uItem];
		else				    
			cdt = &cdt_vert_normal[nm->uItem];

		if(nm->uItem == HTSCROLL_THUMB)
		{
			StretchBlt(nm->hdc, rc->left, rc->top,   rc->right-rc->left, 9, hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
			cdt++;
			StretchBlt(nm->hdc, rc->left, rc->top+9, rc->right-rc->left, (rc->bottom-rc->top)-18, hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
			cdt++;			
			StretchBlt(nm->hdc, rc->left, rc->top+(rc->bottom-rc->top)-9, rc->right-rc->left, 9,hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
			return CDRF_SKIPDEFAULT;
		}
	}
	//INSERTED BUTTONS are handled here...
	else if(nm->nBar == SB_INSBUT)
	{
		CoolSB_DrawProc(nm->hdc, nm->uItem, nm->uState, &nm->rect);
		return CDRF_SKIPDEFAULT;
	}
	else
	{
		return CDRF_DODEFAULT;
	}

	//normal bitmaps, use same code for HORZ and VERT
	StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top,
		hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);

	return CDRF_SKIPDEFAULT;

}
Ejemplo n.º 2
0
LRESULT WINAPI HandleCustomDraw(UINT ctrlid, NMCSBCUSTOMDRAW *nm)
{
	//using namespace Skin;

	RECT *rc;
	CustomDrawTable *cdt;
	UINT code = NM_CUSTOMDRAW;
	int temp = 0;
	int thumblen = 0;

	int nPart;
	int nState;
	CComPtr<ISkinScheme> pss;
	GetCurrentScheme(&pss);

	UNREFERENCED_PARAMETER(ctrlid);

	// inserted buttons do not use PREPAINT etc..
	if(nm->nBar == SB_INSBUT)
	{
		CoolSB_DrawProc(nm->hdc, nm->uItem, nm->uState, &nm->rect);
		return CDRF_SKIPDEFAULT;
	}

	if(!fCustomDraw) return CDRF_DODEFAULT;

	if(nm->dwDrawStage == CDDS_PREPAINT)
	{
		if(fCustomDraw)
			return CDRF_SKIPDEFAULT;
		else
			return CDRF_DODEFAULT;
	}

	if(nm->dwDrawStage == CDDS_POSTPAINT)
	{
		
	}

	//the sizing gripper in the bottom-right corner
	if(nm->nBar == SB_BOTH)	
	{
		RECT *rc = &nm->rect;
		if  ( pss )
		{
			pss->DrawBackground( nm->hdc, SCROLLBAR, SBP_SIZEBOX, SZB_RIGHTALIGN, rc);
		}
		/*
		StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top,
			hdcSkin, cdt_box.x, cdt_box.y, cdt_box.width, cdt_box.height, SRCCOPY);
		*/		
		return CDRF_SKIPDEFAULT;
	}
	else if(nm->nBar == SB_HORZ) //ˮƽ
	{
		rc = &nm->rect;
		if ( nm->uItem == HTSCROLL_LEFT || nm->uItem == HTSCROLL_RIGHT )
		{
			if(nm->uState == CDIS_DISABLED)	
				nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED ;
			else if(nm->uState == CDIS_HOT)	
				nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTHOT : ABS_RIGHTHOT ;
			else if(nm->uState == CDIS_SELECTED) 
				nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED ;
			else				   
				nState = nm->uItem == HTSCROLL_LEFT ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL ;

			nState = SBP_ARROWBTN;
			
			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc);
			}
			return CDRF_SKIPDEFAULT;

		}
		else if ( nm->uItem == HTSCROLL_THUMB )
		{

			if(nm->uState == CDIS_DISABLED)	
				nState = SCRBS_DISABLED ;
			else if(nm->uState == CDIS_HOT)	
				nState = SCRBS_HOT ;
			else if(nm->uState == CDIS_SELECTED) 
				nState = SCRBS_PRESSED ;
			else				   
				nState = SCRBS_NORMAL ;

			// first draw thumb
			nState = SBP_THUMBBTNHORZ;
			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc);
			}
			// second draw gripper
			
			RECT rcGripper;
			BOOL bRet = pss->GetRect( SCROLLBAR, SBP_GRIPPERHORZ, nState, &rcGripper);
			if ( bRet )
			{
				if ( rc->right - rc->left > rcGripper.right - rcGripper.left + 4 )
				{
					RECT rcClient = *rc;
					rcClient.left = rcClient.left + ( rc->right - rc->left - rcGripper.right + rcGripper.left ) / 2;
					rcClient.right = rcClient.left + rcGripper.right - rcGripper.left;
					if  ( pss )
					{
						pss->DrawBackground( nm->hdc, SCROLLBAR, SBP_GRIPPERHORZ, nState, rc);
					}
					
				}
			}
			return CDRF_SKIPDEFAULT;

		}
		else if ( nm->uItem == HTSCROLL_PAGELEFT )
		{
			nState = SBP_LOWERTRACKHORZ;
			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc);
			}
			return CDRF_SKIPDEFAULT;
		}
		else if ( nm->uItem == HTSCROLL_PAGERIGHT )
		{
			nState = SBP_UPPERTRACKHORZ;
			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc);
			}
			return CDRF_SKIPDEFAULT;
		}

	}
	else if(nm->nBar == SB_VERT)
	{
		rc = &nm->rect;
		if ( nm->uItem == HTSCROLL_UP || nm->uItem == HTSCROLL_DOWN )
		{
			if(nm->uState == CDIS_DISABLED)	
				nState = nm->uItem == HTSCROLL_UP ? ABS_UPDISABLED : ABS_DOWNDISABLED ;
			else if(nm->uState == CDIS_HOT)	
				nState = nm->uItem == HTSCROLL_UP ? ABS_UPHOT : ABS_DOWNHOT ;
			else if(nm->uState == CDIS_SELECTED) 
				nState = nm->uItem == HTSCROLL_UP ? ABS_UPPRESSED : ABS_DOWNRESSED ;
			else				   
				nState = nm->uItem == HTSCROLL_UP ? ABS_UPNORMAL : ABS_DOWNNORMAL ;

			nState = SBP_ARROWBTN;

			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc);
			}
			return CDRF_SKIPDEFAULT;

		}
		else if ( nm->uItem == HTSCROLL_THUMB )
		{

			if(nm->uState == CDIS_DISABLED)	
				nState = SCRBS_DISABLED ;
			else if(nm->uState == CDIS_HOT)	
				nState = SCRBS_HOT ;
			else if(nm->uState == CDIS_SELECTED) 
				nState = SCRBS_PRESSED ;
			else				   
				nState = SCRBS_NORMAL ;

			// first draw thumb
			nState = SBP_THUMBBTNHORZ;
			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, nState, rc);
			}
			// second draw gripper

			RECT rcGripper;
			BOOL bRet = pss->GetRect( SCROLLBAR, SBP_GRIPPERHORZ, nState, &rcGripper);
			if ( bRet )
			{
				if ( rc->bottom - rc->top > rcGripper.bottom - rcGripper.top + 4 )
				{
					RECT rcClient = *rc;
					rcClient.top = rcClient.top + ( rc->bottom - rc->top - rcGripper.bottom + rcGripper.top ) / 2;
					rcClient.bottom = rcClient.top + rcGripper.bottom - rcGripper.top;
					if  ( pss )
					{
						pss->DrawBackground( nm->hdc, SCROLLBAR, SBP_GRIPPERVERT, nState, rc);
					}

				}
			}
			return CDRF_SKIPDEFAULT;

		}
		else if ( nm->uItem == HTSCROLL_PAGEGUP )
		{
			nState = SBP_LOWERTRACKVERT;
			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc);
			}
			return CDRF_SKIPDEFAULT;
		}
		else if ( nm->uItem == HTSCROLL_PAGEGDOWN )
		{
			nState = SBP_UPPERTRACKVERT;
			if  ( pss )
			{
				pss->DrawBackground( nm->hdc, SCROLLBAR, nPart, 1, rc);
			}
			return CDRF_SKIPDEFAULT;
		}
	}
	//INSERTED BUTTONS are handled here...
	else if(nm->nBar == SB_INSBUT)
	{
		CoolSB_DrawProc(nm->hdc, nm->uItem, nm->uState, &nm->rect);
		return CDRF_SKIPDEFAULT;
	}
	else
	{
		return CDRF_DODEFAULT;
	}

	//normal bitmaps, use same code for HORZ and VERT
	//StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top,
	//	hdcSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);

	return CDRF_SKIPDEFAULT;

}