MS_BMP_BTN.C
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:5k
源码类别:

DVD

开发平台:

Others

  1. /* **************************************************************************************
  2. *  Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
  3. *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
  4. *
  5. *  File: $Workfile: MS_BMP_BTN.C $
  6. *
  7. * Description:
  8. * ============
  9. * bitmaps buttons
  10. *
  11. * Log:
  12. * ====
  13. * $Revision: 3 $
  14. * Last Modified by $Author: Leslie $ at $Modtime: 03-01-02 10:48 $
  15. ****************************************************************************************
  16. * Updates:
  17. ****************************************************************************************
  18. * $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/MS_BMP_BTN.C $
  19.  * 
  20.  * 3     03-01-09 4:43 Leslie
  21.  * Unicode support
  22.  * 
  23.  * 3     23/04/02 9:39 Nirm
  24.  * - Added dependency in "Config.h".
  25.  * 
  26.  * 2     4/22/02 18:22 Rinata
  27.  * add USE_SMALL_BMP_BUTTONS buttons
  28.  * 
  29.  * 1     4/22/02 14:46 Rinata
  30. *
  31. *
  32. *****************************************************************************************/
  33. #include "Config.h" // Global Configuration - do not remove!
  34. #ifdef USE_BMP_BUTTON
  35. #ifdef _DEBUG
  36. #include "DebugDbgMain.h"
  37. #undef IFTRACE
  38. #define IFTRACE if (gTraceMenu)
  39. #endif //_DEBUG
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. #include <string.h>
  43. #include "Includesysdefs.h"
  44. #include "Decoderosdrendr.h"
  45. #include "PlaycoreScPadScMgr.h"
  46. #include "UIMenu_Sysms_lib.h"
  47. #include "UIMenu_Sysosd_drv.h"
  48. #include "UIMenu_Sysms_wdgt.h"
  49. #define MS_MAX_ASCII_BUTTON_TEXT_LENGTH   MS_STATIC_MAX_LENGTH
  50. static void display (MS_WIDGET *widget, char focus)
  51. {
  52. wchar_t *text = ((MS_BMP_BUTTON *)widget)->present.text;
  53. // We need a NULL_CHAR at the end
  54. wchar_t str[MS_MAX_ASCII_BUTTON_TEXT_LENGTH + 2];
  55. unsigned char ucBgColor = BACK_COLOR( widget, focus );
  56. if (MS_IS_USE_SC(widget)) {
  57. if ( NULL_HANDLE != (WORD)text )
  58. sc_GetBytes((WORD)text, 0, MS_MAX_ASCII_BUTTON_TEXT_LENGTH, (BYTE*)str);
  59. }
  60. if ( MS_IS_ASCII(widget) )
  61. {
  62. if (MS_IS_USE_SC(widget)) {
  63. if (NULL_HANDLE != (WORD)text) {
  64. text= str;
  65. }
  66. else
  67. text= NULL;
  68. }
  69. else {
  70. if (NULL != text) {
  71. text= str;
  72. }
  73. }
  74. if (NULL == text)
  75. text= L"";
  76. }
  77. if( focus )
  78. {
  79. OSD_DrawBitmap( ((MS_BMP_BUTTON *)widget)->bitmap.bitmap_pos.x,
  80.   ((MS_BMP_BUTTON *)widget)->bitmap.bitmap_pos.y,   
  81.   ((MS_BMP_BUTTON *)widget)->bitmap.bitmap_buff ,
  82. #if defined(USE_BMP_BUTTON) && defined(USE_ICON_BUTTONS)
  83.   7,
  84. #else
  85.   10,
  86. #endif
  87.                        //((MS_BMP_BUTTON *)widget)->bitmap.bgIndex,
  88.                        BACK_COLOR(widget, focus));
  89. }
  90. else
  91. {
  92. OSD_DrawBitmap( ((MS_BMP_BUTTON *)widget)->bitmap.bitmap_pos.x,
  93.   ((MS_BMP_BUTTON *)widget)->bitmap.bitmap_pos.y,
  94.   ((MS_BMP_BUTTON *)widget)->bitmap.bitmap_buff,
  95.                      0,
  96.                      0 );
  97. }
  98. }
  99. MS_UOP bmp_button_user_op(MS_WIDGET *widget,MS_UOP uop,char param) 
  100. {
  101. MS_BMP_BUTTON *button = (MS_BMP_BUTTON *)widget;
  102. switch (uop)
  103. {
  104.   case MS_UOP_DELETE:
  105.   uop = MS_UOP_NOP;
  106.   break;
  107.   case MS_UOP_DISPLAY:
  108.   display(widget,param);
  109.   uop = MS_UOP_NOP;
  110.   break;
  111.   case MS_UOP_ENTER:
  112.   button->action();
  113.   uop = MS_UOP_NOP;
  114.   break;
  115. }
  116. return uop;
  117. }
  118. void MS_init_bmp_button(MS_BMP_BUTTON *msb, MS_POS *pos,MS_COLOR color,
  119. MS_UOP (*user_op)(MS_WIDGET *,MS_UOP,char),
  120. void *text,void (* action)(void), 
  121. unsigned char attr)
  122. {
  123. #ifdef _DEBUG
  124. if (NULL == msb) {
  125. tr_printf(("FATAL: MS_init_bmp_button() Failed: NULL control.n"));
  126. return;
  127. }
  128. #endif
  129. ((MS_WIDGET *)msb)->pos = *pos;
  130. ((MS_WIDGET *)msb)->parent = NO_PARENT;
  131. msb->present.text = text;
  132. msb->action = action;
  133. ((MS_WIDGET *)msb)->attr = attr;
  134. ((MS_WIDGET *)msb)->color = color;
  135. if (NULL != user_op)
  136. ((MS_WIDGET *)msb)->user_op = user_op;
  137. else
  138. ((MS_WIDGET *)msb)->user_op = bmp_button_user_op;
  139. ((MS_WIDGET *)msb)->attrh = ALIGN_CENTER;
  140. }
  141. MS_BMP_BUTTON *MS_create_bmp_button(MS_POS *pos, MS_COLOR color,
  142. MS_UOP (*user_op)(MS_WIDGET *,MS_UOP,char),
  143. void *text,
  144. void (* action)(void), 
  145. unsigned char attr)
  146. {
  147. MS_BMP_BUTTON *msb;
  148. dbg_printf(("MS_create_bmp_buttonn"));
  149. msb = (MS_BMP_BUTTON *) malloc (sizeof(MS_BMP_BUTTON));
  150. #ifdef _DEBUG
  151. if (NULL == msb) {
  152. tr_printf(("FATAL: MS_create_bmp_button() Failed: Low system resources.n"));
  153. return NULL;
  154. }
  155. #endif //_DEBUG
  156. MS_init_bmp_button(msb, pos, color, user_op, text, action, attr);
  157. return msb;
  158. }
  159. #endif // USE_BMP_BUTTON