?? mso_vlist.c
字號:
/* **************************************************************************************
* Copyright (c) 2004 ZORAN Corporation, All Rights Reserved
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
* File: $Workfile: o_vlist.c $
*
* Description:
* ============
* Project definition of the MSO_VLIST 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 "include\math-macro.h"
#include "GUI\Menu_system\ms_object.h"
#include "GUI\Menu_system\ms_navigation.h"
#include "gui\menu_system\osd_rendering.h"
#include "gui\menu_system\ms_display.h"
#include "GUI\Menu_system\ms_screen.h"
#include "GUI\Menu_system\ms_container.h"
#include "GUI\Object_class\Vlist\mso_vlist.h"
#include "GUI\Resource\Bitmap\bitmap.h"
#include "Menu\menu_operation_def.h"
#include "Font\fonts.h"
#include "Library\String_generate.h"
#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif
/***************************************************************************************
* Named Constants
****************************************************************************************/
#define LIST_ITEM_MIN_HEIGHT 24
#define SCROLL_MIN_HEIGHT 24
#define SCROLLBAR_WIDTH 16
#define DEFAULT_OFFSET 4 // Offset in pixel before the first item in the list.
/***************************************************************************************
* Private static functions
****************************************************************************************/
static UINT16 VlistGetRelativeItemIndex(MSO_OBJECT __NEAR *pObject, MSO_CONTAINER __NEAR *pContainer);
static BOOL VlistSetFocusToRelativeItem(MSO_OBJECT __NEAR *pThis, UINT16 wIndex);
static BOOL _VScrollListBarFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);
static BOOL _VScrollListArrowFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);
static BOOL _VScrollListArrowOnSideFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);
/***************************************************************************************
* Operation functions
****************************************************************************************/
/***************************************************************************************
* Function : VListOperation
*
* In : pThis = Pointer to MSO_VLIST object.
*
* MsOp = Operation ID.
*
* lParam = Parameter associated with an MS_OP if any.
*
* Out : None.
*
* Return : ID of the operation that is to be propagated once processing is done,
* otherwise MS_OP_NONE.
*
* Desc : This function default operation function of MSO_VLIST objects.
*
* NOTE : The MS_ATTR_GENERAL_PURPOSE_1 attribute is used determine the item
* to be focused when scrolling past the currently displayed items.
* I.e. If the last item in the list is currently focused, and user presses the
* down key, then the first item should be focused.
****************************************************************************************/
MS_OP VListOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
switch(MsOp)
{
case MS_OP_INIT:
{
//((MSO_VLIST __NEAR*)pThis)->moParam.mwTotalItems = 0;
((MSO_VLIST __NEAR*)pThis)->moParam.mwFirstDisplayItem = 0;
MS_SET_FOCUS_ON_FIRSTITEM(pThis);
//MS_CLEAR_VSLIST_DISPLAY_SCROLL_ARROW(pThis);
}
break;
case MS_OP_MENU_SET_FOCUS_TO_INDEX:
if (!VlistSetFocusToRelativeItem(pThis, (UINT16)lParam))
return MsOp;
return MS_OP_NONE;
default:
break;
}
//If up or down operation, send to the focused child first.
if ((MsOp == MS_OP_UP) || (MsOp == MS_OP_DOWN))
{
MSO_VLIST __NEAR* pList = (MSO_VLIST __NEAR*)pThis;
BOOL bSimulate = (MS_PARAM_OP_SIMULATE & lParam) ? TRUE : FALSE;
MSO_OBJECT __NEAR* pFocusObject = MS_GetFocusInContainer((MSO_CONTAINER __NEAR*)pList);
if(NULL != pFocusObject)
{
MsOp = MS_SendOperation(pFocusObject, MsOp, lParam);
if(MsOp == MS_OP_UP)
{
UINT16 wFocusedItem;
wFocusedItem = pList->moParam.mwFirstDisplayItem + VlistGetRelativeItemIndex(pFocusObject, (MSO_CONTAINER __NEAR *)pList);
// Scroll the list pagewise if the Up key is being held down (lParam is 1).
// Will scroll up only till the first page.
if ( (MS_PARAM_OP_KEYHOLD & lParam)
&& (0 != pList->moParam.mwFirstDisplayItem)
&& (wFocusedItem == pList->moParam.mwFirstDisplayItem))
{
if(FALSE == bSimulate)
{
if (pList->moParam.mwFirstDisplayItem > pList->moParam.mcNumVisibleItems)
pList->moParam.mwFirstDisplayItem -= pList->moParam.mcNumVisibleItems;
else
pList->moParam.mwFirstDisplayItem = 0;
// Refresh list and set focus to the first item.
MS_SET_FOCUS_ON_FIRSTITEM(pList);
return MS_OP_REFRESH;
}
else
return MS_OP_NONE;
}
// Don't scroll if key hold while focus on first item in the list
if ((MS_PARAM_OP_KEYHOLD & lParam) && (0 == wFocusedItem))
{
return MS_OP_NONE;
}
// We are focused on the first item.
if(0 == wFocusedItem)
{
// Let the parent handle the navigation in case the Vlist doesn't do wrap up/down
// If a Vscroll-List contains the Vlist and does wrap up-down, then the focus will to the
// last currently displayed item in the Vlist.
// Limitation: Don't handle the unfocusable items
if (MS_NavIsContainerWrapUD(pThis))
{
if(pList->moParam.mwTotalItems > pList->moParam.mcNumVisibleItems)
{
if(FALSE == bSimulate)
{
UINT16 wTemp = pList->moParam.mwTotalItems % pList->moParam.mcNumVisibleItems;
if(0 == wTemp)
wTemp = pList->moParam.mcNumVisibleItems;
pList->moParam.mwFirstDisplayItem = pList->moParam.mwTotalItems - wTemp;
// Refresh list and set focus to the last item.
MS_SET_FOCUS_ON_LASTITEM(pList);
return MS_OP_REFRESH;
}
else
return MS_OP_NONE;
}
}
}
else
{
// Update the first displayed item index.
if(wFocusedItem <= pList->moParam.mwFirstDisplayItem)
{
if(FALSE == bSimulate)
{
if(MS_IS_VLIST_SCROLL_SINGLE_ITEM(pList))
{
// pList->moParam.mwFirstDisplayItem is >= 1 as well as wFocusedItem
pList->moParam.mwFirstDisplayItem -= 1;
// Refresh list and set focus to the first item.
MS_SET_FOCUS_ON_FIRSTITEM(pList);
}
else
{
if (pList->moParam.mwFirstDisplayItem > pList->moParam.mcNumVisibleItems)
pList->moParam.mwFirstDisplayItem -= pList->moParam.mcNumVisibleItems;
else
pList->moParam.mwFirstDisplayItem = 0;
// Refresh list and set focus to the last item.
MS_SET_FOCUS_ON_LASTITEM(pList);
}
return MS_OP_REFRESH;
}
else
return MS_OP_NONE;
}
}
return MS_NavInContainer((MSO_CONTAINER __NEAR*)pThis, MsOp, bSimulate);
}
else if (MsOp == MS_OP_DOWN)
{
UINT16 wFocusedItem;
wFocusedItem = pList->moParam.mwFirstDisplayItem + VlistGetRelativeItemIndex(pFocusObject, (MSO_CONTAINER __NEAR *)pList);
// Scroll the list pagewise if the Down key is being held down (lParam is 1).
// Will scroll down only till the last page.
if((MS_PARAM_OP_KEYHOLD & lParam)
&& ((pList->moParam.mwTotalItems - pList->moParam.mwFirstDisplayItem) > pList->moParam.mcNumVisibleItems)
&& (wFocusedItem == (pList->moParam.mwFirstDisplayItem + pList->moParam.mcNumVisibleItems - 1)))
{
if(FALSE == bSimulate)
{
pList->moParam.mwFirstDisplayItem += pList->moParam.mcNumVisibleItems;
// Refresh list and set focus to the last item.
MS_SET_FOCUS_ON_LASTITEM(pList);
return MS_OP_REFRESH;
}
else
return MS_OP_NONE;
}
// Don't scroll if key hold while focus on last item in the list
if ((MS_PARAM_OP_KEYHOLD & lParam) && (wFocusedItem == (pList->moParam.mwTotalItems - 1)))
{
return MS_OP_NONE;
}
// Let the parent handle the navigation in case the Vlist doesn't do wrap up/down
if (wFocusedItem >= (pList->moParam.mwTotalItems - 1))
{
// If a Vscroll-List contains the Vlist and does wrap up-down, then the focus will to the
// first currently displayed item in the Vlist.
// Limitation: Don't handle the unfocusable items
if (MS_NavIsContainerWrapUD(pThis))
{
if (pList->moParam.mwTotalItems > pList->moParam.mcNumVisibleItems)
{
if (FALSE == bSimulate)
{
pList->moParam.mwFirstDisplayItem = 0;
// Refresh list and set focus to the first item.
MS_SET_FOCUS_ON_FIRSTITEM(pList);
return MS_OP_REFRESH;
}
else
return MS_OP_NONE;
}
}
}
else
{
// Update the first displayed item index.
if (wFocusedItem >= (pList->moParam.mwFirstDisplayItem + pList->moParam.mcNumVisibleItems - 1))
{
if (FALSE == bSimulate)
{
if (MS_IS_VLIST_SCROLL_SINGLE_ITEM(pList))
{
pList->moParam.mwFirstDisplayItem += 1;
// Refresh list and set focus to the last item.
MS_SET_FOCUS_ON_LASTITEM(pList);
}
else
{
pList->moParam.mwFirstDisplayItem += pList->moParam.mcNumVisibleItems;
// Refresh list and set focus to the first item.
MS_SET_FOCUS_ON_FIRSTITEM(pList);
}
return MS_OP_REFRESH;
}
return MS_OP_NONE;
}
}
return MS_NavInContainer((MSO_CONTAINER __NEAR*)pThis, MsOp, bSimulate);
}
}
}
return MS_BasicContainerOperation(pThis, MsOp, lParam);
}
/***************************************************************************************
* Function : VScrollListOperation
*
* In : pThis = Pointer to MSO_VSCROLL_LIST object.
*
* MsOp = Operation ID.
*
* lParam = Parameter associated with an MS_OP if any.
*
* Out : None.
*
* Return : ID of the operation that is to be propagated once processing is done,
* otherwise MS_OP_NONE.
*
* Desc : This function default operation function of MSO_VSCROLL_LIST objects.
****************************************************************************************/
MS_OP VScrollListOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
MS_ASSERT(NULL != pThis);
switch(MsOp)
{
case MS_OP_OPEN:
{
MSO_OBJECT __NEAR* pObject = NULL;
MS_DESCRIPTOR_VSCROLL_LIST* pScrollListDescriptor = (MS_DESCRIPTOR_VSCROLL_LIST*)pThis->mpDescriptor;
if(NULL != pScrollListDescriptor->mpDescriptorVList)
{
pObject = MS_CreateAndAddObject((MS_DESCRIPTOR*)pScrollListDescriptor->mpDescriptorVList, (MSO_CONTAINER __NEAR*)pThis);
// Resize the list according to X, Y padding and dimensions of the scrollbar.
pObject->moArea.msX = pScrollListDescriptor->mcXPadding;
pObject->moArea.msY = pScrollListDescriptor->mcYPadding;
pObject->moArea.mwH = pThis->moArea.mwH - (pScrollListDescriptor->mcYPadding << 1);
if(MS_IS_VSLIST_DISPLAY_SCROLL_ARROW(pThis) && !MS_IS_VSLIST_DISPLAY_SCROLL_ARROW_ON_SIDE(pThis))
pObject->moArea.mwW = pThis->moArea.mwW - (pScrollListDescriptor->mcXPadding << 1);
else
pObject->moArea.mwW = pThis->moArea.mwW - (pScrollListDescriptor->mcXPadding * 3) - SCROLLBAR_WIDTH;
}
}
break;
}
return MS_BasicContainerOperation(pThis, MsOp, lParam);
}
/***************************************************************************************
* Display functions
****************************************************************************************/
/***************************************************************************************
* Function : VListFillOSDSeg
*
* In : pThis = Pointer to a MSO_VLIST object.
*
* pAbsArea = Absolute area of pThis object.
*
* Out : None.
*
* Return : None.
*
* Desc : Default display function of MSO_VLIST objects.
****************************************************************************************/
BOOL VListFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea)
{
// To avoid compiler warnings:
pThis = pThis;
// Just fill in the background:
return OSDR_FillOsdSegBitmapFitArea(BMP_BG_3, pAbsArea);
}
/***************************************************************************************
* Function : VScrollListFillOSDSeg
*
* In : pThis = Pointer to a MSO_VSCROLL_LIST object.
*
* pAbsArea = Absolute area of pThis object.
*
* Out : None.
*
* Return : None.
*
* Desc : Default display function of MSO_VSCROLL_LIST objects.
****************************************************************************************/
BOOL VScrollListFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea)
{
if(MS_IS_VSLIST_DISPLAY_SCROLL_ARROW(pThis))
{
if(MS_IS_VSLIST_DISPLAY_SCROLL_ARROW_ON_SIDE(pThis))
return _VScrollListArrowOnSideFillOSDSeg(pThis, pAbsArea);
else
return _VScrollListArrowFillOSDSeg(pThis, pAbsArea);
}
else
return _VScrollListBarFillOSDSeg(pThis, pAbsArea);
}
/***************************************************************************************
* Function : VScrollListFillOSDSeg
*
* In : pThis = Pointer to a MSO_VSCROLL_LIST object.
*
* pAbsArea = Absolute area of pThis object.
*
* Out : None.
*
* Return : TRUE if successful.
*
* Desc : Display function of the vertical scroll list with scroll bar.
****************************************************************************************/
static BOOL _VScrollListBarFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea)
{
UINT16 wScrollHeight = 0;
UINT16 wScrollStartX = 0;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -