⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mso_page.c

📁 ZORAN 962/966 SOURCE CODE,DVD chip
💻 C
字号:
/* **************************************************************************************
*  Copyright (c) 2004 ZORAN Corporation, All Rights Reserved
*  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
*  File: $Workfile: o_text.c $
*
* Description:	
* ============
* Project definition of the MSO_TEXT functions
*
****************************************************************************************/
#include "Config.h"		// Global Configuration - do not remove!

#ifdef DEBUG_UI_TRACE
#undef IFTRACE
#define IFTRACE if (gTraceUI)
#include "Debug\DbgMain.h"
#endif //DEBUG_UI_TRACE

#include "Include\SysDefs.h"

/////////////////////////////////////////////////////////////////////////////
// Include files
#include <stdio.h>
#include <string.h>

#include "GUI\Menu_system\ms_object.h"
#include "GUI\Menu_system\ms_container.h"
#include "gui\menu_system\ms_display.h"
#include "GUI\Menu_system\ms_screen.h"
#include "gui\menu_system\osd_rendering.h"
#include "GUI\Object_class\Page\mso_page.h"
#include "GUI\Resource\Bitmap\bitmap.h"
#include "Menu\menu_operation_def.h"
#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef	dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif


#define TABBTN_OVERLAP_WINDOW_W		6


/**************************************************************************
*	Function	: OPAGE_GetTabBtn
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
MSO_TABBTN __NEAR* OPAGE_GetTabBtn(MSO_PAGE __NEAR* pThisPage)
{
	MS_DESCRIPTOR_PAGE* pPageDescriptor;
	//MSO_TABBTN __NEAR* pTabBtn;

	pPageDescriptor = (MS_DESCRIPTOR_PAGE*)(((MSO_OBJECT __NEAR*)pThisPage)->mpDescriptor);
	return (MSO_TABBTN __NEAR*)MS_FindObjectFromDescriptor((MSO_CONTAINER __NEAR*)pThisPage, 
										(MS_DESCRIPTOR *)(pPageDescriptor->mpDescriptorTabBtn));
}
/**************************************************************************
*	Function	: OPAGE_GetTabBtn
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
#pragma argsused
MSO_PAGE __NEAR* OPAGE_GetPageFromIndex(MSO_BOOK __NEAR* pBook, UINT16 wPageIndex)
{
	MSO_PAGE __NEAR* pPage;
	
	MS_ASSERT(NULL != pBook);
	if (MS_IsContentFrozen(pBook))
	{
		MS_BREAK_POINT();
		return NULL;
	}

	pPage = (MSO_PAGE __NEAR*)((MSO_CONTAINER __NEAR*)pBook)->mpOlist;
	while(NULL != pPage)
	{
		if(wPageIndex == pPage->moParam.mwPageIndex)
			return pPage;
		pPage =(MSO_PAGE __NEAR*) ((MSO_OBJECT __NEAR *)pPage)->mpNext;
	}
	return NULL;
}
/**************************************************************************
*	Function	: OPAGE_AddPageToBook
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
MSO_PAGE __NEAR* OPAGE_AddPageToBook(MS_DESCRIPTOR_PAGE* poDescriptor, MSO_BOOK __NEAR* poBook)
{
	MSO_PAGE __NEAR* pPage;
	UINT16 wPageIndex;

	MS_ASSERT(!MS_IsContentFrozen(poBook));

	wPageIndex = MS_CountObjects((MSO_CONTAINER __NEAR*)poBook);

	pPage = (MSO_PAGE __NEAR*)MS_CreateAndAddObject((MS_DESCRIPTOR*)poDescriptor, (MSO_CONTAINER __NEAR *) poBook);
	if (NULL != pPage)
		pPage->moParam.mwPageIndex = wPageIndex;
	return (pPage);
}
/**************************************************************************
*	Function	: OPAGE_RemovePageFromBook
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
BOOL OPAGE_RemovePageFromBook(MSO_PAGE __NEAR* pThisPage)
{
	MSO_BOOK __NEAR* pBook;
	MSO_PAGE __NEAR* pPage;
	MSO_TABBTN __NEAR* pTabBtn;
	MSO_PAGE __NEAR* pSelectedPage;
	UINT16 wPageIndex;
	UINT16 wPageNumber;
	BOOL bResult;

	if (NULL == pThisPage)
		return 1;
	
	bResult = 0;
	
	pBook = (MSO_BOOK __NEAR*)(((MSO_OBJECT __NEAR*)pThisPage)->mpParent);
	MS_ASSERT(NULL != pBook);
	MS_ASSERT(!MS_IsContentFrozen(pBook));
	
	wPageNumber = MS_CountObjects((MSO_CONTAINER __NEAR*)pBook);
	if(wPageNumber)
	{
		wPageIndex = pThisPage->moParam.mwPageIndex;

		// If the selected page is different form the page to remove, freeze the selected page in order to release
		// memory in the ms_heap to defrost the page to remove. We will defrost the selected page before exit this function.
		pSelectedPage = (MSO_PAGE __NEAR*)MS_GetSelectedInContainer(pBook);
		if (pSelectedPage != pThisPage)
			MS_SendOperation((MSO_OBJECT __NEAR*)pSelectedPage, MS_OP_FREEZE, 0);
		else
			pSelectedPage = NULL;
		
		// Ask children to prepare for being removed
		MS_SendOperation((MSO_OBJECT __NEAR*)pThisPage, MS_OP_EMPTY, 0);
		if (MS_RemoveObject((MSO_OBJECT __NEAR*)pThisPage))
		{
			pPage = (MSO_PAGE __NEAR*)(((MSO_CONTAINER __NEAR*)pBook)->mpOlist);
			while (--wPageNumber)
			{
				MS_ASSERT(NULL != pPage)
				if (pPage->moParam.mwPageIndex > wPageIndex)
				{
					pPage->moParam.mwPageIndex--;
					pTabBtn = OPAGE_GetTabBtn(pPage);
					((MSO_OBJECT __NEAR*)pTabBtn)->moArea.msY -= ((MSO_OBJECT __NEAR*)pTabBtn)->moArea.mwH;

				}
				((MSO_OBJECT __NEAR*)pPage) = ((MSO_OBJECT __NEAR*)pPage)->mpNext;
			}
			bResult = 1;
		}
	}

	// Defrost the selected frozen page.
	if (NULL != pSelectedPage)
		MS_SendOperation((MSO_OBJECT __NEAR*)pSelectedPage, MS_OP_DEFROST, 0);

	// If removed the focus 
	if (MS_CountObjects((MSO_CONTAINER __NEAR*)pBook))
	{
		if (MS_IsFocused(pBook))
		{
			if(NULL == MS_GetFocusInContainer((MSO_CONTAINER __NEAR*)pBook))
				MS_ScreenSetFocusObject((MSO_OBJECT __NEAR*)OPAGE_GetTabBtn(OPAGE_GetPageFromIndex(pBook, 0)));
		}
		else if (NULL == MS_GetSelectedInContainer(pBook))
		{
			pSelectedPage = OPAGE_GetPageFromIndex(pBook, 0);
			MS_SetSelected(pSelectedPage);
			MS_SendOperation((MSO_OBJECT __NEAR*)pSelectedPage, MS_OP_SELECT_CHANGE, 0);
		}
	}

	return bResult;
}
/**************************************************************************
*	Function	: OPAGE_BookOperation
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
MS_OP OPAGE_BookOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{	
	// Pre-processing
	switch (MsOp)
	{
	case MS_OP_FOCUS_CHANGE:
		{
			if (MS_IsFocused(pThis))
			{
				MSO_OBJECT __NEAR* pObject = MS_GetSelectedInContainer((MSO_CONTAINER __NEAR*)pThis);
				if ((NULL != pObject) && MS_GetFocusInContainer((MSO_CONTAINER __NEAR*)pThis) != pObject)
				{
					MS_ClearSlected(pObject);
					MS_SendOperation(pObject, MS_OP_SELECT_CHANGE, lParam);				
				}
			}
		}
		break;
		
	default:
		break;
	}		
	return MS_BasicContainerOperation(pThis, MsOp, lParam);
}

/**************************************************************************
*	Function	: OPAGE_PageOperation
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
MS_OP OPAGE_PageOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{	
	// Pre-processing
	switch (MsOp)
	{
	case MS_OP_OPEN:
		{
			MSO_OBJECT __NEAR* pObject;
			MS_DESCRIPTOR_PAGE* pPageDescriptor = (MS_DESCRIPTOR_PAGE*)(pThis->mpDescriptor);

			// Force the page to be layer 0, if focused, then it will switch to layer 1.
			MS_SetOsdLayer(pThis, MS_ATTR_OSD_LAYER_0);
			
			if(NULL != pPageDescriptor->mpDescriptorTabBtn)
			{	
				pObject = MS_CreateAndAddObject((MS_DESCRIPTOR*)(pPageDescriptor->mpDescriptorTabBtn),(MSO_CONTAINER __NEAR*)pThis);
				MS_ClearOsdLayer(pObject);
				MS_SetOsdLayer(pObject, MS_ATTR_OSD_LAYER_1);
				MS_SetPrevFocus(pObject);
				pObject->moArea.msY += (((MSO_PAGE __NEAR*)pThis)->moParam.mwPageIndex * pObject->moArea.mwH);		
			}
		}
      		break;
		
	case MS_OP_FOCUS_CHANGE:	
		if (MS_IsFocused(pThis))
		{
			// Mark the page as the active one, focus can be outside the book, 
			// and still one page is active, so we can't use focus to know which page is active.
			MS_SetSelected(pThis);
		}
		else
		{
			// If the book isn't focus and the page loses focus, nothing to do
			if (MS_IsFocused(pThis->mpParent))
			{	// Mark the page as in-active, focus can be outside the book, 
				// and still one page is active, so we can't use focus to know which page is active.
				MS_ClearSlected(pThis);
			}
			else
				break;
		} // FALL THRU
		
	case MS_OP_SELECT_CHANGE:
		{
			MSO_OBJECT __NEAR* pObject;
			MS_DESCRIPTOR_PAGE* pPageDescriptor = (MS_DESCRIPTOR_PAGE*)(pThis->mpDescriptor);
			
			MS_DisplayAddObject((MSO_OBJECT __NEAR*)pThis);

			pObject = MS_FindObjectFromDescriptor((MSO_CONTAINER __NEAR*)pThis, 	(MS_DESCRIPTOR*)pPageDescriptor->mpDescriptorWindow);
			
			if(MS_IsSelected(pThis))
			{
				if(NULL == pObject)
				{
					// Add the window, we are adding a page
					pObject = MS_CreateAndAddObject((MS_DESCRIPTOR*)(pPageDescriptor->mpDescriptorWindow),(MSO_CONTAINER __NEAR*)pThis);
		 			if (NULL == pObject)
						break;

					// Open the added window (Add the contents of the window, sending MS_OP_OPEN to it)
					MS_SendOperation(pObject, MS_OP_OPEN, 0);
					MS_SendOperation(pObject, MS_OP_INIT, 0);
					
					MS_ClearOsdLayer(pObject);
					MS_SetOsdLayer(pObject, MS_ATTR_OSD_LAYER_0);
				}
				else if (MS_IsContentFrozen(pObject))
				{
					// The window is there, but it is frozen
	 				if (MS_OP_DEFROST == MS_SendOperation(pObject, MS_OP_DEFROST, 0))
					{
						MS_BREAK_POINT();
						break;
	 				}
				}
				MS_ChangeOsdLayer(pThis, MS_ATTR_OSD_LAYER_1);
				// Set the window as visible
				MS_ClearInvisible(pObject);
			}
			else
			{
				if((NULL != pObject) && !MS_IsContentFrozen(pObject))
				{
					MS_ChangeOsdLayer(pThis, MS_ATTR_OSD_LAYER_0);
					// Freeze  the window in the page and set it to invisible
					if (MS_OP_NONE == MS_SendOperation((MSO_OBJECT __NEAR*)pObject, MS_OP_FREEZE, 0))
						MS_SetInvisible(pObject);
				}
				else
				{
					MS_BREAK_POINT();
				}
			}
		}
      		break;
			
	default:
		break;
	}
	return (MS_BasicContainerOperation(pThis, MsOp, lParam));
}
/**************************************************************************
*	Function	: OPAGE_TabBtnOperation
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
MS_OP OPAGE_TabBtnOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{	
	switch (MsOp)
	{
	case MS_OP_INIT:
		pThis->moArea.mwW += TABBTN_OVERLAP_WINDOW_W;
       	 break;
			
	case MS_OP_FOCUS_CHANGE:
		MS_DisplayAddObject(pThis);
       	 break;
	}
	return MS_BasicContainerOperation(pThis, MsOp, lParam);
}
/**************************************************************************
*	Function	: OPAGE_TabBtnFillOSDSeg
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
BOOL OPAGE_TabBtnFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea)
{		
	CONST UINT8* pBmp;
	
	if (MS_IsSelected(pThis->mpParent))
		pBmp = BMP_BG_2;
	else
		pBmp = BMP_BG_PUSHED_1;
	OSDR_FillOsdSegBitmapFitArea(pBmp, pAbsArea);

	if (MS_IsFocused(pThis))
		OSDR_FillOsdSegBitmapFitArea(BMP_FG_FOCUS, pAbsArea);
	//else if (MS_IsFocused(pThis->mpParent))
	//	OSDR_FillOsdSegBitmapFitArea(BMP_FG_PREV_FOCUS, pAbsArea);
	
	if (MS_IsSelected(pThis->mpParent))
		OSDR_FillOsdSegRectangle(	pThis->moArea.mwW - TABBTN_OVERLAP_WINDOW_W, 
									0,
									TABBTN_OVERLAP_WINDOW_W,
									pThis->moArea.mwH,
									pAbsArea,
									CIDX_7);

	return FALSE;
}
/**************************************************************************
*	Function	: OPAGE_WindowOperation
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
MS_OP OPAGE_WindowOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{	
	// Pre-processing
	switch (MsOp)
	{
	case MS_OP_INIT:
		MS_SetInvisible(pThis);
		break;
	}	
	return MS_BasicContainerOperation(pThis, MsOp, lParam);
}
/**************************************************************************
*	Function	: OPAGE_WindowFillOSDSeg
*
*	In		:
*	Out 	:
*	Return	:
*	Desc	: 
***************************************************************************/
#pragma argsused
BOOL OPAGE_WindowFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea)
{		
	OSDR_FillOsdSegBitmapFitArea(BMP_BG_2, pAbsArea);
	return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -