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

📄 mso_hslider.c

📁 ZORAN 962/966 SOURCE CODE,DVD chip
💻 C
📖 第 1 页 / 共 2 页
字号:
/* **************************************************************************************
*  Copyright (c) 2004 ZORAN Corporation, All Rights Reserved
*  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
*  File: $Workfile: o_hslider.c $
*
* Description:	
* ============
* Project definition of the MSO_HSLIDER 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\osd_rendering.h"
#include "GUI\menu_system\ms_display.h"

#include "GUI\Object_class\Hslider\mso_hslider.h"
#include "GUI\Resource\Bitmap\bitmap.h"
#include "Menu\menu_operation_def.h"

#include "Library\String_generate.h"


// Include configuration header file: named constants, macros and typedefs.
#include "GUI\Object_class\Hslider\mso_hslider_config.h"
// Include custom header file: customer specific definitions, over-writing common ones.
#include "GUI\Object_class\Hslider\mso_hslider_custom.h"

#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef	dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif


/**************************************************************************
*	Function 	: 	HSliderOperation
*
*	In		: 	
*
*	Out		: 	
*
*	Desc 	:	MSO_HSLIDER user operation function. 	
 ***************************************************************************/
MS_OP HSliderOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
	MSO_HSLIDER __NEAR* pHSlider = (MSO_HSLIDER __NEAR*)pThis;

    // To remove compiler warning:
    lParam = lParam;
	
	switch(MsOp)
	{
        case MS_OP_INIT:
            {
                // Check that values are reasonable:
                MS_ASSERT(pHSlider->moParam.mwCurrentValue >= pHSlider->moParam.mwMinValue);
                	// ... current value is greater than the minimum.
                MS_ASSERT(pHSlider->moParam.mwCurrentValue <= pHSlider->moParam.mwMaxValue);
                	// ... current value is less than the maximum.
                MS_ASSERT(pHSlider->moParam.mwMinValue < pHSlider->moParam.mwMaxValue);
                	// ... the minimum value is less than the maximum.
                MS_ASSERT(pHSlider->moParam.mwStepIndex < pHSlider->moParam.mwMaxValue);
                	// ... the step index is less than the maximum.
                MS_ASSERT((pHSlider->moParam.mwMaxValue % pHSlider->moParam.mwStepIndex) == 0);
                	// ... the maximum value can be reached.

                // Initialise the slider to the correct value:
                if(((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
                {
                    pHSlider->moParam.mwCurrentValue =
		                    ((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator(HS_ACTION_GET, 0);
                }
            }
            break;

        case MS_OP_FOCUS_CHANGE:
            MS_DisplayAddObject(pThis);
            break;

        case MS_OP_RIGHT:
            // Update the display:
            if((pHSlider->moParam.mwCurrentValue + pHSlider->moParam.mwStepIndex) <=
                    pHSlider->moParam.mwMaxValue)
            {
                pHSlider->moParam.mwCurrentValue += pHSlider->moParam.mwStepIndex;
                MS_DisplayAddObject(pThis);
            }
            // Call the action associated with this slider (if any):
			if(((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
            {
                ((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator(HS_ACTION_SET, pHSlider->moParam.mwCurrentValue);
            }
            MsOp = MS_OP_NONE;
			break;

        case MS_OP_LEFT:
            // Update the display:
            if((pHSlider->moParam.mwCurrentValue - pHSlider->moParam.mwStepIndex) >=
                    pHSlider->moParam.mwMinValue)
            {
                pHSlider->moParam.mwCurrentValue -= pHSlider->moParam.mwStepIndex;
                MS_DisplayAddObject(pThis);
            }
            // Call the action associated with this slider (if any):
            if(((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
            {
                ((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator(HS_ACTION_SET, pHSlider->moParam.mwCurrentValue);
            }
            MsOp = MS_OP_NONE;
			break;

        case MS_OP_REFRESH:
		if(((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
		{
		    ((MSO_HSLIDER __NEAR*)pThis)->moParam.mwCurrentValue =
		    		((MS_DESCRIPTOR_HSLIDER*)pHSlider->moObject.mpDescriptor)->mpfMutator(HS_ACTION_GET, pHSlider->moParam.mwCurrentValue);
		}
		MS_DisplayAddObject(pThis);
		MsOp = MS_OP_NONE;
		break;
	}
	
	return(MsOp);
}


/**************************************************************************
*	Function 	: 	HSliderFillOSDSeg
*
*	In		: 	
*
*	Out		: 	
*
*	Desc 	:	MSO_HSLIDER display function. 
 ***************************************************************************/
BOOL HSliderFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea)
{
	MSO_HSLIDER __NEAR* pHSlider = (MSO_HSLIDER __NEAR*)pThis;
	MS_DESCRIPTOR_HSLIDER *pSliderDescriptor = (MS_DESCRIPTOR_HSLIDER*)(pHSlider->moObject.mpDescriptor);
	UINT16 wXTextOffset = ((pSliderDescriptor->mcTabWidth >> 1) + 2);
	FORMATED_UNICODE_STRING oFormUniStr;
	MS_AREA 	oArea;
	UINT16 wPixelJump;
	UINT16 wXoffset;
	UINT16 wYoffset;
	UINT16 wValueColor = (MS_IsFocusable(pThis) ? CIDX_HSLIDER_TEXT_DEFAUT : CIDX_HSLIDER_TEXT_NOT_FOCUSABLE);

	wXoffset = (pThis->moArea.mwW > pSliderDescriptor->mcBarWidth)
	                    ? ((pThis->moArea.mwW - pSliderDescriptor->mcBarWidth) >> 1)
	                    : 0;
	wYoffset = (pThis->moArea.mwH > pSliderDescriptor->mcBarHeight)
	                    ? ((pThis->moArea.mwH - pSliderDescriptor->mcBarHeight) >> 1)
	                    : 0;

	// Display the background bar, centred horizontally and vertically in the containing area:
	OSDR_FillOsdSegRectangle(wXoffset,
							wYoffset,
							pSliderDescriptor->mcBarWidth,
							pSliderDescriptor->mcBarHeight,
							pAbsArea,
							CIDX_HSLIDER_BG_BAR_COLOUR);

	// Fill the horizontal slide bar area from the left...
	// Work out how wide each value jump is ((total width / number of values) * current slider value).
	// Multiply by 100 to maintain resolution (no floating point number available).
	wPixelJump = (UINT16)((pSliderDescriptor->mcBarWidth * 100) / (pHSlider->moParam.mwMaxValue - pHSlider->moParam.mwMinValue));
	wPixelJump *= (UINT16)(pHSlider->moParam.mwCurrentValue - pHSlider->moParam.mwMinValue);
	wPixelJump /= 100;
	
	// Ensure that we haven't (somehow) got a value wider than the bar itself:
	if(wPixelJump > pHSlider->moObject.moArea.mwW)
		wPixelJump = pHSlider->moObject.moArea.mwW;

	if(wPixelJump > 0)	// If we need to fill the area...
	{
		// Fill in the current value indication on the slider bar:
		OSDR_FillOsdSegRectangle(wXoffset, wYoffset, wPixelJump, pSliderDescriptor->mcBarHeight, pAbsArea, CIDX_HSLIDER_FG_BAR_COLOUR);
	}

	// Display the slider tab...
	oArea.msX = pAbsArea->msX + wXoffset + wPixelJump - (pSliderDescriptor->mcTabWidth >> 1);
	oArea.msY = pAbsArea->msY + (pAbsArea->mwH >> 1) - (pSliderDescriptor->mcTabHeight >> 1);
	oArea.mwW = pSliderDescriptor->mcTabWidth;
	oArea.mwH = pSliderDescriptor->mcTabHeight;

	OSDR_FillOsdSegBitmapFitArea(BMP_BG_2, (MS_AREA __NEAR*)&oArea);

	// Display the minimum value, if required:
	if(TRUE == pSliderDescriptor->bDisplayMinAndMaxValues)
	{
		STR_GenerateNumericValue((INT32)pHSlider->moParam.mwMinValue, oFormUniStr.mszUniStr, 0, UNISTR_LENGTH_MAX + 1);
		oFormUniStr.mtFontIndex = FONT_VALUE_MIN;
		OSDR_FormatUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr);

		wXoffset = (pThis->moArea.mwW > pSliderDescriptor->mcBarWidth)
					? ((pThis->moArea.mwW - pSliderDescriptor->mcBarWidth) >> 1) - oFormUniStr.mwPixelWidth - wXTextOffset
					: 0;
		
#ifdef D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
		wYoffset = pAbsArea->mwH >> 1;
#endif // D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
		OSDR_FillOsdSegUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr,
								pAbsArea,
								wXoffset,
								wYoffset,
								ALIGN_H_LEFT,
#ifdef D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
								ALIGN_V_CENTER,
#else // D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
								ALIGN_V_TOP,
#endif // D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
								wValueColor);

		// Display Max.
		STR_GenerateNumericValue((INT32)pHSlider->moParam.mwMaxValue, oFormUniStr.mszUniStr, 0, UNISTR_LENGTH_MAX + 1);
		oFormUniStr.mtFontIndex = FONT_VALUE_MAX;
		OSDR_FormatUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr);

		wXoffset = (pThis->moArea.mwW > pSliderDescriptor->mcBarWidth)
		                    ? ((pThis->moArea.mwW - pSliderDescriptor->mcBarWidth) >> 1) + pSliderDescriptor->mcBarWidth + wXTextOffset
		                    : pSliderDescriptor->mcBarWidth;

		OSDR_FillOsdSegUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr,
								pAbsArea,
								wXoffset,
								wYoffset,
								ALIGN_H_LEFT,
#ifdef D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
								ALIGN_V_CENTER,
#else // D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
								ALIGN_V_TOP,
#endif // D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
								wValueColor);
	}
    
	// Display current value, if required:
	if(TRUE == pSliderDescriptor->bDisplayCurrentValue)
	{
		UINT16 wYTextOffset = ((pSliderDescriptor->mcTabHeight >> 1) + 2);

		STR_GenerateNumericValue((INT32)pHSlider->moParam.mwCurrentValue, oFormUniStr.mszUniStr, 0, UNISTR_LENGTH_MAX + 1);
		oFormUniStr.mtFontIndex = FONT_VALUE_CURRENT;
		OSDR_FormatUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr);

		wXoffset = (pThis->moArea.mwW > pSliderDescriptor->mcBarWidth)
					? ((pThis->moArea.mwW - pSliderDescriptor->mcBarWidth) >> 1) + (pSliderDescriptor->mcBarWidth >> 1)
					: (pSliderDescriptor->mcBarWidth >> 1);

		wYoffset = (pThis->moArea.mwH > pSliderDescriptor->mcBarHeight)
					? (((pThis->moArea.mwH - pSliderDescriptor->mcTabHeight) >> 1) - (pSliderDescriptor->mcTabHeight >> 1) - oFormUniStr.mcPixelHeight -wYTextOffset)
					: 0;

		OSDR_FillOsdSegUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr, 
								pAbsArea,
								(pAbsArea->mwW >> 1),
								(pAbsArea->mwH >> 2),                        
								ALIGN_H_CENTER,
								ALIGN_V_CENTER,
								wValueColor);
	}
    
	// If required, display the focus highlight:
	if(MS_IsFocused(pThis))
	{
		if(HS_HIGHLIGHT_ON_TAB == pSliderDescriptor->eHLPos)
		{
			OSDR_FillOsdSegBitmapFitArea(BMP_FG_FOCUS, (MS_AREA __NEAR*)&oArea);
		}
		else
		{
			OSDR_FillOsdSegBitmapFitArea(BMP_FG_FOCUS, pAbsArea);
		}
	}
	return FALSE;
} 

/**************************************************************************

⌨️ 快捷键说明

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