www.pudn.com > DualDisplay.rar > DemoCustom.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. 
******************************************************************************/ 
// DemoCustom.cpp: implementation of the CDemoCustom class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "aygshell.h" 
#include "DispDemo1.h" 
#include "DemoCustom.h" 
#include  
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CDemoCustom::CDemoCustom(WORD wWidth, WORD wHeight) 
{ 
	RawFrameBufferInfo* pExternalOutput = m_DisplayConfig.CreateMarathonFrameBuffer(wWidth, wHeight); 
 
	if (!pExternalOutput || !pExternalOutput->pFramePointer) 
	{ 
		TRACE(L"\n\r************************ Unable to use extenral display at requested resolution *****************\n\r"); 
		return; 
	} 
 
 
	TRACE(L"\n\rDrawing white border and blue diagonal in %d x %d Frane Buffer \n\r",pExternalOutput->cxPixels, pExternalOutput->cyPixels); 
 
	for (int y=0; y < pExternalOutput->cyPixels; y++) 
	{ 
		for (int x=0; x < pExternalOutput->cxPixels; x++) 
		{ 
			PWORD pPixel = (PWORD)((PBYTE)pExternalOutput->pFramePointer +  
				(y * pExternalOutput->cyStride) +  
				(x * pExternalOutput->cxStride)); 
			if ((x == 0) || //left 
				(x == pExternalOutput->cxPixels-1) || // right 
				(y == 0) || // top 
				(y == pExternalOutput->cyPixels-1) // bottom 
				) 
				*pPixel = 0xFFFF;	// WHITE 
			else if (x == y)	// diaginal 
				*pPixel = 0x001F;	// BLUE 
			else 
				*pPixel = 0x0;		// BLACK 
		} 
	} 
 
	RawFrameBufferInfo* pXScaleFB = m_DisplayConfig.GetXScaleFrameBuffer(); 
 
	TRACE(L"\n\rDrawing small white close box into system memory that XScale's frame buffer.\n\r"); 
 
	for (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); 
 
	}	 
	SHFullScreen(m_hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON |  SHFS_SHOWSTARTICON); 
} 
 
CDemoCustom::~CDemoCustom() 
{ 
 
}