mso_hslider.c

来自「Zoran V966 DVD 解码 Soc芯片的源程序」· C语言 代码 · 共 586 行 · 第 1/2 页

C
586
字号
*	Function 	: 	_DisplaySliderRectangleAndTab
*
*	In		: 	
*
*	Out		: 	
*
*	Desc 	:	Displays the rectangle and tab of the slider 
 ***************************************************************************/
static void _DisplaySliderRectangleAndTab(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea, 
										UINT16 wXoffset, UINT16 wYoffset)
{
	MSO_HSLIDER __NEAR* pHSlider = (MSO_HSLIDER __NEAR*)pThis;
	UINT16 		wPixelJump;
	MS_AREA 	oArea;
	MS_DESCRIPTOR_HSLIDER_VLIST *pSliderDescriptor = (MS_DESCRIPTOR_HSLIDER_VLIST*)(pHSlider->moObject.mpDescriptor);

	// 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 / 2);
	oArea.msY = pAbsArea->msY + (pAbsArea->mwH / 2) - (pSliderDescriptor->mcTabHeight / 2);
	oArea.mwW = pSliderDescriptor->mcTabWidth;
	oArea.mwH = pSliderDescriptor->mcTabHeight;

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

/**************************************************************************
*	Function 	: 	_DisplayVlistSliderValues
*
*	In		: 	
*
*	Out		: 	
*
*	Desc 	: 	Displays the values (if any) on the slider 	
 ***************************************************************************/
 #pragma argsused
static void _DisplayVlistSliderValues(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea, UINT16 wYoffset)
{
	FORMATED_UNICODE_STRING oFormUniStr;
	MSO_HSLIDER __NEAR* pHSlider = (MSO_HSLIDER __NEAR*)pThis;
	MS_DESCRIPTOR_HSLIDER_VLIST *pSliderDescriptor = (MS_DESCRIPTOR_HSLIDER_VLIST*)(pHSlider->moObject.mpDescriptor);
	UINT16 wXoffset;
	UINT16 wXTextOffset = ((pSliderDescriptor->mcTabWidth >> 1) + 2);
	UINT16 wValueColor = (MS_IsFocusable(pThis) ? CIDX_HSLIDER_TEXT_DEFAUT : CIDX_HSLIDER_TEXT_NOT_FOCUSABLE);
	
	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);

      		if(pThis->moArea.mwW > pSliderDescriptor->mcBarWidth)
			wXoffset = (pThis->moArea.mwW >> 1) - oFormUniStr.mwPixelWidth -wXTextOffset;
		else
			wXoffset = 0;

		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);

        	if(pThis->moArea.mwW > pSliderDescriptor->mcBarWidth)
			wXoffset = (pThis->moArea.mwW >> 1) + pSliderDescriptor->mcBarWidth + wXTextOffset;
		else
                     wXoffset = 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)
    	{
    		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);

        	if(pThis->moArea.mwW > pSliderDescriptor->mcBarWidth)
			wXoffset = ((pThis->moArea.mwW >> 1) + (pSliderDescriptor->mcBarWidth >> 1));
		else
			wXoffset = (pSliderDescriptor->mcBarWidth  >> 1);

        	OSDR_FillOsdSegUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr,
								pAbsArea,
								wXoffset, 
								(pAbsArea->mwH >> 2),
								ALIGN_H_CENTER,
								ALIGN_V_CENTER,
								wValueColor);
	}
}

/**************************************************************************
*	Function 	: 	HSliderOperationOnVList
*
*	In		: 	
*
*	Out		: 	
*
*	Desc 	:	MSO_HSLIDER user operation function. 	
 ***************************************************************************/
#pragma argsused
MS_OP HSliderOperationOnVList(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
	MSO_HSLIDER __NEAR* pHSlider = (MSO_HSLIDER __NEAR*)pThis;
	
	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_VLIST*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
			{
				pHSlider->moParam.mwCurrentValue =
					((MS_DESCRIPTOR_HSLIDER_VLIST*)pHSlider->moObject.mpDescriptor)->mpfMutator(HS_ACTION_GET, 0);
			}
		}
		break;

	case MS_OP_REFRESH:
		{
			if(((MS_DESCRIPTOR_HSLIDER_VLIST*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
			{
				pHSlider->moParam.mwCurrentValue = ((MS_DESCRIPTOR_HSLIDER_VLIST*)pHSlider->moObject.mpDescriptor)->mpfMutator(HS_ACTION_GET, 0);
				MS_DisplayAddObject(pThis);
			}
		}
		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_VLIST*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
		{
			((MS_DESCRIPTOR_HSLIDER_VLIST*)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_VLIST*)pHSlider->moObject.mpDescriptor)->mpfMutator != NULL)
		{
			((MS_DESCRIPTOR_HSLIDER_VLIST*)pHSlider->moObject.mpDescriptor)->mpfMutator(HS_ACTION_SET, pHSlider->moParam.mwCurrentValue);
		}
		MsOp = MS_OP_NONE;
		break;
	}	
	return MsOp;
}


/**************************************************************************
*	Function 	: 	HSliderFillOSDSegOnVList
*
*	In		: 	
*
*	Out		: 	
*
*	Desc 	:	MSO_HSLIDER display function. 
 ***************************************************************************/
BOOL HSliderFillOSDSegOnVList(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea)
{
	MSO_HSLIDER __NEAR* pHSlider = (MSO_HSLIDER __NEAR*)pThis;
	MS_DESCRIPTOR_HSLIDER_VLIST *pSliderDescriptor = (MS_DESCRIPTOR_HSLIDER_VLIST*)(pHSlider->moObject.mpDescriptor);
	UINT16 wColor = ((!MS_IsFocusable(pThis) || MS_IS_HSLIDER_DISABLED(pThis)) ? CIDX_HSLIDER_TEXT_NOT_FOCUSABLE : CIDX_HSLIDER_TEXT_DEFAUT);
	FORMATED_UNICODE_STRING oFormUniStr;
	MS_AREA 	oArea;
	UINT16 wXoffset;
	UINT16 wYoffset;


	if(NULL != pSliderDescriptor->mName)
	{
		/*Display name of the parameter */
		oFormUniStr.mtFontIndex = FONT_PARAMETER_NAME;
		OSDR_GetFormUniStr_OsdMessage((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr, pSliderDescriptor->mName);

		OSDR_FillOsdSegUniString((FORMATED_UNICODE_STRING __NEAR*)&oFormUniStr, 
								pAbsArea, 
								12, /* Displayed as a choice */
								(pAbsArea->mwH >> 1), 
								0,
								ALIGN_V_CENTER, 
								wColor);
	}

	/* determine the x offset for the slider */
	wXoffset = (pThis->moArea.mwW > pSliderDescriptor->mcBarWidth) ? (pThis->moArea.mwW >> 1) : 0;
	
	/* determine the y offset for the slider */
 	wYoffset = (pThis->moArea.mwH > pSliderDescriptor->mcBarHeight) ? ((pThis->moArea.mwH - pSliderDescriptor->mcBarHeight)  >> 1) : 0;

 	_DisplaySliderRectangleAndTab((MSO_OBJECT __NEAR*) pHSlider, (MS_AREA __NEAR*) pAbsArea, wXoffset, wYoffset);
	
#ifdef D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
	wYoffset = pAbsArea->mwH >> 1;
#endif // D_GUI_MSO_SLIDER_MIN_MAX_TEXT_ALIGNED_CENTER
	
	_DisplayVlistSliderValues((MSO_OBJECT __NEAR*) pHSlider, (MS_AREA __NEAR*) pAbsArea, wYoffset);
  
	// 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 + =
减小字号Ctrl + -
显示快捷键?