wingui.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:231k
源码类别:

MTK

开发平台:

C/C++

  1. /*******************************************************************************
  2. *  Modification Notice:
  3. *  --------------------------
  4. *  This software is modified by MediaTek Inc. and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *******************************************************************************/
  35.  /*******************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  *   wingui.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *   Maui_Software
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  GUI related funtions
  47.  *
  48.  * Author:
  49.  * -------
  50.  * -------
  51.  *
  52.  *------------------------------------------------------------------------------
  53.  * $Log$
  54.  *
  55.  * removed!
  56.  * removed!
  57.  * apply correct compile option: __MMI_RESOURCE_ENFB_SUPPORT__
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * 
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * 
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * 
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * 
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * 
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * 
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * 
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * check in [NewFeature]MMI trace string
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * Add gdi_image_estimate_show_fullscreen_time bypass function.
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * 
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * 
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * Turn on backlight in the end of MMICheckDiskDisplay
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * 
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * 
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * 
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * 
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * 
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * 
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * 
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * 
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * 
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * 
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * 
  150.  *
  151.  *******************************************************************************/
  152. /******************************************************************************
  153.  *
  154.  *  File:            %P%
  155.  *  -----
  156.  *
  157.  *  SCCS Version:    %I%
  158.  *  -------------
  159.  *
  160.  *  Copyright Statement:
  161.  *  --------------------
  162.  *****************************************************************************/
  163.  /**
  164.  * Copyright Notice
  165.  * (c) 2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  166.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  167.  *  (It is illegal to remove this copyright notice from this software or any
  168.  *  portion of it)
  169.  */
  170. /**********************************************************************************
  171.    Filename:      wingui.c
  172.    Author:        manju
  173.    Date Created:  September-03-2002
  174.    Contains:      OS / hardware driver interface for the UI
  175.    Platform:      Win32 / Hardware (Use the MMI_BUILD_TYPE flag)
  176. **********************************************************************************
  177.  *  Project:        
  178.  *  --------
  179.  *
  180.  *  Software Unit:  MMI
  181.  *  --------------
  182.  *
  183.  *  Description:
  184.  *  ------------
  185.  *  
  186.  *  
  187.  *  Modification History:
  188.  *  ---------------------
  189.  *  Date       Vers  Auth  Details
  190.  *  ----       ----  ----  -------
  191.  *  20040517   1.0   Leo Hu   Initial version.
  192.  */
  193. #include "mmi_features.h"       /* for gdi_profile and sub_lcd setting */
  194. #include "PixcomFontengine.h"
  195. #include "pixteldatatypes.h"
  196. #include "globalconstants.h"
  197. #include "EventsGprot.h"
  198. #include "TimerEvents.h"
  199. #include "gui_config.h"
  200. #include "Bootup.h"
  201. #include "FileSystemDef.h"
  202. #include "UCS2prot.h"
  203. #include "gui_data_types.h"
  204. #include "gui.h"
  205. #include "gui_bytestream.h"
  206. #include "wgui_categories_defs.h"
  207. #include "kal_non_specific_general_types.h"
  208. #include "gdi_include.h"        /* graphic lib */
  209. #include "gui_setting.h"
  210. #include "lcd_sw_rnd.h"
  211. #include "wgui_status_icons.h"
  212. #include "DebugInitDef.h"
  213. /* PMT VIKAS START 20051217 */
  214. #if defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__) || defined (__MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__)     /* 072505 Calvin modified */
  215. #include"gd_primitive.h"        /* for gd functions */
  216. #endif 
  217. /* PMT VIKAS END 20051217 */
  218. /* bear - hardware only for LCD interface */
  219. #ifdef MMI_ON_HARDWARE_P
  220. /* lcd driver related */
  221. #include "kal_non_specific_general_types.h"
  222. #include "lcd_sw.h"
  223. #include "lcd_sw_inc.h"
  224. #include "lcd_if.h"
  225. #include "L4Dr.h"
  226. #endif /* MMI_ON_HARDWARE_P */ 
  227. #ifdef __MMI_SCREEN_ROTATE__
  228. #include "ScreenRotationGprot.h"
  229. #endif 
  230. #if defined(__MMI_RESOURCE_ENFB_SUPPORT__)
  231.     #include "ResMemMgrGprot.h"
  232. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  233. /************************************************************************/
  234. /*  Variable                                                            */
  235. /************************************************************************/
  236. /* Device bitmaps used for graphics contexts */
  237. /* Test valuse are used here and there for gui to determine use which LCD context */
  238. bitmap main_LCD_device_bitmap;
  239. bitmap sub_LCD_device_bitmap;
  240. bitmap *current_LCD_device_bitmap = NULL;
  241. bitmap *current_saved_LCD_device_bitmap = NULL;
  242. UI_font_type UI_font;
  243. color UI_current_text_color;
  244. /* Body in PixcomFontEngine - to draw a string */
  245. extern U32 ShowString(S32 x, S32 y, stFontAttribute Font, U8 BackGround, U8 *String, U32 LineHeight);
  246. #ifdef MMI_ON_HARDWARE_P
  247. extern kal_bool custom_cfg_gpio_set_level(kal_uint8 gpio_dev_type, kal_uint8 gpio_dev_level);
  248. #endif 
  249. /* 1: Selects OS timer implementation. Timers are multiplexed by the OS */
  250. /* 0: Selects UI timer implementation. Timers are multiplexed by the UI */
  251. #define  WINGUI_USE_OS_TIMERS       1
  252. #if(!WINGUI_USE_OS_TIMERS)
  253. #define UI_TIMER_RESOLUTION   100
  254. #endif 
  255. /* actual body of these parameter is at gui_wrapper.c */
  256. extern S32 MAIN_LCD_device_width;
  257. extern S32 MAIN_LCD_device_height;
  258. #ifdef __MMI_SUBLCD__
  259. extern S32 SUB_LCD_device_width;
  260. extern S32 SUB_LCD_device_height;
  261. #endif /* __MMI_SUBLCD__ */ 
  262. extern U16 gCurrLangIndex;  /* MTK Leo add 0106 */
  263. extern U16 *MainLCD_ShadowBuf_p;
  264. extern S16 MMI_status_icons_list1[];
  265. extern S16 MMI_status_icons_list2[];
  266. extern S16 MMI_status_icons_list3[];
  267. /* PMT VIKAS START 20050707 */
  268. #ifdef __MMI_UI_DALMATIAN_SOFTKEYS__
  269. extern void (*pixtel_shuffle_draw_background) (void);
  270. #endif 
  271. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  272. extern BOOL line_draw;                  /* 20050412 modified */
  273. extern BOOL inline_bottom_line_draw;    /* 20050412 modified */
  274. #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  275. /* PMT VIKAS END 20050707 */
  276. /************************************************************************/
  277. /* Function Pre-Declare                                               */
  278. /************************************************************************/
  279. void UI_set_sub_LCD_graphics_context(void);
  280. void UI_set_main_LCD_graphics_context(void);
  281. void UI_putpixel(S32 x, S32 y, color c);
  282. void UI_putpixel_alpha(S32 x, S32 y, color c);
  283. void _show_transparent_image(S32 x, S32 y, U8 *image, UI_transparent_color_type t);
  284. void _animated_image_processor(void);
  285. U8 _show_animation_frame(S32 x, S32 y, U8 *image, S16 frame_number);
  286. U8 _show_transparent_animation_frame(S32 x, S32 y, U8 *image, UI_transparent_color_type t, S16 frame_number);
  287. void _show_animated_image(S32 x, S32 y, animated_image *a);
  288. animated_image *_show_animation(S32 x, S32 y, U8 *image);
  289. //animated_image*       _show_transparent_animation(S32 x,S32 y,byte *image,UI_transparent_color_type t);//071205 Calvin removed
  290. //animated_image*       _show_transparent_animation_frames(S32 x,S32 y,byte* image,UI_transparent_color_type t,S16 start_frame,S16 end_frame);//071205 Calvin removed
  291. void _load_animation_frames(U8 *image, animated_image *a);
  292. //void                                  _hide_animated_image(animated_image *a);//071205 Calvin removed
  293. //void                                  _set_hide_animated_image(animated_image *a,void (*f)(S32 x1,S32 y1,S32 x2,S32 y2));//071205 Calvin removed
  294. /************************************************************************/
  295. /* UnChanged Code                                                       */
  296. /************************************************************************/
  297. /* /// Vikram for WBMP */
  298. U8 Display_WBMP(S32 sx, S32 sy, FILE_HANDLE file);
  299. /* End */
  300. /*****************************************************************************
  301.  * FUNCTION
  302.  *  _pfgetc
  303.  * DESCRIPTION
  304.  *  
  305.  * PARAMETERS
  306.  *  file        [IN]        
  307.  * RETURNS
  308.  *  
  309.  *****************************************************************************/
  310. U8 _pfgetc(FILE_HANDLE file)
  311. {
  312.     /*----------------------------------------------------------------*/
  313.     /* Local Variables                                                */
  314.     /*----------------------------------------------------------------*/
  315.     /*----------------------------------------------------------------*/
  316.     /* Code Body                                                      */
  317.     /*----------------------------------------------------------------*/
  318.     return (U8) pfgetc(file);
  319. }
  320. /*****************************************************************************
  321.  * FUNCTION
  322.  *  _pfgetword
  323.  * DESCRIPTION
  324.  *  
  325.  * PARAMETERS
  326.  *  file        [IN]        
  327.  * RETURNS
  328.  *  
  329.  *****************************************************************************/
  330. U16 _pfgetword(FILE_HANDLE file)
  331. {
  332.     /*----------------------------------------------------------------*/
  333.     /* Local Variables                                                */
  334.     /*----------------------------------------------------------------*/
  335.     U16 MSB, LSB;
  336.     /*----------------------------------------------------------------*/
  337.     /* Code Body                                                      */
  338.     /*----------------------------------------------------------------*/
  339.     LSB = _pfgetc(file);
  340.     MSB = _pfgetc(file);
  341.     return ((U16) ((MSB << 8) | LSB));
  342. }
  343. /*****************************************************************************
  344.  * FUNCTION
  345.  *  _pfgetdword
  346.  * DESCRIPTION
  347.  *  
  348.  * PARAMETERS
  349.  *  file        [IN]        
  350.  * RETURNS
  351.  *  
  352.  *****************************************************************************/
  353. U32 _pfgetdword(FILE_HANDLE file)
  354. {
  355.     /*----------------------------------------------------------------*/
  356.     /* Local Variables                                                */
  357.     /*----------------------------------------------------------------*/
  358.     U32 MSB, LSB;
  359.     /*----------------------------------------------------------------*/
  360.     /* Code Body                                                      */
  361.     /*----------------------------------------------------------------*/
  362.     LSB = _pfgetword(file);
  363.     MSB = _pfgetword(file);
  364.     return ((MSB << 16) | LSB);
  365. }
  366. #define _pfseek(file,offset,flags)  pCacheFileSeek(file,offset,flags)
  367. #define _pfread(data,s1,s2,file)                         
  368.       {  S32 l;                                          
  369.          pCacheFileRead(file,s2,&l,data);                
  370.       }
  371. #define _pfsize(file)   GetFSFileSize(file)
  372. #define _pfeof(file) IsEndOfCurrentFile()
  373. /*****************************************************************************
  374.  * FUNCTION
  375.  *  UI_cross_hatch_fill_rectangle
  376.  * DESCRIPTION
  377.  *  
  378.  * PARAMETERS
  379.  *  x1      [IN]        
  380.  *  y1      [IN]        
  381.  *  x2      [IN]        
  382.  *  y2      [IN]        
  383.  *  c       [IN]        
  384.  * RETURNS
  385.  *  void
  386.  *****************************************************************************/
  387. static U32 UI_translate_gui_alpha_to_gdi_alpha(U8 alpha)
  388. {
  389.     /*----------------------------------------------------------------*/
  390.     /* Local Variables                                                */
  391.     /*----------------------------------------------------------------*/
  392.     U32 alpha_value;
  393.     /*----------------------------------------------------------------*/
  394.     /* Code Body                                                      */
  395.     /*----------------------------------------------------------------*/
  396.     alpha_value = (((U32)(alpha)) << 8) / 100;
  397.     if (256 <= alpha_value)
  398.     {
  399.         alpha_value = 255;
  400.     }
  401.     return alpha_value;
  402. }
  403. /*****************************************************************************
  404.  * FUNCTION
  405.  *  UI_cross_hatch_fill_rectangle
  406.  * DESCRIPTION
  407.  *  
  408.  * PARAMETERS
  409.  *  x1      [IN]        
  410.  *  y1      [IN]        
  411.  *  x2      [IN]        
  412.  *  y2      [IN]        
  413.  *  c       [IN]        
  414.  * RETURNS
  415.  *  void
  416.  *****************************************************************************/
  417. void UI_cross_hatch_fill_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  418. {
  419.     /*----------------------------------------------------------------*/
  420.     /* Local Variables                                                */
  421.     /*----------------------------------------------------------------*/
  422.     /*----------------------------------------------------------------*/
  423.     /* Code Body                                                      */
  424.     /*----------------------------------------------------------------*/
  425.     gdi_fill_dot_rect(x1,y1,x2,y2,gdi_act_color_from_rgb(UI_translate_gui_alpha_to_gdi_alpha(c.alpha),c.r,c.g,c.b));
  426. }
  427. /*****************************************************************************
  428.  * FUNCTION
  429.  *  UI_alternate_cross_hatch_fill_rectangle
  430.  * DESCRIPTION
  431.  *  
  432.  * PARAMETERS
  433.  *  x1      [IN]        
  434.  *  y1      [IN]        
  435.  *  x2      [IN]        
  436.  *  y2      [IN]        
  437.  *  c1      [IN]        
  438.  *  c2      [IN]        
  439.  * RETURNS
  440.  *  void
  441.  *****************************************************************************/
  442. void UI_alternate_cross_hatch_fill_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c1, color c2)
  443. {
  444.     /*----------------------------------------------------------------*/
  445.     /* Local Variables                                                */
  446.     /*----------------------------------------------------------------*/
  447.     S32 i, j, k = 0;
  448.     U8 flag = 0;
  449.     /*----------------------------------------------------------------*/
  450.     /* Code Body                                                      */
  451.     /*----------------------------------------------------------------*/
  452.     if (!((x2 - x1 + 1) % 2))
  453.     {
  454.         flag = 1;
  455.     }
  456.     for (j = y1; j <= y2; j++)
  457.     {
  458.         if (flag)
  459.         {
  460.             pixtel_toggle(k);
  461.         }
  462.         for (i = x1; i <= x2; i++)
  463.         {
  464.             if (k)
  465.             {
  466.                 UI_putpixel(i, j, c1);
  467.             }
  468.             else
  469.             {
  470.                 UI_putpixel(i, j, c2);
  471.             }
  472.             pixtel_toggle(k);
  473.         }
  474.     }
  475. }
  476. /*****************************************************************************
  477.  * FUNCTION
  478.  *  UI_hatch_fill_rectangle
  479.  * DESCRIPTION
  480.  *  
  481.  * PARAMETERS
  482.  *  x1      [IN]        
  483.  *  y1      [IN]        
  484.  *  x2      [IN]        
  485.  *  y2      [IN]        
  486.  *  c       [IN]        
  487.  * RETURNS
  488.  *  void
  489.  *****************************************************************************/
  490. void UI_hatch_fill_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  491. {
  492.     /*----------------------------------------------------------------*/
  493.     /* Local Variables                                                */
  494.     /*----------------------------------------------------------------*/
  495.     S32 i, j, k = 1;
  496.     /*----------------------------------------------------------------*/
  497.     /* Code Body                                                      */
  498.     /*----------------------------------------------------------------*/
  499.     for (j = y1; j <= y2; j++)
  500.     {
  501.         if (k)
  502.         {
  503.             for (i = x1; i <= x2; i++)
  504.             {
  505.                 UI_putpixel(i, j, c);
  506.             }
  507.         }
  508.         pixtel_toggle(k);
  509.     }
  510. }
  511. /*****************************************************************************
  512.  * FUNCTION
  513.  *  UI_alternate_hatch_fill_rectangle
  514.  * DESCRIPTION
  515.  *  
  516.  * PARAMETERS
  517.  *  x1      [IN]        
  518.  *  y1      [IN]        
  519.  *  x2      [IN]        
  520.  *  y2      [IN]        
  521.  *  c1      [IN]        
  522.  *  c2      [IN]        
  523.  * RETURNS
  524.  *  void
  525.  *****************************************************************************/
  526. void UI_alternate_hatch_fill_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c1, color c2)
  527. {
  528.     /*----------------------------------------------------------------*/
  529.     /* Local Variables                                                */
  530.     /*----------------------------------------------------------------*/
  531.     S32 i, j, k = 1;
  532.     /*----------------------------------------------------------------*/
  533.     /* Code Body                                                      */
  534.     /*----------------------------------------------------------------*/
  535.     for (j = y1; j <= y2; j++)
  536.     {
  537.         if (k)
  538.         {
  539.             for (i = x1; i <= x2; i++)
  540.             {
  541.                 UI_putpixel(i, j, c1);
  542.             }
  543.         }
  544.         else
  545.         {
  546.             for (i = x1; i <= x2; i++)
  547.             {
  548.                 UI_putpixel(i, j, c2);
  549.             }
  550.         }
  551.         pixtel_toggle(k);
  552.     }
  553. }
  554. /* Line drawing algorithm  */
  555. /* Bresenham line drawing routine   */
  556. /*****************************************************************************
  557.  * FUNCTION
  558.  *  UI_line_sign
  559.  * DESCRIPTION
  560.  *  
  561.  * PARAMETERS
  562.  *  a       [IN]        
  563.  * RETURNS
  564.  *  
  565.  *****************************************************************************/
  566. S32 UI_line_sign(S32 a)
  567. {
  568.     /*----------------------------------------------------------------*/
  569.     /* Local Variables                                                */
  570.     /*----------------------------------------------------------------*/
  571.     /*----------------------------------------------------------------*/
  572.     /* Code Body                                                      */
  573.     /*----------------------------------------------------------------*/
  574.     if (a < 0)
  575.     {
  576.         return (-1);
  577.     }
  578.     else if (a > 0)
  579.     {
  580.         return (1);
  581.     }
  582.     else
  583.     {
  584.         return (0);
  585.     }
  586. }
  587. /*****************************************************************************
  588.  * FUNCTION
  589.  *  UI_line
  590.  * DESCRIPTION
  591.  *  
  592.  * PARAMETERS
  593.  *  x1      [IN]        
  594.  *  y1      [IN]        
  595.  *  x2      [IN]        
  596.  *  y2      [IN]        
  597.  *  c       [IN]        
  598.  * RETURNS
  599.  *  void
  600.  *****************************************************************************/
  601. void UI_line(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  602. {
  603.     /*----------------------------------------------------------------*/
  604.     /* Local Variables                                                */
  605.     /*----------------------------------------------------------------*/
  606.     S32 dx, dy, p, c1, c2, x, y, xinc, yinc, i;
  607.     /*----------------------------------------------------------------*/
  608.     /* Code Body                                                      */
  609.     /*----------------------------------------------------------------*/
  610.     dx = x2 - x1;
  611.     dy = y2 - y1;
  612.     xinc = UI_line_sign(dx);
  613.     yinc = UI_line_sign(dy);
  614.     dx = abs(dx);
  615.     dy = abs(dy);
  616.     x = x1;
  617.     y = y1;
  618.     if (dx >= dy)
  619.     {
  620.         p = (dy << 1) - dx;
  621.         c1 = dy << 1;
  622.         c2 = (dy - dx) << 1;
  623.         for (i = 0; i <= dx; i++)
  624.         {
  625.             gui_putpixel(x, y, c);
  626.             if (p < 0)
  627.             {
  628.                 p += c1;
  629.             }
  630.             else
  631.             {
  632.                 p += c2;
  633.                 y += yinc;
  634.             }
  635.             x += xinc;
  636.         }
  637.     }
  638.     else
  639.     {
  640.         p = (dx << 1) - dy;
  641.         c1 = dx << 1;
  642.         c2 = (dx - dy) << 1;
  643.         for (i = 0; i <= dy; i++)
  644.         {
  645.             gui_putpixel(x, y, c);
  646.             if (p < 0)
  647.             {
  648.                 p += c1;
  649.             }
  650.             else
  651.             {
  652.                 p += c2;
  653.                 x += xinc;
  654.             }
  655.             y += yinc;
  656.         }
  657.     }
  658. }
  659. /*****************************************************************************
  660.  * FUNCTION
  661.  *  UI_wline
  662.  * DESCRIPTION
  663.  *  
  664.  * PARAMETERS
  665.  *  x1      [IN]        
  666.  *  y1      [IN]        
  667.  *  x2      [IN]        
  668.  *  y2      [IN]        
  669.  *  c       [IN]        
  670.  *  w       [IN]        
  671.  * RETURNS
  672.  *  void
  673.  *****************************************************************************/
  674. void UI_wline(S32 x1, S32 y1, S32 x2, S32 y2, color c, S32 w)
  675. {
  676.     /*----------------------------------------------------------------*/
  677.     /* Local Variables                                                */
  678.     /*----------------------------------------------------------------*/
  679.     S32 dx, dy, p, c1, c2, x, y, xinc, yinc, i, j;
  680.     /*----------------------------------------------------------------*/
  681.     /* Code Body                                                      */
  682.     /*----------------------------------------------------------------*/
  683.     dx = x2 - x1;
  684.     dy = y2 - y1;
  685.     xinc = UI_line_sign(dx);
  686.     yinc = UI_line_sign(dy);
  687.     dx = abs(dx);
  688.     dy = abs(dy);
  689.     x = x1;
  690.     y = y1;
  691.     if (dx >= dy)
  692.     {
  693.         p = (dy << 1) - dx;
  694.         c1 = dy << 1;
  695.         c2 = (dy - dx) << 1;
  696.         for (i = 0; i <= dx; i++)
  697.         {
  698.             for (j = (w >> 1); j >= 0; j--)
  699.             {
  700.                 gui_putpixel(x, y - j, c);
  701.                 gui_putpixel(x, y + j, c);
  702.             }
  703.             if (p < 0)
  704.             {
  705.                 p += c1;
  706.             }
  707.             else
  708.             {
  709.                 p += c2;
  710.                 y += yinc;
  711.             }
  712.             x += xinc;
  713.         }
  714.     }
  715.     else
  716.     {
  717.         p = (dx << 1) - dy;
  718.         c1 = dx << 1;
  719.         c2 = (dx - dy) << 1;
  720.         for (i = 0; i <= dy; i++)
  721.         {
  722.             for (j = (w >> 1); j >= 0; j--)
  723.             {
  724.                 gui_putpixel(x + j, y, c);
  725.                 gui_putpixel(x - j, y, c);
  726.             }
  727.             if (p < 0)
  728.             {
  729.                 p += c1;
  730.             }
  731.             else
  732.             {
  733.                 p += c2;
  734.                 x += xinc;
  735.             }
  736.             y += yinc;
  737.         }
  738.     }
  739. }
  740. /* Available only for Main LCD   */
  741. /*****************************************************************************
  742.  * FUNCTION
  743.  *  UI_smooth_pixel
  744.  * DESCRIPTION
  745.  *  
  746.  * PARAMETERS
  747.  *  x       [IN]        
  748.  *  y       [IN]        
  749.  *  c       [IN]        
  750.  * RETURNS
  751.  *  void
  752.  *****************************************************************************/
  753. void UI_smooth_pixel(S32 x, S32 y, color c)
  754. {
  755.     /*----------------------------------------------------------------*/
  756.     /* Local Variables                                                */
  757.     /*----------------------------------------------------------------*/
  758.     color ca = c;
  759.     color cb = c;
  760.     color cc = c;
  761.     /*----------------------------------------------------------------*/
  762.     /* Code Body                                                      */
  763.     /*----------------------------------------------------------------*/
  764.     ca.alpha = 100;
  765.     cb.alpha = 40;
  766.     cc.alpha = 20;
  767.     UI_putpixel(x, y, ca);
  768.     UI_putpixel(x - 1, y, cb);
  769.     UI_putpixel(x + 1, y, cb);
  770.     UI_putpixel(x, y - 1, cb);
  771.     UI_putpixel(x, y + 1, cb);
  772.     UI_putpixel(x - 1, y - 1, cc);
  773.     UI_putpixel(x - 1, y + 1, cc);
  774.     UI_putpixel(x + 1, y - 1, cc);
  775.     UI_putpixel(x + 1, y + 1, cc);
  776. }
  777. /* Available only for Main LCD   */
  778. /*****************************************************************************
  779.  * FUNCTION
  780.  *  UI_smooth_wline
  781.  * DESCRIPTION
  782.  *  
  783.  * PARAMETERS
  784.  *  x1      [IN]        
  785.  *  y1      [IN]        
  786.  *  x2      [IN]        
  787.  *  y2      [IN]        
  788.  *  c       [IN]        
  789.  *  w       [IN]        
  790.  * RETURNS
  791.  *  void
  792.  *****************************************************************************/
  793. void UI_smooth_wline(S32 x1, S32 y1, S32 x2, S32 y2, color c, S32 w)
  794. {
  795.     /*----------------------------------------------------------------*/
  796.     /* Local Variables                                                */
  797.     /*----------------------------------------------------------------*/
  798.     S32 dx, dy, p, c1, c2, x, y, xinc, yinc, i, j;
  799.     /*----------------------------------------------------------------*/
  800.     /* Code Body                                                      */
  801.     /*----------------------------------------------------------------*/
  802.     dx = x2 - x1;
  803.     dy = y2 - y1;
  804.     xinc = UI_line_sign(dx);
  805.     yinc = UI_line_sign(dy);
  806.     dx = abs(dx);
  807.     dy = abs(dy);
  808.     x = x1;
  809.     y = y1;
  810.     if (dx >= dy)
  811.     {
  812.         p = (dy << 1) - dx;
  813.         c1 = dy << 1;
  814.         c2 = (dy - dx) << 1;
  815.         for (i = 0; i <= dx; i++)
  816.         {
  817.             for (j = (w >> 1); j > 0; j--)
  818.             {
  819.                 UI_smooth_pixel(x, y - j, c);
  820.                 UI_smooth_pixel(x, y + j, c);
  821.             }
  822.             UI_smooth_pixel(x, y, c);
  823.             if (p < 0)
  824.             {
  825.                 p += c1;
  826.             }
  827.             else
  828.             {
  829.                 p += c2;
  830.                 y += yinc;
  831.             }
  832.             x += xinc;
  833.         }
  834.     }
  835.     else
  836.     {
  837.         p = (dx << 1) - dy;
  838.         c1 = dx << 1;
  839.         c2 = (dx - dy) << 1;
  840.         for (i = 0; i <= dy; i++)
  841.         {
  842.             for (j = (w >> 1); j > 0; j--)
  843.             {
  844.                 UI_smooth_pixel(x + j, y, c);
  845.                 UI_smooth_pixel(x - j, y, c);
  846.             }
  847.             UI_smooth_pixel(x, y, c);
  848.             if (p < 0)
  849.             {
  850.                 p += c1;
  851.             }
  852.             else
  853.             {
  854.                 p += c2;
  855.                 x += xinc;
  856.             }
  857.             y += yinc;
  858.         }
  859.     }
  860. }
  861. /* Wu antialiased line drawing algorithm  */
  862. /* Uses fixed point math               */
  863. #define _ALINE_SWAP(a,b)      
  864.       {  S32 temp=a;          
  865.          a=b;                 
  866.          b=temp;              
  867.       }
  868. /*****************************************************************************
  869.  * FUNCTION
  870.  *  UI_antialiased_line
  871.  * DESCRIPTION
  872.  *  
  873.  * PARAMETERS
  874.  *  x1      [IN]        
  875.  *  y1      [IN]        
  876.  *  x2      [IN]        
  877.  *  y2      [IN]        
  878.  *  c       [IN]        
  879.  * RETURNS
  880.  *  void
  881.  *****************************************************************************/
  882. void UI_antialiased_line(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  883. {
  884.     /*----------------------------------------------------------------*/
  885.     /* Local Variables                                                */
  886.     /*----------------------------------------------------------------*/
  887.     S32 x, y, x_inc, y_inc, dx, dy, px, py;
  888.     /*----------------------------------------------------------------*/
  889.     /* Code Body                                                      */
  890.     /*----------------------------------------------------------------*/
  891.     dx = x2 - x1;
  892.     dy = y2 - y1;
  893.     /* PMT HIMANSHU START 20050625 */
  894. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  895.     if (dx == 0 && dy == 0)
  896.     {
  897.         return;
  898.     }
  899. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  900.     /* PMT HIMANSHU END */
  901.     if (abs(dx) > abs(dy))
  902.     {
  903.         if (dx < 0)
  904.         {
  905.             dx = -dx;
  906.             dy = -dy;
  907.             _ALINE_SWAP(x1, x2);
  908.             _ALINE_SWAP(y1, y2);
  909.         }
  910.         x = x1 << 16;
  911.         y = y1 << 16;
  912.         x_inc = 1 << 16;
  913.         y_inc = (dy * 65536) / dx;
  914.         while (1)
  915.         {
  916.             px = x >> 16;
  917.             py = y >> 16;
  918.             if (px >= x2)
  919.             {
  920.                 break;
  921.             }
  922.         #ifndef __MMI_ALPHA_LAYER_SUPPORT__//070306 Alpha layer
  923.             c.alpha = (U8) ((~y >> 8) & 0xff);
  924.         #endif
  925.             UI_putpixel_alpha(px, py, c);
  926.         #ifndef __MMI_ALPHA_LAYER_SUPPORT__//070306 Alpha layer
  927.             c.alpha = ((U8) (y >> 8) & 0xff);
  928.         #endif
  929.             UI_putpixel_alpha(px, py + 1, c);
  930.             x += x_inc;
  931.             y += y_inc;
  932.         }
  933.     }
  934.     else
  935.     {
  936.         if (dy < 0)
  937.         {
  938.             dx = -dx;
  939.             dy = -dy;
  940.             _ALINE_SWAP(x1, x2);
  941.             _ALINE_SWAP(y1, y2);
  942.         }
  943.         x = x1 << 16;
  944.         y = y1 << 16;
  945.         x_inc = (dx * 65536) / dy;
  946.         y_inc = 1 << 16;
  947.         while (1)
  948.         {
  949.             px = x >> 16;
  950.             py = y >> 16;
  951.             if (py >= y2)
  952.             {
  953.                 break;
  954.             }
  955.         #ifndef __MMI_ALPHA_LAYER_SUPPORT__//070306 Alpha layer
  956.             c.alpha = (U8) ((~x >> 8) & 0xff);
  957.         #endif
  958.             UI_putpixel_alpha(px, py, c);
  959.         #ifndef __MMI_ALPHA_LAYER_SUPPORT__//070306 Alpha layer
  960.             c.alpha = (U8) ((x >> 8) & 0xff);
  961.         #endif
  962.             UI_putpixel_alpha(px + 1, py, c);
  963.             x += x_inc;
  964.             y += y_inc;
  965.         }
  966.     }
  967. }
  968. /* Horizontal line drawing routine  */
  969. /*****************************************************************************
  970.  * FUNCTION
  971.  *  flat_triangle_horizontal_line
  972.  * DESCRIPTION
  973.  *  
  974.  * PARAMETERS
  975.  *  x1      [IN]        
  976.  *  x2      [IN]        
  977.  *  y       [IN]        
  978.  *  c       [IN]        
  979.  * RETURNS
  980.  *  void
  981.  *****************************************************************************/
  982. void flat_triangle_horizontal_line(S32 x1, S32 x2, S32 y, color c)
  983. {
  984.     /*----------------------------------------------------------------*/
  985.     /* Local Variables                                                */
  986.     /*----------------------------------------------------------------*/
  987.     S32 x;
  988.     /*----------------------------------------------------------------*/
  989.     /* Code Body                                                      */
  990.     /*----------------------------------------------------------------*/
  991.     if (x2 < x1)
  992.     {
  993.         _ALINE_SWAP(x1, x2);
  994.     }
  995.     for (x = x1 + 1; x <= x2; x++)
  996.     {
  997.         gui_putpixel(x, y, c);
  998.     }
  999. }
  1000. /* Flat polygon (triangle) fill routine   */
  1001. /*****************************************************************************
  1002.  * FUNCTION
  1003.  *  flat_triangle_fill
  1004.  * DESCRIPTION
  1005.  *  
  1006.  * PARAMETERS
  1007.  *  vertices        [?]         
  1008.  *  c               [IN]        
  1009.  * RETURNS
  1010.  *  void
  1011.  *****************************************************************************/
  1012. void flat_triangle_fill(polygon_vertex vertices[], color c)
  1013. {
  1014.     /*----------------------------------------------------------------*/
  1015.     /* Local Variables                                                */
  1016.     /*----------------------------------------------------------------*/
  1017.     S32 tx, ty;
  1018.     S32 bx, by;
  1019.     S32 mx, my;
  1020.     S32 y;
  1021.     float m1, m2;
  1022.     float x1, x2;
  1023.     color color_value = c;
  1024.     /*----------------------------------------------------------------*/
  1025.     /* Code Body                                                      */
  1026.     /*----------------------------------------------------------------*/
  1027.     if (vertices[0].y < vertices[1].y)
  1028.     {
  1029.         tx = vertices[0].x;
  1030.         ty = vertices[0].y;
  1031.         bx = vertices[1].x;
  1032.         by = vertices[1].y;
  1033.     }
  1034.     else
  1035.     {
  1036.         tx = vertices[1].x;
  1037.         ty = vertices[1].y;
  1038.         bx = vertices[0].x;
  1039.         by = vertices[0].y;
  1040.     }
  1041.     if (vertices[2].y < ty)
  1042.     {
  1043.         mx = tx;
  1044.         my = ty;
  1045.         tx = vertices[2].x;
  1046.         ty = vertices[2].y;
  1047.     }
  1048.     else if (vertices[2].y > by)
  1049.     {
  1050.         mx = bx;
  1051.         my = by;
  1052.         bx = vertices[2].x;
  1053.         by = vertices[2].y;
  1054.     }
  1055.     else
  1056.     {
  1057.         mx = vertices[2].x;
  1058.         my = vertices[2].y;
  1059.     }
  1060.     m1 = ((float)(mx - tx)) / ((float)(my - ty));
  1061.     m2 = ((float)(bx - tx)) / ((float)(by - ty));
  1062.     x1 = (float)tx;
  1063.     x2 = (float)tx;
  1064.     if (mx < bx)
  1065.     {
  1066.         for (y = ty; y < my; y++)
  1067.         {
  1068.             flat_triangle_horizontal_line((S32) x1, (S32) x2, y, color_value);
  1069.             x1 = (float)x1 + (float)m1;
  1070.             x2 = (float)x2 + (float)m2;
  1071.         }
  1072.         x1 = (float)mx;
  1073.         m1 = ((float)(bx - mx)) / ((float)(by - my));
  1074.         for (y = my; y < by; y++)
  1075.         {
  1076.             flat_triangle_horizontal_line((S32) x1, (S32) x2, y, color_value);
  1077.             x1 = (float)x1 + (float)m1;
  1078.             x2 = (float)x2 + (float)m2;
  1079.         }
  1080.     }
  1081.     else
  1082.     {
  1083.         for (y = ty; y < my; y++)
  1084.         {
  1085.             flat_triangle_horizontal_line((S32) x2, (S32) x1, y, color_value);
  1086.             x1 = (float)x1 + (float)m1;
  1087.             x2 = (float)x2 + (float)m2;
  1088.         }
  1089.         x1 = (float)mx;
  1090.         m1 = ((float)(bx - mx)) / ((float)(by - my));
  1091.         for (y = my; y < by; y++)
  1092.         {
  1093.             flat_triangle_horizontal_line((S32) x2, (S32) x1, y, color_value);
  1094.             x1 = (float)x1 + (float)m1;
  1095.             x2 = (float)x2 + (float)m2;
  1096.         }
  1097.     }
  1098. }
  1099. /*****************************************************************************
  1100.  * FUNCTION
  1101.  *  polygon_draw
  1102.  * DESCRIPTION
  1103.  *  
  1104.  * PARAMETERS
  1105.  *  vertices        [?]         
  1106.  *  n_vertices      [IN]        
  1107.  *  c               [IN]        
  1108.  * RETURNS
  1109.  *  void
  1110.  *****************************************************************************/
  1111. void polygon_draw(polygon_vertex vertices[], S32 n_vertices, color c)
  1112. {
  1113.     /*----------------------------------------------------------------*/
  1114.     /* Local Variables                                                */
  1115.     /*----------------------------------------------------------------*/
  1116.     S32 i;
  1117.     /*----------------------------------------------------------------*/
  1118.     /* Code Body                                                      */
  1119.     /*----------------------------------------------------------------*/
  1120.     if (n_vertices < 3)
  1121.     {
  1122.         return;
  1123.     }
  1124.     for (i = 0; i < (n_vertices - 1); i++)
  1125.     {
  1126.         UI_antialiased_line(vertices[i].x, vertices[i].y, vertices[i + 1].x, vertices[i + 1].y, c);
  1127.     }
  1128.     UI_antialiased_line(vertices[i].x, vertices[i].y, vertices[0].x, vertices[0].y, c);
  1129. }
  1130. /* MTK Elvis */
  1131. #define ARROW_HEIGHT 10 /* 8 */
  1132. #define ARROW_WIDTH     5       /* 6//4 */
  1133. /*****************************************************************************
  1134.  * FUNCTION
  1135.  *  draw_arrow
  1136.  * DESCRIPTION
  1137.  *  
  1138.  * PARAMETERS
  1139.  *  x               [IN]        
  1140.  *  y               [IN]        
  1141.  *  arrow_type      [IN]        
  1142.  *  c               [IN]        
  1143.  * RETURNS
  1144.  *  void
  1145.  *****************************************************************************/
  1146. void draw_arrow(S32 x, S32 y, U8 arrow_type, color c)
  1147. {
  1148.     /*----------------------------------------------------------------*/
  1149.     /* Local Variables                                                */
  1150.     /*----------------------------------------------------------------*/
  1151.     polygon_vertex v[3];
  1152.     /*----------------------------------------------------------------*/
  1153.     /* Code Body                                                      */
  1154.     /*----------------------------------------------------------------*/
  1155.     switch (arrow_type)
  1156.     {
  1157.         case 0: /* Left */
  1158.             v[0].x = x + 0;
  1159.             v[0].y = y + (ARROW_HEIGHT >> 1);
  1160.             v[1].x = x + ARROW_WIDTH;
  1161.             v[1].y = y + 0;
  1162.             v[2].x = x + ARROW_WIDTH;
  1163.             v[2].y = y + ARROW_HEIGHT;
  1164.             flat_triangle_fill(v, c);
  1165.             break;
  1166.         case 1: /* Right */
  1167.             v[0].x = x + ARROW_WIDTH;
  1168.             v[0].y = y + (ARROW_HEIGHT >> 1);
  1169.             v[1].x = x + 0;
  1170.             v[1].y = y + 0;
  1171.             v[2].x = x + 0;
  1172.             v[2].y = y + ARROW_HEIGHT;
  1173.             flat_triangle_fill(v, c);
  1174.             break;
  1175.         case 2: /* Up */
  1176.             v[0].x = x + (ARROW_WIDTH >> 1);
  1177.             v[0].y = y + 0;
  1178.             v[1].x = x;
  1179.             v[1].y = y + ARROW_HEIGHT;
  1180.             v[2].x = x + ARROW_WIDTH;
  1181.             v[2].y = y + ARROW_HEIGHT;
  1182.             flat_triangle_fill(v, c);
  1183.             break;
  1184.         case 3: /* Down */
  1185.             v[0].x = x + (ARROW_WIDTH >> 1);
  1186.             v[0].y = y + ARROW_HEIGHT;
  1187.             v[1].x = x + 0;
  1188.             v[1].y = y + 0;
  1189.             v[2].x = x + ARROW_WIDTH;
  1190.             v[2].y = y + 0;
  1191.             flat_triangle_fill(v, c);
  1192.             break;
  1193.     }
  1194. }
  1195. /*****************************************************************************
  1196.  * FUNCTION
  1197.  *  draw_resizeable_arrow
  1198.  * DESCRIPTION
  1199.  *  
  1200.  * PARAMETERS
  1201.  *  x               [IN]        
  1202.  *  y               [IN]        
  1203.  *  arrow_type      [IN]        
  1204.  *  c               [IN]        
  1205.  *  width           [IN]        
  1206.  *  height          [IN]        
  1207.  * RETURNS
  1208.  *  void
  1209.  *****************************************************************************/
  1210. void draw_resizeable_arrow(S32 x, S32 y, U8 arrow_type, color c, S32 width, S32 height)
  1211. {
  1212.     /*----------------------------------------------------------------*/
  1213.     /* Local Variables                                                */
  1214.     /*----------------------------------------------------------------*/
  1215.     polygon_vertex v[3];
  1216.     /*----------------------------------------------------------------*/
  1217.     /* Code Body                                                      */
  1218.     /*----------------------------------------------------------------*/
  1219.     switch (arrow_type)
  1220.     {
  1221.         case 0: /* Left */
  1222.             v[0].x = x + 0;
  1223.             v[0].y = y + (height >> 1);
  1224.             v[1].x = x + width;
  1225.             v[1].y = y + 0;
  1226.             v[2].x = x + width;
  1227.             v[2].y = y + height;
  1228.             flat_triangle_fill(v, c);
  1229.             break;
  1230.         case 1: /* Right */
  1231.             v[0].x = x + width;
  1232.             v[0].y = y + (height >> 1);
  1233.             v[1].x = x + 0;
  1234.             v[1].y = y + 0;
  1235.             v[2].x = x + 0;
  1236.             v[2].y = y + height;
  1237.             flat_triangle_fill(v, c);
  1238.             break;
  1239.         case 2: /* Up */
  1240.             v[0].x = x + (width >> 1);
  1241.             v[0].y = y + 0;
  1242.             v[1].x = x;
  1243.             v[1].y = y + height;
  1244.             v[2].x = x + width;
  1245.             v[2].y = y + height;
  1246.             flat_triangle_fill(v, c);
  1247.             break;
  1248.         case 3: /* Down */
  1249.             v[0].x = x + (width >> 1);
  1250.             v[0].y = y + height;
  1251.             v[1].x = x + 0;
  1252.             v[1].y = y + 0;
  1253.             v[2].x = x + width;
  1254.             v[2].y = y + 0;
  1255.             flat_triangle_fill(v, c);
  1256.             break;
  1257.     }
  1258. }
  1259. /* MTK end */
  1260. /************************************************************************/
  1261. /* UnUsed Code - designed change, these might be removed in the future  */
  1262. /************************************************************************/
  1263. #define TEST_SUB_LCD_GRAPHICS_CONTEXT(gc) (((gc)==&sub_LCD_device_bitmap)?(1):(0))
  1264. #define TEST_MAIN_LCD_GRAPHICS_CONTEXT(gc)   (((gc)==&main_LCD_device_bitmap)?(1):(0))
  1265. #define SWITCH_GRAPHICS_CONTEXT(gc, flag)                                              
  1266.       {  flag=0;                                                                       
  1267.          if(current_LCD_device_bitmap!=gc)                                             
  1268.          {  flag=1;                                                                    
  1269.             current_saved_LCD_device_bitmap=current_LCD_device_bitmap;                 
  1270.             if(gc==&sub_LCD_device_bitmap) UI_set_sub_LCD_graphics_context();          
  1271.             else UI_set_main_LCD_graphics_context();                                   
  1272.          }                                                                             
  1273.       }
  1274. #define  RESTORE_GRAPHICS_CONTEXT(flag)                                                
  1275.       {  if(flag)                                                                      
  1276.          {  if(current_saved_LCD_device_bitmap==&sub_LCD_device_bitmap)                
  1277.                UI_set_sub_LCD_graphics_context();                                      
  1278.             else                                                                       
  1279.                UI_set_main_LCD_graphics_context();                                     
  1280.          }                                                                             
  1281.       }
  1282. #define GET_GRAPHICS_CONTEXT(gc) (gc)=(bitmap*)(current_LCD_device_bitmap);
  1283. /************************************************************************/
  1284. /* Usable Code                                                         */
  1285. /************************************************************************/
  1286. void (*_ui_text_putpixel) (S32 x, S32 y, color c);
  1287. void (*_ui_text_putpixel_unconditional) (S32 x, S32 y, color c);
  1288. /* This functions is extern by pixcomFontEngine.c */
  1289. /* It set the actual draw color before calling ShowChar() */
  1290. /*****************************************************************************
  1291.  * FUNCTION
  1292.  *  UI_set_current_text_color
  1293.  * DESCRIPTION
  1294.  *  
  1295.  * PARAMETERS
  1296.  *  c       [IN]        
  1297.  * RETURNS
  1298.  *  void
  1299.  *****************************************************************************/
  1300. void UI_set_current_text_color(color c)
  1301. {
  1302.     /*----------------------------------------------------------------*/
  1303.     /* Local Variables                                                */
  1304.     /*----------------------------------------------------------------*/
  1305.     /*----------------------------------------------------------------*/
  1306.     /* Code Body                                                      */
  1307.     /*----------------------------------------------------------------*/
  1308.     UI_current_text_color = c;
  1309. }
  1310. /************************************************************************/
  1311. /* Primitive Drawing                                                    */
  1312. /************************************************************************/
  1313. /* Pixtel's Draw Primitive Function */
  1314. /*****************************************************************************
  1315.  * FUNCTION
  1316.  *  UI_putpixel
  1317.  * DESCRIPTION
  1318.  *  
  1319.  * PARAMETERS
  1320.  *  x       [IN]        
  1321.  *  y       [IN]        
  1322.  *  c       [IN]        
  1323.  * RETURNS
  1324.  *  void
  1325.  *****************************************************************************/
  1326. void UI_putpixel(S32 x, S32 y, color c)
  1327. {
  1328.     /*----------------------------------------------------------------*/
  1329.     /* Local Variables                                                */
  1330.     /*----------------------------------------------------------------*/
  1331.     /*----------------------------------------------------------------*/
  1332.     /* Code Body                                                      */
  1333.     /*----------------------------------------------------------------*/
  1334.     gdi_draw_point(x, y, gdi_act_color_from_rgb(UI_translate_gui_alpha_to_gdi_alpha(c.alpha), c.r, c.g, c.b));
  1335. }
  1336. /*****************************************************************************
  1337.  * FUNCTION
  1338.  *  UI_putpixel_alpha
  1339.  * DESCRIPTION
  1340.  *  
  1341.  * PARAMETERS
  1342.  *  x       [IN]        
  1343.  *  y       [IN]        
  1344.  *  c       [IN]        
  1345.  * RETURNS
  1346.  *  void
  1347.  *****************************************************************************/
  1348. void UI_putpixel_alpha(S32 x, S32 y, color c)
  1349. {
  1350.     /*----------------------------------------------------------------*/
  1351.     /* Local Variables                                                */
  1352.     /*----------------------------------------------------------------*/
  1353.     /*----------------------------------------------------------------*/
  1354.     /* Code Body                                                      */
  1355.     /*----------------------------------------------------------------*/
  1356.     gdi_draw_point(x, y, gdi_act_color_from_rgb(UI_translate_gui_alpha_to_gdi_alpha(c.alpha), c.r, c.g, c.b));
  1357. }
  1358. /*****************************************************************************
  1359.  * FUNCTION
  1360.  *  UI_draw_vertical_line
  1361.  * DESCRIPTION
  1362.  *  
  1363.  * PARAMETERS
  1364.  *  y1      [IN]        
  1365.  *  y2      [IN]        
  1366.  *  x       [IN]        
  1367.  *  c       [IN]        
  1368.  * RETURNS
  1369.  *  void
  1370.  *****************************************************************************/
  1371. void UI_draw_vertical_line(S32 y1, S32 y2, S32 x, color c)
  1372. {
  1373.     /*----------------------------------------------------------------*/
  1374.     /* Local Variables                                                */
  1375.     /*----------------------------------------------------------------*/
  1376.     /*----------------------------------------------------------------*/
  1377.     /* Code Body                                                      */
  1378.     /*----------------------------------------------------------------*/
  1379.     gdi_draw_line(x, y1, x, y2, gdi_act_color_from_rgb(UI_translate_gui_alpha_to_gdi_alpha(c.alpha), c.r, c.g, c.b));
  1380. }
  1381. /*****************************************************************************
  1382.  * FUNCTION
  1383.  *  UI_draw_horizontal_line
  1384.  * DESCRIPTION
  1385.  *  
  1386.  * PARAMETERS
  1387.  *  x1      [IN]        
  1388.  *  x2      [IN]        
  1389.  *  y       [IN]        
  1390.  *  c       [IN]        
  1391.  * RETURNS
  1392.  *  void
  1393.  *****************************************************************************/
  1394. void UI_draw_horizontal_line(S32 x1, S32 x2, S32 y, color c)
  1395. {
  1396.     /*----------------------------------------------------------------*/
  1397.     /* Local Variables                                                */
  1398.     /*----------------------------------------------------------------*/
  1399.     /*----------------------------------------------------------------*/
  1400.     /* Code Body                                                      */
  1401.     /*----------------------------------------------------------------*/
  1402.     gdi_draw_line(x1, y, x2, y, gdi_act_color_from_rgb(UI_translate_gui_alpha_to_gdi_alpha(c.alpha), c.r, c.g, c.b));
  1403. }
  1404. /* MTK ISSUE 30 */
  1405. /*****************************************************************************
  1406.  * FUNCTION
  1407.  *  UI_draw_dotted_horizontal_line
  1408.  * DESCRIPTION
  1409.  *  
  1410.  * PARAMETERS
  1411.  *  x1      [IN]        
  1412.  *  x2      [IN]        
  1413.  *  y       [IN]        
  1414.  *  c       [IN]        
  1415.  * RETURNS
  1416.  *  void
  1417.  *****************************************************************************/
  1418. void UI_draw_dotted_horizontal_line(S32 x1, S32 x2, S32 y, color c)
  1419. {
  1420.     /*----------------------------------------------------------------*/
  1421.     /* Local Variables                                                */
  1422.     /*----------------------------------------------------------------*/
  1423.     S32 i;
  1424.     /*----------------------------------------------------------------*/
  1425.     /* Code Body                                                      */
  1426.     /*----------------------------------------------------------------*/
  1427.     for (i = x1; i <= x2; i = i + 3)
  1428.     {
  1429.         UI_putpixel(i, y, c);
  1430.     }
  1431. }
  1432. /*****************************************************************************
  1433.  * FUNCTION
  1434.  *  UI_draw_dotted_vertical_line
  1435.  * DESCRIPTION
  1436.  *  
  1437.  * PARAMETERS
  1438.  *  y1      [IN]        
  1439.  *  y2      [IN]        
  1440.  *  x       [IN]        
  1441.  *  c       [IN]        
  1442.  * RETURNS
  1443.  *  void
  1444.  *****************************************************************************/
  1445. void UI_draw_dotted_vertical_line(S32 y1, S32 y2, S32 x, color c)
  1446. {
  1447.     /*----------------------------------------------------------------*/
  1448.     /* Local Variables                                                */
  1449.     /*----------------------------------------------------------------*/
  1450.     S32 i;
  1451.     /*----------------------------------------------------------------*/
  1452.     /* Code Body                                                      */
  1453.     /*----------------------------------------------------------------*/
  1454.     /* if (y1>y2) */
  1455.     for (i = y1; i <= y2; i = i + 3)
  1456.     {
  1457.         UI_putpixel(x, i, c);
  1458.     }
  1459. }
  1460. /*****************************************************************************
  1461.  * FUNCTION
  1462.  *  UI_draw_dashed_horizontal_line
  1463.  * DESCRIPTION
  1464.  *  
  1465.  * PARAMETERS
  1466.  *  x1      [IN]        
  1467.  *  x2      [IN]        
  1468.  *  y       [IN]        
  1469.  *  c       [IN]        
  1470.  * RETURNS
  1471.  *  void
  1472.  *****************************************************************************/
  1473. void UI_draw_dashed_horizontal_line(S32 x1, S32 x2, S32 y, color c)
  1474. {
  1475.     /*----------------------------------------------------------------*/
  1476.     /* Local Variables                                                */
  1477.     /*----------------------------------------------------------------*/
  1478.     S32 i;
  1479.     /*----------------------------------------------------------------*/
  1480.     /* Code Body                                                      */
  1481.     /*----------------------------------------------------------------*/
  1482.     for (i = x1; i <= x2; i = i + 6)
  1483.     {
  1484.         UI_putpixel(i, y, c);
  1485.         if ((i + 1) > x2)
  1486.         {
  1487.             return;
  1488.         }
  1489.         UI_putpixel(i + 1, y, c);
  1490.         if ((i + 2) > x2)
  1491.         {
  1492.             return;
  1493.         }
  1494.         UI_putpixel(i + 2, y, c);
  1495.     }
  1496. }
  1497. /*****************************************************************************
  1498.  * FUNCTION
  1499.  *  UI_draw_dashed_vertical_line
  1500.  * DESCRIPTION
  1501.  *  
  1502.  * PARAMETERS
  1503.  *  y1      [IN]        
  1504.  *  y2      [IN]        
  1505.  *  x       [IN]        
  1506.  *  c       [IN]        
  1507.  * RETURNS
  1508.  *  void
  1509.  *****************************************************************************/
  1510. void UI_draw_dashed_vertical_line(S32 y1, S32 y2, S32 x, color c)
  1511. {
  1512.     /*----------------------------------------------------------------*/
  1513.     /* Local Variables                                                */
  1514.     /*----------------------------------------------------------------*/
  1515.     S32 i;
  1516.     /*----------------------------------------------------------------*/
  1517.     /* Code Body                                                      */
  1518.     /*----------------------------------------------------------------*/
  1519.     for (i = y1; i <= y2; i = i + 6)
  1520.     {
  1521.         UI_putpixel(x, i, c);
  1522.         if ((i + 1) > y2)
  1523.         {
  1524.             return;
  1525.         }
  1526.         UI_putpixel(x, i + 1, c);
  1527.         if ((i + 2) > y2)
  1528.         {
  1529.             return;
  1530.         }
  1531.         UI_putpixel(x, i + 2, c);
  1532.     }
  1533. }
  1534. //MTK ISSUE 30 END
  1535. //MTK ISSUE 30 
  1536. /*****************************************************************************
  1537.  * FUNCTION
  1538.  *  UI_draw_dotted_rectangle
  1539.  * DESCRIPTION
  1540.  *  
  1541.  * PARAMETERS
  1542.  *  x1      [IN]        
  1543.  *  y1      [IN]        
  1544.  *  x2      [IN]        
  1545.  *  y2      [IN]        
  1546.  *  c       [IN]        
  1547.  * RETURNS
  1548.  *  void
  1549.  *****************************************************************************/
  1550. void UI_draw_dotted_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  1551. {
  1552.     /*----------------------------------------------------------------*/
  1553.     /* Local Variables                                                */
  1554.     /*----------------------------------------------------------------*/
  1555.     /*----------------------------------------------------------------*/
  1556.     /* Code Body                                                      */
  1557.     /*----------------------------------------------------------------*/
  1558.     UI_draw_dotted_horizontal_line(x1, x2, y1, c);
  1559.     UI_draw_dotted_horizontal_line(x1, x2, y2, c);
  1560.     UI_draw_dotted_vertical_line(y1, y2, x1, c);
  1561.     UI_draw_dotted_vertical_line(y1, y2, x2, c);
  1562.     UI_putpixel(x2, y2, c);
  1563. }
  1564. /*****************************************************************************
  1565.  * FUNCTION
  1566.  *  UI_draw_dashed_rectangle
  1567.  * DESCRIPTION
  1568.  *  
  1569.  * PARAMETERS
  1570.  *  x1      [IN]        
  1571.  *  y1      [IN]        
  1572.  *  x2      [IN]        
  1573.  *  y2      [IN]        
  1574.  *  c       [IN]        
  1575.  * RETURNS
  1576.  *  void
  1577.  *****************************************************************************/
  1578. void UI_draw_dashed_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  1579. {
  1580.     /*----------------------------------------------------------------*/
  1581.     /* Local Variables                                                */
  1582.     /*----------------------------------------------------------------*/
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Code Body                                                      */
  1585.     /*----------------------------------------------------------------*/
  1586.     UI_draw_dashed_horizontal_line(x1, x2, y1, c);
  1587.     UI_draw_dashed_horizontal_line(x1, x2, y2, c);
  1588.     UI_draw_dashed_vertical_line(y1, y2, x1, c);
  1589.     UI_draw_dashed_vertical_line(y1, y2, x2, c);
  1590.     UI_putpixel(x2, y2, c);
  1591. }
  1592. /*****************************************************************************
  1593.  * FUNCTION
  1594.  *  UI_draw_horizontal_line_type
  1595.  * DESCRIPTION
  1596.  *  
  1597.  * PARAMETERS
  1598.  *  y1              [IN]        
  1599.  *  y2              [IN]        
  1600.  *  x               [IN]        
  1601.  *  c               [IN]        
  1602.  *  type_line       [IN]        
  1603.  * RETURNS
  1604.  *  void
  1605.  *****************************************************************************/
  1606. void UI_draw_horizontal_line_type(S32 y1, S32 y2, S32 x, color c, S32 type_line)
  1607. {
  1608.     /*----------------------------------------------------------------*/
  1609.     /* Local Variables                                                */
  1610.     /*----------------------------------------------------------------*/
  1611.     /*----------------------------------------------------------------*/
  1612.     /* Code Body                                                      */
  1613.     /*----------------------------------------------------------------*/
  1614.     switch (type_line)
  1615.     {
  1616.         case 0: /* NORMAL */
  1617.             UI_draw_horizontal_line(y1, y2, x, c);
  1618.             break;
  1619.         case 1: /* DOTTED */
  1620.             UI_draw_dotted_horizontal_line(y1, y2, x, c);
  1621.             break;
  1622.         case 2: /* DASHED */
  1623.             UI_draw_dashed_horizontal_line(y1, y2, x, c);
  1624.             break;
  1625.     }
  1626. }
  1627. /*****************************************************************************
  1628.  * FUNCTION
  1629.  *  UI_draw_vertical_line_type
  1630.  * DESCRIPTION
  1631.  *  
  1632.  * PARAMETERS
  1633.  *  y1              [IN]        
  1634.  *  y2              [IN]        
  1635.  *  x               [IN]        
  1636.  *  c               [IN]        
  1637.  *  type_line       [IN]        
  1638.  * RETURNS
  1639.  *  void
  1640.  *****************************************************************************/
  1641. void UI_draw_vertical_line_type(S32 y1, S32 y2, S32 x, color c, S32 type_line)
  1642. {
  1643.     /*----------------------------------------------------------------*/
  1644.     /* Local Variables                                                */
  1645.     /*----------------------------------------------------------------*/
  1646.     /*----------------------------------------------------------------*/
  1647.     /* Code Body                                                      */
  1648.     /*----------------------------------------------------------------*/
  1649.     switch (type_line)
  1650.     {
  1651.         case 0: /* NORMAL */
  1652.             UI_draw_vertical_line(y1, y2, x, c);
  1653.             break;
  1654.         case 1: /* DOTTED */
  1655.             UI_draw_dotted_vertical_line(y1, y2, x, c);
  1656.             break;
  1657.         case 2: /* DASHED */
  1658.             UI_draw_dashed_vertical_line(y1, y2, x, c);
  1659.             break;
  1660.     }
  1661. }
  1662. void UI_draw_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c);
  1663. /*****************************************************************************
  1664.  * FUNCTION
  1665.  *  UI_draw_rectangle_type
  1666.  * DESCRIPTION
  1667.  *  
  1668.  * PARAMETERS
  1669.  *  x1              [IN]        
  1670.  *  y1              [IN]        
  1671.  *  x2              [IN]        
  1672.  *  y2              [IN]        
  1673.  *  c               [IN]        
  1674.  *  type_line       [IN]        
  1675.  * RETURNS
  1676.  *  void
  1677.  *****************************************************************************/
  1678. void UI_draw_rectangle_type(S32 x1, S32 y1, S32 x2, S32 y2, color c, S32 type_line)
  1679. {
  1680.     /*----------------------------------------------------------------*/
  1681.     /* Local Variables                                                */
  1682.     /*----------------------------------------------------------------*/
  1683.     /*----------------------------------------------------------------*/
  1684.     /* Code Body                                                      */
  1685.     /*----------------------------------------------------------------*/
  1686.     switch (type_line)
  1687.     {
  1688.         case 0:
  1689.             UI_draw_rectangle(x1, y1, x2, y2, c);
  1690.             break;
  1691.         case 1: /* dottted */
  1692.             UI_draw_dotted_rectangle(x1, y1, x2, y2, c);
  1693.             break;
  1694.         case 2: /* dashed */
  1695.             UI_draw_dashed_rectangle(x1, y1, x2, y2, c);
  1696.             break;
  1697.     }
  1698. }
  1699. /*****************************************************************************
  1700.  * FUNCTION
  1701.  *  UI_fill_rectangle
  1702.  * DESCRIPTION
  1703.  *  
  1704.  * PARAMETERS
  1705.  *  x1      [IN]        
  1706.  *  y1      [IN]        
  1707.  *  x2      [IN]        
  1708.  *  y2      [IN]        
  1709.  *  c       [IN]        
  1710.  * RETURNS
  1711.  *  void
  1712.  *****************************************************************************/
  1713. void UI_fill_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  1714. {
  1715.     /*----------------------------------------------------------------*/
  1716.     /* Local Variables                                                */
  1717.     /*----------------------------------------------------------------*/
  1718.     /*----------------------------------------------------------------*/
  1719.     /* Code Body                                                      */
  1720.     /*----------------------------------------------------------------*/
  1721.     gdi_draw_solid_rect(x1, y1, x2, y2, gdi_act_color_from_rgb(UI_translate_gui_alpha_to_gdi_alpha(c.alpha), c.r, c.g, c.b));
  1722. }
  1723. /*****************************************************************************
  1724.  * FUNCTION
  1725.  *  UI_draw_rectangle
  1726.  * DESCRIPTION
  1727.  *  
  1728.  * PARAMETERS
  1729.  *  x1      [IN]        
  1730.  *  y1      [IN]        
  1731.  *  x2      [IN]        
  1732.  *  y2      [IN]        
  1733.  *  c       [IN]        
  1734.  * RETURNS
  1735.  *  void
  1736.  *****************************************************************************/
  1737. void UI_draw_rectangle(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  1738. {
  1739.     /*----------------------------------------------------------------*/
  1740.     /* Local Variables                                                */
  1741.     /*----------------------------------------------------------------*/
  1742.     /*----------------------------------------------------------------*/
  1743.     /* Code Body                                                      */
  1744.     /*----------------------------------------------------------------*/
  1745.     gdi_draw_rect(x1, y1, x2, y2, gdi_act_color_from_rgb(UI_translate_gui_alpha_to_gdi_alpha(c.alpha), c.r, c.g, c.b));
  1746. }
  1747. /*****************************************************************************
  1748.  * FUNCTION
  1749.  *  UI_set_text_clip
  1750.  * DESCRIPTION
  1751.  *  
  1752.  * PARAMETERS
  1753.  *  x1      [IN]        
  1754.  *  y1      [IN]        
  1755.  *  x2      [IN]        
  1756.  *  y2      [IN]        
  1757.  * RETURNS
  1758.  *  void
  1759.  *****************************************************************************/
  1760. void UI_set_text_clip(S32 x1, S32 y1, S32 x2, S32 y2)
  1761. {
  1762.     /*----------------------------------------------------------------*/
  1763.     /* Local Variables                                                */
  1764.     /*----------------------------------------------------------------*/
  1765.     /*----------------------------------------------------------------*/
  1766.     /* Code Body                                                      */
  1767.     /*----------------------------------------------------------------*/
  1768.     /* set clip region */
  1769.     gdi_layer_set_text_clip(x1, y1, x2, y2);
  1770. }
  1771. /*****************************************************************************
  1772.  * FUNCTION
  1773.  *  UI_set_clip
  1774.  * DESCRIPTION
  1775.  *  
  1776.  * PARAMETERS
  1777.  *  x1      [IN]        
  1778.  *  y1      [IN]        
  1779.  *  x2      [IN]        
  1780.  *  y2      [IN]        
  1781.  * RETURNS
  1782.  *  void
  1783.  *****************************************************************************/
  1784. void UI_set_clip(S32 x1, S32 y1, S32 x2, S32 y2)
  1785. {
  1786.     /*----------------------------------------------------------------*/
  1787.     /* Local Variables                                                */
  1788.     /*----------------------------------------------------------------*/
  1789.     /*----------------------------------------------------------------*/
  1790.     /* Code Body                                                      */
  1791.     /*----------------------------------------------------------------*/
  1792.     gdi_layer_set_clip(x1, y1, x2, y2);
  1793.     gdi_layer_get_clip(&x1, &y1, &x2, &y2);
  1794.     /* still keep UI_clip info for pixtel show image for file
  1795.        this shall be remove when integrate font into gdi_font */
  1796.     UI_clip_x1 = x1;
  1797.     UI_clip_y1 = y1;
  1798.     UI_clip_x2 = x2;
  1799.     UI_clip_y2 = y2;
  1800. }
  1801. /*****************************************************************************
  1802.  * FUNCTION
  1803.  *  UI_set_clip_with_bounding_box
  1804.  * DESCRIPTION
  1805.  *  
  1806.  * PARAMETERS
  1807.  *  x1      [IN]        
  1808.  *  y1      [IN]        
  1809.  *  x2      [IN]        
  1810.  *  y2      [IN]        
  1811.  *  bx1     [IN]        
  1812.  *  by1     [IN]        
  1813.  *  bx2     [IN]        
  1814.  *  by2     [IN]        
  1815.  * RETURNS
  1816.  *  void
  1817.  *****************************************************************************/
  1818. void UI_set_clip_with_bounding_box(S32 x1, S32 y1, S32 x2, S32 y2, S32 bx1, S32 by1, S32 bx2, S32 by2)
  1819. {
  1820.     /*----------------------------------------------------------------*/
  1821.     /* Local Variables                                                */
  1822.     /*----------------------------------------------------------------*/
  1823.     /*----------------------------------------------------------------*/
  1824.     /* Code Body                                                      */
  1825.     /*----------------------------------------------------------------*/
  1826.     if (x1 < bx1)
  1827.     {
  1828.         x1 = bx1;
  1829.     }
  1830.     if (y1 < by1)
  1831.     {
  1832.         y1 = by1;
  1833.     }
  1834.     if (x2 > bx2)
  1835.     {
  1836.         x2 = bx2;
  1837.     }
  1838.     if (y2 > by2)
  1839.     {
  1840.         y2 = by2;
  1841.     }
  1842.     UI_set_clip(x1, y1, x2, y2);
  1843. }
  1844. /*****************************************************************************
  1845.  * FUNCTION
  1846.  *  UI_reset_clip
  1847.  * DESCRIPTION
  1848.  *  
  1849.  * PARAMETERS
  1850.  *  void
  1851.  * RETURNS
  1852.  *  void
  1853.  *****************************************************************************/
  1854. void UI_reset_clip(void)
  1855. {
  1856.     /*----------------------------------------------------------------*/
  1857.     /* Local Variables                                                */
  1858.     /*----------------------------------------------------------------*/
  1859.     /*----------------------------------------------------------------*/
  1860.     /* Code Body                                                      */
  1861.     /*----------------------------------------------------------------*/
  1862.     gdi_layer_reset_clip();
  1863.     UI_clip_x1 = 0;
  1864.     UI_clip_y1 = 0;
  1865.     UI_clip_x2 = UI_device_width - 1;
  1866.     UI_clip_y2 = UI_device_height - 1;
  1867. }
  1868. /*****************************************************************************
  1869.  * FUNCTION
  1870.  *  UI_reset_text_clip
  1871.  * DESCRIPTION
  1872.  *  
  1873.  * PARAMETERS
  1874.  *  void
  1875.  * RETURNS
  1876.  *  void
  1877.  *****************************************************************************/
  1878. void UI_reset_text_clip(void)
  1879. {
  1880.     /*----------------------------------------------------------------*/
  1881.     /* Local Variables                                                */
  1882.     /*----------------------------------------------------------------*/
  1883.     /*----------------------------------------------------------------*/
  1884.     /* Code Body                                                      */
  1885.     /*----------------------------------------------------------------*/
  1886.     gdi_layer_reset_text_clip();
  1887. }
  1888. /*****************************************************************************
  1889.  * FUNCTION
  1890.  *  UI_get_text_clip
  1891.  * DESCRIPTION
  1892.  *  
  1893.  * PARAMETERS
  1894.  *  x1      [?]     
  1895.  *  y1      [?]     
  1896.  *  x2      [?]     
  1897.  *  y2      [?]     
  1898.  * RETURNS
  1899.  *  void
  1900.  *****************************************************************************/
  1901. void UI_get_text_clip(S32 *x1, S32 *y1, S32 *x2, S32 *y2)
  1902. {
  1903.     /*----------------------------------------------------------------*/
  1904.     /* Local Variables                                                */
  1905.     /*----------------------------------------------------------------*/
  1906.     /*----------------------------------------------------------------*/
  1907.     /* Code Body                                                      */
  1908.     /*----------------------------------------------------------------*/
  1909.     gdi_layer_get_text_clip(x1, y1, x2, y2);
  1910. }
  1911. /*****************************************************************************
  1912.  * FUNCTION
  1913.  *  UI_get_clip
  1914.  * DESCRIPTION
  1915.  *  
  1916.  * PARAMETERS
  1917.  *  x1      [?]     
  1918.  *  y1      [?]     
  1919.  *  x2      [?]     
  1920.  *  y2      [?]     
  1921.  * RETURNS
  1922.  *  void
  1923.  *****************************************************************************/
  1924. void UI_get_clip(S32 *x1, S32 *y1, S32 *x2, S32 *y2)
  1925. {
  1926.     /*----------------------------------------------------------------*/
  1927.     /* Local Variables                                                */
  1928.     /*----------------------------------------------------------------*/
  1929.     /*----------------------------------------------------------------*/
  1930.     /* Code Body                                                      */
  1931.     /*----------------------------------------------------------------*/
  1932.     gdi_layer_get_clip(x1, y1, x2, y2);
  1933. }
  1934. /*****************************************************************************
  1935.  * FUNCTION
  1936.  *  UI_push_clip
  1937.  * DESCRIPTION
  1938.  *  
  1939.  * PARAMETERS
  1940.  *  void
  1941.  * RETURNS
  1942.  *  void
  1943.  *****************************************************************************/
  1944. void UI_push_clip(void)
  1945. {
  1946.     /*----------------------------------------------------------------*/
  1947.     /* Local Variables                                                */
  1948.     /*----------------------------------------------------------------*/
  1949.     /*----------------------------------------------------------------*/
  1950.     /* Code Body                                                      */
  1951.     /*----------------------------------------------------------------*/
  1952.     gdi_layer_push_clip();
  1953. }
  1954. /*****************************************************************************
  1955.  * FUNCTION
  1956.  *  UI_pop_clip
  1957.  * DESCRIPTION
  1958.  *  
  1959.  * PARAMETERS
  1960.  *  void
  1961.  * RETURNS
  1962.  *  void
  1963.  *****************************************************************************/
  1964. void UI_pop_clip(void)
  1965. {
  1966.     /*----------------------------------------------------------------*/
  1967.     /* Local Variables                                                */
  1968.     /*----------------------------------------------------------------*/
  1969.     /*----------------------------------------------------------------*/
  1970.     /* Code Body                                                      */
  1971.     /*----------------------------------------------------------------*/
  1972.     gdi_layer_pop_clip();
  1973. }
  1974. /*****************************************************************************
  1975.  * FUNCTION
  1976.  *  UI_push_text_clip
  1977.  * DESCRIPTION
  1978.  *  
  1979.  * PARAMETERS
  1980.  *  void
  1981.  * RETURNS
  1982.  *  void
  1983.  *****************************************************************************/
  1984. void UI_push_text_clip(void)
  1985. {
  1986.     /*----------------------------------------------------------------*/
  1987.     /* Local Variables                                                */
  1988.     /*----------------------------------------------------------------*/
  1989.     /*----------------------------------------------------------------*/
  1990.     /* Code Body                                                      */
  1991.     /*----------------------------------------------------------------*/
  1992.     gdi_layer_push_text_clip();
  1993. }
  1994. /*****************************************************************************
  1995.  * FUNCTION
  1996.  *  UI_pop_text_clip
  1997.  * DESCRIPTION
  1998.  *  
  1999.  * PARAMETERS
  2000.  *  void
  2001.  * RETURNS
  2002.  *  void
  2003.  *****************************************************************************/
  2004. void UI_pop_text_clip(void)
  2005. {
  2006.     /*----------------------------------------------------------------*/
  2007.     /* Local Variables                                                */
  2008.     /*----------------------------------------------------------------*/
  2009.     /*----------------------------------------------------------------*/
  2010.     /* Code Body                                                      */
  2011.     /*----------------------------------------------------------------*/
  2012.     gdi_layer_pop_text_clip();
  2013. }
  2014. /*****************************************************************************
  2015.  * FUNCTION
  2016.  *  _read_image_length
  2017.  * DESCRIPTION
  2018.  *  
  2019.  * PARAMETERS
  2020.  *  image       [?]     
  2021.  * RETURNS
  2022.  *  
  2023.  *****************************************************************************/
  2024. S32 _read_image_length(U8 *image)
  2025. {
  2026.     /*----------------------------------------------------------------*/
  2027.     /* Local Variables                                                */
  2028.     /*----------------------------------------------------------------*/
  2029.     U32 rvalue = 0;
  2030.     /*----------------------------------------------------------------*/
  2031.     /* Code Body                                                      */
  2032.     /*----------------------------------------------------------------*/
  2033.     if (image == NULL)
  2034.     {
  2035.         return ((S32) 0);
  2036.     }
  2037.     else
  2038.     {
  2039.         rvalue |= (U32) (image[2]);
  2040.         rvalue |= (U32) ((U32) image[3] << 8);
  2041.         rvalue |= (U32) ((U32) image[4] << 16);
  2042.         rvalue |= (U32) ((U32) image[5] << 24);
  2043.         return ((S32) rvalue);
  2044.     }
  2045. }
  2046. /*****************************************************************************
  2047.  * FUNCTION
  2048.  *  UI_set_text_clip_preset
  2049.  * DESCRIPTION
  2050.  *  
  2051.  * PARAMETERS
  2052.  *  x1      [IN]        
  2053.  *  y1      [IN]        
  2054.  *  x2      [IN]        
  2055.  *  y2      [IN]        
  2056.  * RETURNS
  2057.  *  void
  2058.  *****************************************************************************/
  2059. void UI_set_text_clip_preset(S32 x1, S32 y1, S32 x2, S32 y2)
  2060. {
  2061.     /*----------------------------------------------------------------*/
  2062.     /* Local Variables                                                */
  2063.     /*----------------------------------------------------------------*/
  2064.     S32 prev_x1, prev_y1, prev_x2, prev_y2;
  2065.     /*----------------------------------------------------------------*/
  2066.     /* Code Body                                                      */
  2067.     /*----------------------------------------------------------------*/
  2068.     gdi_layer_get_text_clip(&prev_x1, &prev_y1, &prev_x2, &prev_y2);
  2069.     if (x1 > prev_x1)
  2070.     {
  2071.         prev_x1 = x1;
  2072.     }
  2073.     if (y1 > prev_y1)
  2074.     {
  2075.         prev_y1 = y1;
  2076.     }
  2077.     if (x2 < prev_x2)
  2078.     {
  2079.         prev_x2 = x2;
  2080.     }
  2081.     if (y2 < prev_y2)
  2082.     {
  2083.         prev_y2 = y2;
  2084.     }
  2085.     gdi_layer_set_text_clip(prev_x1, prev_y1, prev_x2, prev_y2);
  2086. }
  2087. /*****************************************************************************
  2088.  * FUNCTION
  2089.  *  UI_set_clip_preset
  2090.  * DESCRIPTION
  2091.  *  
  2092.  * PARAMETERS
  2093.  *  x1      [IN]        
  2094.  *  y1      [IN]        
  2095.  *  x2      [IN]        
  2096.  *  y2      [IN]        
  2097.  * RETURNS
  2098.  *  void
  2099.  *****************************************************************************/
  2100. void UI_set_clip_preset(S32 x1, S32 y1, S32 x2, S32 y2)
  2101. {
  2102.     /*----------------------------------------------------------------*/
  2103.     /* Local Variables                                                */
  2104.     /*----------------------------------------------------------------*/
  2105.     S32 prev_x1, prev_y1, prev_x2, prev_y2;
  2106.     /*----------------------------------------------------------------*/
  2107.     /* Code Body                                                      */
  2108.     /*----------------------------------------------------------------*/
  2109.     gdi_layer_get_clip(&prev_x1, &prev_y1, &prev_x2, &prev_y2);
  2110.     if (x1 > prev_x1)
  2111.     {
  2112.         prev_x1 = x1;
  2113.     }
  2114.     if (y1 > prev_y1)
  2115.     {
  2116.         prev_y1 = y1;
  2117.     }
  2118.     if (x2 < prev_x2)
  2119.     {
  2120.         prev_x2 = x2;
  2121.     }
  2122.     if (y2 < prev_y2)
  2123.     {
  2124.         prev_y2 = y2;
  2125.     }
  2126.     gdi_layer_set_clip(prev_x1, prev_y1, prev_x2, prev_y2);
  2127. }
  2128. /*****************************************************************************
  2129.  * FUNCTION
  2130.  *  UI_set_font
  2131.  * DESCRIPTION
  2132.  *  
  2133.  * PARAMETERS
  2134.  *  f       [IN]        
  2135.  * RETURNS
  2136.  *  void
  2137.  *****************************************************************************/
  2138. void UI_set_font(UI_font_type f)
  2139. {
  2140.     /*----------------------------------------------------------------*/
  2141.     /* Local Variables                                                */
  2142.     /*----------------------------------------------------------------*/
  2143.     /* Let UI_font point to &static_font instead of input parameter */ 
  2144.     static stFontAttribute static_font;
  2145.     /*----------------------------------------------------------------*/
  2146.     /* Code Body                                                      */
  2147.     /*----------------------------------------------------------------*/
  2148.     static_font = *f;
  2149.     UI_font = &static_font;
  2150.     SetFont(static_font, 0);
  2151. }
  2152. /*****************************************************************************
  2153.  * FUNCTION
  2154.  *  UI_printf
  2155.  * DESCRIPTION
  2156.  *  
  2157.  * PARAMETERS
  2158.  *  format      [IN]        
  2159.  * RETURNS
  2160.  *  
  2161.  *****************************************************************************/
  2162. S32 UI_printf(const S8 *format, ...)
  2163. {
  2164.     /*----------------------------------------------------------------*/
  2165.     /* Local Variables                                                */
  2166.     /*----------------------------------------------------------------*/
  2167.     S32 rvalue;
  2168.     U8 temp_buffer[1024];
  2169.     va_list l;
  2170.     /*----------------------------------------------------------------*/
  2171.     /* Code Body                                                      */
  2172.     /*----------------------------------------------------------------*/
  2173.     va_start(l, format);
  2174.     rvalue = vsprintf((S8*) temp_buffer + (sizeof(temp_buffer) / 2) /* UI_printf_buffer */ , format, l);
  2175.     AnsiiToUnicodeString((S8*) temp_buffer, (S8*) temp_buffer + (sizeof(temp_buffer) / 2) /* UI_printf_buffer */ );
  2176.     UI_set_current_text_color(UI_text_color);
  2177.     ShowString(UI_text_x, UI_text_y, *UI_font, 0, (U8*) temp_buffer, UI_text_height);
  2178.     return (rvalue);
  2179. }
  2180. /*****************************************************************************
  2181.  * FUNCTION
  2182.  *  UI_sprintf
  2183.  * DESCRIPTION
  2184.  *  
  2185.  * PARAMETERS
  2186.  *  s           [IN]        
  2187.  *  format      [IN]        
  2188.  * RETURNS
  2189.  *  
  2190.  *****************************************************************************/
  2191. S32 UI_sprintf(UI_string_type s, const S8 *format, ...)
  2192. {
  2193.     /*----------------------------------------------------------------*/
  2194.     /* Local Variables                                                */
  2195.     /*----------------------------------------------------------------*/
  2196.     S32 rvalue;
  2197.     U8 temp_buffer[1024];
  2198.     va_list l;
  2199.     /*----------------------------------------------------------------*/
  2200.     /* Code Body                                                      */
  2201.     /*----------------------------------------------------------------*/
  2202.     va_start(l, format);
  2203.     rvalue = vsprintf((S8*) temp_buffer, format, l);
  2204.     AnsiiToUnicodeString((S8*) s, (S8*) temp_buffer);
  2205.     return (rvalue);
  2206. }
  2207. /*****************************************************************************
  2208.  * FUNCTION
  2209.  *  UI_print_text
  2210.  * DESCRIPTION
  2211.  *  
  2212.  * PARAMETERS
  2213.  *  text        [IN]        
  2214.  * RETURNS
  2215.  *  void
  2216.  *****************************************************************************/
  2217. void UI_print_text(UI_string_type text)
  2218. {
  2219.     /*----------------------------------------------------------------*/
  2220.     /* Local Variables                                                */
  2221.     /*----------------------------------------------------------------*/
  2222.     /*----------------------------------------------------------------*/
  2223.     /* Code Body                                                      */
  2224.     /*----------------------------------------------------------------*/
  2225.     if (text == NULL)
  2226.     {
  2227.         return;
  2228.     }
  2229.     UI_set_current_text_color(UI_text_color);
  2230.     ShowString(UI_text_x, UI_text_y, *UI_font, 0, (U8*) text, UI_text_height);
  2231. }
  2232. /*****************************************************************************
  2233.  * FUNCTION
  2234.  *  UI_print_bordered_text
  2235.  * DESCRIPTION
  2236.  *  
  2237.  * PARAMETERS
  2238.  *  text        [IN]        
  2239.  * RETURNS
  2240.  *  void
  2241.  *****************************************************************************/
  2242. void UI_print_bordered_text(UI_string_type text)
  2243. {
  2244.     /*----------------------------------------------------------------*/
  2245.     /* Local Variables                                                */
  2246.     /*----------------------------------------------------------------*/
  2247.     /*----------------------------------------------------------------*/
  2248.     /* Code Body                                                      */
  2249.     /*----------------------------------------------------------------*/
  2250.     if (text == NULL)
  2251.     {
  2252.         return;
  2253.     }
  2254.     /* MTK Justin added  to optimize the speed of bordered text */
  2255.     UI_set_current_text_color(UI_text_color);
  2256.     ShowStringBordered(UI_text_x, UI_text_y, *UI_font, 0, (U8*) text, UI_text_height);
  2257.     /* MTK Justin end */
  2258. }
  2259. /* MTK Terry Add to Support print n characters */
  2260. /*****************************************************************************
  2261.  * FUNCTION
  2262.  *  UI_print_text_n
  2263.  * DESCRIPTION
  2264.  *  
  2265.  * PARAMETERS
  2266.  *  text        [IN]        
  2267.  *  n           [IN]        
  2268.  * RETURNS
  2269.  *  void
  2270.  *****************************************************************************/
  2271. void UI_print_text_n(UI_string_type text, int n)
  2272. {
  2273.     /*----------------------------------------------------------------*/
  2274.     /* Local Variables                                                */
  2275.     /*----------------------------------------------------------------*/
  2276.     /*----------------------------------------------------------------*/
  2277.     /* Code Body                                                      */
  2278.     /*----------------------------------------------------------------*/
  2279.     if (text == NULL)
  2280.     {
  2281.         return;
  2282.     }
  2283.     UI_set_current_text_color(UI_text_color);
  2284.     ShowString_n(UI_text_x, UI_text_y, *UI_font, 0, (U8*) text, n, UI_text_height);
  2285. }
  2286. /*****************************************************************************
  2287.  * FUNCTION
  2288.  *  UI_print_bordered_text_n
  2289.  * DESCRIPTION
  2290.  *  
  2291.  * PARAMETERS
  2292.  *  text        [IN]        
  2293.  *  n           [IN]        
  2294.  * RETURNS
  2295.  *  void
  2296.  *****************************************************************************/
  2297. void UI_print_bordered_text_n(UI_string_type text, int n)
  2298. {
  2299.     /*----------------------------------------------------------------*/
  2300.     /* Local Variables                                                */
  2301.     /*----------------------------------------------------------------*/
  2302.     /*----------------------------------------------------------------*/
  2303.     /* Code Body                                                      */
  2304.     /*----------------------------------------------------------------*/
  2305.     if (text == NULL)
  2306.     {
  2307.         return;
  2308.     }
  2309.     UI_set_current_text_color(UI_text_color);
  2310.     ShowStringBordered_n(UI_text_x, UI_text_y, *UI_font, 0, (U8*) text, n, UI_text_height);
  2311. }
  2312. /* MTK end */
  2313. /* MTK Leo add for bordered_character */
  2314. /*****************************************************************************
  2315.  * FUNCTION
  2316.  *  UI_print_bordered_character
  2317.  * DESCRIPTION
  2318.  *  
  2319.  * PARAMETERS
  2320.  *  c       [IN]        
  2321.  * RETURNS
  2322.  *  void
  2323.  *****************************************************************************/
  2324. void UI_print_bordered_character(UI_character_type c)
  2325. {
  2326.     /*----------------------------------------------------------------*/
  2327.     /* Local Variables                                                */
  2328.     /*----------------------------------------------------------------*/
  2329.     //////////////////////////////////////
  2330.     //MTK Add By Elvis---2003/06/06 03:52? //
  2331.     //////////////////////////////////////
  2332.     U8 temp_buffer[4];
  2333.     /*----------------------------------------------------------------*/
  2334.     /* Code Body                                                      */
  2335.     /*----------------------------------------------------------------*/
  2336.     temp_buffer[0] = (U8) c;
  2337.     temp_buffer[1] = (U8) (c >> 8);
  2338.     temp_buffer[2] = '';
  2339.     temp_buffer[3] = 0;
  2340.     UI_current_text_color = UI_text_color;
  2341.     ShowStringBordered(UI_text_x, UI_text_y, *UI_font, 0, (U8*) temp_buffer, 0);
  2342. }
  2343. /* MTK Leo end */
  2344. /*****************************************************************************
  2345.  * FUNCTION
  2346.  *  UI_print_character
  2347.  * DESCRIPTION
  2348.  *  
  2349.  * PARAMETERS
  2350.  *  c       [IN]        
  2351.  * RETURNS
  2352.  *  void
  2353.  *****************************************************************************/
  2354. void UI_print_character(UI_character_type c)
  2355. {
  2356.     /*----------------------------------------------------------------*/
  2357.     /* Local Variables                                                */
  2358.     /*----------------------------------------------------------------*/
  2359.     //////////////////////////////////////
  2360.     //MTK Add By Elvis---2003/06/06 03:52? //
  2361.     //////////////////////////////////////
  2362.     U8 temp_buffer[4];
  2363.     /*----------------------------------------------------------------*/
  2364.     /* Code Body                                                      */
  2365.     /*----------------------------------------------------------------*/
  2366.     temp_buffer[0] = (U8) c;
  2367.     temp_buffer[1] = (U8) (c >> 8);
  2368.     temp_buffer[2] = '';
  2369.     temp_buffer[3] = 0;
  2370.     UI_current_text_color = UI_text_color;
  2371.     ShowString(UI_text_x, UI_text_y, *UI_font, 0, (U8*) temp_buffer, 0);
  2372.     /* MTK end // */
  2373. }
  2374. /* MTK Elvis for stacked character */
  2375. /*****************************************************************************
  2376.  * FUNCTION
  2377.  *  UI_print_stacked_character
  2378.  * DESCRIPTION
  2379.  *  
  2380.  * PARAMETERS
  2381.  *  curCh       [IN]        
  2382.  *  pre2Ch      [IN]        
  2383.  *  preCh       [IN]        
  2384.  * RETURNS
  2385.  *  void
  2386.  *****************************************************************************/
  2387. void UI_print_stacked_character(UI_character_type curCh, UI_character_type pre2Ch, UI_character_type preCh)
  2388. {
  2389.     /*----------------------------------------------------------------*/
  2390.     /* Local Variables                                                */
  2391.     /*----------------------------------------------------------------*/
  2392.     /*----------------------------------------------------------------*/
  2393.     /* Code Body                                                      */
  2394.     /*----------------------------------------------------------------*/
  2395.     UI_current_text_color = UI_text_color;
  2396.     ShowStackedChar(UI_text_x, UI_text_y, *UI_font, 0, curCh, 0, 0, pre2Ch, preCh);
  2397. }
  2398. /*****************************************************************************
  2399.  * FUNCTION
  2400.  *  UI_print_bordered_stacked_character
  2401.  * DESCRIPTION
  2402.  *  
  2403.  * PARAMETERS
  2404.  *  curCh       [IN]        
  2405.  *  pre2Ch      [IN]        
  2406.  *  preCh       [IN]        
  2407.  * RETURNS
  2408.  *  void
  2409.  *****************************************************************************/
  2410. void UI_print_bordered_stacked_character(UI_character_type curCh, UI_character_type pre2Ch, UI_character_type preCh)
  2411. {
  2412.     /*----------------------------------------------------------------*/
  2413.     /* Local Variables                                                */
  2414.     /*----------------------------------------------------------------*/
  2415.     /*----------------------------------------------------------------*/
  2416.     /* Code Body                                                      */
  2417.     /*----------------------------------------------------------------*/
  2418.     UI_current_text_color = UI_text_color;
  2419.     ShowStackedChar(UI_text_x, UI_text_y, *UI_font, 0, curCh, 0, 1, pre2Ch, preCh);
  2420. }
  2421. /* MTK end */
  2422. /*****************************************************************************
  2423.  * FUNCTION
  2424.  *  UI_move_text_cursor
  2425.  * DESCRIPTION
  2426.  *  
  2427.  * PARAMETERS
  2428.  *  x       [IN]        
  2429.  *  y       [IN]        
  2430.  * RETURNS
  2431.  *  void
  2432.  *****************************************************************************/
  2433. void UI_move_text_cursor(S32 x, S32 y)
  2434. {
  2435.     /*----------------------------------------------------------------*/
  2436.     /* Local Variables                                                */
  2437.     /*----------------------------------------------------------------*/
  2438.     /*----------------------------------------------------------------*/
  2439.     /* Code Body                                                      */
  2440.     /*----------------------------------------------------------------*/
  2441.     UI_text_x = x;
  2442.     UI_text_y = y;
  2443.     UI_text_height = 0;
  2444. }
  2445. /*****************************************************************************
  2446.  * FUNCTION
  2447.  *  UI_set_line_height
  2448.  * DESCRIPTION
  2449.  *  
  2450.  * PARAMETERS
  2451.  *  height      [IN]        
  2452.  * RETURNS
  2453.  *  void
  2454.  *****************************************************************************/
  2455. void UI_set_line_height(S32 height)
  2456. {
  2457.     /*----------------------------------------------------------------*/
  2458.     /* Local Variables                                                */
  2459.     /*----------------------------------------------------------------*/
  2460.     /*----------------------------------------------------------------*/
  2461.     /* Code Body                                                      */
  2462.     /*----------------------------------------------------------------*/
  2463.     UI_text_height = height;
  2464. }
  2465. /*****************************************************************************
  2466.  * FUNCTION
  2467.  *  UI_set_text_color
  2468.  * DESCRIPTION
  2469.  *  
  2470.  * PARAMETERS
  2471.  *  c       [IN]        
  2472.  * RETURNS
  2473.  *  void
  2474.  *****************************************************************************/
  2475. void UI_set_text_color(color c)
  2476. {
  2477.     /*----------------------------------------------------------------*/
  2478.     /* Local Variables                                                */
  2479.     /*----------------------------------------------------------------*/
  2480.     /*----------------------------------------------------------------*/
  2481.     /* Code Body                                                      */
  2482.     /*----------------------------------------------------------------*/
  2483.     UI_text_color = c;
  2484.     UI_current_text_color = UI_text_color;
  2485. }
  2486. /*****************************************************************************
  2487.  * FUNCTION
  2488.  *  UI_set_text_border_color
  2489.  * DESCRIPTION
  2490.  *  
  2491.  * PARAMETERS
  2492.  *  c       [IN]        
  2493.  * RETURNS
  2494.  *  void
  2495.  *****************************************************************************/
  2496. void UI_set_text_border_color(color c)
  2497. {
  2498.     /*----------------------------------------------------------------*/
  2499.     /* Local Variables                                                */
  2500.     /*----------------------------------------------------------------*/
  2501.     /*----------------------------------------------------------------*/
  2502.     /* Code Body                                                      */
  2503.     /*----------------------------------------------------------------*/
  2504.     UI_text_border_color = c;
  2505. }
  2506. /*****************************************************************************
  2507.  * FUNCTION
  2508.  *  UI_malloc
  2509.  * DESCRIPTION
  2510.  *  
  2511.  * PARAMETERS
  2512.  *  size        [IN]        
  2513.  * RETURNS
  2514.  *  void
  2515.  *****************************************************************************/
  2516. void *UI_malloc(size_t size)
  2517. {
  2518.     /*----------------------------------------------------------------*/
  2519.     /* Local Variables                                                */
  2520.     /*----------------------------------------------------------------*/
  2521.     /*----------------------------------------------------------------*/
  2522.     /* Code Body                                                      */
  2523.     /*----------------------------------------------------------------*/
  2524.     return (OslMalloc(size));
  2525. }
  2526. /*****************************************************************************
  2527.  * FUNCTION
  2528.  *  UI_free
  2529.  * DESCRIPTION
  2530.  *  
  2531.  * PARAMETERS
  2532.  *  ptr     [?]     
  2533.  * RETURNS
  2534.  *  void
  2535.  *****************************************************************************/
  2536. void UI_free(void *ptr)
  2537. {
  2538.     /*----------------------------------------------------------------*/
  2539.     /* Local Variables                                                */
  2540.     /*----------------------------------------------------------------*/
  2541.     /*----------------------------------------------------------------*/
  2542.     /* Code Body                                                      */
  2543.     /*----------------------------------------------------------------*/
  2544.     if (ptr != NULL)
  2545.     {
  2546.         OslMfree(ptr);
  2547.     }
  2548. }
  2549. /* MTK Leo add 1220 */
  2550. /*****************************************************************************
  2551.  * FUNCTION
  2552.  *  UI_get_font_height
  2553.  * DESCRIPTION
  2554.  *  
  2555.  * PARAMETERS
  2556.  *  f       [IN]        
  2557.  * RETURNS
  2558.  *  
  2559.  *****************************************************************************/
  2560. S32 UI_get_font_height(UI_font_type f)
  2561. {
  2562.     /*----------------------------------------------------------------*/
  2563.     /* Local Variables                                                */
  2564.     /*----------------------------------------------------------------*/
  2565.     /*----------------------------------------------------------------*/
  2566.     /* Code Body                                                      */
  2567.     /*----------------------------------------------------------------*/
  2568.     return (Get_FontHeight(*f, (U8) gCurrLangIndex));
  2569. }
  2570. /*****************************************************************************
  2571.  * FUNCTION
  2572.  *  UI_get_character_width
  2573.  * DESCRIPTION
  2574.  *  
  2575.  * PARAMETERS
  2576.  *  c       [IN]        
  2577.  * RETURNS
  2578.  *  
  2579.  *****************************************************************************/
  2580. S32 UI_get_character_width(UI_character_type c)
  2581. {
  2582.     /*----------------------------------------------------------------*/
  2583.     /* Local Variables                                                */
  2584.     /*----------------------------------------------------------------*/
  2585.     S32 w, h;
  2586.     /*----------------------------------------------------------------*/
  2587.     /* Code Body                                                      */
  2588.     /*----------------------------------------------------------------*/
  2589.     Get_CharWidthHeight(c, &w, &h);
  2590.     return (w);
  2591. }
  2592. /*****************************************************************************
  2593.  * FUNCTION
  2594.  *  UI_get_character_height
  2595.  * DESCRIPTION
  2596.  *  
  2597.  * PARAMETERS
  2598.  *  void
  2599.  * RETURNS
  2600.  *  
  2601.  *****************************************************************************/
  2602. S32 UI_get_character_height(void)
  2603. {
  2604.     /*----------------------------------------------------------------*/
  2605.     /* Local Variables                                                */
  2606.     /*----------------------------------------------------------------*/
  2607.     /*----------------------------------------------------------------*/
  2608.     /* Code Body                                                      */
  2609.     /*----------------------------------------------------------------*/
  2610.     return (Get_CharHeight());
  2611. }
  2612. /*****************************************************************************
  2613.  * FUNCTION
  2614.  *  UI_measure_character
  2615.  * DESCRIPTION
  2616.  *  
  2617.  * PARAMETERS
  2618.  *  c           [IN]        
  2619.  *  width       [?]         
  2620.  *  height      [?]         
  2621.  * RETURNS
  2622.  *  void
  2623.  *****************************************************************************/
  2624. void UI_measure_character(UI_character_type c, S32 *width, S32 *height)
  2625. {
  2626.     /*----------------------------------------------------------------*/
  2627.     /* Local Variables                                                */
  2628.     /*----------------------------------------------------------------*/
  2629.     /*----------------------------------------------------------------*/
  2630.     /* Code Body                                                      */
  2631.     /*----------------------------------------------------------------*/
  2632.     Get_CharWidthHeight(c, width, height);
  2633. }
  2634. /*****************************************************************************
  2635.  * FUNCTION
  2636.  *  UI_get_string_width
  2637.  * DESCRIPTION
  2638.  *  
  2639.  * PARAMETERS
  2640.  *  text        [IN]        
  2641.  * RETURNS
  2642.  *  
  2643.  *****************************************************************************/
  2644. S32 UI_get_string_width(UI_string_type text)
  2645. {
  2646.     /*----------------------------------------------------------------*/
  2647.     /* Local Variables                                                */
  2648.     /*----------------------------------------------------------------*/
  2649.     S32 w, h;
  2650.     /*----------------------------------------------------------------*/
  2651.     /* Code Body                                                      */
  2652.     /*----------------------------------------------------------------*/
  2653.     Get_StringWidthHeight((U8*) text, &w, &h);
  2654.     return (w);
  2655. }
  2656. /*****************************************************************************
  2657.  * FUNCTION
  2658.  *  UI_get_string_height
  2659.  * DESCRIPTION
  2660.  *  
  2661.  * PARAMETERS
  2662.  *  text        [IN]        
  2663.  * RETURNS
  2664.  *  
  2665.  *****************************************************************************/
  2666. S32 UI_get_string_height(UI_string_type text)
  2667. {
  2668.     /*----------------------------------------------------------------*/
  2669.     /* Local Variables                                                */
  2670.     /*----------------------------------------------------------------*/
  2671.     /*----------------------------------------------------------------*/
  2672.     /* Code Body                                                      */
  2673.     /*----------------------------------------------------------------*/
  2674.     UI_UNUSED_PARAMETER(text);
  2675.     return (Get_CharHeight());
  2676. }
  2677. /*****************************************************************************
  2678.  * FUNCTION
  2679.  *  UI_measure_string
  2680.  * DESCRIPTION
  2681.  *  
  2682.  * PARAMETERS
  2683.  *  text        [IN]        
  2684.  *  width       [?]         
  2685.  *  height      [?]         
  2686.  * RETURNS
  2687.  *  void
  2688.  *****************************************************************************/
  2689. void UI_measure_string(UI_string_type text, S32 *width, S32 *height)
  2690. {
  2691.     /*----------------------------------------------------------------*/
  2692.     /* Local Variables                                                */
  2693.     /*----------------------------------------------------------------*/
  2694.     /*----------------------------------------------------------------*/
  2695.     /* Code Body                                                      */
  2696.     /*----------------------------------------------------------------*/
  2697.     Get_StringWidthHeight((U8*) text, width, height);
  2698. }
  2699. /*****************************************************************************
  2700.  * FUNCTION
  2701.  *  UI_get_string_width_n
  2702.  * DESCRIPTION
  2703.  *  
  2704.  * PARAMETERS
  2705.  *  text        [IN]        
  2706.  *  n           [IN]        
  2707.  * RETURNS
  2708.  *  
  2709.  *****************************************************************************/
  2710. S32 UI_get_string_width_n(UI_string_type text, S32 n)
  2711. {
  2712.     /*----------------------------------------------------------------*/
  2713.     /* Local Variables                                                */
  2714.     /*----------------------------------------------------------------*/
  2715.     S32 w, h;
  2716.     /*----------------------------------------------------------------*/
  2717.     /* Code Body                                                      */
  2718.     /*----------------------------------------------------------------*/
  2719.     Get_StringWidthHeight_n((U8*) text, n, &w, &h);
  2720.     return (w);
  2721. }
  2722. /*****************************************************************************
  2723.  * FUNCTION
  2724.  *  UI_get_string_width_w
  2725.  * DESCRIPTION
  2726.  *  
  2727.  * PARAMETERS
  2728.  *  text        [IN]        
  2729.  *  w           [IN]        
  2730.  * RETURNS
  2731.  *  
  2732.  *****************************************************************************/
  2733. S32 UI_get_string_width_w(UI_string_type text, S32 w)
  2734. {
  2735.     /*----------------------------------------------------------------*/
  2736.     /* Local Variables                                                */
  2737.     /*----------------------------------------------------------------*/
  2738.     S32 sw, sh;
  2739.     /*----------------------------------------------------------------*/
  2740.     /* Code Body                                                      */
  2741.     /*----------------------------------------------------------------*/
  2742.     Get_StringWidthHeight_w((U8*) text, w, &sw, &sh);
  2743.     return (sw);
  2744. }
  2745. /*****************************************************************************
  2746.  * FUNCTION
  2747.  *  UI_get_string_width_wn
  2748.  * DESCRIPTION
  2749.  *  
  2750.  * PARAMETERS
  2751.  *  text        [IN]        
  2752.  *  w           [IN]        
  2753.  *  n           [IN]        
  2754.  * RETURNS
  2755.  *  
  2756.  *****************************************************************************/
  2757. S32 UI_get_string_width_wn(UI_string_type text, S32 w, S32 n)
  2758. {
  2759.     /*----------------------------------------------------------------*/
  2760.     /* Local Variables                                                */
  2761.     /*----------------------------------------------------------------*/
  2762.     S32 sw, sh;
  2763.     /*----------------------------------------------------------------*/
  2764.     /* Code Body                                                      */
  2765.     /*----------------------------------------------------------------*/
  2766.     Get_StringWidthHeight_wn((U8*) text, w, n, &sw, &sh);
  2767.     return (sw);
  2768. }
  2769. /*****************************************************************************
  2770.  * FUNCTION
  2771.  *  UI_measure_string_n
  2772.  * DESCRIPTION
  2773.  *  
  2774.  * PARAMETERS
  2775.  *  text        [IN]        
  2776.  *  n           [IN]        
  2777.  *  width       [?]         
  2778.  *  height      [?]         
  2779.  * RETURNS
  2780.  *  void
  2781.  *****************************************************************************/
  2782. void UI_measure_string_n(UI_string_type text, S32 n, S32 *width, S32 *height)
  2783. {
  2784.     /*----------------------------------------------------------------*/
  2785.     /* Local Variables                                                */
  2786.     /*----------------------------------------------------------------*/
  2787.     /*----------------------------------------------------------------*/
  2788.     /* Code Body                                                      */
  2789.     /*----------------------------------------------------------------*/
  2790.     Get_StringWidthHeight_n((U8*) text, n, width, height);
  2791. }
  2792. /*****************************************************************************
  2793.  * FUNCTION
  2794.  *  UI_measure_string_w
  2795.  * DESCRIPTION
  2796.  *  
  2797.  * PARAMETERS
  2798.  *  text        [IN]        
  2799.  *  w           [IN]        
  2800.  *  width       [?]         
  2801.  *  height      [?]         
  2802.  * RETURNS
  2803.  *  void
  2804.  *****************************************************************************/
  2805. void UI_measure_string_w(UI_string_type text, S32 w, S32 *width, S32 *height)
  2806. {
  2807.     /*----------------------------------------------------------------*/
  2808.     /* Local Variables                                                */
  2809.     /*----------------------------------------------------------------*/
  2810.     /*----------------------------------------------------------------*/
  2811.     /* Code Body                                                      */
  2812.     /*----------------------------------------------------------------*/
  2813.     Get_StringWidthHeight_w((U8*) text, w, width, height);
  2814. }
  2815. /*****************************************************************************
  2816.  * FUNCTION
  2817.  *  UI_measure_string_wn
  2818.  * DESCRIPTION
  2819.  *  
  2820.  * PARAMETERS
  2821.  *  text        [IN]        
  2822.  *  w           [IN]        
  2823.  *  n           [IN]        
  2824.  *  width       [?]         
  2825.  *  height      [?]         
  2826.  * RETURNS
  2827.  *  void
  2828.  *****************************************************************************/
  2829. void UI_measure_string_wn(UI_string_type text, S32 w, S32 n, S32 *width, S32 *height)
  2830. {
  2831.     /*----------------------------------------------------------------*/
  2832.     /* Local Variables                                                */
  2833.     /*----------------------------------------------------------------*/
  2834.     /*----------------------------------------------------------------*/
  2835.     /* Code Body                                                      */
  2836.     /*----------------------------------------------------------------*/
  2837.     Get_StringWidthHeight_wn((U8*) text, w, n, width, height);
  2838. }
  2839. /*****************************************************************************
  2840.  * FUNCTION
  2841.  *  UI_strlen
  2842.  * DESCRIPTION
  2843.  *  
  2844.  * PARAMETERS
  2845.  *  text        [IN]        
  2846.  * RETURNS
  2847.  *  
  2848.  *****************************************************************************/
  2849. S32 UI_strlen(UI_string_type text)
  2850. {
  2851.     /*----------------------------------------------------------------*/
  2852.     /* Local Variables                                                */
  2853.     /*----------------------------------------------------------------*/
  2854.     /*----------------------------------------------------------------*/
  2855.     /* Code Body                                                      */
  2856.     /*----------------------------------------------------------------*/
  2857.     if (text == NULL)
  2858.     {
  2859.         return (0);
  2860.     }
  2861.     else
  2862.     {
  2863.         return (UCS2Strlen((S8*) text));
  2864.     }
  2865. }
  2866. /*****************************************************************************
  2867.  * FUNCTION
  2868.  *  UI_strcpy
  2869.  * DESCRIPTION
  2870.  *  
  2871.  * PARAMETERS
  2872.  *  text1       [IN]        
  2873.  *  text2       [IN]        
  2874.  * RETURNS
  2875.  *  
  2876.  *****************************************************************************/
  2877. UI_string_type UI_strcpy(UI_string_type text1, UI_string_type text2)
  2878. {
  2879.     /*----------------------------------------------------------------*/
  2880.     /* Local Variables                                                */
  2881.     /*----------------------------------------------------------------*/
  2882.     /*----------------------------------------------------------------*/
  2883.     /* Code Body                                                      */
  2884.     /*----------------------------------------------------------------*/
  2885.     if ((text1 == NULL) || (text2 == NULL))
  2886.     {
  2887.         return (NULL);
  2888.     }
  2889.     else
  2890.     {
  2891.         return ((UI_string_type) UCS2Strcpy((S8*) text1, (S8*) text2));
  2892.     }
  2893. }
  2894. /*****************************************************************************
  2895.  * FUNCTION
  2896.  *  UI_strncpy
  2897.  * DESCRIPTION
  2898.  *  
  2899.  * PARAMETERS
  2900.  *  text1       [IN]        
  2901.  *  text2       [IN]        
  2902.  *  n           [IN]        
  2903.  * RETURNS
  2904.  *  
  2905.  *****************************************************************************/
  2906. UI_string_type UI_strncpy(UI_string_type text1, UI_string_type text2, S32 n)
  2907. {
  2908.     /*----------------------------------------------------------------*/
  2909.     /* Local Variables                                                */
  2910.     /*----------------------------------------------------------------*/
  2911.     /*----------------------------------------------------------------*/
  2912.     /* Code Body                                                      */
  2913.     /*----------------------------------------------------------------*/
  2914.     if ((text1 == NULL) || (text2 == NULL))
  2915.     {
  2916.         return (NULL);
  2917.     }
  2918.     else
  2919.     {
  2920.         return ((UI_string_type) UCS2Strncpy((S8*) text1, (S8*) text2, n));
  2921.     }
  2922. }
  2923. /*****************************************************************************
  2924.  * FUNCTION
  2925.  *  UI_strcat
  2926.  * DESCRIPTION
  2927.  *  
  2928.  * PARAMETERS
  2929.  *  text1       [IN]        
  2930.  *  text2       [IN]        
  2931.  * RETURNS
  2932.  *  
  2933.  *****************************************************************************/
  2934. UI_string_type UI_strcat(UI_string_type text1, UI_string_type text2)
  2935. {
  2936.     /*----------------------------------------------------------------*/
  2937.     /* Local Variables                                                */
  2938.     /*----------------------------------------------------------------*/
  2939.     /*----------------------------------------------------------------*/
  2940.     /* Code Body                                                      */
  2941.     /*----------------------------------------------------------------*/
  2942.     if ((text1 == NULL) || (text2 == NULL))
  2943.     {
  2944.         return (NULL);
  2945.     }
  2946.     else
  2947.     {
  2948.         return ((UI_string_type) UCS2Strcat((S8*) text1, (S8*) text2));
  2949.     }
  2950. }
  2951. /*****************************************************************************
  2952.  * FUNCTION
  2953.  *  UI_strcmp
  2954.  * DESCRIPTION
  2955.  *  
  2956.  * PARAMETERS
  2957.  *  text1       [IN]        
  2958.  *  text2       [IN]        
  2959.  * RETURNS
  2960.  *  
  2961.  *****************************************************************************/
  2962. S32 UI_strcmp(UI_string_type text1, UI_string_type text2)
  2963. {
  2964.     /*----------------------------------------------------------------*/
  2965.     /* Local Variables                                                */
  2966.     /*----------------------------------------------------------------*/
  2967.     /*----------------------------------------------------------------*/
  2968.     /* Code Body                                                      */
  2969.     /*----------------------------------------------------------------*/
  2970.     if ((text1 == NULL) || (text2 == NULL))
  2971.     {
  2972.         return (-1);
  2973.     }
  2974.     else
  2975.     {
  2976.         return (UCS2Strcmp((S8*) text1, (S8*) text2));
  2977.     }
  2978. }
  2979. /*****************************************************************************
  2980.  * FUNCTION
  2981.  *  UI_strncmp
  2982.  * DESCRIPTION
  2983.  *  
  2984.  * PARAMETERS
  2985.  *  text1       [IN]        
  2986.  *  text2       [IN]        
  2987.  *  n           [IN]        
  2988.  * RETURNS
  2989.  *  
  2990.  *****************************************************************************/
  2991. S32 UI_strncmp(UI_string_type text1, UI_string_type text2, S32 n)
  2992. {
  2993.     /*----------------------------------------------------------------*/
  2994.     /* Local Variables                                                */
  2995.     /*----------------------------------------------------------------*/
  2996.     /*----------------------------------------------------------------*/
  2997.     /* Code Body                                                      */
  2998.     /*----------------------------------------------------------------*/
  2999.     if ((text1 == NULL) || (text2 == NULL))
  3000.     {
  3001.         return (-1);
  3002.     }
  3003.     else
  3004.     {
  3005.         return (UCS2Strncmp((S8*) text1, (S8*) text2, n));
  3006.     }
  3007. }
  3008. /*****************************************************************************
  3009.  * FUNCTION
  3010.  *  UI_memcpy
  3011.  * DESCRIPTION
  3012.  *  
  3013.  * PARAMETERS
  3014.  *  d       [?]         
  3015.  *  s       [IN]        
  3016.  *  n       [IN]        
  3017.  * RETURNS
  3018.  *  void
  3019.  *****************************************************************************/
  3020. void *UI_memcpy(void *d, const void *s, S32 n)
  3021. {
  3022.     /*----------------------------------------------------------------*/
  3023.     /* Local Variables                                                */
  3024.     /*----------------------------------------------------------------*/
  3025.     /*----------------------------------------------------------------*/
  3026.     /* Code Body                                                      */
  3027.     /*----------------------------------------------------------------*/
  3028.     return (memcpy(d, s, n));
  3029. }
  3030. /*****************************************************************************
  3031.  * FUNCTION
  3032.  *  HW_itoa
  3033.  * DESCRIPTION
  3034.  *  
  3035.  * PARAMETERS
  3036.  *  value       [IN]        
  3037.  *  s           [?]         
  3038.  *  radix       [IN]        
  3039.  * RETURNS
  3040.  *  
  3041.  *****************************************************************************/
  3042. S8 *HW_itoa(S32 value, S8 *s, S32 radix)
  3043. {
  3044.     /*----------------------------------------------------------------*/
  3045.     /* Local Variables                                                */
  3046.     /*----------------------------------------------------------------*/
  3047.     /*----------------------------------------------------------------*/
  3048.     /* Code Body                                                      */
  3049.     /*----------------------------------------------------------------*/
  3050.     if (s == NULL)
  3051.     {
  3052.         return (NULL);
  3053.     }
  3054.     else
  3055.     {
  3056.         /* JL/Pluto */
  3057. #define LEN 20
  3058.         U8 *temp;
  3059.         U32 rem;
  3060.         static U8 rev[LEN + 1];
  3061.         rev[LEN] = 0;
  3062.         if (value == 0)
  3063.         {
  3064.             (s)[0] = '0';
  3065.             ++(s);
  3066.             (s)[0] = '';
  3067.             return s;
  3068.         }
  3069.         temp = &rev[LEN];
  3070.         while (value)
  3071.         {
  3072.             rem = value % radix;
  3073.             if (rem < 10)
  3074.             {
  3075.                 *--temp = (U8) (rem + '0');
  3076.             }
  3077.             else if (radix == 16)
  3078.             {
  3079.                 *--temp = "abcdef"[rem - 10];
  3080.             }
  3081.             value /= radix;
  3082.         }
  3083.         while (*temp)
  3084.         {
  3085.             (s)[0] = *temp++;
  3086.             ++(s);
  3087.         }
  3088.         (s)[0] = '';
  3089.         return s;
  3090.     }
  3091. }
  3092. /*****************************************************************************
  3093.  * FUNCTION
  3094.  *  UI_itoa
  3095.  * DESCRIPTION
  3096.  *  
  3097.  * PARAMETERS
  3098.  *  value       [IN]        
  3099.  *  s           [IN]        
  3100.  *  radix       [IN]        
  3101.  * RETURNS
  3102.  *  
  3103.  *****************************************************************************/
  3104. UI_string_type UI_itoa(S32 value, UI_string_type s, S32 radix)
  3105. {
  3106.     /*----------------------------------------------------------------*/
  3107.     /* Local Variables                                                */
  3108.     /*----------------------------------------------------------------*/
  3109.     /*----------------------------------------------------------------*/
  3110.     /* Code Body                                                      */
  3111.     /*----------------------------------------------------------------*/
  3112.     if (s == NULL)
  3113.     {
  3114.         return (NULL);
  3115.     }
  3116.     else
  3117.     {
  3118.         S8 ts[32];
  3119.         HW_itoa(value, ts, radix);
  3120.         AnsiiToUnicodeString((S8*) s, (S8*) ts);
  3121.         return (s);
  3122.     }
  3123. }
  3124. /*****************************************************************************
  3125.  * FUNCTION
  3126.  *  hw_atoi
  3127.  * DESCRIPTION
  3128.  *  
  3129.  * PARAMETERS
  3130.  *  s       [IN]        
  3131.  * RETURNS
  3132.  *  
  3133.  *****************************************************************************/
  3134. S32 hw_atoi(const S8 *s)
  3135. {
  3136.     /*----------------------------------------------------------------*/
  3137.     /* Local Variables                                                */
  3138.     /*----------------------------------------------------------------*/
  3139.     S32 n = 0;
  3140.     S32 i = 0;
  3141.     /*----------------------------------------------------------------*/
  3142.     /* Code Body                                                      */
  3143.     /*----------------------------------------------------------------*/
  3144.     while (s[i] != '')
  3145.     {
  3146.         n *= 10;
  3147.         n += s[i] - '0';
  3148.         i++;
  3149.     }
  3150.     return n;
  3151. }
  3152. /*****************************************************************************
  3153.  * FUNCTION
  3154.  *  HW_atoi
  3155.  * DESCRIPTION
  3156.  *  
  3157.  * PARAMETERS
  3158.  *  s       [IN]        
  3159.  * RETURNS
  3160.  *  
  3161.  *****************************************************************************/
  3162. S32 HW_atoi(const S8 *s)
  3163. {
  3164.     /*----------------------------------------------------------------*/
  3165.     /* Local Variables                                                */
  3166.     /*----------------------------------------------------------------*/
  3167.     S32 n = 0;
  3168.     S32 i = 0;
  3169.     /*----------------------------------------------------------------*/
  3170.     /* Code Body                                                      */
  3171.     /*----------------------------------------------------------------*/
  3172.     while (s[i] != '')
  3173.     {
  3174.         n *= 10;
  3175.         n += s[i] - '0';
  3176.         i++;
  3177.     }
  3178.     return n;
  3179. }
  3180. /*****************************************************************************
  3181.  * FUNCTION
  3182.  *  UI_atoi
  3183.  * DESCRIPTION
  3184.  *  
  3185.  * PARAMETERS
  3186.  *  s       [IN]        
  3187.  * RETURNS
  3188.  *  
  3189.  *****************************************************************************/
  3190. S32 UI_atoi(UI_string_type s)
  3191. {
  3192.     /*----------------------------------------------------------------*/
  3193.     /* Local Variables                                                */
  3194.     /*----------------------------------------------------------------*/
  3195.     S8 ts[32];
  3196.     S32 conv;
  3197.     /*----------------------------------------------------------------*/
  3198.     /* Code Body                                                      */
  3199.     /*----------------------------------------------------------------*/
  3200.     if (s == NULL)
  3201.     {
  3202.         return (0);
  3203.     }
  3204.     else
  3205.     {
  3206.         UnicodeToAnsii(ts, (S8*) s);
  3207.         conv = HW_atoi((S8*) ts);
  3208.         return (conv);
  3209.     }
  3210. }
  3211. /*****************************************************************************
  3212.  * FUNCTION
  3213.  *  UI_transparent_color
  3214.  * DESCRIPTION
  3215.  *  
  3216.  * PARAMETERS
  3217.  *  r       [IN]        
  3218.  *  g       [IN]        
  3219.  *  b       [IN]        
  3220.  * RETURNS
  3221.  *  
  3222.  *****************************************************************************/
  3223. UI_transparent_color_type UI_transparent_color(U8 r, U8 g, U8 b)
  3224. {
  3225.     /*----------------------------------------------------------------*/
  3226.     /* Local Variables                                                */
  3227.     /*----------------------------------------------------------------*/
  3228.     /*----------------------------------------------------------------*/
  3229.     /* Code Body                                                      */
  3230.     /*----------------------------------------------------------------*/