OSD_DRV.C
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:13k
- /* **************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: OSD_DRV.C $
- *
- * Description:
- * ============
- * low level OSD handler
- *
- * Log:
- * ====
- * $Revision: 21 $
- * Last Modified by $Author: Terencet $ at $Modtime: 3/12/04 3:27p $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/UI/Menu_sys/OSD_DRV.C $
- *
- * 21 3/12/04 3:29p Terencet
- * display english string if current language string is null
- *
- * 20 03-03-19 16:28 Rogerl
- * Avoid too much warning messages ouput to Hyperterminal
- *
- * 19 03-03-04 11:50 Hannahh
- * remove the customer name of all project.
- *
- * 18 03-02-26 15:13 Mikelv
- * change frame
- *
- * 17 03-02-08 16:00 Rogerl
- * Fix OSD_GetFontHeight,
- * Don't treat ALIGN_LEFT_PAD as ALIGN_LEFT in OSD_PutText
- *
- * 16 03-01-17 11:56 Rogerl
- * add OSD_3DFrameRect
- *
- * 15 03-01-09 4:43 Leslie
- * Unicode support
- *
- * 14 11/22/02 9:30a Leslie
- * Use Look-up table for Ascii to String convertion
- *
- * 13 10/30/02 18:03 Rond
- *
- * 15 5/22/02 8:52a Tomasp
- * Changed include paths.
- *
- * 14 23/04/02 9:39 Nirm
- * - Added dependency in "Config.h".
- *
- * 13 4/22/02 14:50 Rinata
- * under USE_BMP_BUTTON setup menu with bitmap buttons
- *
- * 12 4/11/02 6:11a Tomasp
- * ASCII character with code >= 0xF0 are also replaced.
- *
- * 11 19/03/02 20:56 Nirm
- * Improvements in OSD_CorneredFrame().
- *
- * 10 17/03/02 20:05 Nirm
- * Added OSD_CorneredFrame().
- *
- * 9 11/03/02 14:12 Nirm
- * Code cleanup.
- *
- * 8 24/02/02 14:13 Nirm
- * - Added support for various characters.
- *
- * 7 16/01/02 8:57 Nirm
- * Fixed debug-messages.
- *
- * 6 13/01/02 16:41 Atai
- * Remove old Defines
- *
- * 5 9/01/02 18:23 Nirm
- * Corrected Include-Paths.
- *
- * 4 31/12/01 16:10 Nirm
- * Corrected wrong casting, which caused giberish on the OSD.
- *
- * 3 30/12/01 10:06 Atai
- * Add explicit casting
- *
- * 2 25/12/01 12:03 Atai
- * code cleaning
- **************************************************************************************** */
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef _DEBUG
- #include "DebugDbgMain.h"
- #undef IFTRACE
- #define IFTRACE if (gTraceMenu)
- #endif //_DEBUG
- #include <stdio.h>
- #include "Includesysdefs.h"
- #include "Decoderosdrendr.h"
- #include "Decoderosdlayou.h"
- #include "UIMenu_Sysms_wdgt.h"
- #include "UIMenu_Sysosd_drv.h"
- #include "UIMenu_Sysms_lib.h"
- //START of customer specific include files
- #include "Stringsstrings.h"
- //END of customer specific include files
- static unsigned short Xorigin;
- static unsigned short Yorigin;
- #ifdef _DEBUG
- #define IFTRACE if (gTraceMenu)
- #include "DebugDbgMain.h"
- #endif
- int OSD_GetFontHeight(void)
- {
- #ifdef D_LINE_DOUBLING
- return (pgoCurrentFont->m_cHeight * 2);
- #else
- return
- #ifdef USE_FONT24x32
- // use height parameter in fonts
- pgoCurrentFont->m_cHeight;
- #else
- pgoCurrentFont->m_cHeight;
- #endif
- #endif // D_LINE_DOUBLING
- }
- #ifdef D_LINE_DOUBLING
- #define OSD_DRAW_RECTANGLE( _x_, _y_, _w_, _h_ ) OSDDrawRectangle( (_x_), ((_y_) >> 1), (_w_), ((_h_) >> 1) )
- #else
- #define OSD_DRAW_RECTANGLE( _x_, _y_, _w_, _h_ ) OSDDrawRectangle( (_x_), (_y_), (_w_), (_h_) )
- #endif
- void OSD_AimedFrame(int x, int y, int w, int h, int h_length, int v_length,
- unsigned char color, unsigned char thickness)
- {
- int iEffectiveHeight= (v_length - thickness);
- /*
- int iHorizCenter, iVertCenter;
- x += Xorigin;
- y += Yorigin;
- OSDSetBrushColor(color);
- iHorizCenter= ((x + w - thickness) / 2);
- iVertCenter= ((y + h - thickness) / 2);
- // Draw the Crosshair:
- // Top Center
- OSD_DRAW_RECTANGLE(iHorizCenter, y, thickness, iEffectiveHeight);
- // Bottom Center
- OSD_DRAW_RECTANGLE(iHorizCenter, (y + h - v_length), thickness, iEffectiveHeight);
- // Left Center
- OSD_DRAW_RECTANGLE(x, iVertCenter, h_length, thickness);
- // Right Center
- OSD_DRAW_RECTANGLE((x + w - h_length), iVertCenter, h_length, thickness);
- // Adjust the coordinates to align the Frame with the Crosshair
- x += (h_length / 2);
- y += (v_length / 2);
- w -= h_length;
- h -= v_length;
- // Draw the Corners of the Frame:
- // Top-Left Corner
- OSD_DRAW_RECTANGLE(x, y, h_length, thickness);
- OSD_DRAW_RECTANGLE(x, (y + thickness), thickness, iEffectiveHeight);
- // Top-Right Corner
- OSD_DRAW_RECTANGLE((x + w - h_length), y, h_length, thickness);
- OSD_DRAW_RECTANGLE((x + w - thickness), (y + thickness), thickness, iEffectiveHeight);
- // Bottom-Left Corner
- OSD_DRAW_RECTANGLE(x, (y + h - thickness), h_length, thickness);
- OSD_DRAW_RECTANGLE(x, (y + h - v_length), thickness, iEffectiveHeight);
- // Bottom-Right Corner
- OSD_DRAW_RECTANGLE((x + w - h_length), (y + h - thickness), h_length, thickness);
- OSD_DRAW_RECTANGLE((x + w - thickness), (y + h - v_length), thickness, iEffectiveHeight);
- return;
- int iEffectiveHeight= (v_length - thickness);
- */
- int tx,ty,tw,th;
- x += Xorigin;
- y += Yorigin;
- tx = x;
- ty = y;
- tw = w;
- th = h ;
-
- x = tx + tw/2 - thickness - h_length ;
- y = ty + th/2 - thickness - v_length;
- w = thickness *2 + h_length *2 ;
- h = thickness*2 + v_length*2 ;
- OSDSetBrushColor(color);
-
- // Top-Left Corner
- OSD_DRAW_RECTANGLE(x, y, h_length, thickness);
- OSD_DRAW_RECTANGLE(x, (y + thickness), thickness, iEffectiveHeight);
- // Top-Right Corner
- OSD_DRAW_RECTANGLE((x + w - h_length), y, h_length, thickness);
- OSD_DRAW_RECTANGLE((x + w - thickness), (y + thickness), thickness, iEffectiveHeight);
- // Bottom-Left Corner
- OSD_DRAW_RECTANGLE(x, (y + h - thickness), h_length, thickness);
- OSD_DRAW_RECTANGLE(x, (y + h - v_length), thickness, iEffectiveHeight);
- // Bottom-Right Corner
- OSD_DRAW_RECTANGLE((x + w - h_length), (y + h - thickness), h_length, thickness);
- OSD_DRAW_RECTANGLE((x + w - thickness), (y + h - v_length), thickness, iEffectiveHeight);
- //cross range
- x = x - (h_length/2);
- y = y - (v_length/2);
- w = w + h_length;
- h = h + v_length;
- //cross up
- OSD_DRAW_RECTANGLE( (x + w/2 - thickness/2 ), y , thickness, v_length);
- //cross left
- OSD_DRAW_RECTANGLE( x, (y + h/2 - thickness/2 ), h_length, thickness);
- //cross right
- OSD_DRAW_RECTANGLE( x+w-h_length, (y + h/2 - thickness/2 ), h_length, thickness);
- //cross down
- OSD_DRAW_RECTANGLE( (x + w/2 - thickness/2 ), y+h-v_length , thickness, v_length);
-
- return;
- }
- void OSD_CorneredFrame(int x, int y, int w, int h, int h_length, int v_length,
- unsigned char color, unsigned char thickness)
- {
- int iEffectiveHeight= (v_length - thickness);
- x += Xorigin;
- y += Yorigin;
- OSDSetBrushColor(color);
- // Top-Left Corner
- OSD_DRAW_RECTANGLE(x, y, h_length, thickness);
- OSD_DRAW_RECTANGLE(x, (y + thickness), thickness, iEffectiveHeight);
- // Top-Right Corner
- OSD_DRAW_RECTANGLE((x + w - h_length), y, h_length, thickness);
- OSD_DRAW_RECTANGLE((x + w - thickness), (y + thickness), thickness, iEffectiveHeight);
- // Bottom-Left Corner
- OSD_DRAW_RECTANGLE(x, (y + h - thickness), h_length, thickness);
- OSD_DRAW_RECTANGLE(x, (y + h - v_length), thickness, iEffectiveHeight);
- // Bottom-Right Corner
- OSD_DRAW_RECTANGLE((x + w - h_length), (y + h - thickness), h_length, thickness);
- OSD_DRAW_RECTANGLE((x + w - thickness), (y + h - v_length), thickness, iEffectiveHeight);
- return;
- }
- void OSD_FrameRect(int x,int y,int w,int h,unsigned char color,unsigned char thickness)
- {
- int iInnerHeight = (h - (2 * thickness));
-
- x += Xorigin;
- y += Yorigin;
- dbg_printf(("OSD_FrameRect %d %d %d %d color: %d thickness %d STARTn",x,y,w,h,(int)color,(int)thickness));
-
- OSDSetBrushColor(color);
- // Top horizontal line
- OSD_DRAW_RECTANGLE(x, y, w, thickness);
- // Bottom horizontal
- OSD_DRAW_RECTANGLE(x, y + h - thickness, w, thickness);
- // Left vertical line
- OSD_DRAW_RECTANGLE(x, y + thickness, thickness, iInnerHeight);
- // Right vertical line
- OSD_DRAW_RECTANGLE(x + w - thickness, y + thickness, thickness, iInnerHeight);
- dbg_printf(("OSD_FrameRect %d %d %d %d color: %d thickness %d ENDn",x,y,w,h,(int)color,(int)thickness));
- return;
- }
- void OSD_3DFrameRect(int x,int y,int w,int h,unsigned char colorLT, unsigned char colorRB, unsigned char thickness)
- {
- int iInnerHeight = (h - (2 * thickness));
-
- x += Xorigin;
- y += Yorigin;
- //dbg_printf(("OSD_3DFrameRect %d %d %d %d color: %d thickness %d STARTn",x,y,w,h,(int)color,(int)thickness));
-
- OSDSetBrushColor(colorLT);
- // Top horizontal line
- OSD_DRAW_RECTANGLE(x, y, w, thickness);
- // Left vertical line
- OSD_DRAW_RECTANGLE(x, y + thickness, thickness, iInnerHeight);
- OSDSetBrushColor(colorRB);
- // Bottom horizontal
- OSD_DRAW_RECTANGLE(x, y + h - thickness, w, thickness);
- // Right vertical line
- OSD_DRAW_RECTANGLE(x + w - thickness, y + thickness, thickness, iInnerHeight);
- //dbg_printf(("OSD_FrameRect %d %d %d %d color: %d thickness %d ENDn",x,y,w,h,(int)color,(int)thickness));
- }
- // Calculate the frame bounds for the specified rectangle
- void OSD_CalcFramedPos( MS_POS *pmspos )
- {
- unsigned char cExtraPixels = C_INSET + C_THICKNESS;
- pmspos->x -= cExtraPixels;
- if ( (short) pmspos->x < 0 )
- pmspos->x = 0;
- pmspos->y -= cExtraPixels;
- if ( (short) pmspos->y < 0 )
- pmspos->y = 0;
- pmspos->w += (2 * cExtraPixels);
- pmspos->h += (2 * cExtraPixels);
- }
- void OSD_PutRect(int x,int y,int w,int h,unsigned char color)
- {
- x+=Xorigin;
- y+=Yorigin;
-
- dbg_printf(("OSD_PutRect %d %d %d %d color: %d STARTn",x,y,w,h,(int)color));
- OSDSetBrushColor(color);
- OSD_DRAW_RECTANGLE(x, y, w, h);
- dbg_printf(("OSD_PutRect %d %d %d %d color: %d ENDn",x,y,w,h,(int)color));
- return;
- }
- void OSD_PutText(int x,int y,int w,int h,unsigned char forward_color,unsigned char backward_color,void *text, char alignment,char ascii)
- {
- int y_gap;
- int iFontHeight = OSD_GetFontHeight();
- #ifdef D_MS_EXTENSIONS
- char szConcatBuffer[MS_STATIC_MAX_LENGTH + 1];
- #endif // MS_EXTENSIONS
- // Force wWidth = FIT_STRING_SZ for ALIGN_LEFT
- if ( alignment == ALIGN_LEFT )
- w = FIT_STRING_SZ;
- // Don't do the following for use ALIGN_LEFT_PAD as a new justify attribute, Roger 030207
- //if ( alignment == ALIGN_LEFT_PAD )
- // alignment = ALIGN_LEFT;
- x+=Xorigin;
- y+=Yorigin;
- dbg_printf(("OSD_PutText %d %d %d %d color: (%d,%d)n",x,y,w,h,(int)forward_color,(int)backward_color));
- y_gap = (h-iFontHeight)/2;
- OSDSetBrushColor(backward_color);
- #ifdef D_LINE_DOUBLING
- OSDDrawRectangle(x, (y>>1), w, (y_gap>>1));
- #else
- OSDDrawRectangle(x,y,w,y_gap);
- #endif // D_LINE_DOUBLING
- y+= y_gap;
- OSDSetFontColor(forward_color, backward_color);
- if ( ascii != C_ASCII )
- {
- if ( text == 0 )
- {
- dbg_printf(("OSD_PutText(): Warning: text is NULL.n"));
- }
- //#ifdef D_NEW_STRING
- // if ((int)text < 0x100)
- // text = (void *) ((Strings_Common[LANGUAGE_ENGLISH])[(int)text]);
- // else
- // text = (void *) ((Strings[gCurrentLanguage])[(int)text - 0x100]);
- //#else
- #ifdef DEFAULT_ENGLISH_FOR_NULL_STRING
- if(NULL == (Strings[gCurrentLanguage])[(int)text])
- {
- //replace with english string if current language string is null
- text = (void *) ((Strings[LANGUAGE_ENGLISH])[(int)text]);
- }
- else
- #endif
- text = (void *) ((Strings[gCurrentLanguage])[(int)text]);
- //#endif
- #ifdef D_MS_EXTENSIONS
- if ( *((char *)text) == ESCSQ_MSG )
- {
- char *pucSrc = (char *) text;
- char *pucDst = szConcatBuffer;
- while ( *pucSrc == ESCSQ_MSG )
- {
- pucSrc = (char *) ( (Strings[gCurrentLanguage])[(int) pucSrc[1]] );
- while ( *pucSrc )
- {
- *pucDst = *pucSrc;
- pucDst++;
- pucSrc++;
- } // while ( *pucSrc )
- text = (void *) ((char *) text + 2);
- pucSrc = (char *) text;
- } // while ( *pucSrc == ESCSQ_MSG )
- *pucDst = ' ';
- text = (void *) szConcatBuffer;
- } // ( *((char *)text) == ESCSQ_MSG )
- #endif // D_MS_EXTENSIONS
- } // ascii != C_ASCII
- #ifdef D_LINE_DOUBLING
- OSDPrintStr((BYTE *)text, x, (y>>1), w, alignment);
- #else
- OSDPrintStr((BYTE *)text, x, y, w, alignment);
- #endif // D_LINE_DOUBLING
- OSDSetBrushColor(backward_color);
- y += iFontHeight;
- h -= ( y_gap + iFontHeight );
- #ifdef D_LINE_DOUBLING
- OSDDrawRectangle(x, (y>>1), w, (h>>1));
- #else
- OSDDrawRectangle(x, y, w, h);
- #endif // D_LINE_DOUBLING
- return;
- }
- //#ifdef USE_BMP_BUTTON
- void OSD_DrawBitmap(WORD wXPos , WORD wYPos , CONST BYTE *pcBm, BYTE FocusIndex, BYTE newBGindex )
- {
- wXPos += Xorigin;
- wYPos += Yorigin;
- OSDDisplayFocusBitmap(wXPos, wYPos, pcBm , FocusIndex, newBGindex );
- }
- //#endif
- void OSD_TurnOff(void)
- {
- dbg_printf(("OSD turn OFFn"));
- Xorigin = 0;
- Yorigin = 0;
- OSDTurnOff();
- }
- void OSD_TurnOn(void)
- {
- dbg_printf(("OSD turn ONn"));
- OSDTurnOn();
- }
- void OSD_SetOrigin(MS_WIDGET *widget)
- {
- MS_WIDGET *curr = (MS_WIDGET *)widget->parent;
- Xorigin = widget->pos.x;
- Yorigin = widget->pos.y;
- while (curr != NO_PARENT) {
- Xorigin += curr->pos.x;
- Yorigin += curr->pos.y;
- curr = (MS_WIDGET *)curr->parent;
- }
- }