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

MTK

开发平台:

C/C++

  1.             nInlinePenSize = 0;
  2.             break;
  3.     }
  4. #ifndef __MMI_TOUCH_SCREEN__    /* PMT MANISH   20050616 */
  5.     switch (gpPicEditPen->penMove)
  6.     {
  7.         case PIC_EDIT_PEN_MOVE_1:
  8.             nInlinePenMoveFactor = 0;
  9.             break;
  10.         case PIC_EDIT_PEN_MOVE_2:
  11.             nInlinePenMoveFactor = 1;
  12.             break;
  13.         case PIC_EDIT_PEN_MOVE_3:
  14.             nInlinePenMoveFactor = 2;
  15.             break;
  16.         case PIC_EDIT_PEN_MOVE_4:
  17.             nInlinePenMoveFactor = 3;
  18.             break;
  19.         default:
  20.             nInlinePenMoveFactor = 0;
  21.             break;
  22.     }
  23. #endif /* __MMI_TOUCH_SCREEN__ */ 
  24.     for (iCount = 0; iCount < MAX_TYPE_PEN_COLOR; ++iCount)
  25.     {
  26.         pInlinePenColorIndexList[iCount] = (U8*) GetString((U16) (iCount + 1 + STR_PE_COLOR_NONE));
  27.         inlinePERGBlist[iCount][0] = (U8) ((0xFF000000 & gPEColorRGB[iCount + 1]) >> 24);
  28.         inlinePERGBlist[iCount][1] = (U8) ((0x00FF0000 & gPEColorRGB[iCount + 1]) >> 16);
  29.         inlinePERGBlist[iCount][2] = (U8) ((0x0000FF00 & gPEColorRGB[iCount + 1]) >> 8);
  30.     }
  31.     inlinePERGBlist[iCount - 1][0] = (U8) ((0xFF000000 & gPEColorRGB[iCount - 1]) >> 24);
  32.     inlinePERGBlist[iCount - 1][1] = (U8) ((0x00FF0000 & gPEColorRGB[iCount - 1]) >> 16);
  33.     inlinePERGBlist[iCount - 1][2] = (U8) ((0x0000FF00 & gPEColorRGB[iCount - 1]) >> 8);
  34.     inputBuffer = GetCurrNInputBuffer(SCR_PE_PEN_SETTING, &inputBufferSize);    /* added for inline edit history */
  35.     RegisterHighlightHandler(PicEditPenSettingInlineEdit);
  36.     g_pe_color_index = nInlinePenColorIndex + 1;
  37.     SetPicEditPenSettingInlineItemData();
  38.     if (inputBuffer != NULL)
  39.         SetCategory57Data(PicEditInLineItems,
  40. #ifdef __MMI_TOUCH_SCREEN__
  41.                           4,
  42. #else 
  43.                           6,
  44. #endif 
  45.                           inputBuffer);
  46.     ShowCategory57Screen(STR_PE_EDIT_OPT_PEN_SETTING, GetRootTitleIcon(MENU_PICTURE_EDITOR),
  47.                          STR_GLOBAL_OK, IMG_GLOBAL_OK, STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
  48. #ifdef __MMI_TOUCH_SCREEN__
  49.                          4,
  50. #else 
  51.                          6,
  52. #endif 
  53.                          NULL, PicEditInLineItems, 0, guiBuffer);
  54.     DisableCategory57ScreenDone();
  55.     RegisterInlineSelectHighlightHandler(&PicEditInLineItems[PE_PEN_SIZE_SELECT], PicEditPenSettingSelectInlineEdit);
  56. #ifndef __MMI_TOUCH_SCREEN__
  57.     RegisterInlineSelectHighlightHandler(&PicEditInLineItems[PE_PEN_MOVE_SELECT], PicEditPenSettingSelectInlineEdit);
  58. #endif 
  59.     RegisterInlineSelectHighlightHandler(&PicEditInLineItems[PE_PEN_COLOR_SELECT], PicEditPenSettingSelectInlineEdit);
  60.     PicEditPenSettingSelectInlineEdit(-1);
  61.     /* SetExitHandler(SCR_PE_PEN_SETTING, ExitScr4PicEditPenSetting); */
  62. }
  63. /*****************************************************************************
  64.  * FUNCTION
  65.  *  ExitScr4PicEditPenSetting
  66.  * DESCRIPTION
  67.  *  Exit function for EntryScr4PicEditPenSetting
  68.  * PARAMETERS
  69.  *  void
  70.  * RETURNS
  71.  *  void
  72.  *****************************************************************************/
  73. void ExitScr4PicEditPenSetting(void)
  74. {
  75.     /*----------------------------------------------------------------*/
  76.     /* Local Variables                                                */
  77.     /*----------------------------------------------------------------*/
  78.     history h;
  79.     S16 nHistory = 0;
  80.     U16 inputBufferSize;
  81.     /*----------------------------------------------------------------*/
  82.     /* Code Body                                                      */
  83.     /*----------------------------------------------------------------*/
  84.     CloseCategory57Screen();
  85.     h.scrnID = SCR_PE_PEN_SETTING;
  86.     h.entryFuncPtr = EntryScr4PicEditPenSetting;
  87.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  88.     GetCategory57History(h.guiBuffer);
  89.     inputBufferSize = (S16) GetCategory57DataSize();    /* added for inline edit history */
  90.     GetCategory57Data((U8*) h.inputBuffer);             /* added for inline edit history */
  91.     AddNHistory(h, inputBufferSize);                    /* added for inline edit history */
  92. }
  93. /*****************************************************************************
  94.  * FUNCTION
  95.  *  GoBackPicEditPenSettingHistory
  96.  * DESCRIPTION
  97.  *  Go Back function for Pen settign screen
  98.  * PARAMETERS
  99.  *  void
  100.  * RETURNS
  101.  *  void
  102.  *****************************************************************************/
  103. void GoBackPicEditPenSettingHistory(void)
  104. {
  105.     /*----------------------------------------------------------------*/
  106.     /* Local Variables                                                */
  107.     /*----------------------------------------------------------------*/
  108.     /*----------------------------------------------------------------*/
  109.     /* Code Body                                                      */
  110.     /*----------------------------------------------------------------*/
  111.     CloseCategory57Screen();
  112.     GoBackHistory();
  113. }
  114. /*****************************************************************************
  115.  * FUNCTION
  116.  *  PicEditPenSettingInlineEdit
  117.  * DESCRIPTION
  118.  *  Changes the softkeys for pen setting screen
  119.  * PARAMETERS
  120.  *  nIndex      [IN]        
  121.  * RETURNS
  122.  *  void
  123.  *****************************************************************************/
  124. void PicEditPenSettingInlineEdit(S32 nIndex)
  125. {
  126.     /*----------------------------------------------------------------*/
  127.     /* Local Variables                                                */
  128.     /*----------------------------------------------------------------*/
  129.     /*----------------------------------------------------------------*/
  130.     /* Code Body                                                      */
  131.     /*----------------------------------------------------------------*/
  132.     nSelPEPenSetting = (U8) nIndex;
  133.     ChangePenSettingSoftkey();
  134. }
  135. /*****************************************************************************
  136.  * FUNCTION
  137.  *  PicEditPenSettingSelectInlineEdit
  138.  * DESCRIPTION
  139.  *  changes softkey when inline item selected on pen setting screen
  140.  * PARAMETERS
  141.  *  index       [IN]        
  142.  * RETURNS
  143.  *  void
  144.  *****************************************************************************/
  145. void PicEditPenSettingSelectInlineEdit(S32 index)
  146. {
  147.     /*----------------------------------------------------------------*/
  148.     /* Local Variables                                                */
  149.     /*----------------------------------------------------------------*/
  150.     /*----------------------------------------------------------------*/
  151.     /* Code Body                                                      */
  152.     /*----------------------------------------------------------------*/
  153.     if ((nSelPEPenSetting == PE_PEN_COLOR_SELECT) && (index != -1))
  154.     {
  155.         g_pe_color_index = index;
  156.     }
  157.     ChangePenSettingSoftkey();
  158. }
  159. /*****************************************************************************
  160.  * FUNCTION
  161.  *  ChangePenSettingSoftkey
  162.  * DESCRIPTION
  163.  *  Changes softkey on pen setting screen
  164.  * PARAMETERS
  165.  *  void
  166.  * RETURNS
  167.  *  void
  168.  *****************************************************************************/
  169. void ChangePenSettingSoftkey(void)
  170. {
  171.     /*----------------------------------------------------------------*/
  172.     /* Local Variables                                                */
  173.     /*----------------------------------------------------------------*/
  174.     /*----------------------------------------------------------------*/
  175.     /* Code Body                                                      */
  176.     /*----------------------------------------------------------------*/
  177.     if (CheckPicEditPenSettingChange())
  178.     {
  179.         ChangeRightSoftkey(STR_GLOBAL_DONE, IMG_GLOBAL_BACK);
  180.         SetRightSoftkeyFunction(EntryScr4PicEditPenSettingSaveConfirm, KEY_EVENT_UP);
  181.     }
  182.     else
  183.     {
  184.         ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  185.         SetRightSoftkeyFunction(GoBackPicEditPenSettingHistory, KEY_EVENT_UP);
  186.     }
  187.     if ((nSelPEPenSetting == PE_PEN_COLOR_SELECT) && (g_pe_color_index + 1 == PE_COLOR_CUSTOM_1))
  188.     {
  189.         ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  190.         SetCategory57LeftSoftkeyFunction(EntryScr4PicEditCustomColor);
  191.     }
  192.     else
  193.     {
  194.         ChangeLeftSoftkey((U16) NULL, (U16) NULL);
  195.     }
  196. }
  197. /*****************************************************************************
  198.  * FUNCTION
  199.  *  EntryScr4PicEditPenSettingSaveConfirm
  200.  * DESCRIPTION
  201.  *  Confirmation screen for save pen settings
  202.  * PARAMETERS
  203.  *  void
  204.  * RETURNS
  205.  *  void
  206.  *****************************************************************************/
  207. void EntryScr4PicEditPenSettingSaveConfirm(void)
  208. {
  209. #if (0)
  210. /* under construction !*/
  211. /* under construction !*/
  212. /* under construction !*/
  213. /* under construction !*/
  214. /* under construction !*/
  215. /* under construction !*/
  216. /* under construction !*/
  217. /* under construction !*/
  218. /* under construction !*/
  219. /* under construction !*/
  220. /* under construction !*/
  221. /* under construction !*/
  222. /* under construction !*/
  223. /* under construction !*/
  224. #endif /* (0) */ 
  225.     /*----------------------------------------------------------------*/
  226.     /* Code Body                                                      */
  227.     /*----------------------------------------------------------------*/
  228.     DisplayConfirm(
  229.         STR_GLOBAL_YES,
  230.         IMG_GLOBAL_YES,
  231.         STR_GLOBAL_NO,
  232.         IMG_GLOBAL_NO,
  233.         get_string(STR_GLOBAL_SAVE),
  234.         IMG_GLOBAL_QUESTION,
  235.         WARNING_TONE);
  236.     SetLeftSoftkeyFunction(SavePicEditPenSetting, KEY_EVENT_UP);
  237.     SetRightSoftkeyFunction(GoBackPicEditPenSettingConfirmHistory, KEY_EVENT_UP);
  238.     /* playRequestedTone(WARNING_TONE) ; */
  239.     /* SetExitHandler(SCR_PE_PEN_SETTING_SAVE, ExitScr4PicEditPenSettingSaveConfirm); */
  240. }
  241. /*****************************************************************************
  242.  * FUNCTION
  243.  *  ExitScr4PicEditPenSettingSaveConfirm
  244.  * DESCRIPTION
  245.  *  Exit function EntryScr4PicEditPenSettingSaveConfirm
  246.  * PARAMETERS
  247.  *  void
  248.  * RETURNS
  249.  *  void
  250.  *****************************************************************************/
  251. void ExitScr4PicEditPenSettingSaveConfirm(void)
  252. {
  253.     /*----------------------------------------------------------------*/
  254.     /* Local Variables                                                */
  255.     /*----------------------------------------------------------------*/
  256.     history h;  /* Variable to hold the history data */
  257.     S16 nHistory = 0;
  258.     /*----------------------------------------------------------------*/
  259.     /* Code Body                                                      */
  260.     /*----------------------------------------------------------------*/
  261.     stopRequestedTone(WARNING_TONE);
  262.     h.scrnID = SCR_PE_PEN_SETTING_SAVE;
  263.     h.entryFuncPtr = EntryScr4PicEditPenSettingSaveConfirm;
  264.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  265.     GetCategoryHistory(h.guiBuffer);
  266. }
  267. /*****************************************************************************
  268.  * FUNCTION
  269.  *  GoBackPicEditPenSettingConfirmHistory
  270.  * DESCRIPTION
  271.  *  Go Back History for save pen setting coonfirmatioon screen
  272.  * PARAMETERS
  273.  *  void
  274.  * RETURNS
  275.  *  void
  276.  *****************************************************************************/
  277. void GoBackPicEditPenSettingConfirmHistory(void)
  278. {
  279.     /*----------------------------------------------------------------*/
  280.     /* Local Variables                                                */
  281.     /*----------------------------------------------------------------*/
  282.     /*----------------------------------------------------------------*/
  283.     /* Code Body                                                      */
  284.     /*----------------------------------------------------------------*/
  285.     CloseCategory57Screen();
  286.     DeleteUptoScrID(SCR_PE_EDIT_PIC_OPT);
  287.     GoBackHistory();
  288. }
  289. /*****************************************************************************
  290.  * FUNCTION
  291.  *  SavePicEditPenSetting
  292.  * DESCRIPTION
  293.  *  Saves Pen setting
  294.  * PARAMETERS
  295.  *  void
  296.  * RETURNS
  297.  *  void
  298.  *****************************************************************************/
  299. void SavePicEditPenSetting(void)
  300. {
  301.     /*----------------------------------------------------------------*/
  302.     /* Local Variables                                                */
  303.     /*----------------------------------------------------------------*/
  304.     U8 infoPalette[MAX_TYPE_PEN_COLOR * 4];
  305.     /*----------------------------------------------------------------*/
  306.     /* Code Body                                                      */
  307.     /*----------------------------------------------------------------*/
  308.     gpPicEditPen->penColorIndex = (U8) nInlinePenColorIndex + 1;
  309.     switch (nInlinePenSize)
  310.     {
  311.         case 0:
  312.             gpPicEditPen->penPixel = PIC_EDIT_PEN_PIXEL_1;
  313.             break;
  314.         case 1:
  315.             gpPicEditPen->penPixel = PIC_EDIT_PEN_PIXEL_2;
  316.             break;
  317.         case 2:
  318.             gpPicEditPen->penPixel = PIC_EDIT_PEN_PIXEL_3;
  319.             break;
  320.         case 3:
  321.             gpPicEditPen->penPixel = PIC_EDIT_PEN_PIXEL_4;
  322.             break;
  323.         default:
  324.             gpPicEditPen->penPixel = PIC_EDIT_PEN_PIXEL_1;
  325.             break;
  326.     }
  327. #ifndef __MMI_TOUCH_SCREEN__    /* PMT MANISH   20050616 */
  328.     switch (nInlinePenMoveFactor)
  329.     {
  330.         case 0:
  331.             gpPicEditPen->penMove = PIC_EDIT_PEN_MOVE_1;
  332.             break;
  333.         case 1:
  334.             gpPicEditPen->penMove = PIC_EDIT_PEN_MOVE_2;
  335.             break;
  336.         case 2:
  337.             gpPicEditPen->penMove = PIC_EDIT_PEN_MOVE_3;
  338.             break;
  339.         case 3:
  340.             gpPicEditPen->penMove = PIC_EDIT_PEN_MOVE_4;
  341.             break;
  342.         default:
  343.             gpPicEditPen->penMove = PIC_EDIT_PEN_MOVE_1;
  344.             break;
  345.     }
  346. #endif /* __MMI_TOUCH_SCREEN__ */ 
  347.     CloseCategory57Screen();
  348.     GetPaletteInfo(infoPalette);
  349.     memcpy(gpPEFileBuff + 54, &infoPalette, MAX_TYPE_PEN_COLOR * gPEBitsPerPixel);
  350.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  351.     DeleteUptoScrID(SCR_PE_EDIT_PIC);
  352. }
  353. /*****************************************************************************
  354.  * FUNCTION
  355.  *  SetPicEditFillPicInlineItemData
  356.  * DESCRIPTION
  357.  *  Setup inline item data for fill image background
  358.  * PARAMETERS
  359.  *  void
  360.  * RETURNS
  361.  *  void
  362.  *****************************************************************************/
  363. void SetPicEditFillPicInlineItemData(void)
  364. {
  365.     /*----------------------------------------------------------------*/
  366.     /* Local Variables                                                */
  367.     /*----------------------------------------------------------------*/
  368.     /*----------------------------------------------------------------*/
  369.     /* Code Body                                                      */
  370.     /*----------------------------------------------------------------*/
  371.     SetInlineItemActivation(&PicEditInLineItems[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  372.     SetInlineItemCaption(&PicEditInLineItems[0], (PU8) (get_string(STR_PE_EDIT_OPT_FILL_PIC)));
  373.     SetInlineItemActivation(&PicEditInLineItems[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  374.     SetInlineItemSelect(
  375.         &PicEditInLineItems[1],
  376.         MAX_TYPE_PEN_COLOR - 1,
  377.         pInlinePenColorIndexList,
  378.         &nInlinePenColorIndex);
  379.     RegisterInlineSelectHighlightHandler(&PicEditInLineItems[1], PicEditPenColorHiLiteHandler);
  380. }
  381. /*****************************************************************************
  382.  * FUNCTION
  383.  *  EntryScr4PicEditFillPic
  384.  * DESCRIPTION
  385.  *  Entry function for filling image with selected color
  386.  * PARAMETERS
  387.  *  void
  388.  * RETURNS
  389.  *  void
  390.  *****************************************************************************/
  391. void EntryScr4PicEditFillPic(void)
  392. {
  393.     /*----------------------------------------------------------------*/
  394.     /* Local Variables                                                */
  395.     /*----------------------------------------------------------------*/
  396.     U8 *guiBuffer;
  397.     U8 *inputBuffer;        /* added for inline edit history */
  398.     U16 inputBufferSize;    /* added for inline edit history */
  399.     U8 iCount;
  400.     /*----------------------------------------------------------------*/
  401.     /* Code Body                                                      */
  402.     /*----------------------------------------------------------------*/
  403.     /* ExecuteCurrExitHandler(); */
  404.     EntryNewScreen(SCR_PE_FILL_PIC, ExitScr4PicEditFillPic, NULL, NULL);
  405.     guiBuffer = GetCurrGuiBuffer(SCR_PE_FILL_PIC);
  406.     //Pixtel patch
  407.     //      nInlinePenColorIndex=gpPicEditPen->penBackgrdColorIndex;
  408.     for (iCount = 0; iCount < MAX_TYPE_PEN_COLOR; iCount++)
  409.     {
  410.         pInlinePenColorIndexList[iCount] = (U8*) GetString((U16) (iCount + 1 + STR_PE_COLOR_NONE));
  411.         inlinePERGBlist[iCount][0] = (U8) ((0xFF000000 & gPEColorRGB[iCount + 1]) >> 24);
  412.         inlinePERGBlist[iCount][1] = (U8) ((0x00FF0000 & gPEColorRGB[iCount + 1]) >> 16);
  413.         inlinePERGBlist[iCount][2] = (U8) ((0x0000FF00 & gPEColorRGB[iCount + 1]) >> 8);
  414.     }
  415.     inputBuffer = GetCurrNInputBuffer(SCR_PE_FILL_PIC, &inputBufferSize);       /* added for inline edit history */
  416.     RegisterHighlightHandler(ChangeSoftkeyFillPic);
  417.     g_pe_color_index = nInlinePenColorIndex + 1;
  418.     InitializeCategory57Screen();
  419.     SetPicEditFillPicInlineItemData();
  420.     if (inputBuffer != NULL)
  421.     {
  422.         SetCategory57Data(PicEditInLineItems, 2, inputBuffer);
  423.     }
  424.     ShowCategory57Screen(
  425.         STR_PE_EDIT_OPT_FILL_PIC,
  426.         GetRootTitleIcon(MENU_PICTURE_EDITOR),
  427.         0,
  428.         0,
  429.         STR_GLOBAL_BACK,
  430.         IMG_GLOBAL_BACK,
  431.         2,
  432.         NULL,
  433.         PicEditInLineItems,
  434.         0,
  435.         guiBuffer);
  436.     EnableCategory57ScreenDone();
  437.     SetCategory57RightSoftkeyFunctions(EntryScr4PicEditFillPicSaveConfirm, GoBackHistory);
  438. }
  439. /*****************************************************************************
  440.  * FUNCTION
  441.  *  ExitScr4PicEditFillPic
  442.  * DESCRIPTION
  443.  *  Exit function for EntryScr4PicEditFillPic
  444.  * PARAMETERS
  445.  *  void
  446.  * RETURNS
  447.  *  void
  448.  *****************************************************************************/
  449. void ExitScr4PicEditFillPic(void)
  450. {
  451.     /*----------------------------------------------------------------*/
  452.     /* Local Variables                                                */
  453.     /*----------------------------------------------------------------*/
  454.     history h;
  455.     S16 nHistory = 0;
  456.     U16 inputBufferSize;
  457.     /*----------------------------------------------------------------*/
  458.     /* Code Body                                                      */
  459.     /*----------------------------------------------------------------*/
  460.     CloseCategory57Screen();
  461.     h.scrnID = SCR_PE_FILL_PIC;
  462.     h.entryFuncPtr = EntryScr4PicEditFillPic;
  463.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  464.     GetCategory57History(h.guiBuffer);
  465.     inputBufferSize = (S16) GetCategory57DataSize();    /* added for inline edit history */
  466.     GetCategory57Data((U8*) h.inputBuffer);             /* added for inline edit history */
  467.     AddNHistory(h, inputBufferSize);                    /* added for inline edit history */
  468. }
  469. /*****************************************************************************
  470.  * FUNCTION
  471.  *  ChangeSoftkeyFillPic
  472.  * DESCRIPTION
  473.  *  Changes softkeys when inline item selected
  474.  * PARAMETERS
  475.  *  index       [IN]        
  476.  * RETURNS
  477.  *  void
  478.  *****************************************************************************/
  479. void ChangeSoftkeyFillPic(S32 index)
  480. {
  481.     /*----------------------------------------------------------------*/
  482.     /* Local Variables                                                */
  483.     /*----------------------------------------------------------------*/
  484.     /*----------------------------------------------------------------*/
  485.     /* Code Body                                                      */
  486.     /*----------------------------------------------------------------*/
  487.     if (gpPicEditPen->penBackgrdColorIndex != (U8) g_pe_color_index)
  488.     {
  489.         ChangeRightSoftkey(STR_GLOBAL_DONE, IMG_GLOBAL_BACK);
  490.         ChangeLeftSoftkey((U16) NULL, (U16) NULL);
  491.         SetRightSoftkeyFunction(EntryScr4PicEditFillPicSaveConfirm, KEY_EVENT_UP);
  492.     }
  493.     else
  494.     {
  495.         ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  496.         /* ChangeLeftSoftkey(STR_GLOBAL_OK,IMG_GLOBAL_OK); */
  497.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  498.         SetCategory57LeftSoftkeyFunction(EntryScr4PicEditFillPicSaveConfirm);
  499.     }
  500. }
  501. /*****************************************************************************
  502.  * FUNCTION
  503.  *  PicEditFillPicSelectInlineEdit
  504.  * DESCRIPTION
  505.  *  Changes softkeys when inline item selected
  506.  * PARAMETERS
  507.  *  index       [IN]        
  508.  * RETURNS
  509.  *  void
  510.  *****************************************************************************/
  511. void PicEditFillPicSelectInlineEdit(S32 index)
  512. {
  513.     /*----------------------------------------------------------------*/
  514.     /* Local Variables                                                */
  515.     /*----------------------------------------------------------------*/
  516.     /*----------------------------------------------------------------*/
  517.     /* Code Body                                                      */
  518.     /*----------------------------------------------------------------*/
  519.     g_pe_color_index = index + 1;
  520.     ChangeSoftkeyFillPic(index);
  521. }
  522. /*****************************************************************************
  523.  * FUNCTION
  524.  *  EntryScr4PicEditFillPicSaveConfirm
  525.  * DESCRIPTION
  526.  *  Confirmation screen for filling image with color selected
  527.  * PARAMETERS
  528.  *  void
  529.  * RETURNS
  530.  *  void
  531.  *****************************************************************************/
  532. void EntryScr4PicEditFillPicSaveConfirm(void)
  533. {
  534. #if (0)
  535. /* under construction !*/
  536. /* under construction !*/
  537. /* under construction !*/
  538. /* under construction !*/
  539. /* under construction !*/
  540. /* under construction !*/
  541. /* under construction !*/
  542. /* under construction !*/
  543. /* under construction !*/
  544. /* under construction !*/
  545. /* under construction !*/
  546. /* under construction !*/
  547. /* under construction !*/
  548. /* under construction !*/
  549. #endif /* (0) */ 
  550.     /*----------------------------------------------------------------*/
  551.     /* Code Body                                                      */
  552.     /*----------------------------------------------------------------*/
  553.     DisplayConfirm(
  554.         STR_GLOBAL_YES,
  555.         IMG_GLOBAL_YES,
  556.         STR_GLOBAL_NO,
  557.         IMG_GLOBAL_NO,
  558.         get_string(STR_PE_EDIT_OPT_FILL_PIC),
  559.         IMG_GLOBAL_QUESTION,
  560.         WARNING_TONE);
  561.     SetLeftSoftkeyFunction(SavePicEditFillPic, KEY_EVENT_UP);
  562.     SetRightSoftkeyFunction(GoBackPicEditFillPicConfirmHistory, KEY_EVENT_UP);
  563.     /* playRequestedTone(WARNING_TONE) ; */
  564.     /* SetExitHandler(SCR_PE_FILL_PIC_SAVE, ExitScr4PicEditFillPicSaveConfirm); */
  565. }
  566. /*****************************************************************************
  567.  * FUNCTION
  568.  *  ExitScr4PicEditFillPicSaveConfirm
  569.  * DESCRIPTION
  570.  *  Exit function for EntryScr4PicEditFillPicSaveConfirm
  571.  * PARAMETERS
  572.  *  void
  573.  * RETURNS
  574.  *  void
  575.  *****************************************************************************/
  576. void ExitScr4PicEditFillPicSaveConfirm(void)
  577. {
  578.     /*----------------------------------------------------------------*/
  579.     /* Local Variables                                                */
  580.     /*----------------------------------------------------------------*/
  581.     history h;  /* Variable to hold the history data */
  582.     S16 nHistory = 0;
  583.     /*----------------------------------------------------------------*/
  584.     /* Code Body                                                      */
  585.     /*----------------------------------------------------------------*/
  586.     stopRequestedTone(WARNING_TONE);
  587.     h.scrnID = SCR_PE_FILL_PIC_SAVE;
  588.     h.entryFuncPtr = EntryScr4PicEditFillPicSaveConfirm;
  589.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  590.     GetCategoryHistory(h.guiBuffer);
  591. }
  592. /*****************************************************************************
  593.  * FUNCTION
  594.  *  GoBackPicEditFillPicConfirmHistory
  595.  * DESCRIPTION
  596.  *  Go Back history function for the confirmation screen for filling image
  597.  * PARAMETERS
  598.  *  void
  599.  * RETURNS
  600.  *  void
  601.  *****************************************************************************/
  602. void GoBackPicEditFillPicConfirmHistory(void)
  603. {
  604.     /*----------------------------------------------------------------*/
  605.     /* Local Variables                                                */
  606.     /*----------------------------------------------------------------*/
  607.     /*----------------------------------------------------------------*/
  608.     /* Code Body                                                      */
  609.     /*----------------------------------------------------------------*/
  610.     CloseCategory57Screen();
  611.     DeleteUptoScrID(SCR_PE_EDIT_PIC_OPT);
  612.     GoBackHistory();
  613. }
  614. /*****************************************************************************
  615.  * FUNCTION
  616.  *  SavePicEditFillPic
  617.  * DESCRIPTION
  618.  *  Fills image with the color selected
  619.  * PARAMETERS
  620.  *  void
  621.  * RETURNS
  622.  *  void
  623.  *****************************************************************************/
  624. void SavePicEditFillPic(void)
  625. {
  626.     /*----------------------------------------------------------------*/
  627.     /* Local Variables                                                */
  628.     /*----------------------------------------------------------------*/
  629.     U8 infoPalette[MAX_TYPE_PEN_COLOR * 4];
  630.     /*----------------------------------------------------------------*/
  631.     /* Code Body                                                      */
  632.     /*----------------------------------------------------------------*/
  633.     gpPicEditPen->penBackgrdColorIndex = (U8) nInlinePenColorIndex + 1;
  634.     CloseCategory57Screen();
  635.     GetPaletteInfo(infoPalette);
  636.     gPEImageWidth_bak = gPEImageWidth;
  637.     gPEImageHeight_bak = gPEImageHeight;
  638.     SET_PE_IMAGE_EDIT(gPEAttrib);
  639.     UNSET_PE_MARK_IMAGE(gPEAttrib);
  640.     UNSET_PE_COPY_IMAGE(gPEAttrib);
  641.     memcpy(&gpPEFileBuff[54], &infoPalette, MAX_TYPE_PEN_COLOR * gPEBitsPerPixel);
  642.     memset(
  643.         &gpPEFileBuff[PIC_EDIT_FILE_HEADER_SIZE],
  644.         ((gpPicEditPen->penBackgrdColorIndex) | (gpPicEditPen->penBackgrdColorIndex << 4)),
  645.         (gpPicEditPen->maxY - gpPicEditPen->minY) * GetImageWidth(gpPicEditPen->minX, gpPicEditPen->maxX));
  646.     SavePEContext();
  647.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  648.     DeleteUptoScrID(SCR_PE_EDIT_PIC);
  649. }
  650. /*****************************************************************************
  651.  * FUNCTION
  652.  *  EntryScr4PicEditScrResize
  653.  * DESCRIPTION
  654.  *  Entry screen for resize image
  655.  * PARAMETERS
  656.  *  void
  657.  * RETURNS
  658.  *  void
  659.  *****************************************************************************/
  660. void EntryScr4PicEditScrResize(void)
  661. {
  662.     /*----------------------------------------------------------------*/
  663.     /* Local Variables                                                */
  664.     /*----------------------------------------------------------------*/
  665.     U8 *guiBuffer;
  666.     U8 iCount;
  667.     U8 *inputBuffer;        /* added for inline edit history */
  668.     U16 inputBufferSize;    /* added for inline edit history */
  669.     /*----------------------------------------------------------------*/
  670.     /* Code Body                                                      */
  671.     /*----------------------------------------------------------------*/
  672.     /* ExecuteCurrExitHandler(); */
  673.     EntryNewScreen(SCR_PE_SCR_RESIZE, ExitScr4PicEditScrResize, NULL, NULL);
  674.     InitializeCategory57Screen();
  675.     guiBuffer = GetCurrGuiBuffer(SCR_PE_SCR_RESIZE);
  676.     //Pixtel patch
  677.     //      memset( (void *)PicEditInLineItems, 0, sizeof( InlineItem )*MAX_RESIZE_INLINE_EDIT );
  678.     for (iCount = 0; iCount < MAX_TYPE_SCR_TYPE; ++iCount)
  679.     {
  680.     #ifdef __MMI_MAINLCD_240X320__
  681.         pInlinePEScrList[iCount] = (U8*) GetString((U16) (iCount + STR_PE_RESIZE_32)); /* 110805 resize region Calvin added */
  682.     #else 
  683.         pInlinePEScrList[iCount] = (U8*) GetString((U16) (iCount + STR_PE_RESIZE_16));
  684.     #endif 
  685.     }
  686.     inputBuffer = GetCurrNInputBuffer(SCR_PE_SCR_RESIZE, &inputBufferSize);     /* added for inline edit history */
  687.     //Pixtel patch
  688.     //      FillPicEditResizeInLine(PicEditInLineItems);
  689.     RegisterHighlightHandler(ChangeResizeSoftKey);
  690.     /* Pixtel patch */
  691.     if (inputBuffer != NULL)    /* added for inline edit history */
  692.     {
  693.         SetCategory57Data(PicEditInLineItems, MAX_RESIZE_INLINE_EDIT, inputBuffer);     /* sets the data */
  694.     }
  695.     else
  696.     {
  697.         memset((void*)PicEditInLineItems, 0, sizeof(InlineItem) * MAX_RESIZE_INLINE_EDIT);
  698.         FillPicEditResizeInLine(PicEditInLineItems);
  699.     }
  700.     DisableCategory57ScreenDone();
  701.     ShowCategory57Screen(
  702.         STR_PE_EDIT_OPT_RESIZE,
  703.         GetRootTitleIcon(MENU_PICTURE_EDITOR),
  704.         STR_GLOBAL_OK,
  705.         IMG_GLOBAL_OK,
  706.         STR_GLOBAL_BACK,
  707.         IMG_GLOBAL_BACK,
  708.         MAX_RESIZE_INLINE_EDIT,
  709.         (U16*) NULL,
  710.         PicEditInLineItems,
  711.         0,
  712.         guiBuffer);
  713.     DisableCategory57ScreenDone();
  714.     SetLeftSoftkeyFunction(ValidateScrWidthHeight, KEY_EVENT_UP);
  715.     SetCategory57RightSoftkeyFunctions(ValidateScrWidthHeight, GoBackHistory);
  716.     /* SetExitHandler(SCR_PE_SCR_RESIZE, ExitScr4PicEditScrResize); */
  717. }
  718. /*****************************************************************************
  719.  * FUNCTION
  720.  *  ExitScr4PicEditScrResize
  721.  * DESCRIPTION
  722.  *  Exit function for EntryScr4PicEditScrResize
  723.  * PARAMETERS
  724.  *  void
  725.  * RETURNS
  726.  *  void
  727.  *****************************************************************************/
  728. void ExitScr4PicEditScrResize(void)
  729. {
  730.     /*----------------------------------------------------------------*/
  731.     /* Local Variables                                                */
  732.     /*----------------------------------------------------------------*/
  733.     history h;
  734.     S16 nHistory = 0;
  735.     U16 inputBufferSize;
  736.     /*----------------------------------------------------------------*/
  737.     /* Code Body                                                      */
  738.     /*----------------------------------------------------------------*/
  739.     CloseCategory57Screen();
  740.     h.scrnID = SCR_PE_SCR_RESIZE;
  741.     h.entryFuncPtr = EntryScr4PicEditScrResize;
  742.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  743.     GetCategoryHistory(h.guiBuffer);
  744.     inputBufferSize = (S16) GetCategory57DataSize();    /* added for inline edit history */
  745.     GetCategory57Data((U8*) h.inputBuffer);             /* added for inline edit history */
  746.     AddNHistory(h, inputBufferSize);                    /* added for inline edit history */
  747. }
  748. /*****************************************************************************
  749.  * FUNCTION
  750.  *  FillPicEditResizeInLine
  751.  * DESCRIPTION
  752.  *  Fills the Inline buffer for resize image screen
  753.  * PARAMETERS
  754.  *  ResizeInline        [?]     
  755.  * RETURNS
  756.  *  void
  757.  *****************************************************************************/
  758. void FillPicEditResizeInLine(InlineItem *ResizeInline)
  759. {
  760.     /*----------------------------------------------------------------*/
  761.     /* Local Variables                                                */
  762.     /*----------------------------------------------------------------*/
  763.     /*----------------------------------------------------------------*/
  764.     /* Code Body                                                      */
  765.     /*----------------------------------------------------------------*/
  766.     SetInlineItemActivation(&ResizeInline[0], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  767.     SetInlineItemCaption(&ResizeInline[0], (PU8) (GetString(STR_PE_RESIZE_TO)));
  768.     SetInlineItemActivation(&ResizeInline[1], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  769.     SetInlineItemSelect(&ResizeInline[1], (S32) MAX_TYPE_SCR_TYPE, pInlinePEScrList, &nInlinePEScr);
  770.     RegisterInlineSelectHighlightHandler(&ResizeInline[1], HighlightResizeInlineItemHandler);
  771.     SetInlineItemActivation(&ResizeInline[2], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  772.     SetInlineItemCaption(&ResizeInline[2], (PU8) (GetString(STR_PE_RESIZE_WIDTH)));
  773.     SetInlineItemActivation(&ResizeInline[3], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  774.     SetInlineItemTextEdit(&ResizeInline[3], (PU8) nInlinePEScrWidth, PE_RESIZE_BUF_SIZE, INPUT_TYPE_NUMERIC);   /* 100405 image editor Calvin */
  775.     RightJustifyInlineItem(&ResizeInline[3]);
  776.     EnableInlineItemBoundary(&ResizeInline[3]);
  777.     SetInlineItemActivation(&ResizeInline[4], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  778.     SetInlineItemCaption(&ResizeInline[4], (PU8) (GetString(STR_PE_RESIZE_HEIGHT)));
  779.     SetInlineItemActivation(&ResizeInline[5], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  780.     SetInlineItemTextEdit(&ResizeInline[5], (PU8) nInlinePEScrHeight, PE_RESIZE_BUF_SIZE, INPUT_TYPE_NUMERIC);  /* 100405 image editor Calvin */
  781.     RightJustifyInlineItem(&ResizeInline[5]);
  782.     EnableInlineItemBoundary(&ResizeInline[5]);
  783. }
  784. /*****************************************************************************
  785.  * FUNCTION
  786.  *  HighlightResizeInlineItemHandler
  787.  * DESCRIPTION
  788.  *  Highlight Handler for Inline Item selected
  789.  * PARAMETERS
  790.  *  index       [IN]        
  791.  * RETURNS
  792.  *  void
  793.  *****************************************************************************/
  794. void HighlightResizeInlineItemHandler(S32 index)
  795. {
  796.     /*----------------------------------------------------------------*/
  797.     /* Local Variables                                                */
  798.     /*----------------------------------------------------------------*/
  799.     U8 scrWParam[4 * ENCODING_LENGTH], scrHParam[4 * ENCODING_LENGTH];
  800.     /*----------------------------------------------------------------*/
  801.     /* Code Body                                                      */
  802.     /*----------------------------------------------------------------*/
  803.     if (index == PE_SCR_4)
  804.     {
  805.         if (!nInlinePenColorIndex)
  806.         {
  807.             /* Leo start 20050824 */
  808.             //                      sprintf((PS8)scrWParam,"%d",nInlinePenSize);
  809.             //                      sprintf((PS8)scrHParam,"%d",nInlinePenMoveFactor);
  810.             /* Leo end 20050824 */
  811.             sprintf((PS8) scrWParam, "%d", gPEImageWidth);
  812.             sprintf((PS8) scrHParam, "%d", gPEImageHeight);
  813.             nInlinePenColorIndex = 1;
  814.             AnsiiToUnicodeString((PS8) nInlinePEScrWidth, (PS8) scrWParam);
  815.             AnsiiToUnicodeString((PS8) nInlinePEScrHeight, (PS8) scrHParam);
  816.             EnableInlineItem(PicEditInLineItems, 3);
  817.             EnableInlineItem(PicEditInLineItems, 5);
  818.         }
  819.     }
  820.     else
  821.     {
  822.         if (nInlinePenColorIndex)
  823.         {
  824.             UnicodeToAnsii((PS8) scrWParam, (PS8) nInlinePEScrWidth);
  825.             UnicodeToAnsii((PS8) scrHParam, (PS8) nInlinePEScrHeight);
  826.             nInlinePenSize = (U16) atoi((PS8) scrWParam);
  827.             nInlinePenMoveFactor = (U16) atoi((PS8) scrHParam);
  828.             nInlinePenColorIndex = 0;
  829.         }
  830.         sprintf((PS8) scrWParam, "");
  831.         sprintf((PS8) scrHParam, "");
  832.         AnsiiToUnicodeString((PS8) nInlinePEScrWidth, (PS8) scrWParam);
  833.         AnsiiToUnicodeString((PS8) nInlinePEScrHeight, (PS8) scrHParam);
  834.         DisableInlineItem(PicEditInLineItems, 3);
  835.         DisableInlineItem(PicEditInLineItems, 5);
  836.     }
  837.     RedrawCategoryFunction();
  838. }
  839. /*****************************************************************************
  840.  * FUNCTION
  841.  *  ChangeResizeSoftKey
  842.  * DESCRIPTION
  843.  *  Change softkey for Resize screen
  844.  * PARAMETERS
  845.  *  nIndex      [IN]        
  846.  * RETURNS
  847.  *  void
  848.  *****************************************************************************/
  849. void ChangeResizeSoftKey(S32 nIndex)
  850. {
  851.     /*----------------------------------------------------------------*/
  852.     /* Local Variables                                                */
  853.     /*----------------------------------------------------------------*/
  854.     /*----------------------------------------------------------------*/
  855.     /* Code Body                                                      */
  856.     /*----------------------------------------------------------------*/
  857.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  858.     SetCategory57LeftSoftkeyFunction(ValidateScrWidthHeight);
  859. }
  860. /*****************************************************************************
  861.  * FUNCTION
  862.  *  SetResizeInlineItemValues
  863.  * DESCRIPTION
  864.  *  Sets Resize Inline item values
  865.  * PARAMETERS
  866.  *  void
  867.  * RETURNS
  868.  *  void
  869.  *****************************************************************************/
  870. void SetResizeInlineItemValues(void)
  871. {
  872.     /*----------------------------------------------------------------*/
  873.     /* Local Variables                                                */
  874.     /*----------------------------------------------------------------*/
  875.     /*----------------------------------------------------------------*/
  876.     /* Code Body                                                      */
  877.     /*----------------------------------------------------------------*/
  878.     nInlinePEScr = (U32) GetPicEditScr();
  879.     //nInlinePenSize used as temp buffer for inline Width
  880.     //      nInlinePenSize =(S32)gPEImageWidth;     
  881.     //      gPEImageWidth_bak =(S32)gPEImageWidth;     
  882.     //nInlinePenMoveFactor used as temp buffer for inline Height
  883.     //      nInlinePenMoveFactor =(S32)gPEImageHeight;
  884.     //      gPEImageHeight_bak =(S32)gPEImageHeight;
  885.     //nInlinePenColorIndex used as flag for Inline Resize Screen
  886.     nInlinePenColorIndex = 0;
  887. }
  888. /*****************************************************************************
  889.  * FUNCTION
  890.  *  ValidateScrWidthHeight
  891.  * DESCRIPTION
  892.  *  Validates and sets the values for width and height of image
  893.  * PARAMETERS
  894.  *  void
  895.  * RETURNS
  896.  *  void
  897.  *****************************************************************************/
  898. void ValidateScrWidthHeight(void)
  899. {
  900.     /*----------------------------------------------------------------*/
  901.     /* Local Variables                                                */
  902.     /*----------------------------------------------------------------*/
  903.     U8 scrWParam[4 * ENCODING_LENGTH], scrHParam[4 * ENCODING_LENGTH];
  904.     U16 nWidth, nHeight;
  905.     BOOL bFlag = FALSE;
  906.     /*----------------------------------------------------------------*/
  907.     /* Code Body                                                      */
  908.     /*----------------------------------------------------------------*/
  909.     CloseCategory57Screen();
  910.     gPEImageWidth_bak = gPEImageWidth;
  911.     gPEImageHeight_bak = gPEImageHeight;
  912.     gPEImageResized = MMI_TRUE;
  913.     switch (nInlinePEScr)
  914.     {
  915.         case PE_SCR_1:
  916.             gPEImageWidth = PE_SCR_SIZE_1;
  917.             gPEImageHeight = PE_SCR_SIZE_1;
  918.             break;
  919.         case PE_SCR_2:
  920.             gPEImageWidth = PE_SCR_SIZE_2;
  921.             gPEImageHeight = PE_SCR_SIZE_2;
  922.             break;
  923.         case PE_SCR_3:
  924.             gPEImageWidth = PE_SCR_SIZE_MAX;
  925.             gPEImageHeight = PE_SCR_SIZE_MAX;
  926.             break;
  927.         case PE_SCR_4:
  928.             UnicodeToAnsii((PS8) scrWParam, (PS8) nInlinePEScrWidth);
  929.             UnicodeToAnsii((PS8) scrHParam, (PS8) nInlinePEScrHeight);
  930.             nWidth = (U16) atoi((PS8) scrWParam);
  931.             nHeight = (U16) atoi((PS8) scrHParam);
  932.             if (((nWidth >= PE_SCR_SIZE_MIN) && (nWidth <= PE_SCR_SIZE_MAX)) &&
  933.                 ((nHeight >= PE_SCR_SIZE_MIN) && (nHeight <= PE_SCR_SIZE_MAX)))
  934.             {
  935.                 gPEImageWidth = nWidth;
  936.                 gPEImageHeight = nHeight;
  937.             }
  938.             else
  939.             {
  940.                 /* 092005 Image Editor Size Calvin */
  941.             #ifdef __MMI_MAINLCD_240X320__
  942.                 DisplayPopup(
  943.                     (U8*) GetString(STR_PE_RESIZE_ERROR_BIG),
  944.                     IMG_GLOBAL_WARNING,
  945.                     0,
  946.                     PE_NOTIFYDURATION,
  947.                     (U8) WARNING_TONE);
  948.             #else /* __MMI_MAINLCD_240X320__ */ 
  949.                 DisplayPopup(
  950.                     (U8*) GetString(STR_PE_RESIZE_ERROR),
  951.                     IMG_GLOBAL_WARNING,
  952.                     0,
  953.                     PE_NOTIFYDURATION,
  954.                     (U8) WARNING_TONE);
  955.             #endif /* __MMI_MAINLCD_240X320__ */ 
  956.                 /* 092005 Calvin end */
  957.                 bFlag = TRUE;
  958.             }
  959.             break;
  960.         default:
  961.             gPEImageWidth = PE_SCR_SIZE_2;
  962.             gPEImageHeight = PE_SCR_SIZE_2;
  963.             break;
  964.     }
  965.     if (!bFlag)
  966.     {
  967.         /* CloseCategory57Screen(); */
  968.         UNSET_PE_PEN_DOWN(gPEAttrib);
  969.         /* check if image is resized to smaller size */
  970.         if (!SetPicEditPenMarkBoundary())
  971.         {
  972.             SavePEContext();
  973.             gPECurrentAction = SEL_PE_EDIT_OPT_SAVE_PIC;
  974.             SetPicEditPenBoundary();
  975.             ResizePicEditImageDataBuff();
  976.             if (IS_PE_ZOOM_IMAGE(gPEAttrib))
  977.             {
  978.                 SetPicEditZoomWindow(FALSE);
  979.             }
  980.             SET_PE_IMAGE_EDIT(gPEAttrib);
  981.             UNSET_PE_MARK_IMAGE(gPEAttrib);
  982.             DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  983.             DeleteUptoScrID(SCR_PE_EDIT_PIC);
  984.         }
  985.         else
  986.         {
  987.             gPECurrentAction = SEL_PE_EDIT_OPT_RESIZE;
  988.             DeleteUptoScrID(SCR_PE_EDIT_PIC);
  989.             GoBackHistory();
  990.         }
  991.     }
  992. }
  993. /*****************************************************************************
  994.  * FUNCTION
  995.  *  EntryScr4PicEditHelp
  996.  * DESCRIPTION
  997.  *  Entry screen for help
  998.  * PARAMETERS
  999.  *  void
  1000.  * RETURNS
  1001.  *  void
  1002.  *****************************************************************************/
  1003. void EntryScr4PicEditHelp(void)
  1004. {
  1005.     /*----------------------------------------------------------------*/
  1006.     /* Local Variables                                                */
  1007.     /*----------------------------------------------------------------*/
  1008.     U8 *guiBuffer;
  1009.     S8 *buffer;
  1010.     S32 bufferSize;
  1011.     /*----------------------------------------------------------------*/
  1012.     /* Code Body                                                      */
  1013.     /*----------------------------------------------------------------*/
  1014.     /* ExecuteCurrExitHandler(); */
  1015.     EntryNewScreen(SCR_PE_HELP, ExitScr4PicEditHelp, NULL, NULL);
  1016.     guiBuffer = GetCurrGuiBuffer(SCR_PE_HELP);
  1017.     /* Leo add 20050705 start */
  1018. #ifdef __MMI_TOUCH_SCREEN__
  1019.     buffer = GetString(STR_PE_HELP_DESCRIPTION_TOUCH);
  1020. #else 
  1021.     buffer = GetString(STR_PE_HELP_DESCRIPTION);
  1022. #endif 
  1023.     /* Leo add 20050705 end */
  1024.     bufferSize = pfnUnicodeStrlen(buffer);
  1025.     ShowCategory74Screen(
  1026.         STR_PE_EDIT_OPT_HELP,
  1027.         GetRootTitleIcon(MENU_PICTURE_EDITOR),
  1028.         0,
  1029.         0,
  1030.         STR_GLOBAL_BACK,
  1031.         IMG_GLOBAL_BACK,
  1032.         (PU8) buffer,
  1033.         bufferSize,
  1034.         guiBuffer);
  1035.     /* go back to option menu */
  1036.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1037.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1038.     /* SetExitHandler (SCR_PE_HELP,ExitScr4PicEditHelp); */
  1039. }
  1040. /*****************************************************************************
  1041.  * FUNCTION
  1042.  *  ExitScr4PicEditHelp
  1043.  * DESCRIPTION
  1044.  *  Exit function for EntryScr4PicEditHelp
  1045.  * PARAMETERS
  1046.  *  void
  1047.  * RETURNS
  1048.  *  void
  1049.  *****************************************************************************/
  1050. void ExitScr4PicEditHelp(void)
  1051. {
  1052.     /*----------------------------------------------------------------*/
  1053.     /* Local Variables                                                */
  1054.     /*----------------------------------------------------------------*/
  1055.     history h;
  1056.     S16 nHistory = 0;
  1057.     /*----------------------------------------------------------------*/
  1058.     /* Code Body                                                      */
  1059.     /*----------------------------------------------------------------*/
  1060.     h.scrnID = SCR_PE_HELP;
  1061.     h.entryFuncPtr = EntryScr4PicEditHelp;
  1062.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1063.     GetCategoryHistory(h.guiBuffer);
  1064.     AddHistory(h);
  1065. }
  1066. /*****************************************************************************
  1067.  * FUNCTION
  1068.  *  EntryScr4PicEditCustomColor
  1069.  * DESCRIPTION
  1070.  *  Entry screen function for custom color setting change
  1071.  * PARAMETERS
  1072.  *  void
  1073.  * RETURNS
  1074.  *  void
  1075.  *****************************************************************************/
  1076. void EntryScr4PicEditCustomColor(void)
  1077. {
  1078.     /*----------------------------------------------------------------*/
  1079.     /* Local Variables                                                */
  1080.     /*----------------------------------------------------------------*/
  1081.     U8 *guiBuffer;
  1082.     /*----------------------------------------------------------------*/
  1083.     /* Code Body                                                      */
  1084.     /*----------------------------------------------------------------*/
  1085.     /* ExecuteCurrExitHandler(); */
  1086.     EntryNewScreen(SCR_PE_CUSTOM_COLOR, ExitScr4PicEditCustomColor, NULL, NULL);
  1087.     guiBuffer = GetCurrGuiBuffer(SCR_PE_CUSTOM_COLOR);
  1088.     inlineCustomRGB[0] = inlinePERGBlist[PE_COLOR_CUSTOM_1][0];
  1089.     inlineCustomRGB[1] = inlinePERGBlist[PE_COLOR_CUSTOM_1][1];
  1090.     inlineCustomRGB[2] = inlinePERGBlist[PE_COLOR_CUSTOM_1][2];
  1091.     ShowCategory91Screen(
  1092.         STR_PE_COLOR_SEL,
  1093.         GetRootTitleIcon(MENU_PICTURE_EDITOR),
  1094.         STR_GLOBAL_OK,
  1095.         IMG_GLOBAL_OK,
  1096.         STR_GLOBAL_BACK,
  1097.         IMG_GLOBAL_BACK,
  1098.         &inlineCustomRGB[0],
  1099.         &inlineCustomRGB[1],
  1100.         &inlineCustomRGB[2],
  1101.         &highlighted_slider,
  1102.         guiBuffer);
  1103.     SetLeftSoftkeyFunction(SavePicEditCustomColor, KEY_EVENT_UP);
  1104.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1105.     /* SetExitHandler(SCR_PE_CUSTOM_COLOR, ExitScr4PicEditCustomColor); */
  1106. }
  1107. /*****************************************************************************
  1108.  * FUNCTION
  1109.  *  ExitScr4PicEditCustomColor
  1110.  * DESCRIPTION
  1111.  *  Exit function for EntryScr4PicEditCustomColor
  1112.  * PARAMETERS
  1113.  *  void
  1114.  * RETURNS
  1115.  *  void
  1116.  *****************************************************************************/
  1117. void ExitScr4PicEditCustomColor(void)
  1118. {
  1119.     /*----------------------------------------------------------------*/
  1120.     /* Local Variables                                                */
  1121.     /*----------------------------------------------------------------*/
  1122.     history h;
  1123.     S16 nHistory = 0;
  1124.     /*----------------------------------------------------------------*/
  1125.     /* Code Body                                                      */
  1126.     /*----------------------------------------------------------------*/
  1127.     h.scrnID = SCR_PE_CUSTOM_COLOR;
  1128.     h.entryFuncPtr = EntryScr4PicEditCustomColor;
  1129.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1130.     GetCategoryHistory(h.guiBuffer);
  1131.     AddHistory(h);
  1132. }
  1133. /*****************************************************************************
  1134.  * FUNCTION
  1135.  *  SavePicEditCustomColor
  1136.  * DESCRIPTION
  1137.  *  Saves custom color settings
  1138.  * PARAMETERS
  1139.  *  void
  1140.  * RETURNS
  1141.  *  void
  1142.  *****************************************************************************/
  1143. void SavePicEditCustomColor(void)
  1144. {
  1145.     /*----------------------------------------------------------------*/
  1146.     /* Local Variables                                                */
  1147.     /*----------------------------------------------------------------*/
  1148.     U8 infoPalette[MAX_TYPE_PEN_COLOR * 4];
  1149.     /*----------------------------------------------------------------*/
  1150.     /* Code Body                                                      */
  1151.     /*----------------------------------------------------------------*/
  1152.     inlinePERGBlist[PE_COLOR_CUSTOM_1][0] = inlineCustomRGB[0];
  1153.     inlinePERGBlist[PE_COLOR_CUSTOM_1][1] = inlineCustomRGB[1];
  1154.     inlinePERGBlist[PE_COLOR_CUSTOM_1][2] = inlineCustomRGB[2];
  1155.     gPEColorRGB[PE_COLOR_CUSTOM_1] &= 0x000000FF;
  1156.     gPEColorRGB[PE_COLOR_CUSTOM_1] |=
  1157.         ((((U32) inlineCustomRGB[0]) << 24) | (((U32) inlineCustomRGB[1]) << 16) |
  1158.          (((U32) inlineCustomRGB[2]) << 8));
  1159.     /* Removed by Leo               gpPicEditPen->penColorIndex=(U8)nInlinePenColorIndex+1; */
  1160.     GetPaletteInfo(infoPalette);
  1161.     memcpy(gpPEFileBuff + 54, &infoPalette, MAX_TYPE_PEN_COLOR * gPEBitsPerPixel);
  1162.     GoBackHistory();
  1163. }
  1164. /*****************************************************************************
  1165.  * FUNCTION
  1166.  *  EntryScr4PicEditSaveImageConfirm
  1167.  * DESCRIPTION
  1168.  *  Confirmation screen for Saving image
  1169.  * PARAMETERS
  1170.  *  void
  1171.  * RETURNS
  1172.  *  void
  1173.  *****************************************************************************/
  1174. void EntryScr4PicEditSaveImageConfirm(void)
  1175. {
  1176. #if (0)
  1177. /* under construction !*/
  1178. /* under construction !*/
  1179. /* under construction !*/
  1180. /* under construction !*/
  1181. /* under construction !*/
  1182. /* under construction !*/
  1183. /* under construction !*/
  1184. /* under construction !*/
  1185. /* under construction !*/
  1186. /* under construction !*/
  1187. /* under construction !*/
  1188. /* under construction !*/
  1189. /* under construction !*/
  1190. /* under construction !*/
  1191. #endif /* (0) */ 
  1192.     /*----------------------------------------------------------------*/
  1193.     /* Code Body                                                      */
  1194.     /*----------------------------------------------------------------*/
  1195.     DisplayConfirm(
  1196.         STR_GLOBAL_YES,
  1197.         IMG_GLOBAL_YES,
  1198.         STR_GLOBAL_NO,
  1199.         IMG_GLOBAL_NO,
  1200.         get_string(STR_GLOBAL_SAVE),
  1201.         IMG_GLOBAL_QUESTION,
  1202.         WARNING_TONE);
  1203.     SetLeftSoftkeyFunction(PicEditSaveImage, KEY_EVENT_UP);
  1204.     SetRightSoftkeyFunction(GoBackPicEditSaveImageConfirmHistory, KEY_EVENT_UP);
  1205.     playRequestedTone(WARNING_TONE);
  1206.     /* SetExitHandler(SCR_PE_SAVE_IMAGE_CONFIRM, ExitScr4PicEditPenSettingSaveConfirm); */
  1207. }
  1208. /*****************************************************************************
  1209.  * FUNCTION
  1210.  *  ExitScr4PicEditSaveImageConfirm
  1211.  * DESCRIPTION
  1212.  *  Exit screen function for EntryScr4PicEditSaveImageConfirm
  1213.  * PARAMETERS
  1214.  *  void
  1215.  * RETURNS
  1216.  *  void
  1217.  *****************************************************************************/
  1218. void ExitScr4PicEditSaveImageConfirm(void)
  1219. {
  1220.     /*----------------------------------------------------------------*/
  1221.     /* Local Variables                                                */
  1222.     /*----------------------------------------------------------------*/
  1223.     history h;  /* Variable to hold the history data */
  1224.     S16 nHistory = 0;
  1225.     /*----------------------------------------------------------------*/
  1226.     /* Code Body                                                      */
  1227.     /*----------------------------------------------------------------*/
  1228.     stopRequestedTone(WARNING_TONE);
  1229.     h.scrnID = SCR_PE_SAVE_IMAGE_CONFIRM;
  1230.     h.entryFuncPtr = EntryScr4PicEditSaveImageConfirm;
  1231.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1232.     GetCategoryHistory(h.guiBuffer);
  1233. }
  1234. /*****************************************************************************
  1235.  * FUNCTION
  1236.  *  GoBackPicEditSaveImageConfirmHistory
  1237.  * DESCRIPTION
  1238.  *  Go back histroy fucntion for saving image confirmation screen
  1239.  * PARAMETERS
  1240.  *  void
  1241.  * RETURNS
  1242.  *  void
  1243.  *****************************************************************************/
  1244. void GoBackPicEditSaveImageConfirmHistory(void)
  1245. {
  1246.     /*----------------------------------------------------------------*/
  1247.     /* Local Variables                                                */
  1248.     /*----------------------------------------------------------------*/
  1249.     /*----------------------------------------------------------------*/
  1250.     /* Code Body                                                      */
  1251.     /*----------------------------------------------------------------*/
  1252.     InitPicEditPen();
  1253.     GoBacknHistory(1);
  1254. }
  1255. /*****************************************************************************
  1256.  * FUNCTION
  1257.  *  PicEditSaveImage
  1258.  * DESCRIPTION
  1259.  *  Saves image
  1260.  * PARAMETERS
  1261.  *  void
  1262.  * RETURNS
  1263.  *  void
  1264.  *****************************************************************************/
  1265. void PicEditSaveImage(void)
  1266. {
  1267.     /*----------------------------------------------------------------*/
  1268.     /* Local Variables                                                */
  1269.     /*----------------------------------------------------------------*/
  1270.     S32 result;
  1271.     /*----------------------------------------------------------------*/
  1272.     /* Code Body                                                      */
  1273.     /*----------------------------------------------------------------*/
  1274.     result = SavePicEditImageDataBuff();
  1275.     if (result == FS_NO_ERROR)
  1276.     {
  1277.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  1278.     }
  1279.     else
  1280.     {
  1281.         DisplayPopup(
  1282.             (U8*) get_string(GetFileSystemErrorString(result)),
  1283.             IMG_GLOBAL_ERROR,
  1284.             1,
  1285.             PE_NOTIFYDURATION,
  1286.             ERROR_TONE);
  1287.     }
  1288.     InitPicEditPen();
  1289.     DeleteNHistory(1);
  1290. }
  1291. /*****************************************************************************
  1292.  * FUNCTION
  1293.  *  SetPicEditPenAtCenter
  1294.  * DESCRIPTION
  1295.  *  Sets Pen at the center of the image if bflag TRUE
  1296.  * PARAMETERS
  1297.  *  bFlag       [IN]        
  1298.  * RETURNS
  1299.  *  void
  1300.  *****************************************************************************/
  1301. void SetPicEditPenAtCenter(BOOL bFlag)
  1302. {
  1303.     /*----------------------------------------------------------------*/
  1304.     /* Local Variables                                                */
  1305.     /*----------------------------------------------------------------*/
  1306.     /*----------------------------------------------------------------*/
  1307.     /* Code Body                                                      */
  1308.     /*----------------------------------------------------------------*/
  1309.     if (bFlag)
  1310.     {
  1311.         gpPicEditPen->penX = (U16) (UI_device_width / 2) + PE_IMAGE_WIDTH_EXTRA;
  1312.         gpPicEditPen->penY = (U16) (UI_device_height / 2) + PE_IMAGE_HEIGHT_EXTRA;
  1313.     }
  1314.     else
  1315.     {
  1316.         gpPicEditPen->penX = gpPicEditPen->minX;
  1317.         gpPicEditPen->penY = gpPicEditPen->minY;
  1318.     }
  1319. }
  1320. /*****************************************************************************
  1321.  * FUNCTION
  1322.  *  SetPicEditPenBoundary
  1323.  * DESCRIPTION
  1324.  *  Sets Pen boundary wrt to the image size
  1325.  * PARAMETERS
  1326.  *  void
  1327.  * RETURNS
  1328.  *  void
  1329.  *****************************************************************************/
  1330. void SetPicEditPenBoundary(void)
  1331. {
  1332.     /*----------------------------------------------------------------*/
  1333.     /* Local Variables                                                */
  1334.     /*----------------------------------------------------------------*/
  1335.     U16 nWidth, nHeight;
  1336.     /*----------------------------------------------------------------*/
  1337.     /* Code Body                                                      */
  1338.     /*----------------------------------------------------------------*/
  1339.     switch (nInlinePEScr)
  1340.     {
  1341.         case PE_SCR_1:
  1342.             nWidth = PE_SCR_SIZE_1;
  1343.             nHeight = PE_SCR_SIZE_1;
  1344.             break;
  1345.         case PE_SCR_2:
  1346.             nWidth = PE_SCR_SIZE_2;
  1347.             nHeight = PE_SCR_SIZE_2;
  1348.             break;
  1349.         case PE_SCR_3:
  1350.             nWidth = PE_SCR_SIZE_MAX;
  1351.             nHeight = PE_SCR_SIZE_MAX;
  1352.             break;
  1353.         case PE_SCR_4:
  1354.             nWidth = gPEImageWidth;
  1355.             nHeight = gPEImageHeight;
  1356.             break;
  1357.         default:
  1358.             nWidth = PE_SCR_SIZE_2;
  1359.             nHeight = PE_SCR_SIZE_2;
  1360.             break;
  1361.     }
  1362.     gpPicEditPen->minX = SET_WINDOW_MINX(nWidth);
  1363.     gpPicEditPen->maxX = gpPicEditPen->minX + (U16) nWidth;
  1364.     gpPicEditPen->minY = SET_WINDOW_MINY(nHeight);
  1365.     gpPicEditPen->maxY = gpPicEditPen->minY + (U16) nHeight;
  1366. }
  1367. /*****************************************************************************
  1368.  * FUNCTION
  1369.  *  SavePicEditImageDataBuff
  1370.  * DESCRIPTION
  1371.  *  Saves Image data buffer
  1372.  * PARAMETERS
  1373.  *  void
  1374.  * RETURNS
  1375.  *  void
  1376.  *****************************************************************************/
  1377. S32 SavePicEditImageDataBuff(void)
  1378. {
  1379.     /*----------------------------------------------------------------*/
  1380.     /* Local Variables                                                */
  1381.     /*----------------------------------------------------------------*/
  1382.     FILE_HANDLE fileHandle;
  1383.     S8 fileBuf[100 * ENCODING_LENGTH];  /* padding for filepath */
  1384.     S8 fileName[100 * ENCODING_LENGTH]; /* padding for filepath */
  1385.     S8 localBuffer[30 * ENCODING_LENGTH];
  1386.     U32 wByte = 0;
  1387.     S32 result;
  1388.     U16 image_size;
  1389.     /*----------------------------------------------------------------*/
  1390.     /* Code Body                                                      */
  1391.     /*----------------------------------------------------------------*/
  1392. #ifdef __ASCII
  1393.     pfnUnicodeStrcpy((PS8) fileName, PICTURE_EDITOR_PATH);
  1394. #else 
  1395.     AnsiiToUnicodeString((PS8) fileName, PICTURE_EDITOR_PATH);
  1396. #endif 
  1397.     memset(fileName, 0, sizeof(fileName));
  1398.     sprintf(fileBuf, "%c:\", MMI_PUBLIC_DRV);
  1399.     AnsiiToUnicodeString((S8*) fileName, (S8*) fileBuf);
  1400.     pfnUnicodeStrcat((S8*) fileName, (S8*) FMGR_DEFAULT_FOLDER_IMAGES);
  1401.     fileHandle = FS_Open((U16*) fileName, FS_OPEN_DIR | FS_READ_ONLY);
  1402.     if (fileHandle < 0)
  1403.     {
  1404.         fileHandle = pcreateDir(fileName);
  1405.         pfclose(fileHandle);
  1406.     }
  1407.     else
  1408.     {
  1409.         pfclose(fileHandle);
  1410.     }
  1411.     if (IS_PE_ADD_IMAGE(gPEAttrib))
  1412.     {
  1413.         //              wByte=0;
  1414.         //              while(1)
  1415.         //              {
  1416.         //                      sprintf(localBuffer,"Picture%d.bmp",(wByte%MAXIMUM_PICTURE_EDITOR_IMAGES)+1);
  1417.         sprintf(localBuffer, "Picture%d.bmp", gPicEditCurrPic + 1);
  1418.         AnsiiToUnicodeString((S8*) fileBuf, (S8*) localBuffer);
  1419.         //                      if (!SearchPicEditFileName(fileBuf)) break; else wByte++;
  1420.         //              }
  1421.     }
  1422.     else
  1423.     {
  1424.         pfnUnicodeStrcpy((S8*) fileBuf, (S8*) gPicEditorInfo[gPicEditCurrPic].ImageName);
  1425.     }
  1426.     pfnUnicodeStrcat((S8*) fileName, (S8*) fileBuf);
  1427.     if ((fileHandle = FS_Open((PU16) fileName, FS_READ_WRITE | FS_CREATE_ALWAYS)) < 0)
  1428.     {
  1429.         return fileHandle;
  1430.     }
  1431.     image_size = PIC_EDIT_FILE_HEADER_SIZE + ((GetImageWidth(0, gPEImageWidth) * gPEImageHeight));
  1432.     memcpy((S8*) & gpPEFileBuff[2], &image_size, 2);
  1433.     /* pfwrite(gpPEFileBuff,1,PIC_EDIT_FILE_BUFF,fileHandle,&wByte); */
  1434.     result = FS_Write(fileHandle, gpPEFileBuff, image_size, &wByte);    /* (gpPEFileBuff,1,image_size,fileHandle,&wByte); */
  1435.     if (result < 0)
  1436.     {
  1437.         FS_Close(fileHandle);
  1438.         return result;
  1439.     }
  1440.     FS_Close(fileHandle);
  1441.     if (IS_PE_ADD_IMAGE(gPEAttrib))
  1442.     {
  1443.         /* AddPictureEditorImage(( S8*)fileBuf); */
  1444.         AddPictureEditorImageAtIndex((S8*) fileBuf, gPicEditCurrPic);
  1445.         WritePicEditListToNVRAM();
  1446.     }
  1447.     return FS_NO_ERROR;
  1448. }
  1449. /*****************************************************************************
  1450.  * FUNCTION
  1451.  *  SearchPicEditFileName
  1452.  * DESCRIPTION
  1453.  *  Search file name in the images already present
  1454.  * PARAMETERS
  1455.  *  sFile       [?]     
  1456.  * RETURNS
  1457.  *  void
  1458.  *****************************************************************************/
  1459. U8 SearchPicEditFileName(S8 *sFile)
  1460. {
  1461.     /*----------------------------------------------------------------*/
  1462.     /* Local Variables                                                */
  1463.     /*----------------------------------------------------------------*/
  1464.     U8 jCount;
  1465.     /*----------------------------------------------------------------*/
  1466.     /* Code Body                                                      */
  1467.     /*----------------------------------------------------------------*/
  1468.     /* for (jCount=0;jCount<gPEImageCount;jCount++) */
  1469.     for (jCount = 0; jCount < MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  1470.     {
  1471.         if ((gPicEditorInfo[jCount].ImagesId) &&
  1472.             (!pfnUnicodeStrcmp((S8*) sFile, (S8*) gPicEditorInfo[jCount].ImageName)))
  1473.         {
  1474.             return 1;
  1475.         }
  1476.     }
  1477.     return 0;
  1478. }
  1479. /*****************************************************************************
  1480.  * FUNCTION
  1481.  *  GetPicEditCurrentImageName
  1482.  * DESCRIPTION
  1483.  *  Gets the image name for image selected
  1484.  * PARAMETERS
  1485.  *  void
  1486.  * RETURNS
  1487.  *  void
  1488.  *****************************************************************************/
  1489. U8 *GetPicEditCurrentImageName(void)
  1490. {
  1491.     /*----------------------------------------------------------------*/
  1492.     /* Local Variables                                                */
  1493.     /*----------------------------------------------------------------*/
  1494.     /*----------------------------------------------------------------*/
  1495.     /* Code Body                                                      */
  1496.     /*----------------------------------------------------------------*/
  1497.     return gPicEditorInfo[gPicEditCurrPic].ImageName;
  1498. }
  1499. /*****************************************************************************
  1500.  * FUNCTION
  1501.  *  GetPicEditCurrentImageId
  1502.  * DESCRIPTION
  1503.  *  Gets the image id for image selected
  1504.  * PARAMETERS
  1505.  *  void
  1506.  * RETURNS
  1507.  *  void
  1508.  *****************************************************************************/
  1509. U16 GetPicEditCurrentImageId(void)
  1510. {
  1511.     /*----------------------------------------------------------------*/
  1512.     /* Local Variables                                                */
  1513.     /*----------------------------------------------------------------*/
  1514.     /*----------------------------------------------------------------*/
  1515.     /* Code Body                                                      */
  1516.     /*----------------------------------------------------------------*/
  1517.     return gPicEditorInfo[gPicEditCurrPic].ImagesId;
  1518. }
  1519. /*****************************************************************************
  1520.  * FUNCTION
  1521.  *  SetPicEditPenMarkBoundary
  1522.  * DESCRIPTION
  1523.  *  Sets the mark boundary
  1524.  * PARAMETERS
  1525.  *  void
  1526.  * RETURNS
  1527.  *  void
  1528.  *****************************************************************************/
  1529. extern PicEditMarkBox gPicEditZoomWindow;
  1530. BOOL SetPicEditPenMarkBoundary(void)
  1531. {
  1532.     /*----------------------------------------------------------------*/
  1533.     /* Local Variables                                                */
  1534.     /*----------------------------------------------------------------*/
  1535.     U16 nWidth, nHeight;
  1536.     /*----------------------------------------------------------------*/
  1537.     /* Code Body                                                      */
  1538.     /*----------------------------------------------------------------*/
  1539.     switch (nInlinePEScr)
  1540.     {
  1541.         case PE_SCR_1:
  1542.             nWidth = PE_SCR_SIZE_1;
  1543.             nHeight = PE_SCR_SIZE_1;
  1544.             break;
  1545.         case PE_SCR_2:
  1546.             nWidth = PE_SCR_SIZE_2;
  1547.             nHeight = PE_SCR_SIZE_2;
  1548.             break;
  1549.         case PE_SCR_3:
  1550.             nWidth = PE_SCR_SIZE_MAX;
  1551.             nHeight = PE_SCR_SIZE_MAX;
  1552.             break;
  1553.         case PE_SCR_4:
  1554.             nWidth = gPEImageWidth;
  1555.             nHeight = gPEImageHeight;
  1556.             break;
  1557.         default:
  1558.             nWidth = PE_SCR_SIZE_2;
  1559.             nHeight = PE_SCR_SIZE_2;
  1560.             break;
  1561.     }
  1562.     if (((gpPicEditPen->maxX - gpPicEditPen->minX) >= nWidth) && ((gpPicEditPen->maxY - gpPicEditPen->minY) >= nHeight))
  1563.     {
  1564.         gPicEditZoomWindow.minX = gPicEditMark.minX = gpPicEditPen->penX = gpPicEditPen->minX;
  1565.         gPicEditZoomWindow.minY = gPicEditMark.minY = gpPicEditPen->penY = gpPicEditPen->minY;
  1566.         gPicEditZoomWindow.maxX = gPicEditMark.maxX = gPicEditMark.minX + nWidth;
  1567.         gPicEditZoomWindow.maxY = gPicEditMark.maxY = gPicEditMark.minY + nHeight;
  1568.         return TRUE;
  1569.     }
  1570.     else
  1571.     {
  1572.         return FALSE;
  1573.     }
  1574. }
  1575. /*****************************************************************************
  1576.  * FUNCTION
  1577.  *  GetPicEditScr
  1578.  * DESCRIPTION
  1579.  *  Gets the image size
  1580.  * PARAMETERS
  1581.  *  void
  1582.  * RETURNS
  1583.  *  void
  1584.  *****************************************************************************/
  1585. U8 GetPicEditScr(void)
  1586. {
  1587.     /*----------------------------------------------------------------*/
  1588.     /* Local Variables                                                */
  1589.     /*----------------------------------------------------------------*/
  1590.     /*----------------------------------------------------------------*/
  1591.     /* Code Body                                                      */
  1592.     /*----------------------------------------------------------------*/
  1593.     if ((gPEImageWidth == PE_SCR_SIZE_1) && (gPEImageHeight == PE_SCR_SIZE_1))
  1594.     {
  1595.         return PE_SCR_1;
  1596.     }
  1597.     else if ((gPEImageWidth == PE_SCR_SIZE_2) && (gPEImageHeight == PE_SCR_SIZE_2))
  1598.     {
  1599.         return PE_SCR_2;
  1600.     }
  1601.     else if ((gPEImageWidth == PE_SCR_SIZE_MAX) && (gPEImageHeight == PE_SCR_SIZE_MAX))
  1602.     {
  1603.         return PE_SCR_3;
  1604.     }
  1605.     else
  1606.     {
  1607.         return PE_SCR_4;
  1608.     }
  1609. }
  1610. /*****************************************************************************
  1611.  * FUNCTION
  1612.  *  CheckPicEditPenSettingChange
  1613.  * DESCRIPTION
  1614.  *  Checks if pen setting changed
  1615.  * PARAMETERS
  1616.  *  void
  1617.  * RETURNS
  1618.  *  void
  1619.  *****************************************************************************/
  1620. BOOL CheckPicEditPenSettingChange(void)
  1621. {
  1622.     /*----------------------------------------------------------------*/
  1623.     /* Local Variables                                                */
  1624.     /*----------------------------------------------------------------*/
  1625.     U8 penPixel;
  1626. #ifndef __MMI_TOUCH_SCREEN__
  1627.     U8 penMove;
  1628. #endif 
  1629.     /*----------------------------------------------------------------*/
  1630.     /* Code Body                                                      */
  1631.     /*----------------------------------------------------------------*/
  1632.     if (nInlinePenColorIndex != gpPicEditPen->penColorIndex - 1)
  1633.     {
  1634.         return TRUE;
  1635.     }
  1636.     switch (nInlinePenSize)
  1637.     {
  1638.         case 0:
  1639.             penPixel = PIC_EDIT_PEN_PIXEL_1;
  1640.             break;
  1641.         case 1:
  1642.             penPixel = PIC_EDIT_PEN_PIXEL_2;
  1643.             break;
  1644.         case 2:
  1645.             penPixel = PIC_EDIT_PEN_PIXEL_3;
  1646.             break;
  1647.         case 3:
  1648.             penPixel = PIC_EDIT_PEN_PIXEL_4;
  1649.             break;
  1650.         default:
  1651.             penPixel = PIC_EDIT_PEN_PIXEL_1;
  1652.             break;
  1653.     }
  1654. #ifndef __MMI_TOUCH_SCREEN__    /* PMT MANISH   20050616 */
  1655.     switch (nInlinePenMoveFactor)
  1656.     {
  1657.         case 0:
  1658.             penMove = PIC_EDIT_PEN_MOVE_1;
  1659.             break;
  1660.         case 1:
  1661.             penMove = PIC_EDIT_PEN_MOVE_2;
  1662.             break;
  1663.         case 2:
  1664.             penMove = PIC_EDIT_PEN_MOVE_3;
  1665.             break;
  1666.         case 3:
  1667.             penMove = PIC_EDIT_PEN_MOVE_4;
  1668.             break;
  1669.         default:
  1670.             penMove = PIC_EDIT_PEN_MOVE_1;
  1671.             break;
  1672.     }
  1673. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1674.     if (gpPicEditPen->penPixel != penPixel)
  1675.     {
  1676.         return TRUE;
  1677.     }
  1678. #ifndef __MMI_TOUCH_SCREEN__
  1679.     if (gpPicEditPen->penMove != penMove)
  1680.     {
  1681.         return TRUE;
  1682.     }
  1683. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1684.     return FALSE;
  1685. }
  1686. /*****************************************************************************
  1687.  * FUNCTION
  1688.  *  ReadPicEditListFromNVRAM
  1689.  * DESCRIPTION
  1690.  *  Reads image names present from NVRAM
  1691.  * PARAMETERS
  1692.  *  void
  1693.  * RETURNS
  1694.  *  void
  1695.  *****************************************************************************/
  1696. void ReadPicEditListFromNVRAM(void)
  1697. {
  1698.     /*----------------------------------------------------------------*/
  1699.     /* Local Variables                                                */
  1700.     /*----------------------------------------------------------------*/
  1701.     S16 error = 0;
  1702.     int nCount;
  1703.     /*----------------------------------------------------------------*/
  1704.     /* Code Body                                                      */
  1705.     /*----------------------------------------------------------------*/
  1706.     PRINT_INFORMATION(("Reading Picture List from NVRAM"));
  1707.     gPEImageCount = 0;
  1708.     if (ReadRecord(NVRAM_PICTURE_EDITOR_LID, (U16) (1), (void*)&gPicEditorInfo, NVRAM_PICTURE_EDITOR_SIZE, &error) < 0)
  1709.     {
  1710.         PRINT_INFORMATION(("PICTURE EDITOR : ReadRecord failed (ecode %d)", (int)error));
  1711.         memset(&gPicEditorInfo, '', NVRAM_PICTURE_EDITOR_SIZE);
  1712.         WriteRecord(NVRAM_PICTURE_EDITOR_LID, (U16) (1), (void*)&gPicEditorInfo, NVRAM_PICTURE_EDITOR_SIZE, &error);
  1713.     }
  1714.     for (nCount = 0; nCount < MAXIMUM_PICTURE_EDITOR_IMAGES; nCount++)
  1715.         if (gPicEditorInfo[nCount].ImagesId)
  1716.         {
  1717.             gPEImageCount++;
  1718.         }
  1719. }
  1720. /*****************************************************************************
  1721.  * FUNCTION
  1722.  *  WritePicEditListToNVRAM
  1723.  * DESCRIPTION
  1724.  *  Writes the image names in NVRAM
  1725.  * PARAMETERS
  1726.  *  void
  1727.  * RETURNS
  1728.  *  void
  1729.  *****************************************************************************/
  1730. void WritePicEditListToNVRAM(void)
  1731. {
  1732.     /*----------------------------------------------------------------*/
  1733.     /* Local Variables                                                */
  1734.     /*----------------------------------------------------------------*/
  1735.     S16 error = 0;
  1736.     /*----------------------------------------------------------------*/
  1737.     /* Code Body                                                      */
  1738.     /*----------------------------------------------------------------*/
  1739.     PRINT_INFORMATION(("Picture Name List To Write Record NVRAM"));
  1740.     if (WriteRecord(
  1741.             NVRAM_PICTURE_EDITOR_LID,
  1742.             (U16) (1),
  1743.             (void*)&gPicEditorInfo,
  1744.             NVRAM_PICTURE_EDITOR_SIZE,
  1745.             &error) != NVRAM_PICTURE_EDITOR_SIZE)
  1746.     {
  1747.         PRINT_INFORMATION(("PICTURE EDITOR : WriteRecord failed (ecode %d)", (int)error));
  1748.     }
  1749. }
  1750. /*****************************************************************************
  1751.  * FUNCTION
  1752.  *  AddPictureEditorImage
  1753.  * DESCRIPTION
  1754.  *  Add image to the image editor pictures
  1755.  * PARAMETERS
  1756.  *  fileName        [IN]        
  1757.  * RETURNS
  1758.  *  void
  1759.  *****************************************************************************/
  1760. S8 AddPictureEditorImage(S8 *fileName)
  1761. {
  1762.     /*----------------------------------------------------------------*/
  1763.     /* Local Variables                                                */
  1764.     /*----------------------------------------------------------------*/
  1765.     U16 searchId, jCount, nIndex = 0;
  1766.     BOOL bFound = FALSE;
  1767.     /*----------------------------------------------------------------*/
  1768.     /* Code Body                                                      */
  1769.     /*----------------------------------------------------------------*/
  1770.     if ((gPEImageCount) == MAXIMUM_PICTURE_EDITOR_IMAGES)
  1771.     {
  1772.         return 0;
  1773.     }
  1774.     for (jCount = 0; jCount < MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  1775.     {
  1776.         if (!
  1777.             ((gPicEditorInfo[jCount].ImagesId >= (U16) PICTURE_EDITOR_IMAGE_BASE) &&
  1778.              (gPicEditorInfo[jCount].ImagesId <= PICTURE_EDITOR_IMAGE_BASE_END)))
  1779.         {
  1780.             nIndex = jCount;
  1781.             break;
  1782.         }
  1783.     }
  1784.     if (!nIndex)
  1785.     {
  1786.         return 0;
  1787.     }
  1788.     for (searchId = (U16) PICTURE_EDITOR_IMAGE_BASE; searchId <= PICTURE_EDITOR_IMAGE_BASE_END; searchId++)
  1789.     {
  1790.         bFound = FALSE;
  1791.         for (jCount = 0; jCount < MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  1792.         {
  1793.             if (gPicEditorInfo[jCount].ImagesId == searchId)
  1794.             {
  1795.                 bFound = TRUE;
  1796.                 break;
  1797.             }
  1798.         }
  1799.         if (bFound == FALSE)
  1800.         {
  1801.             break;
  1802.         }
  1803.     }
  1804.     gPicEditorInfo[nIndex].ImagesId = searchId;
  1805.     memset((S8*) gPicEditorInfo[nIndex].ImageName, '', sizeof(U8) * MAX_IMAGE_NAME_WIDTH);
  1806.     pfnUnicodeStrcpy((S8*) gPicEditorInfo[nIndex].ImageName, fileName);
  1807.     gPEImageCount++;
  1808.     return 1;
  1809. }
  1810. /*****************************************************************************
  1811.  * FUNCTION
  1812.  *  AddPictureEditorImageAtIndex
  1813.  * DESCRIPTION
  1814.  *  Add image to the image editor pictures
  1815.  * PARAMETERS
  1816.  *  fileName        [IN]        
  1817.  *  nIndex          [IN]        
  1818.  * RETURNS
  1819.  *  void
  1820.  *****************************************************************************/
  1821. S8 AddPictureEditorImageAtIndex(S8 *fileName, U8 nIndex)
  1822. {
  1823.     /*----------------------------------------------------------------*/
  1824.     /* Local Variables                                                */
  1825.     /*----------------------------------------------------------------*/
  1826.     U16 searchId, jCount;
  1827.     BOOL bFound = FALSE;
  1828.     /*----------------------------------------------------------------*/
  1829.     /* Code Body                                                      */
  1830.     /*----------------------------------------------------------------*/
  1831.     if (!
  1832.         ((gPicEditorInfo[nIndex].ImagesId >= (U16) PICTURE_EDITOR_IMAGE_BASE) &&
  1833.          (gPicEditorInfo[nIndex].ImagesId <= PICTURE_EDITOR_IMAGE_BASE_END)))
  1834.     {
  1835.         if ((gPEImageCount) == MAXIMUM_PICTURE_EDITOR_IMAGES)
  1836.         {
  1837.             return 0;
  1838.         }
  1839.         for (searchId = (U16) PICTURE_EDITOR_IMAGE_BASE; searchId <= PICTURE_EDITOR_IMAGE_BASE_END; searchId++)
  1840.         {
  1841.             bFound = FALSE;
  1842.             for (jCount = 0; jCount < MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  1843.             {
  1844.                 if (gPicEditorInfo[jCount].ImagesId == searchId)
  1845.                 {
  1846.                     bFound = TRUE;
  1847.                     break;
  1848.                 }
  1849.             }
  1850.             if (bFound == FALSE)
  1851.             {
  1852.                 break;
  1853.             }
  1854.         }
  1855.         gPicEditorInfo[nIndex].ImagesId = searchId;
  1856.         gPEImageCount++;
  1857.     }
  1858.     memset((S8*) gPicEditorInfo[nIndex].ImageName, '', sizeof(U8) * MAX_IMAGE_NAME_WIDTH);
  1859.     pfnUnicodeStrcpy((S8*) gPicEditorInfo[nIndex].ImageName, fileName);
  1860.     return 1;
  1861. }
  1862. /*****************************************************************************
  1863.  * FUNCTION
  1864.  *  DeletePictureEditorImage
  1865.  * DESCRIPTION
  1866.  *  Deletes Image from image editor images
  1867.  *  
  1868.  *  Returns FALSE if fail else TRUE
  1869.  * PARAMETERS
  1870.  *  ImageId     [IN]        
  1871.  * RETURNS
  1872.  *  S8
  1873.  *****************************************************************************/
  1874. S8 DeletePictureEditorImage(U16 ImageId)
  1875. {
  1876.     /*----------------------------------------------------------------*/
  1877.     /* Local Variables                                                */
  1878.     /*----------------------------------------------------------------*/
  1879.     /* U8 iCount,jCount; */
  1880.     U8 iCount;
  1881.     /*----------------------------------------------------------------*/
  1882.     /* Code Body                                                      */
  1883.     /*----------------------------------------------------------------*/
  1884.     /* for(iCount=0;iCount<gPEImageCount;iCount++) */
  1885.     for (iCount = 0; iCount < MAXIMUM_PICTURE_EDITOR_IMAGES; iCount++)
  1886.     {
  1887.         if (gPicEditorInfo[iCount].ImagesId == ImageId)
  1888.         {
  1889.             break;
  1890.         }
  1891.     }
  1892.     /* if(iCount==gPEImageCount) return 0; */
  1893.     if (iCount == MAXIMUM_PICTURE_EDITOR_IMAGES)
  1894.     {
  1895.         return 0;
  1896.     }
  1897.     //      for(jCount=iCount;jCount<gPEImageCount-1;jCount++)
  1898.     //              memcpy(&gPicEditorInfo[jCount],&gPicEditorInfo[jCount+1],sizeof(DYNIMAGEINFO));
  1899.     //      gPEImageCount--;
  1900.     //      memset(&gPicEditorInfo[gPEImageCount],0,sizeof(DYNIMAGEINFO));
  1901.     memset(&gPicEditorInfo[iCount], 0, sizeof(DYNIMAGEINFO));
  1902.     gPEImageCount--;
  1903.     return 1;
  1904. }
  1905. /*****************************************************************************
  1906.  * FUNCTION
  1907.  *  GetPictureEditorImageInfo
  1908.  * DESCRIPTION
  1909.  *  Gets Image editor Info (Common function)
  1910.  *  
  1911.  *  Return image count
  1912.  * PARAMETERS
  1913.  *  pictureEditorInfo       [IN]        
  1914.  * RETURNS
  1915.  *  U8
  1916.  *****************************************************************************/
  1917. U8 GetPictureEditorImageInfo(DYNIMAGEINFO **pictureEditorInfo)
  1918. {
  1919.     /*----------------------------------------------------------------*/
  1920.     /* Local Variables                                                */
  1921.     /*----------------------------------------------------------------*/
  1922.     /*----------------------------------------------------------------*/
  1923.     /* Code Body                                                      */
  1924.     /*----------------------------------------------------------------*/
  1925.     *pictureEditorInfo = gPicEditorInfo;
  1926.     return gPEImageCount;
  1927. }
  1928. /*****************************************************************************
  1929.  * FUNCTION
  1930.  *  GetPictureEditorImageNameInFileSystem
  1931.  * DESCRIPTION
  1932.  *  Gets image name of the image by image id input
  1933.  *  
  1934.  *  Returns NULL if not found else pointer to the image name
  1935.  * PARAMETERS
  1936.  *  ImageId     [IN]        
  1937.  * RETURNS
  1938.  *  S8*
  1939.  *****************************************************************************/
  1940. S8 *GetPictureEditorImageNameInFileSystem(U16 ImageId)
  1941. {
  1942.     /*----------------------------------------------------------------*/
  1943.     /* Local Variables                                                */
  1944.     /*----------------------------------------------------------------*/
  1945.     int nCount = 0;
  1946.     /*----------------------------------------------------------------*/
  1947.     /* Code Body                                                      */
  1948.     /*----------------------------------------------------------------*/
  1949.     if (ImageId >= PICTURE_EDITOR_IMAGE_BASE && ImageId <= PICTURE_EDITOR_IMAGE_BASE_END)
  1950.     {
  1951.         /* for(nCount=0;nCount<gPEImageCount;nCount++) */
  1952.         for (nCount = 0; nCount < MAXIMUM_PICTURE_EDITOR_IMAGES; nCount++)
  1953.         {
  1954.             if (gPicEditorInfo[nCount].ImagesId == ImageId)
  1955.             {
  1956.                 return (S8*) gPicEditorInfo[nCount].ImageName;
  1957.             }
  1958.         }
  1959.     }
  1960.     return NULL;
  1961. }
  1962. /*****************************************************************************
  1963.  * FUNCTION
  1964.  *  GetPictureEditorImageNameWithPathInFileSystem
  1965.  * DESCRIPTION
  1966.  *  Get image name with full path by image id input
  1967.  *  
  1968.  *  returns poiinter to the image name with full path if found else NULL
  1969.  * PARAMETERS
  1970.  *  ImageId     [IN]        
  1971.  * RETURNS
  1972.  *  S8*
  1973.  *****************************************************************************/
  1974. S8 *GetPictureEditorImageNameWithPathInFileSystem(U16 ImageId)
  1975. {
  1976.     /*----------------------------------------------------------------*/
  1977.     /* Local Variables                                                */
  1978.     /*----------------------------------------------------------------*/
  1979.     U8 *fileName = NULL;
  1980.     static S8 imageData[MAX_IMAGE_NAME_PATH_WIDTH + MAX_IMAGE_NAME_WIDTH];
  1981. #ifdef MMI_ON_HARDWARE_P
  1982.     S8 imagePath[100];
  1983. #endif 
  1984.     int nCount = 0;
  1985.     /*----------------------------------------------------------------*/
  1986.     /* Code Body                                                      */
  1987.     /*----------------------------------------------------------------*/
  1988.     if (ImageId >= PICTURE_EDITOR_IMAGE_BASE && ImageId <= PICTURE_EDITOR_IMAGE_BASE_END)
  1989.     {
  1990.         /* for(nCount=0;nCount<gPEImageCount;nCount++) */
  1991.         for (nCount = 0; nCount < MAXIMUM_PICTURE_EDITOR_IMAGES; nCount++)
  1992.         {
  1993.             if (gPicEditorInfo[nCount].ImagesId == ImageId)
  1994.             {
  1995.                 fileName = (U8*) gPicEditorInfo[nCount].ImageName;
  1996.                 break;
  1997.             }
  1998.         }
  1999.         /* if(nCount==gPEImageCount) return NULL; */
  2000.         if (nCount == MAXIMUM_PICTURE_EDITOR_IMAGES)
  2001.         {
  2002.             return NULL;
  2003.         }
  2004.     #ifdef MMI_ON_HARDWARE_P
  2005.         memset(imagePath, 0, sizeof(imagePath));
  2006.         sprintf(imagePath, "%c:\", MMI_PUBLIC_DRV);
  2007.         AnsiiToUnicodeString(imageData, imagePath);
  2008.         pfnUnicodeStrcat((S8*) imageData, (S8*) FMGR_DEFAULT_FOLDER_IMAGES);
  2009.     #else /* MMI_ON_HARDWARE_P */ 
  2010.     #ifdef __ASCII
  2011.         pfnUnicodeStrcpy((PS8) imageData, PICTURE_EDITOR_PATH);
  2012.     #else 
  2013.         AnsiiToUnicodeString((PS8) imageData, PICTURE_EDITOR_PATH);
  2014.     #endif 
  2015.     #endif /* MMI_ON_HARDWARE_P */ 
  2016.         pfnUnicodeStrcat((PS8) imageData, (PS8) fileName);
  2017.         return imageData;
  2018.     }
  2019.     return NULL;
  2020. }
  2021. #endif /* __MMI_PICTURE_EDITOR_SUPPORT__ */