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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright 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.  *  wgui_panel.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  MAUI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  Panel - UI component
  47.  *
  48.  * Author:
  49.  * -------
  50.  * -------
  51.  *
  52.  *============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  *------------------------------------------------------------------------------
  63.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  64.  *============================================================================
  65.  ****************************************************************************/
  66. #include "wgui_panel.h"
  67. #include "gui_panel.h"
  68. #include "EventsGprot.h"
  69. /*****************************************************************************              
  70.  * Local Variable                                                                    
  71.  *****************************************************************************/
  72. static gui_panel_struct MMI_panel;
  73. /*****************************************************************************              
  74.  * Local Function                                                                    
  75.  *****************************************************************************/
  76. static void wgui_panel_general_key_handler(void)
  77. {
  78.     /*----------------------------------------------------------------*/
  79.     /* Local Variables                                                */
  80.     /*----------------------------------------------------------------*/
  81.     U16 keycode, keytype;
  82.     
  83.     /*----------------------------------------------------------------*/
  84.     /* Code Body                                                      */
  85.     /*----------------------------------------------------------------*/
  86.     GetkeyInfo(&keycode, &keytype);
  87.     gui_panel_general_key_handler(&MMI_panel, keycode, keytype);
  88. }
  89. /*****************************************************************************              
  90.  * Extern Global Function                                                                    
  91.  *****************************************************************************/
  92. void wgui_panel_create(
  93.         S32 x, 
  94.         S32 y, 
  95.         S32 width, 
  96.         S32 height, 
  97.         gui_util_painter_struct background,
  98.         MMI_BOOL display_focus)
  99. {
  100.     /*----------------------------------------------------------------*/
  101.     /* Local Variables                                                */
  102.     /*----------------------------------------------------------------*/
  103.     /*----------------------------------------------------------------*/
  104.     /* Code Body                                                      */
  105.     /*----------------------------------------------------------------*/
  106.     gui_panel_create(
  107.         &MMI_panel,
  108.         x,
  109.         y,
  110.         width,
  111.         height,
  112.         background,
  113.         display_focus);
  114. }
  115. void wgui_panel_close(void)
  116. {
  117.     /*----------------------------------------------------------------*/
  118.     /* Local Variables                                                */
  119.     /*----------------------------------------------------------------*/
  120.     /*----------------------------------------------------------------*/
  121.     /* Code Body                                                      */
  122.     /*----------------------------------------------------------------*/
  123.     // TODO: stop animation timer
  124. }
  125. void wgui_panel_show(void)
  126. {
  127.     /*----------------------------------------------------------------*/
  128.     /* Local Variables                                                */
  129.     /*----------------------------------------------------------------*/
  130.     /*----------------------------------------------------------------*/
  131.     /* Code Body                                                      */
  132.     /*----------------------------------------------------------------*/
  133.     gui_panel_show(&MMI_panel);
  134. }
  135. void wgui_panel_set_element_focus(
  136.         S32 element_index,
  137.         MMI_BOOL update_display)
  138. {
  139.     /*----------------------------------------------------------------*/
  140.     /* Local Variables                                                */
  141.     /*----------------------------------------------------------------*/
  142.     /*----------------------------------------------------------------*/
  143.     /* Code Body                                                      */
  144.     /*----------------------------------------------------------------*/
  145.     gui_panel_set_element_focus(
  146.         &MMI_panel,
  147.         element_index,
  148.         update_display);
  149. }
  150. S32 wgui_panel_add_element(
  151.         S32 x,
  152.         S32 y,
  153.         S32 width,
  154.         S32 height,
  155.         U16 keycode,
  156.         FuncPtr up_event_callback,
  157.         FuncPtr repeat_event_callback,
  158.         gui_util_painter_struct normal_painter,
  159.         gui_util_painter_struct down_painter,
  160.         gui_util_painter_struct focussed_painter,
  161.         MMI_BOOL redraw_bg_after_state_changed)
  162. {
  163.     /*----------------------------------------------------------------*/
  164.     /* Local Variables                                                */
  165.     /*----------------------------------------------------------------*/
  166.     /*----------------------------------------------------------------*/
  167.     /* Code Body                                                      */
  168.     /*----------------------------------------------------------------*/
  169.     return gui_panel_add_element(
  170.             &MMI_panel,
  171.             x,
  172.             y,
  173.             width,
  174.             height,
  175.             keycode,
  176.             up_event_callback,
  177.             repeat_event_callback,
  178.             normal_painter,
  179.             down_painter,
  180.             focussed_painter,
  181.             redraw_bg_after_state_changed);
  182. }
  183. void wgui_panel_register_keys(void)
  184. {
  185.     /*----------------------------------------------------------------*/
  186.     /* Local Variables                                                */
  187.     /*----------------------------------------------------------------*/
  188.     S32 elem_idx;
  189.     
  190.     /*----------------------------------------------------------------*/
  191.     /* Code Body                                                      */
  192.     /*----------------------------------------------------------------*/
  193.     for (elem_idx = 0; elem_idx < MMI_panel.element_count; elem_idx++)
  194.     {
  195.         gui_panel_element_struct *e = &MMI_panel.elements[elem_idx];
  196.         if (e->keycode != KEY_INVALID)
  197.         {
  198.             SetKeyHandler(wgui_panel_general_key_handler, e->keycode, KEY_EVENT_DOWN);
  199.             SetKeyHandler(wgui_panel_general_key_handler, e->keycode, KEY_EVENT_UP);
  200.             SetKeyHandler(wgui_panel_general_key_handler, e->keycode, KEY_LONG_PRESS);
  201.             SetKeyHandler(wgui_panel_general_key_handler, e->keycode, KEY_REPEAT);
  202.         }
  203.     }
  204. }