Beispiel #1
0
BOOL CPuzzle::Init(int iRows, int iCols)
/***********************************************************************/
{
	if (iRows > MAX_ROWS)
		iRows = MAX_ROWS;
	if (iRows <= 1)
		iRows = 2;
	if (iCols > MAX_COLS)
		iCols = MAX_COLS;
	if (iCols <= 1)
		iCols = 2;

	if (iRows != m_iRows || iCols != m_iCols)
	{
		LPSCENE lpScene = CScene::GetScene(GetParent(m_hWnd));
		if (lpScene)
		{
			LPOFFSCREEN lpOffScreen = lpScene->GetOffScreen();
			if (lpOffScreen)
				lpOffScreen->CopyBits();
		}
		m_iRows = iRows;
		m_iCols = iCols;
		Setup();
	}
	return(TRUE);
}
Beispiel #2
0
LOCAL void Gauge_Paint (HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	if ( !hDC )
		return;

	LPSCENE lpScene = CScene::GetScene( GetParent(hWindow) );
	if ( lpScene )
	{
		RECT rect = *lpRect;
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rect, 2 );
		lpScene->Paint( hDC, &rect, (LPPOINT)lpRect );
	}

	LPHGAUGEINFO lpInfo;
	if ( !(lpInfo = Gauge_GetInfo (hWindow) ) )
		return;

	RECT  rClient;
	GetClientRect (hWindow, & rClient);
	int iX, iY;
	int iXCenter = rClient.left + ((rClient.right - rClient.left) / 2);
	POINT ptOrigin;
	ptOrigin.x = iXCenter;
	ptOrigin.y = rClient.bottom - 2;

	HPEN hPen = CreatePen (PS_SOLID, 2, lpInfo->rgbArmColor);
	HPEN hOldPen = (HPEN)SelectObject (hDC, hPen);

	// Position to the arm origin and draw the arm
	MoveToEx (hDC, ptOrigin.x, ptOrigin.y, NULL);
	GetEndPoint (lpInfo, ptOrigin, & iX, & iY);
	LineTo (hDC, iX, iY);
	SelectObject (hDC, hOldPen);
	DeleteObject (hPen);

//	HBRUSH hBrush, hBrushOld;
//	LOGBRUSH lb;
//	// Draw a circle at the origin
//	lb.lbStyle = BS_SOLID;
//	lb.lbColor = lpInfo->rgbCircleColor;
//	lb.lbHatch = 0;
//	hBrush = CreateBrushIndirect (& lb);
//	hBrushOld = (HBRUSH)SelectObject (hDC, hBrush);
//	Ellipse (hDC, ptOrigin.x - 4, ptOrigin.y - 4, ptOrigin.x + 4, ptOrigin.y + 4);
//	SelectObject (hDC, hBrushOld);
//	DeleteObject (hBrush);

//	// Draw a circle at the end of the arm
//	lb.lbStyle = BS_SOLID;
//	lb.lbColor = lpInfo->rgbEndCircleColor;
//	lb.lbHatch = 0;
//	hBrush = CreateBrushIndirect (& lb);
//	hBrushOld = (HBRUSH)SelectObject (hDC, hBrush);
//	Ellipse (hDC, iX - 3, iY - 3, iX + 3, iY + 3);
//	SelectObject (hDC, hBrushOld);
//	DeleteObject (hBrush);
}
Beispiel #3
0
//***************************************************************************
static long AVIDraw(PINSTINFO pi, ICDRAW FAR *lpicd, LONG cbicd)
//***************************************************************************
{
	UINT  wFlags;

	wFlags = DDF_SAME_HDC;
	if ((lpicd->dwFlags & ICDRAW_NULLFRAME) || !lpicd->lpData)
	{
		if (lpicd->dwFlags & ICDRAW_UPDATE)
			wFlags |= DDF_UPDATE;
		else
			return ICERR_OK;
	}
	if (lpicd->dwFlags & ICDRAW_PREROLL)
		wFlags |= DDF_DONTDRAW;
	if (lpicd->dwFlags & ICDRAW_HURRYUP)
		wFlags |= DDF_HURRYUP;

//	if ( lpMyDrawDibProc )
//	{
//		CDib MyDib( (LPBITMAPINFOHEADER)lpicd->lpFormat, ((LPBITMAPINFO)lpicd->lpFormat)->bmiColors, (LPTR)lpicd->lpData );
//		(*lpMyDrawDibProc)( &MyDib );
//	}
#ifdef UNUSED
	LPSCENE lpScene = CScene::GetScene(GetParent(GetFocus()));
	if ( lpScene )
	{
		PDIB lpDib;
		lpScene->GetDIBs( NULL, &lpDib, NULL );
		if ( lpDib )
		{
			CDib MyDib( (LPBITMAPINFOHEADER)lpicd->lpFormat, ((LPBITMAPINFO)lpicd->lpFormat)->bmiColors, (LPTR)lpicd->lpData );
			lpDib->DibBlt( &MyDib,	100/*dstLeft*/, 100/*dstTop*/, 100/*dstWidth*/, 100/*dstHeight*/,
									100/*srcLeft*/, 100/*srcTop*/, 100/*srcWidth*/, 100/*srcHeight*/,
									YES/*bTransparent*/, NULL/*lpRGB*/, NULL/*lpLut*/, NULL/*hPal*/ );
		}
	}
#endif

	if (!DrawDibDraw(pi->hdd, pi->hdc, pi->xDst, pi->yDst, pi->dxDst, pi->dyDst,
			(LPBITMAPINFOHEADER)lpicd->lpFormat, lpicd->lpData, pi->xSrc, pi->ySrc,
			pi->dxSrc, pi->dySrc, wFlags))
	{
		if (wFlags & DDF_UPDATE)
			return ICERR_CANTUPDATE;
		else
			return ICERR_UNSUPPORTED;
	}

//	if ( lpMyDrawDCProc )
//		(*lpMyDrawDCProc)( pi->hdc );

	TestDrawDCProc( pi->hdc );

	return ICERR_OK;
}
Beispiel #4
0
BOOL WINPROC EXPORT SceneDialogProc( HWND hDlg, UINT msg, WPARAM wParam,
							  LPARAM lParam )
/***********************************************************************/
{
	LPSCENE lpScene = CScene::GetScene(hDlg);
	if (lpScene)
		return(lpScene->DialogProc(hDlg, msg, wParam, lParam));
	else
		return(FALSE);
}
Beispiel #5
0
void CPuzzle::OnDraw(HDC hDC, LPRECT lpRect, BOOL fGrid)
/***********************************************************************/
{
	int iPieces;
	RECT rOut, rClient, rPaint, rWindow;
	HDC hDCOut;
	POINT ptDst;
	PDIB pDibOut = NULL;

	GetClientRect(m_hWnd, &rClient);
	GetWindowRect(m_hWnd, &rWindow);
	if (!IntersectRect(&rPaint, &rClient, lpRect))
		return;
	if (!m_pDib)
		return;

	LPSCENE lpScene = CScene::GetScene(GetParent(m_hWnd));
	if (!lpScene)
		return;
	LPOFFSCREEN lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
		hDCOut = lpOffScreen->GetDC();
		rOut = rPaint;
		MapWindowPoints( m_hWnd, GetParent(m_hWnd), (LPPOINT)&rOut, 2 );
		MapWindowPoints( m_hWnd, GetParent(m_hWnd), (LPPOINT)&rClient, 2 );
		MapWindowPoints( NULL, GetParent(m_hWnd), (LPPOINT)&rWindow, 2 );
		pDibOut = lpOffScreen->GetWritableDIB();
	}
	else
		hDCOut = hDC;

	iPieces = m_iCols * m_iRows;
	for (int i = 0; i < iPieces; ++i)
		DrawPiece(i, hDCOut, pDibOut, (LPPOINT)&rClient.left, &rPaint, fGrid);

	if (m_iSelect >= 0)
	{
		if (m_bHintMode)
			DrawHint(m_iSelect, hDCOut, (LPPOINT)&rClient.left, &rPaint);
		DrawPiece(m_iSelect, hDCOut, pDibOut, (LPPOINT)&rClient.left, &rPaint, FALSE, &m_ptSelect);
	}

	// when we are all done we draw from the WinG DC to the output DC
	if (lpOffScreen)
	{
		ptDst.x = rPaint.left;
		ptDst.y = rPaint.top;
		lpOffScreen->DrawRect( hDC, &rOut, &ptDst );
	}
}
Beispiel #6
0
void CLGBApp::OnPaletteChanged(HWND hWnd, HWND hWndCausedBy)
/***********************************************************************/
{ // Some app caused (or is causing) the palette to change
	PTOON pToon = NULL;
	LPSCENE lpScene = GetScene();
	if (lpScene)
	    pToon = lpScene->GetToon();
    if (pToon)
	{
        pToon->OnPaletteChanged(hWnd, hWndCausedBy);
	}
    else           
	{
		CPHApp::OnPaletteChanged(hWnd, hWndCausedBy);
	}
}
Beispiel #7
0
BOOL CLGBApp::OnQueryNewPalette(HWND hWnd)
/***********************************************************************/
{ // Receiving focus; chance to select and realize our palette
    // first see if there is a toon control somewhere
	PTOON pToon = NULL;
	LPSCENE lpScene = GetScene();
	if (lpScene)
	    pToon = lpScene->GetToon();
    if (pToon)
	{
        return(pToon->OnQueryNewPalette(hWnd));
	}
    else
	{
		return(CPHApp::OnQueryNewPalette(hWnd));
	}
}
Beispiel #8
0
LOCAL void Hotspot_OnPaint(HWND hWindow)
/***********************************************************************/
{
	PAINTSTRUCT ps;
	HDC hDC;

	if ( !(hDC = BeginPaint( hWindow, &ps )) )
		return;

	LPSCENE lpScene = CScene::GetScene( GetParent(hWindow) );
	if ( lpScene )
	{
		RECT rect = ps.rcPaint;
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rect, 2 );
		lpScene->Paint( hDC, &rect, (LPPOINT)&ps.rcPaint );
	}

	EndPaint( hWindow, &ps );
}
Beispiel #9
0
LONG WINPROC EXPORT SceneWindowProc( HWND hWnd, UINT msg, WPARAM wParam,
							  LPARAM lParam )
/***********************************************************************/
{
	LPSCENE lpScene;

	if (msg == WM_NCCREATE) // first message a window gets
	{
		lpScene = CScene::m_lpScene;
		CScene::m_lpScene = NULL;
	}
	else
		lpScene = CScene::GetScene(hWnd);

	if (lpScene)
		return(lpScene->WindowProc(hWnd, msg, wParam, lParam));
	else
		return((*CScene::m_lpOldWndProc)(hWnd, msg, wParam, lParam));
}
Beispiel #10
0
void CPuzzle::PlaySound(UINT idResource)
/***********************************************************************/
{
	FNAME szFileName;

	HWND hParent = GetParent(m_hWnd);
	HWND hItem = GetDlgItem(hParent, idResource);
	LPSCENE lpScene = CScene::GetScene(hParent);
	if (hItem)
	{
		GetWindowText(hItem, szFileName, sizeof(szFileName));
		if (lpScene->GetSound())
			lpScene->GetSound()->StartFile( szFileName, NO/*bLoop*/, -1/*iChannel*/ );
	}
	else
	{
		if (lpScene->GetSound())
			lpScene->GetSound()->StartResourceID( IDW_PUZZLENEXT, NO/*bLoop*/, -1/*iChannel*/, GetWindowInstance(m_hWnd) );
	}
}
Beispiel #11
0
LOCAL void Slider_Paint (HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL	bHasFocus, bSelected, bDown;
	DWORD	dwStyle;
	RECT	rSrcArea, rDstArea;
	POINT	ptDst;
	UINT	id;
	PDIB	pdibSrc, pdibDst;
	HDC		hWinGDC;

	LPHSLIDERINFO lpInfo;
	if (! (lpInfo = (LPHSLIDERINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) )
		return;

	rSrcArea = *lpRect;
	rDstArea = *lpRect;
	MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2 );

	LPSCENE lpScene = CScene::GetScene (GetParent (hWindow) );
	if (! lpScene)
		return;

	if ( !lpScene->GetDIBs( &pdibSrc, &pdibDst, &hWinGDC ) )
		return;
	if ( !pdibSrc || !pdibDst || !hWinGDC )
		return;

	bSelected = GetWindowWord (hWindow, GWW_STATE);
	dwStyle = GetWindowLong (hWindow, GWL_STYLE);
	bHasFocus = (GetFocus () == hWindow);
	bDown = ( bSelected || (lpInfo->bTrack && lpInfo->bInRect && bHasFocus) );

	// Repair the dirty bitmap with the clean bitmap
	if ( pdibSrc->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8)
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
	}
	else
	{
		pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						NO /*bTransparent*/ );
	}

	// Draw the slider background
	RECT rSlider = lpInfo->rSlider;
	RECT rInner = lpInfo->rSlider;
	rInner.top = lpInfo->iCenter - (lpInfo->iTrackWidth / 2);
	rInner.bottom = lpInfo->iCenter + (lpInfo->iTrackWidth / 2);
	MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rSlider, 2);
	MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rInner, 2);

	// Turn off tick painting because using background bitmap
	#ifdef UNUSED
	HBRUSH hBrush = CreateSolidBrush (lpInfo->rgbBackgnd);
	HBRUSH hBrush2 = (HBRUSH)GetStockObject (BLACK_BRUSH);

	FillRect (hWinGDC, & rSlider, hBrush);
	FillRect (hWinGDC, & rInner, hBrush2);
	DeleteObject (hBrush);
	#endif

	RECT	rClient;
	GetClientRect (hWindow, & rClient);
	MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rClient, 2 );

	// Turn off tick painting because using background bitmap
	#ifdef UNUSED
	// Draw a chiselled border
	RECT	rBorder = rClient;
	InflateRect (& rBorder, 1, 1);
	int cxButton = rBorder.right - rBorder.left;
	int cyButton = rBorder.bottom - rBorder.top;			   
	HPEN hLitePen = CreatePen (PS_SOLID, 1, RGB (255, 255, 255));
	HPEN hDarkPen = CreatePen (PS_SOLID, 1, RGB (128, 128, 128));
	HPEN hOldPen = (HPEN)SelectObject (hWinGDC, hLitePen);

	MoveToEx (hWinGDC, rBorder.left, rBorder.bottom - 1, NULL);
	LineTo (hWinGDC, rBorder.left, rBorder.top);
	LineTo (hWinGDC, rBorder.right - 1, rBorder.top);
	
	MoveToEx (hWinGDC, rBorder.left + 1, rBorder.bottom - 2, NULL);
	LineTo (hWinGDC, rBorder.left + 1, rBorder.top + 1);
	LineTo (hWinGDC, rBorder.right - 2, rBorder.top + 1);
	
	SelectObject (hWinGDC, hDarkPen);
	MoveToEx (hWinGDC, rBorder.right - 1, rBorder.top, NULL);
	LineTo (hWinGDC, rBorder.right - 1, rBorder.bottom - 1);
	LineTo (hWinGDC, rBorder.left, rBorder.bottom - 1);
	
	MoveToEx (hWinGDC, rBorder.right - 2, rBorder.top + 1, NULL);
	LineTo (hWinGDC, rBorder.right - 2, rBorder.bottom - 2);
	LineTo (hWinGDC, rBorder.left + 1, rBorder.bottom - 2);

	SelectObject (hWinGDC, hOldPen);
	DeleteObject (hLitePen);
	DeleteObject (hDarkPen);

	// If tick-marks are wanted
	if (lpInfo->iTicks)
	{
		int pw = 2; // pen width
		HPEN hTickPen = CreatePen (PS_SOLID, pw, lpInfo->rgbBackgnd);
		hOldPen = (HPEN)SelectObject (hWinGDC, hTickPen);

		int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left;
		int wx = rClient.right - rClient.left - iBmpWidth;
		int dx = wx / lpInfo->iTicks;
		wx = wx - (dx * lpInfo->iTicks) - pw;
		int x = rClient.left + (iBmpWidth + wx + pw) / 2; // wx is now the excess
		int y1 = rClient.top + 2;
		int y2 = y1 + 10;
		for (int idx = 0; idx <= lpInfo->iTicks ; idx++)
		{
			MoveToEx (hWinGDC, x, y1, NULL);
			LineTo (hWinGDC, x, y2);
			x += dx;
		}
		SelectObject (hWinGDC, hOldPen);
		DeleteObject (hTickPen);
	}
	#endif

	rSrcArea = lpInfo->rBitmap;
	rDstArea = lpInfo->rBitmap;
	MapWindowPoints (hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2 );

	// Get the control ID to load the bitmap resource
	if (! (id = GetWindowWord (hWindow, GWW_ICONID) ) )
		id = GET_WINDOW_ID (hWindow);

	if (pdibSrc = CDib::LoadDibFromResource (GetWindowInstance (hWindow),
		MAKEINTRESOURCE(id), GetApp()->m_hPal, (dwStyle & BS_MASK) != 0 ))
	{ // Load the resource
		if ( pdibSrc->GetCompression() == BI_RLE8 ||
			 pdibDst->GetCompression() == BI_RLE8 )
		{ // compressed DIBs must use GDI copying (lose transparency ability)
			pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rSrcArea.left, rSrcArea.top,
						rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top );
		}
		else
		{
			RGBTRIPLE rgb;
			LPRGBTRIPLE lpRGB = NULL;
			if (dwStyle & BS_MASK)
			{
				STRING szColor;
				GetWindowText(hWindow, szColor, sizeof(szColor));
				AsciiRGB( szColor, &rgb );
				lpRGB = &rgb;
			}
			if (dwStyle & BS_HIGHLIGHT)
			{
				// Get the transparency color
				BYTE bTrans = *pdibSrc->GetXY(0, 0);

				// Get the color to replace
				LPTR lpColor = pdibSrc->GetXY(1, 0);
				BYTE bColor = *lpColor;
				*lpColor = bTrans;

				// Get the hightlight color
				LPTR lpHighlight = pdibSrc->GetXY(2, 0); 
				BYTE bHighlight = *lpHighlight;
				*lpHighlight = bTrans;

				// Replace the pixels in the DIB
				if (bDown && (bColor != bHighlight))
				{
					HPTR hp = pdibSrc->GetPtr();
					DWORD dwSize = pdibSrc->GetSizeImage();
					while ( dwSize-- )
					{
						if (*hp == bColor)
							*hp = bHighlight;
						++hp;
					}
				}
			}

			// Set slider position if needed
			if (lpInfo->Position)
			{
				int iBmpWidth = lpInfo->rBitmap.right - lpInfo->rBitmap.left;
				int iWidth = rClient.right - rClient.left - iBmpWidth;
				int x = (int)(((long)(lpInfo->Position - lpInfo->Min) * iWidth) / (lpInfo->Max - lpInfo->Min));
				rDstArea.left += x;
				if (rDstArea.left < rClient.left)
					rDstArea.left = rClient.left;
				else
				if (rDstArea.left + iBmpWidth > rClient.right)
					rDstArea.left = rClient.right - iBmpWidth;
				rDstArea.right = rDstArea.left + iBmpWidth;
			}

			pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rSrcArea.left, rSrcArea.top,
						rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
						(dwStyle & BS_TRANSPARENT) != 0 /*bTransparent*/, lpRGB );
		}
		delete pdibSrc;
	}

	ptDst.x = rSrcArea.left;
	ptDst.y = rSrcArea.top;
	if (lpScene)
		lpScene->Paint( hDC, &rClient, &ptDst );
}
Beispiel #12
0
LOCAL void Bmulti_Paint(HWND hWindow, HDC hDC, LPRECT lpRect)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	POINT ptDst;
	PDIB pdibSrc, pdibDst;
	UINT id;
	HDC hWinGDC;
	HPALETTE hLoadPal;	
	BOOL	fUseScene = TRUE;

	LPBMULTICONTINFO lpInfo;
	if (! (lpInfo = (LPBMULTICONTINFO)GetWindowLong (hWindow, GWL_DATAPTR) ) )
		return;

	rSrcArea = *lpRect;
	rDstArea = *lpRect;

	LPSCENE lpScene = CScene::GetScene(GetParent(hWindow));
	if ( !lpScene )
		return;

	if ( lpScene->GetDIBs( &pdibSrc, &pdibDst, &hWinGDC ) )
	{
		if ( !pdibDst )
			return;
		hLoadPal = GetApp()->m_hPal;
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
	}
	else
		return;

	bSelected = GetWindowWord (hWindow, GWW_STATE);
	dwStyle = GetWindowLong (hWindow, GWL_STYLE);
	bHasFocus = (GetFocus() == hWindow);
	bDown = ( bSelected || (lpInfo->bTrack && lpInfo->bInRect && bHasFocus) );

	// Draw the Bitmap
	if ( !(id = GetWindowWord( hWindow, GWW_ICONID )) )
		id = GET_WINDOW_ID( hWindow );
	id += lpInfo->State;

	// Repair the dirty bitmap with the clean bitmap
	if ( pdibSrc && pdibDst )
	{
		if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8)
		{ // compressed DIBs must use GDI copying (lose transparency ability)
			pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		}
		else
		{
			pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						NO /*bTransparent*/ );
		}
	}

	if (pdibSrc = CDib::LoadDibFromResource( GetWindowInstance(hWindow),
		MAKEINTRESOURCE(id), hLoadPal, (dwStyle & BS_MASK) != 0 ) )
	{ // Load the resource
			// Do highlighting andf transparency
		RGBTRIPLE rgb;
		LPRGBTRIPLE lpRGB = NULL;
		if (dwStyle & BS_MASK)
		{
			STRING szColor;
			GetWindowText(hWindow, szColor, sizeof(szColor));
			AsciiRGB( szColor, &rgb );
			lpRGB = &rgb;
		}
		if (dwStyle & BS_HIGHLIGHT)
		{
			// Get the transparency color
			BYTE bTrans = *pdibSrc->GetXY(0, 0);

			// Get the color to replace
			LPTR lpColor = pdibSrc->GetXY(1, 0);
			BYTE bColor = *lpColor;
			*lpColor = bTrans;

			// Get the hightlight color
			LPTR lpHighlight = pdibSrc->GetXY(2, 0); 
			BYTE bHighlight = *lpHighlight;
			*lpHighlight = bTrans;

			// Replace the pixels in the DIB
			if (bDown && (bColor != bHighlight))
			{
				HPTR hp = pdibSrc->GetPtr();
				DWORD dwSize = pdibSrc->GetSizeImage();
				while ( dwSize-- )
				{
					if (*hp == bColor)
						*hp = bHighlight;
					++hp;
				}
			}
		}
		if ( pdibSrc->GetCompression() == BI_RLE8 || pdibDst->GetCompression() == BI_RLE8 )
		{ // compressed DIBs must use GDI copying (lose transparency ability)
			pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rSrcArea.left, rSrcArea.top,
						rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top );
		}
		else
		{
			pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
						rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rSrcArea.left, rSrcArea.top,
						rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
						(dwStyle & BS_TRANSPARENT) != 0 /*bTransparent*/, lpRGB );
		}
		delete pdibSrc;
	}

	ptDst.x = rSrcArea.left;
	ptDst.y = rSrcArea.top;
	if (fUseScene)
		lpScene->Paint( hDC, &rDstArea, &ptDst );

}
Beispiel #13
0
LOCAL void Meter_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
    RECT	rSrcArea, rDstArea, rControlArea;
    POINT	ptDst;
    PDIB	pdibSrc, pdibDst, pdibSrc2, pdibTmp;
    UINT	id;
    LPOFFSCREEN lpOffScreen;
    LPSCENE lpScene;
    HDC		hWinGDC;
    HPALETTE hLoadPal;

    lpScene = CScene::GetScene( GetParent(hWindow) );
    if (!lpScene)
        return;

    LPMETERCONTINFO lpInfo;
    if (!(lpInfo = (LPMETERCONTINFO)GetWindowLong(hWindow, GWL_DATAPTR) ))
        return;

    rSrcArea = * lpRect;
    rDstArea = * lpRect;
    rControlArea = * lpRect;

    lpOffScreen = lpScene->GetOffScreen();
    if (lpOffScreen)
    {
        MapWindowPoints(hWindow, GetParent(hWindow), (LPPOINT)& rDstArea, 2);
        if (!(pdibSrc = lpOffScreen->GetReadOnlyDIB() ) )
            return;
        if (!(pdibDst = lpOffScreen->GetWritableDIB() ) )
            return;
        hWinGDC = lpOffScreen->GetDC();
        hLoadPal = GetApp()->m_hPal;
    }
    else
    {
        return;
    }

    RECT	rClient;
    GetClientRect(hWindow, & rClient);
    MapWindowPoints(hWindow, GetParent(hWindow), (LPPOINT)& rClient, 2 );

    // Get the control style
    DWORD dwStyle = GetWindowStyle(hWindow);
    BOOL bVert = (dwStyle & MC_VERT) ? TRUE : FALSE ;

    // Get the control id
    if (!(id = GetWindowWord(hWindow, GWW_ICONID) ) )
        id = GET_WINDOW_ID(hWindow);

    // Refresh the background,
    // compressed DIBs must use GDI copying (lose transparency ability)
    if (pdibSrc->GetCompression() == BI_RLE8 ||
            pdibDst->GetCompression() == BI_RLE8)
    {
        pdibSrc->DCBlt(hWinGDC,
                       rDstArea.left, rDstArea.top,
                       rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
                       rDstArea.left, rDstArea.top,
                       rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
    }
    else
    {
        pdibSrc->DibBlt(pdibDst,
                        rDstArea.left, rDstArea.top,
                        rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
                        rDstArea.left, rDstArea.top,
                        rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
                        NO /*bTransparent*/ );
    }

    // Load the resource
    if (pdibSrc = CDib::LoadDibFromResource(GetWindowInstance(hWindow),
                                            MAKEINTRESOURCE(id), hLoadPal, (dwStyle & BS_MASK) != 0) )
    {
        if (pdibSrc2 = CDib::LoadDibFromResource(GetWindowInstance(hWindow),
                       MAKEINTRESOURCE(id + 1), hLoadPal, (dwStyle & BS_MASK) != 0) )
        {
            int iBitmapWidth = pdibSrc->GetWidth();
            int iBitmapHeight = pdibSrc->GetHeight();

            rSrcArea.left = 0;
            rSrcArea.top = 0;
            rSrcArea.right = rSrcArea.left + iBitmapWidth;
            rSrcArea.bottom = rSrcArea.top + iBitmapHeight;
            rDstArea = rClient;
            rDstArea.right = rDstArea.left + iBitmapWidth;
            rDstArea.bottom = rDstArea.top + iBitmapHeight;

            // Get the position width
            int iPosWidth;
            if (bVert)
            {
                iPosWidth = (int)( (float)iBitmapHeight *
                                   ((float)lpInfo->lPosition / ((float)lpInfo->Max - (float)lpInfo->Min)));
                iPosWidth = iBitmapHeight - iPosWidth;
            }
            else
            {
                iPosWidth = (int)( (float)iBitmapWidth *
                                   ((float)lpInfo->lPosition / ((float)lpInfo->Max - (float)lpInfo->Min)));
            }
            // compressed DIBs must use GDI copying (lose transparency ability)
            if (pdibSrc->GetCompression() == BI_RLE8 ||
                    pdibDst->GetCompression() == BI_RLE8 )
            {
                pdibSrc->DCBlt(hWinGDC,
                               rDstArea.left, rDstArea.top,
                               rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
                               rSrcArea.left, rSrcArea.top,
                               rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top);
            }
            else
            {
                RGBTRIPLE rgb;
                LPRGBTRIPLE lpRGB = NULL;
                if (dwStyle & BS_MASK)
                {
                    STRING szColor;
                    GetWindowText(hWindow, szColor, sizeof(szColor));
                    AsciiRGB(szColor, & rgb);
                    if (fHighlight)
                    {
                        // this relies on the fact that AsciiRGB replaces commas
                        // with NULL terminators
                        LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
                        lp += lstrlen(lp) + 1; // passed green
                        lp += lstrlen(lp) + 1; // passed blue to higlight color
                        AsciiRGB(lp, & rgb);
                    }
                    lpRGB = & rgb;
                }
                // Render the first bitmap
                pdibTmp = pdibSrc;
                pdibTmp->DibBlt(pdibDst,
                                rDstArea.left, rDstArea.top,
                                rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
                                rSrcArea.left, rSrcArea.top,
                                rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
                                FALSE /*bTransparent*/, lpRGB);
            }

            // Adjust the source and dest rect's and render the 2nd bitmap

            if (bVert)
            {
                //rDstArea.top = rDstArea.top;// iPosWidth;
                rDstArea.bottom = rDstArea.top + iPosWidth;
                //rSrcArea.top = rSrcArea.bottom - iPosWidth;
                rSrcArea.bottom = iPosWidth;
            }
            else
            {
                rDstArea.right = rDstArea.left + iPosWidth;
                rSrcArea.right = rSrcArea.left + iPosWidth;
            }
            // compressed DIBs must use GDI copying (lose transparency ability)
            if (pdibSrc->GetCompression() == BI_RLE8 ||
                    pdibDst->GetCompression() == BI_RLE8 )
            {
                pdibSrc->DCBlt(hWinGDC,
                               rDstArea.left, rDstArea.top,
                               rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
                               rSrcArea.left, rSrcArea.top,
                               rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top);
            }
            else
            {
                RGBTRIPLE rgb;
                LPRGBTRIPLE lpRGB = NULL;
                if (dwStyle & BS_MASK)
                {
                    STRING szColor;
                    GetWindowText(hWindow, szColor, sizeof(szColor));
                    AsciiRGB(szColor, & rgb);
                    if (fHighlight)
                    {
                        // this relies on the fact that AsciiRGB replaces commas
                        // with NULL terminators
                        LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
                        lp += lstrlen(lp) + 1; // passed green
                        lp += lstrlen(lp) + 1; // passed blue to higlight color
                        AsciiRGB(lp, & rgb);
                    }
                    lpRGB = & rgb;
                }
                // Render the first bitmap
                pdibTmp = pdibSrc2;
                pdibTmp->DibBlt(pdibDst,
                                rDstArea.left, rDstArea.top,
                                rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
                                rSrcArea.left, rSrcArea.top,
                                rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
                                FALSE /*bTransparent*/, lpRGB);

            }
        }
        delete pdibSrc;
        delete pdibSrc2;
    }

    ptDst.x = rControlArea.left;
    ptDst.y = rControlArea.top;
    if (lpOffScreen)
    {
        lpOffScreen->DrawRect(hDC, & rClient, & ptDst);
    }
}
Beispiel #14
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	PTOON pToon = NULL;
	PDIB pdibSrc, pdibDst;
	LPOFFSCREEN lpOffScreen = NULL;

	if (IsRectEmpty(lpRect))
		return;
	PSTORY pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	// Draw the Bitmap
	rSrcArea = *lpRect;
	rDstArea = *lpRect;

	LPSCENE lpScene = CScene::GetScene(GetParent(hWindow));
	if (lpScene)
		lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
	 	if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
	}
	else
	{
		// see if there is a toon control
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		pdibSrc = pToon->GetStageDib();
		MapWindowPoints( hWindow, GetParent(hToon), (LPPOINT)&rDstArea, 2 );
 	}

	// create a dib to draw into
	pdibDst = new CDib();
	if (!pdibDst)
		return;
	if (!pdibDst->Create(pdibSrc->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pdibDst;
		return;
	}
	pdibDst->CopyColorTable(pdibSrc);
	
	// copy our color table into the dest dib
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	// draw in background
	pdibSrc->DibBlt( pdibDst,
					0, 0,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	rDstArea.left, rDstArea.top,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	NO /*bTransparent*/ );

	// now draw in foreground
	RGBTRIPLE rgb;
	LPRGBTRIPLE lpRGB = NULL;
	if (dwStyle & BS_MASK)
	{
		STRING szColor;
		GetWindowText(hWindow, szColor, sizeof(szColor));
		AsciiRGB( szColor, &rgb );
		if (fHighlight)
		{
			// this relies on the fact that AsciiRGB replaces commas
			// with NULL terminators
			LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
			lp += lstrlen(lp) + 1; // passed green
			lp += lstrlen(lp) + 1; // passed blue to higlight color
			AsciiRGB(lp, &rgb);
			rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
		}
		else
			rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
		lpRGB = &rgb;
	}
	pStory->m_pDib->DibBlt( pdibDst,
				0, 0,
				rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				YES /*bTransparent*/, lpRGB, App.m_lpLut );

	pdibDst->DCBlt( hDC,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
			 	0, 0,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top);

	delete pdibDst;
}
Beispiel #15
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	POINT ptDst;
	PDIB pdibSrc, pdibDst, pDib;
	LPOFFSCREEN lpOffScreen;
	PTOON pToon;
	LPSCENE lpScene;
	PSTORY pStory;
	RGBQUAD rgbQuad[256];
	BITMAPINFOHEADER bmi;
	LPTR lp;
	HDC hWinGDC;
	HPALETTE hWinGPal = NULL, hDisplayPal = NULL, hOldPal;

	if (IsRectEmpty(lpRect))
		return;
	pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	lpScene = CScene::GetScene(GetParent(hWindow));
	if (!lpScene)
		return;

	rSrcArea = *lpRect;
	rDstArea = *lpRect;
	bSelected = GetWindowWord(hWindow, GWW_STATE );
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
 		if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		if ( !(pdibDst = lpOffScreen->GetWritableDIB()) )
			return;
		hWinGDC = lpOffScreen->GetDC();
		hWinGPal = hDisplayPal = GetApp()->m_hPal;
	}
	else
	{
		// fix
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		MapWindowPoints( hWindow, pToon->GetWindow(), (LPPOINT)&rDstArea, 2 );
		pdibSrc = pToon->GetStageDib();
		lp = ToonGetDIBPointer(pToon->GetToonHandle(), &bmi);
		ToonGetColors(pToon->GetToonHandle(), 0, 256, rgbQuad);
		bmi.biClrUsed = 256;
		pdibDst = new CDib(&bmi, rgbQuad, lp);
		if (!pdibDst)
			return;
		hWinGDC = ToonDC(pToon->GetToonHandle());
		// to make sure we don't change the system palette
		hDisplayPal = CopySystemPalette();
		// to match WinG dib
		hWinGPal = CreateCustomPalette(rgbQuad, 256);
	}

	if (!pStory->m_fMappedToPalette && ((dwStyle & BS_MASK) == 0))
	{
		pStory->m_pDib->MapToPalette(hWinGPal);
		pStory->m_fMappedToPalette = TRUE;
	}


	// Copy source dib so we can twiddle its bits
	pDib = new CDib();
	if (!pDib)
	{
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	if (!pDib->Create(pStory->m_pDib->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pDib;
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	pDib->CopyColorTable(pStory->m_pDib);
	// draw in source bitmap
	pStory->m_pDib->DibBlt( pDib,
					0, 0,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	rSrcArea.left, rSrcArea.top,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	NO /*bTransparent*/ );
	
	if ( pdibSrc->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8)
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
	}
	else
	{
		pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	NO /*bTransparent*/ );
	}

	if ( pDib->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8 )
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pDib->DCBlt( hWinGDC,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					rSrcArea.left, rSrcArea.top,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top );
	}
	else
	{
		RGBTRIPLE rgb;
		LPRGBTRIPLE lpRGB = NULL;
		if (dwStyle & BS_MASK)
		{
			STRING szColor;
			GetWindowText(hWindow, szColor, sizeof(szColor));
			AsciiRGB( szColor, &rgb );
			if (fHighlight)
			{
				// this relies on the fact that AsciiRGB replaces commas
				// with NULL terminators
				LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
				lp += lstrlen(lp) + 1; // passed green
				lp += lstrlen(lp) + 1; // passed blue to higlight color
				AsciiRGB(lp, &rgb);
				rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
			}
			else
				rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
			lpRGB = &rgb;
		}
		else
		{
			BYTE bTrans = *pStory->m_pDib->GetXY(0, 0);
			LPTR lpColor = pStory->m_pDib->GetXY(1, 0);
			LPTR lpHighlight = pStory->m_pDib->GetXY(2, 0); 
			BYTE bColor = *lpColor;
			BYTE bHighlight = *lpHighlight;
			// if highlight color is the transparent color then
			// we are hiding and showing highlighted area
			// if not, then we are changing the color of highlighted area
			if (bHighlight == bTrans)
			{
				// we need to strip off highlight info if we are not
				// highlighted
				if (!fHighlight && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp != bColor)
							*hp = bTrans;
						++hp;
						--dwSize;
					}
				}
			}
			else
			{
				// we need to change the color if we are highlighted
				if (fHighlight && (bColor != bHighlight) && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp == bColor)
							*hp = bHighlight;
						++hp;
						--dwSize;
					}
				}
			}
		}
		pDib->DibBlt( pdibDst,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					0, 0,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
					YES/*bTransparent*/, lpRGB, NULL, hWinGPal );
	}
	delete pDib;

	ptDst.x = rSrcArea.left;
	ptDst.y = rSrcArea.top;
	if (lpOffScreen)
	{
		lpOffScreen->DrawRect( hDC, &rDstArea, &ptDst );
	}
	else
	{
		//if (hDisplayPal)
		//{
		//	hOldPal = SelectPalette(hDC, hDisplayPal, FALSE);
		//	RealizePalette(hDC);
		//}
		//pdibDst->DCBlt( hDC,
		//	ptDst.x, ptDst.y,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
		//	rDstArea.left, rDstArea.top,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		WinGStretchBlt( hDC,
			ptDst.x, ptDst.y,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
			hWinGDC,
			rDstArea.left, rDstArea.top,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		//if (hDisplayPal)
	    //{
		//	SelectPalette(hDC, hOldPal, TRUE);
	   	//	DeleteObject(hDisplayPal);
		//}
		if (hWinGPal)
			DeleteObject(hWinGPal);
	}
}