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

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.  *
  37.  * Filename:
  38.  * ---------
  39.  *   wgui_categories_PE.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui_Software
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Picture Editor related categoreis.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  *------------------------------------------------------------------------------
  92.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  93.  *============================================================================
  94.  ****************************************************************************/
  95. /* Include MMI header file */
  96. #include "MMI_features.h"
  97. #include "stdC.h"
  98. #include "L4Dr1.h"
  99. #include "PixtelDataTypes.h"
  100. #include "GlobalDefs.h"
  101. #include "gui_data_types.h"
  102. #include "CustDataProts.h"
  103. #include "CustMenuRes.h"
  104. #include "EventsDef.h"
  105. #include "gui_themes.h"
  106. #include "gui.h"
  107. #include "wgui.h"
  108. #include "CustThemesRes.h"
  109. #include "wgui_inputs.h"
  110. #include "wgui_categories.h"
  111. #include "wgui_fixed_menus.h"
  112. #include "wgui_categories_defs.h"
  113. #include "wgui_softkeys.h"
  114. #include "wgui_categories_PE.h"
  115. #include "DebugInitDef.h"
  116. #include "gui_color_slider.h"
  117. #include "gdi_include.h"
  118. #include "wgui_draw_manager.h"
  119. #ifdef __MMI_TOUCH_SCREEN__
  120. #include "wgui_touch_screen.h"
  121. #endif 
  122. /*
  123.  * type definition
  124.  */
  125. #define RED_COLOR   MMI_CAT91_COLOR_SLIDER_RED_COLOR 
  126. #define GREEN_COLOR MMI_CAT91_COLOR_SLIDER_GREEN_COLOR 
  127. #define BLUE_COLOR  MMI_CAT91_COLOR_SLIDER_BLUE_COLOR 
  128. #define TOTAL_COLOR MMI_CAT91_COLOR_SLIDER_TOTAL_COLOR 
  129. typedef struct
  130. {
  131.     color cColor;
  132.     mmi_cat91_color_slider_enum highlighted_slider;
  133. } mmi_cat91_history_struct;
  134. /*
  135.  * Define
  136.  */
  137. #define SLIDER_BAR_WIDTH                  (UI_device_width-10)
  138. #define SLIDER_BAR_HEIGHT                 (10)
  139. #define SLIDER_BAR_GAP                    (14)
  140. #define SELECTED_COLOR_AREA_WIDTH         (40)
  141. #define SELECTED_COLOR_AREA_HEIGHT        (14)
  142. /* 
  143.  * Local Variable
  144.  */
  145. static color_slider cat91_color_slider[TOTAL_COLOR];
  146. static U8 *cat91_color_value[TOTAL_COLOR];
  147. static S32 cat91_selected_color_x;
  148. static S32 cat91_selected_color_y;
  149. #ifdef __MMI_TOUCH_SCREEN__
  150. static S32 cat91_color_slider_bar_y1;
  151. static S32 cat91_color_slider_bar_y2;
  152. static S32 cat91_color_slider_bar_y3;
  153. static S32 cat91_color_slider_bar_y3_bottom;
  154. #endif /* __MMI_TOUCH_SCREEN__ */ 
  155. static color cat91_highlight_color = {122, 211, 255, 100};
  156. static mmi_cat91_color_slider_enum *cat91_highlighted_slider;
  157. static U8 color_slider_gc_percentages[] = 
  158. {
  159.     100
  160. };
  161. static color red_color_slider_gc_colors[] = 
  162. {
  163.     {0, 0, 0, 100},
  164.     {255, 0, 0, 100},
  165. };
  166. static gradient_color red_color_slider_gc = 
  167. {
  168.     red_color_slider_gc_colors,
  169.     color_slider_gc_percentages,
  170.     2
  171. };
  172. static color green_color_slider_gc_colors[] = 
  173. {
  174.     {0, 0, 0, 100},
  175.     {0, 255, 0, 100},
  176. };
  177. static gradient_color green_color_slider_gc = 
  178. {
  179.     green_color_slider_gc_colors,
  180.     color_slider_gc_percentages,
  181.     2
  182. };
  183. static color blue_color_slider_gc_colors[] = 
  184. {
  185.     {0, 0, 0, 100},
  186.     {0, 0, 245, 100},   /* FIXME. avoid transparent color */
  187. };
  188. static gradient_color blue_color_slider_gc = 
  189. {
  190.     blue_color_slider_gc_colors,
  191.     color_slider_gc_percentages,
  192.     2
  193. };
  194. static UI_filled_area red_color_slider_filler = 
  195. {
  196.     UI_FILLED_AREA_TYPE_GRADIENT_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  197.     NULL,
  198.     &red_color_slider_gc,
  199.     {0, 0, 0, 0},
  200.     {0, 0, 0, 0},
  201.     {0, 0, 0, 100},
  202.     {0, 0, 0, 0},
  203.     0,
  204. };
  205. static UI_filled_area green_color_slider_filler = 
  206. {
  207.     UI_FILLED_AREA_TYPE_GRADIENT_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  208.     NULL,
  209.     &green_color_slider_gc,
  210.     {0, 0, 0, 0},
  211.     {0, 0, 0, 0},
  212.     {0, 0, 0, 100},
  213.     {0, 0, 0, 0},
  214.     0,
  215. };
  216. static UI_filled_area blue_color_slider_filler = 
  217. {
  218.     UI_FILLED_AREA_TYPE_GRADIENT_COLOR | UI_FILLED_AREA_SINGLE_BORDER,
  219.     NULL,
  220.     &blue_color_slider_gc,
  221.     {0, 0, 0, 0},
  222.     {0, 0, 0, 0},
  223.     {0, 0, 0, 100},
  224.     {0, 0, 0, 0},
  225.     0,
  226. };
  227. /*
  228.  * Global Variable
  229.  */
  230. /*
  231.  * Global Function
  232.  */
  233. extern BOOL r2lMMIFlag;
  234. extern horizontal_select MMI_inline_select_menu;
  235. extern void UI_dummy_menuitem_displayed_function(S32 index, S32 x1, S32 y1, S32 x2, S32 y2);
  236. /*****************************************************************************
  237.  * FUNCTION
  238.  *  cat91_draw_highlight
  239.  * DESCRIPTION
  240.  *  Draw Highlight color slider area of category91
  241.  * PARAMETERS
  242.  *  x1      [IN]        Start-point of x-coordinate
  243.  *  y1      [IN]        Start-point of y-coordinate
  244.  *  x2      [IN]        End-point of x-coordinate
  245.  *  y2      [IN]        End-point of y-coordinate
  246.  * RETURNS
  247.  *  void
  248.  *****************************************************************************/
  249. void cat91_draw_highlight(S32 x1, S32 y1, S32 x2, S32 y2)
  250. {
  251.     /*----------------------------------------------------------------*/
  252.     /* Local Variables                                                */
  253.     /*----------------------------------------------------------------*/
  254.     /*----------------------------------------------------------------*/
  255.     /* Code Body                                                      */
  256.     /*----------------------------------------------------------------*/
  257.     gdi_draw_solid_rect(
  258.         x1,
  259.         y1,
  260.         x2,
  261.         y2,
  262.         gdi_act_color_from_rgb(255, cat91_highlight_color.r, cat91_highlight_color.g, cat91_highlight_color.b));
  263. }
  264. /*****************************************************************************
  265.  * FUNCTION
  266.  *  cat91_redraw_selected_color
  267.  * DESCRIPTION
  268.  *  Draw selected color preview area of category91
  269.  * PARAMETERS
  270.  *  void
  271.  * RETURNS
  272.  *  void
  273.  *****************************************************************************/
  274. void cat91_redraw_selected_color(void)
  275. {
  276.     /*----------------------------------------------------------------*/
  277.     /* Local Variables                                                */
  278.     /*----------------------------------------------------------------*/
  279.     S32 area_width = SELECTED_COLOR_AREA_WIDTH, area_height = SELECTED_COLOR_AREA_HEIGHT;
  280.     /*----------------------------------------------------------------*/
  281.     /* Code Body                                                      */
  282.     /*----------------------------------------------------------------*/
  283.     if (*cat91_color_value[RED_COLOR] == 0 && *cat91_color_value[GREEN_COLOR] == 0 &&
  284.         *cat91_color_value[BLUE_COLOR] >= 248)
  285.     {
  286.         *cat91_color_value[BLUE_COLOR] = 247;
  287.     }
  288.     gdi_draw_solid_rect(
  289.         cat91_selected_color_x,
  290.         cat91_selected_color_y,
  291.         cat91_selected_color_x + area_width - 1,
  292.         cat91_selected_color_y + area_height - 1,
  293.         gdi_act_color_from_rgb(255, *cat91_color_value[RED_COLOR], *cat91_color_value [GREEN_COLOR], *cat91_color_value [BLUE_COLOR]));
  294. }
  295. /*****************************************************************************
  296.  * FUNCTION
  297.  *  cat91_show_color_sliders
  298.  * DESCRIPTION
  299.  *  Draw color sliders of category91
  300.  * PARAMETERS
  301.  *  void
  302.  * RETURNS
  303.  *  void
  304.  *****************************************************************************/
  305. static void cat91_show_color_sliders(void)
  306. {
  307.     /*----------------------------------------------------------------*/
  308.     /* Local Variables                                                */
  309.     /*----------------------------------------------------------------*/
  310.     color_slider *cs = &cat91_color_slider[*cat91_highlighted_slider];
  311.     /*----------------------------------------------------------------*/
  312.     /* Code Body                                                      */
  313.     /*----------------------------------------------------------------*/
  314.     gdi_layer_push_clip();
  315.     gdi_layer_reset_clip();
  316.     cat91_draw_highlight(0, cs->y - 4, UI_device_width - 1, cs->y + cs->height + cs->sheight + 2);
  317. #ifdef __MMI_TOUCH_SCREEN__
  318.     cat91_color_slider_bar_y1 = cat91_color_slider[RED_COLOR].y - 4;
  319.     cat91_color_slider_bar_y2 = cat91_color_slider[GREEN_COLOR].y - 4;
  320.     cat91_color_slider_bar_y3 = cat91_color_slider[BLUE_COLOR].y - 4;
  321.     cat91_color_slider_bar_y3_bottom =
  322.         cat91_color_slider[BLUE_COLOR].y + cat91_color_slider[BLUE_COLOR].height +
  323.         cat91_color_slider[BLUE_COLOR].sheight + 2;
  324. #endif /* __MMI_TOUCH_SCREEN__ */ 
  325.     gui_color_slider_show(&cat91_color_slider[RED_COLOR]);
  326.     gui_color_slider_show(&cat91_color_slider[GREEN_COLOR]);
  327.     gui_color_slider_show(&cat91_color_slider[BLUE_COLOR]);
  328.     gdi_layer_pop_clip();
  329. }
  330. /*****************************************************************************
  331.  * FUNCTION
  332.  *  cat91_setup_color_sliders
  333.  * DESCRIPTION
  334.  *  Setup color sliders for category91
  335.  * PARAMETERS
  336.  *  R       [IN/OUT]        Value of color Red
  337.  *  G       [IN/OUT]        Value of color Green
  338.  *  B       [IN/OUT]        Value of color Blue
  339.  * RETURNS
  340.  *  void
  341.  *****************************************************************************/
  342. static void cat91_setup_color_sliders(U8 *R, U8 *G, U8 *B)
  343. {
  344.     /*----------------------------------------------------------------*/
  345.     /* Local Variables                                                */
  346.     /*----------------------------------------------------------------*/
  347.     S32 x, y1, y2, y3;
  348.     S32 width = SLIDER_BAR_WIDTH, height = SLIDER_BAR_HEIGHT, gap = SLIDER_BAR_GAP;
  349.     S32 area_height = SELECTED_COLOR_AREA_HEIGHT;
  350.     /*----------------------------------------------------------------*/
  351.     /* Code Body                                                      */
  352.     /*----------------------------------------------------------------*/
  353.     cat91_color_value[RED_COLOR] = R;
  354.     cat91_color_value[GREEN_COLOR] = G;
  355.     cat91_color_value[BLUE_COLOR] = B;
  356.     cat91_selected_color_x = (UI_device_width >> 1) - 20;
  357.     cat91_selected_color_y = (MMI_title_y + MMI_title_height) + 2;
  358.     x = UI_device_width - width - 2;
  359.     y1 = cat91_selected_color_y + area_height + 10;
  360.     y2 = y1 + height + gap - 1;
  361.     y3 = y2 + height + gap - 1;
  362.     gui_color_slider_create(&cat91_color_slider[RED_COLOR], x, y1, width, height);
  363.     gui_color_slider_set_filler(&cat91_color_slider[RED_COLOR], &red_color_slider_filler);
  364.     gui_color_slider_set_range(&cat91_color_slider[RED_COLOR], 32);
  365.     gui_color_slider_set_value(&cat91_color_slider[RED_COLOR], (*R) >> 3);
  366.     gui_color_slider_set_hide_function(&cat91_color_slider[RED_COLOR], cat91_draw_highlight);
  367.     gui_color_slider_create(&cat91_color_slider[GREEN_COLOR], x, y2, width, height);
  368.     gui_color_slider_set_filler(&cat91_color_slider[GREEN_COLOR], &green_color_slider_filler);
  369.     gui_color_slider_set_range(&cat91_color_slider[GREEN_COLOR], 32);
  370.     gui_color_slider_set_value(&cat91_color_slider[GREEN_COLOR], (*G) >> 3);
  371.     gui_color_slider_set_hide_function(&cat91_color_slider[GREEN_COLOR], cat91_draw_highlight);
  372.     gui_color_slider_create(&cat91_color_slider[BLUE_COLOR], x, y3, width, height);
  373.     gui_color_slider_set_filler(&cat91_color_slider[BLUE_COLOR], &blue_color_slider_filler);
  374.     gui_color_slider_set_range(&cat91_color_slider[BLUE_COLOR], 31);
  375.     gui_color_slider_set_value(&cat91_color_slider[BLUE_COLOR], (*B) >> 3);
  376.     gui_color_slider_set_hide_function(&cat91_color_slider[BLUE_COLOR], cat91_draw_highlight);
  377. }
  378. /*****************************************************************************
  379.  * FUNCTION
  380.  *  cat91_redraw_content_area
  381.  * DESCRIPTION
  382.  *  Draw content area of category91
  383.  * PARAMETERS
  384.  *  void
  385.  * RETURNS
  386.  *  void
  387.  *****************************************************************************/
  388. void cat91_redraw_content_area(void)
  389. {
  390.     /*----------------------------------------------------------------*/
  391.     /* Local Variables                                                */
  392.     /*----------------------------------------------------------------*/
  393.     S32 x1, y1, x2, y2;
  394.     S32 width = SELECTED_COLOR_AREA_WIDTH, height = SELECTED_COLOR_AREA_HEIGHT;
  395.     color hc = gui_color(196, 196, 196);
  396.     /*----------------------------------------------------------------*/
  397.     /* Code Body                                                      */
  398.     /*----------------------------------------------------------------*/
  399.     gdi_layer_lock_frame_buffer();
  400.     /* Decide the region */
  401.     x1 = 0;
  402.     y1 = (MMI_title_y + MMI_title_height);
  403.     x2 = UI_device_width - 1;
  404.     y2 = (MMI_title_y + MMI_title_height) + MMI_content_height - 1;
  405.     gdi_layer_reset_clip();
  406.     /* clear background */
  407.     gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_WHITE);
  408.     /* draw the preview area for selected color */
  409.     gdi_draw_rect(
  410.         cat91_selected_color_x - 1,
  411.         cat91_selected_color_y - 1,
  412.         cat91_selected_color_x + width,
  413.         cat91_selected_color_y + height,
  414.         GDI_COLOR_BLACK);
  415.     cat91_redraw_selected_color();
  416.     gdi_draw_line(
  417.         0,
  418.         cat91_selected_color_y + height + 2,
  419.         UI_device_width - 1,
  420.         cat91_selected_color_y + height + 2,
  421.         gdi_act_color_from_rgb(255, hc.r, hc.g, hc.b));
  422.     /* show all color sliders */
  423.     cat91_show_color_sliders();
  424.     gdi_layer_unlock_frame_buffer();
  425.     gdi_layer_blt_previous(x1, y1, x2, y2);
  426. }
  427. /*****************************************************************************
  428.  * FUNCTION
  429.  *  cat91_increase_current_value
  430.  * DESCRIPTION
  431.  *  Increate the value of active color slider
  432.  * PARAMETERS
  433.  *  void
  434.  * RETURNS
  435.  *  void
  436.  *****************************************************************************/
  437. void cat91_increase_current_value(void)
  438. {
  439.     /*----------------------------------------------------------------*/
  440.     /* Local Variables                                                */
  441.     /*----------------------------------------------------------------*/
  442.     color_slider *cs;
  443.     S32 x1, y1, x2, y2;
  444.     U8 *cp;
  445.     /*----------------------------------------------------------------*/
  446.     /* Code Body                                                      */
  447.     /*----------------------------------------------------------------*/
  448.     /* Decide the region */
  449.     x1 = MMI_content_x;
  450.     y1 = MMI_content_y;
  451.     x2 = MMI_content_x + MMI_content_width - 1;
  452.     y2 = MMI_content_y + MMI_content_height - 1;
  453.     /* Decide the active color slider */
  454.     cs = &cat91_color_slider[*cat91_highlighted_slider];
  455.     cp = cat91_color_value[*cat91_highlighted_slider];
  456.     /* Hide active color slider */
  457.     gui_color_slider_hide(cs);
  458.     /* Calculate new value */
  459.     cs->value++;
  460.     if (cs->value >= cs->range)
  461.     {
  462.         cs->value = cs->range - 1;
  463.     }
  464.     *cp = (U8) (cs->value << 3);
  465.     /* Show active color slider */
  466.     gui_color_slider_show(cs);
  467.     /* Update selected color preview area */
  468.     cat91_redraw_selected_color();
  469.     gdi_layer_blt_previous(x1, y1, x2, y2);
  470. }
  471. /*****************************************************************************
  472.  * FUNCTION
  473.  *  cat91_decrease_current_value
  474.  * DESCRIPTION
  475.  *  Decreate the value of active color slider
  476.  * PARAMETERS
  477.  *  void
  478.  * RETURNS
  479.  *  void
  480.  *****************************************************************************/
  481. void cat91_decrease_current_value(void)
  482. {
  483.     /*----------------------------------------------------------------*/
  484.     /* Local Variables                                                */
  485.     /*----------------------------------------------------------------*/
  486.     color_slider *cs;
  487.     S32 x1, y1, x2, y2;
  488.     U8 *cp;
  489.     /*----------------------------------------------------------------*/
  490.     /* Code Body                                                      */
  491.     /*----------------------------------------------------------------*/
  492.     /* Decide the region */
  493.     x1 = MMI_content_x;
  494.     y1 = MMI_content_y;
  495.     x2 = MMI_content_x + MMI_content_width - 1;
  496.     y2 = MMI_content_y + MMI_content_height - 1;
  497.     /* Decide the active color slider */
  498.     cs = &cat91_color_slider[*cat91_highlighted_slider];
  499.     cp = cat91_color_value[*cat91_highlighted_slider];    
  500.     /* Hide active color slider */
  501.     gui_color_slider_hide(cs);
  502.     cs->value--;
  503.     if (cs->value < 0)
  504.     {
  505.         cs->value = 0;
  506.     }
  507.     *cp = (U8) (cs->value << 3);
  508.     /* Show active color slider */
  509.     gui_color_slider_show(cs);
  510.     /* Update selected color preview area */
  511.     cat91_redraw_selected_color();
  512.     gdi_layer_blt_previous(x1, y1, x2, y2);
  513. }
  514. /*****************************************************************************
  515.  * FUNCTION
  516.  *  cat91_goto_previous_slider
  517.  * DESCRIPTION
  518.  *  Change to previous color slider
  519.  * PARAMETERS
  520.  *  void
  521.  * RETURNS
  522.  *  void
  523.  *****************************************************************************/
  524. void cat91_goto_previous_slider(void)
  525. {
  526.     /*----------------------------------------------------------------*/
  527.     /* Local Variables                                                */
  528.     /*----------------------------------------------------------------*/
  529.     /*----------------------------------------------------------------*/
  530.     /* Code Body                                                      */
  531.     /*----------------------------------------------------------------*/
  532.     if (*cat91_highlighted_slider > RED_COLOR)
  533.     {
  534.         (*cat91_highlighted_slider)--;
  535.     }
  536.     cat91_redraw_content_area();
  537. }
  538. /*****************************************************************************
  539.  * FUNCTION
  540.  *  cat91_goto_next_slider
  541.  * DESCRIPTION
  542.  *  Change to next color slider
  543.  * PARAMETERS
  544.  *  void
  545.  * RETURNS
  546.  *  void
  547.  *****************************************************************************/
  548. void cat91_goto_next_slider(void)
  549. {
  550.     /*----------------------------------------------------------------*/
  551.     /* Local Variables                                                */
  552.     /*----------------------------------------------------------------*/
  553.     /*----------------------------------------------------------------*/
  554.     /* Code Body                                                      */
  555.     /*----------------------------------------------------------------*/
  556.     if (*cat91_highlighted_slider < TOTAL_COLOR - 1)
  557.     {
  558.         (*cat91_highlighted_slider)++;
  559.     }
  560.     cat91_redraw_content_area();
  561. }
  562. /*****************************************************************************
  563.  * FUNCTION
  564.  *  cat91_keyboard_key_handler
  565.  * DESCRIPTION
  566.  *  Function to handle keyboard key events.
  567.  * PARAMETERS
  568.  *  vkey_code       [IN]        Key code
  569.  *  key_state       [IN]        Key_state
  570.  * RETURNS
  571.  *  void
  572.  *****************************************************************************/
  573. void cat91_keyboard_key_handler(S32 vkey_code, S32 key_state)
  574. {
  575. #if(MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32)
  576.     /*----------------------------------------------------------------*/
  577.     /* Local Variables                                                */
  578.     /*----------------------------------------------------------------*/
  579.     /*----------------------------------------------------------------*/
  580.     /* Code Body                                                      */
  581.     /*----------------------------------------------------------------*/
  582.     if (key_state)
  583.     {
  584.         switch (vkey_code)
  585.         {
  586.             case 37:
  587.                 cat91_decrease_current_value();
  588.                 break;
  589.             case 39:
  590.                 cat91_increase_current_value();
  591.                 break;
  592.             case 38:
  593.                 cat91_goto_previous_slider();
  594.                 break;
  595.             case 40:
  596.                 cat91_goto_next_slider();
  597.                 break;
  598.         }
  599.     }
  600. #else /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  601.     UI_UNUSED_PARAMETER(vkey_code);
  602.     UI_UNUSED_PARAMETER(key_state);
  603. #endif /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  604. }
  605. #if defined(__MMI_TOUCH_SCREEN__)
  606. /*****************************************************************************
  607.  * FUNCTION
  608.  *  category91_control_area_pen_handler
  609.  * DESCRIPTION
  610.  *  Function to handle pen events.
  611.  * PARAMETERS
  612.  *  point           [IN]        Coordinate of pen position
  613.  *  pen_event       [IN]        Type of pen event
  614.  * RETURNS
  615.  *  void
  616.  *****************************************************************************/
  617. static MMI_BOOL category91_control_area_pen_handler(mmi_pen_point_struct point, mmi_pen_event_type_enum pen_event)
  618. {
  619.     /*----------------------------------------------------------------*/
  620.     /* Local Variables                                                */
  621.     /*----------------------------------------------------------------*/
  622.     BOOL ret = MMI_TRUE;
  623.     gui_slide_control_pen_event_enum slide_event;
  624.     gui_pen_event_param_struct slide_param;
  625.     static color_slider *current_color_slider;
  626.     static U8 *current_color_pointer;
  627.     /*----------------------------------------------------------------*/
  628.     /* Code Body                                                      */
  629.     /*----------------------------------------------------------------*/
  630.     switch (pen_event)
  631.     {
  632.         case MMI_PEN_EVENT_DOWN:
  633.         {
  634.             S32 pen_down_slider = -1;
  635.             color_slider *cs = NULL;
  636.             U8 *cp = NULL;
  637.             current_color_slider = NULL;
  638.             current_color_pointer = NULL;
  639.             if (wgui_color_slider_translate_pen_event
  640.                 (&cat91_color_slider[RED_COLOR], pen_event, point.x, point.y, &slide_event, &slide_param))
  641.             {
  642.                 pen_down_slider = 0;
  643.                 cs = &cat91_color_slider[RED_COLOR];
  644.                 cp = cat91_color_value[RED_COLOR];
  645.             }
  646.             else if (wgui_color_slider_translate_pen_event
  647.                      (&cat91_color_slider[GREEN_COLOR], pen_event, point.x, point.y, &slide_event, &slide_param))
  648.             {
  649.                 pen_down_slider = 1;
  650.                 cs = &cat91_color_slider[GREEN_COLOR];
  651.                 cp = cat91_color_value[GREEN_COLOR];
  652.             }
  653.             else if (wgui_color_slider_translate_pen_event
  654.                      (&cat91_color_slider[BLUE_COLOR], pen_event, point.x, point.y, &slide_event, &slide_param))
  655.             {
  656.                 pen_down_slider = 2;
  657.                 cs = &cat91_color_slider[BLUE_COLOR];
  658.                 cp = cat91_color_value[BLUE_COLOR];
  659.             }
  660.             if (pen_down_slider >= 0)
  661.             {
  662.                 current_color_slider = cs;
  663.                 current_color_pointer = cp;
  664.                 if (pen_down_slider != *cat91_highlighted_slider)
  665.                 {
  666.                     *cat91_highlighted_slider = pen_down_slider;
  667.                     cat91_redraw_content_area();
  668.                 }
  669.                 if (GUI_SLIDE_CONTROL_PEN_JUMP_TO_I == slide_event)
  670.                 {
  671.                     gui_lock_double_buffer();
  672.                     gui_color_slider_hide(cs);
  673.                     cs->value = (S32) slide_param._u.i;
  674.                     gui_color_slider_show(cs);
  675.                     *cp = (U8) (cs->value << 3);
  676.                     cat91_redraw_selected_color();
  677.                     gui_unlock_double_buffer();
  678.                     gui_BLT_double_buffer(
  679.                         MMI_content_x,
  680.                         MMI_content_y,
  681.                         MMI_content_x + MMI_content_width - 1,
  682.                         MMI_content_y + MMI_content_height - 1);
  683.                 }
  684.             }
  685.             else
  686.             {
  687.                 /* Change highlight if needed */
  688.                 if (point.y > cat91_color_slider_bar_y3_bottom)
  689.                 {
  690.                     pen_down_slider = -1;
  691.                 }
  692.                 else if (point.y >= cat91_color_slider_bar_y3)
  693.                 {
  694.                     pen_down_slider = 2;
  695.                 }
  696.                 else if (point.y >= cat91_color_slider_bar_y2)
  697.                 {
  698.                     pen_down_slider = 1;
  699.                 }
  700.                 else if (point.y >= cat91_color_slider_bar_y1)
  701.                 {
  702.                     pen_down_slider = 0;
  703.                 }
  704.                 if (pen_down_slider >= 0 && pen_down_slider != *cat91_highlighted_slider)
  705.                 {
  706.                     *cat91_highlighted_slider = pen_down_slider;
  707.                     cat91_redraw_content_area();
  708.                 }
  709.                 else
  710.                 {
  711.                     ret = MMI_FALSE;
  712.                 }
  713.             }
  714.             break;
  715.         }
  716.         default:
  717.             if (current_color_slider)
  718.             {
  719.                 wgui_color_slider_translate_pen_event(
  720.                     current_color_slider,
  721.                     pen_event,
  722.                     point.x,
  723.                     point.y,
  724.                     &slide_event,
  725.                     &slide_param);
  726.                 if (GUI_SLIDE_CONTROL_PEN_JUMP_TO_I == slide_event)
  727.                 {
  728.                     gui_lock_double_buffer();
  729.                     gui_color_slider_hide(current_color_slider);
  730.                     current_color_slider->value = (S32) slide_param._u.i;
  731.                     gui_color_slider_show(current_color_slider);
  732.                     *current_color_pointer = (U8) (current_color_slider->value << 3);
  733.                     cat91_redraw_selected_color();
  734.                     gui_unlock_double_buffer();
  735.                     gui_BLT_double_buffer(
  736.                         MMI_content_x,
  737.                         MMI_content_y,
  738.                         MMI_content_x + MMI_content_width - 1,
  739.                         MMI_content_y + MMI_content_height - 1);
  740.                 }
  741.                 if (pen_event == MMI_PEN_EVENT_UP || pen_event == MMI_PEN_EVENT_ABORT)
  742.                 {
  743.                     current_color_slider = NULL;
  744.                     current_color_pointer = NULL;
  745.                 }
  746.             }
  747.             break;
  748.     }
  749.     return ret;
  750. }
  751. /*****************************************************************************
  752.  * FUNCTION
  753.  *  category91_control_area_pen_down_handler
  754.  * DESCRIPTION
  755.  *  Function to handle pen down event
  756.  * PARAMETERS
  757.  *  point       [IN]        Coordinate of pen position
  758.  * RETURNS
  759.  *  void
  760.  *****************************************************************************/
  761. static MMI_BOOL category91_control_area_pen_down_handler(mmi_pen_point_struct point)
  762. {
  763.     /*----------------------------------------------------------------*/
  764.     /* Local Variables                                                */
  765.     /*----------------------------------------------------------------*/
  766.     /*----------------------------------------------------------------*/
  767.     /* Code Body                                                      */
  768.     /*----------------------------------------------------------------*/
  769.     return category91_control_area_pen_handler(point, MMI_PEN_EVENT_DOWN);
  770. }
  771. /*****************************************************************************
  772.  * FUNCTION
  773.  *  category91_control_area_pen_move_handler
  774.  * DESCRIPTION
  775.  *  Function to handle pen move event
  776.  * PARAMETERS
  777.  *  point       [IN]        Coordinate of pen position
  778.  * RETURNS
  779.  *  void
  780.  *****************************************************************************/
  781. static MMI_BOOL category91_control_area_pen_move_handler(mmi_pen_point_struct point)
  782. {
  783.     /*----------------------------------------------------------------*/
  784.     /* Local Variables                                                */
  785.     /*----------------------------------------------------------------*/
  786.     /*----------------------------------------------------------------*/
  787.     /* Code Body                                                      */
  788.     /*----------------------------------------------------------------*/
  789.     return category91_control_area_pen_handler(point, MMI_PEN_EVENT_MOVE);
  790. }
  791. /*****************************************************************************
  792.  * FUNCTION
  793.  *  category91_control_area_pen_longtap_handler
  794.  * DESCRIPTION
  795.  *  Function to handle pen longtap event
  796.  * PARAMETERS
  797.  *  point       [IN]        Coordinate of pen position
  798.  * RETURNS
  799.  *  void
  800.  *****************************************************************************/
  801. static MMI_BOOL category91_control_area_pen_longtap_handler(mmi_pen_point_struct point)
  802. {
  803.     /*----------------------------------------------------------------*/
  804.     /* Local Variables                                                */
  805.     /*----------------------------------------------------------------*/
  806.     /*----------------------------------------------------------------*/
  807.     /* Code Body                                                      */
  808.     /*----------------------------------------------------------------*/
  809.     return category91_control_area_pen_handler(point, MMI_PEN_EVENT_LONG_TAP);
  810. }
  811. /*****************************************************************************
  812.  * FUNCTION
  813.  *  category91_control_area_pen_repeat_handler
  814.  * DESCRIPTION
  815.  *  Function to handle pen repeat event
  816.  * PARAMETERS
  817.  *  point       [IN]        Coordinate of pen position
  818.  * RETURNS
  819.  *  void
  820.  *****************************************************************************/
  821. static MMI_BOOL category91_control_area_pen_repeat_handler(mmi_pen_point_struct point)
  822. {
  823.     /*----------------------------------------------------------------*/
  824.     /* Local Variables                                                */
  825.     /*----------------------------------------------------------------*/
  826.     /*----------------------------------------------------------------*/
  827.     /* Code Body                                                      */
  828.     /*----------------------------------------------------------------*/
  829.     return category91_control_area_pen_handler(point, MMI_PEN_EVENT_REPEAT);
  830. }
  831. /*****************************************************************************
  832.  * FUNCTION
  833.  *  category91_control_area_pen_up_handler
  834.  * DESCRIPTION
  835.  *  Function to handle pen up event
  836.  * PARAMETERS
  837.  *  point       [IN]        Coordinate of pen position
  838.  * RETURNS
  839.  *  void
  840.  *****************************************************************************/
  841. static MMI_BOOL category91_control_area_pen_up_handler(mmi_pen_point_struct point)
  842. {
  843.     /*----------------------------------------------------------------*/
  844.     /* Local Variables                                                */
  845.     /*----------------------------------------------------------------*/
  846.     /*----------------------------------------------------------------*/
  847.     /* Code Body                                                      */
  848.     /*----------------------------------------------------------------*/
  849.     return category91_control_area_pen_handler(point, MMI_PEN_EVENT_UP);
  850. }
  851. /*****************************************************************************
  852.  * FUNCTION
  853.  *  category91_control_area_pen_abort_handler
  854.  * DESCRIPTION
  855.  *  Function to handle pen abort event
  856.  * PARAMETERS
  857.  *  point       [IN]        Coordinate of pen position
  858.  * RETURNS
  859.  *  void
  860.  *****************************************************************************/
  861. static MMI_BOOL category91_control_area_pen_abort_handler(mmi_pen_point_struct point)
  862. {
  863.     /*----------------------------------------------------------------*/
  864.     /* Local Variables                                                */
  865.     /*----------------------------------------------------------------*/
  866.     /*----------------------------------------------------------------*/
  867.     /* Code Body                                                      */
  868.     /*----------------------------------------------------------------*/
  869.     return category91_control_area_pen_handler(point, MMI_PEN_EVENT_ABORT);
  870. }
  871. #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  872. /*****************************************************************************
  873.  * FUNCTION
  874.  *  DrawCate91CategoryControlArea
  875.  * DESCRIPTION
  876.  *  Function to draw category controll area of category91
  877.  * PARAMETERS
  878.  *  coordinate      [IN]        Coordinate of pen position
  879.  * RETURNS
  880.  *  void
  881.  *****************************************************************************/
  882. void DrawCate91CategoryControlArea(dm_coordinates *coordinate)
  883. {
  884.     /*----------------------------------------------------------------*/
  885.     /* Local Variables                                                */
  886.     /*----------------------------------------------------------------*/
  887.     /*----------------------------------------------------------------*/
  888.     /* Code Body                                                      */
  889.     /*----------------------------------------------------------------*/
  890.     cat91_redraw_content_area();
  891. }
  892. /*****************************************************************************
  893.  * FUNCTION
  894.  *  ShowCategory91Screen
  895.  * DESCRIPTION
  896.  *  Displays the color picker screen
  897.  * PARAMETERS
  898.  *  title                   [IN]        Title for the screen
  899.  *  title_icon              [IN]        Icon shown with the title
  900.  *  left_softkey            [IN]        Left softkey label
  901.  *  left_softkey_icon       [IN]        Icon for the Left softkey
  902.  *  right_softkey           [IN]        Right softkey label
  903.  *  right_softkey_icon      [IN]        Icon for the Right softkey
  904.  *  R                       [IN]        Pointer to value of color red
  905.  *  G                       [IN]        Pointer to value of color green
  906.  *  B                       [IN]        Pointer to value of color blue
  907.  *  history_buffer          [IN]        History buffer
  908.  * RETURNS
  909.  *  void
  910.  *****************************************************************************/
  911. void ShowCategory91Screen(
  912.         U16 title,
  913.         U16 title_icon,
  914.         U16 left_softkey,
  915.         U16 left_softkey_icon,
  916.         U16 right_softkey,
  917.         U16 right_softkey_icon,
  918.         U8 *R,
  919.         U8 *G,
  920.         U8 *B,
  921.         mmi_cat91_color_slider_enum *highlighted_slider, /* Fred */
  922.         U8 *history_buffer)
  923. {
  924.     /*----------------------------------------------------------------*/
  925.     /* Local Variables                                                */
  926.     /*----------------------------------------------------------------*/
  927.     dm_data_struct dm_data;
  928.     /*----------------------------------------------------------------*/
  929.     /* Code Body                                                      */
  930.     /*----------------------------------------------------------------*/
  931.     gdi_layer_lock_frame_buffer();
  932.     MMI_menu_shortcut_number = -1;
  933.     /* Setup softkeys */
  934.     change_left_softkey(left_softkey, left_softkey_icon);
  935.     change_right_softkey(right_softkey, right_softkey_icon);
  936.     SetupCategoryKeyHandlers();
  937.     /* Setup title */
  938.     MMI_title_string = (UI_string_type) get_string(title);
  939.     MMI_title_icon = (PU8) get_image(title_icon);
  940.     /* Get color information from history buffer */
  941.     if (history_buffer != NULL)
  942.     {
  943.         mmi_cat91_history_struct *hist = (mmi_cat91_history_struct *)history_buffer;
  944.         *R = hist->cColor.r;
  945.         *G = hist->cColor.g;
  946.         *B = hist->cColor.b;
  947.         *highlighted_slider = hist->highlighted_slider;
  948.     }
  949.     /* Setup color sliders */
  950.     cat91_setup_color_sliders(R, G, B);
  951.     cat91_highlighted_slider = highlighted_slider;
  952.     register_keyboard_key_handler(cat91_keyboard_key_handler);
  953.     /* Setup key handlers */
  954.     SetKeyHandler(cat91_goto_previous_slider, KEY_UP_ARROW, KEY_EVENT_DOWN);
  955.     SetKeyHandler(cat91_goto_next_slider, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  956.     SetKeyHandler(cat91_decrease_current_value, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  957.     SetKeyHandler(cat91_increase_current_value, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  958.     gdi_layer_unlock_frame_buffer();
  959.     ExitCategoryFunction = UI_dummy_function;
  960.     dm_reset_context();
  961.     dm_setup_category_functions(dm_redraw_category_screen, GetCategory91History, dummy_get_history_size);
  962.     dm_add_rectangle(*current_MMI_theme->UI_white_color, 1);
  963.     dm_register_category_controlled_callback(DrawCate91CategoryControlArea);
  964.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  965.     dm_data.s32CatId = MMI_CATEGORY91_ID;
  966.     dm_data.s32flags = 0;
  967.     dm_setup_data(&dm_data);
  968. #ifdef __MMI_TOUCH_SCREEN__
  969.     wgui_register_category_screen_control_area_pen_handlers(
  970.         category91_control_area_pen_down_handler,
  971.         MMI_PEN_EVENT_DOWN);
  972.     wgui_register_category_screen_control_area_pen_handlers(category91_control_area_pen_up_handler, MMI_PEN_EVENT_UP);
  973.     wgui_register_category_screen_control_area_pen_handlers(
  974.         category91_control_area_pen_move_handler,
  975.         MMI_PEN_EVENT_MOVE);
  976.     wgui_register_category_screen_control_area_pen_handlers(
  977.         category91_control_area_pen_repeat_handler,
  978.         MMI_PEN_EVENT_REPEAT);
  979.     wgui_register_category_screen_control_area_pen_handlers(
  980.         category91_control_area_pen_longtap_handler,
  981.         MMI_PEN_EVENT_LONG_TAP);
  982.     wgui_register_category_screen_control_area_pen_handlers(
  983.         category91_control_area_pen_abort_handler,
  984.         MMI_PEN_EVENT_ABORT);
  985. #endif /* __MMI_TOUCH_SCREEN__ */ 
  986.     dm_redraw_category_screen();
  987. }
  988. /*****************************************************************************
  989.  * FUNCTION
  990.  *  GetCategory91History
  991.  * DESCRIPTION
  992.  *  Gets the history buffer for the color picker screen
  993.  * PARAMETERS
  994.  *  history_buffer      [IN/OUT]        History buffer
  995.  * RETURNS
  996.  *  void
  997.  *****************************************************************************/
  998. U8 *GetCategory91History(U8 *history_buffer)
  999. {
  1000.     /*----------------------------------------------------------------*/
  1001.     /* Local Variables                                                */
  1002.     /*----------------------------------------------------------------*/
  1003.     mmi_cat91_history_struct *hist = (mmi_cat91_history_struct *)history_buffer;
  1004.     /*----------------------------------------------------------------*/
  1005.     /* Code Body                                                      */
  1006.     /*----------------------------------------------------------------*/
  1007.     hist->cColor.r = *cat91_color_value[RED_COLOR];
  1008.     hist->cColor.g = *cat91_color_value[GREEN_COLOR];
  1009.     hist->cColor.b = *cat91_color_value[BLUE_COLOR];
  1010.     hist->highlighted_slider = *cat91_highlighted_slider;
  1011.     return (history_buffer);
  1012. }