www.pudn.com > DualDisplay.rar > DemoGDI.cpp


/****************************************************************************** 
** Copyright (C) 2004. Intel Corporation. All Rights Reserved.  
** 
** The source code contained or described herein and all documents related to the 
** source code ("Material") are owned by Intel Corporation or its suppliers or  
** licensors. Title to the Material remains with Intel Corporation or its suppliers 
** and licensors. The Material contains trade secrets and proprietary and  
** confidential information of Intel or its suppliers and licensors. The Material  
** is protected by worldwide copyright and trade secret laws and treaty provisions. 
** No part of the Material may be used, copied, reproduced, modified, published,  
** uploaded, posted, transmitted, distributed, or disclosed in any way without  
** Intel’s prior express written permission. 
**  
** No license under any patent, copyright, trade secret or other intellectual  
** property right is granted to or conferred upon you by disclosure or delivery  
** of the Materials, either expressly, by implication, inducement, estoppel or  
** otherwise. Any license under such intellectual property rights must be express  
** and approved by Intel in writing. 
******************************************************************************/ 
// DemoGDI.cpp: implementation of the CDemoGDI class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "DispDemo1.h" 
#include "DemoGDI.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CDemoGDI::CDemoGDI(WORD wWidth, WORD wHeight) 
{ 
	CString str; 
	str.Format(L"This screen is %d x %d", wWidth, wHeight); 
 
	HDC hdcExternal = m_DisplayConfig.CreateSecondMarathonHDC(wWidth, wHeight); 
 
	SetTextColor(hdcExternal, RGB(0x00, 0xA0, 0xFF)); // Kinda Cyan/Blue 
	SetBkColor(hdcExternal, RGB(0x00, 0x00, 0x00)); 
	SetBkMode(hdcExternal, OPAQUE); 
	Rectangle(hdcExternal, 0, 0, wWidth, wHeight); 
	DrawText(hdcExternal, str, str.GetLength(), CRect(0,0,wWidth, wHeight), DT_LEFT|DT_TOP|DT_WORDBREAK); 
 
	// now switch to display it 
	m_DisplayConfig.SetInternalSource(DCFG_SOURCE_XSCALE); 
	m_DisplayConfig.SetExternalSource(DCFG_SOURCE_MARATHON); 
 
	RawFrameBufferInfo* pXScaleFB = m_DisplayConfig.GetXScaleFrameBuffer();  
 
	TRACE(L"\n\rDrawing small white close box into system memory that XScale's frame buffer.\n\r"); 
 
	for (int y=0; y < pXScaleFB->cyPixels; y++) 
	{ 
		for (int x=0; x < pXScaleFB->cxPixels; x++) 
		{ 
			PWORD pPixel = (PWORD)((PBYTE)pXScaleFB->pFramePointer +  
				(y * pXScaleFB->cyStride) +  
				(x * pXScaleFB->cxStride)); 
 
			if ((x < 32) && (y < 32)) 
			{	// in close box area? 
				if ((x == 0) || (x == 32-1) || (y == 0) || (y == 32-1) || (x == y) || ((32-1-x) == y)) 
					*pPixel = 0xFFFF;// WHITE 
				else 
					*pPixel = 0x0;	// BLACK 
			} 
			else 
				*pPixel = 0x001F; // BLUE 
		} 
	} 
 
	// Create a window to recieve touch screen inputs 
	m_hWnd = CreateWindow(L"Static", L"MyInputWindow", WS_VISIBLE, 
		  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
		  CW_USEDEFAULT, NULL, NULL, AfxGetInstanceHandle(), NULL); 
 
	SHFullScreen(m_hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON |  SHFS_HIDESTARTICON); 
	MoveWindow(m_hWnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), TRUE);   
	SetCapture(m_hWnd); 
 
	// now switch to display it 
	m_DisplayConfig.SetInternalSource(DCFG_SOURCE_XSCALE); 
	m_DisplayConfig.SetExternalSource(DCFG_SOURCE_MARATHON); 
 
	MSG msg; 
	while (GetMessage(&msg, m_hWnd, WM_MOUSEFIRST, WM_MOUSELAST))  
	{ 
		TranslateMessage(&msg); 
		DispatchMessage(&msg); 
 
		WORD xPos = LOWORD(msg.lParam);  
		WORD yPos = HIWORD(msg.lParam); 
 
		TRACE(L"\n\rScreen Tap at %d x %d\n\r", xPos, yPos); 
 
		if ((xPos < 32) && (yPos < 32))	// assuming Carbonado-like rotated display.  Looking for click withing box in XScale buffer 
			DestroyWindow(m_hWnd); 
		else 
		{ 
			FillRect(hdcExternal, CRect(0,0,wWidth, wHeight), (HBRUSH)GetStockObject(BLACK_BRUSH)); 
 
			str.Format(L"This text starts at (%d,%d) on a %d x %d screen", xPos, yPos, wWidth, wHeight); 
			DrawText(hdcExternal, str, str.GetLength(), CRect(xPos, yPos, wWidth, wHeight), DT_LEFT|DT_TOP|DT_WORDBREAK); 
		} 
	}	 
	SHFullScreen(m_hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON |  SHFS_SHOWSTARTICON); 
} 
 
CDemoGDI::~CDemoGDI() 
{ 
 
}