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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  *  PictureEditor.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  MAUI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  
  47.  *
  48.  * Author:
  49.  * -------
  50.  *  
  51.  *
  52.  *==============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  *------------------------------------------------------------------------------
  143.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  144.  *==============================================================================
  145.  *******************************************************************************/
  146. /**
  147.  * Copyright Notice
  148.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  149.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  150.  *  (It is illegal to remove this copyright notice from this software or any
  151.  *  portion of it)
  152.  */
  153. /**************************************************************
  154.    FILENAME : PictureEditor.c
  155.    PURPOSE     : Main functions of the Picture Editor application
  156.    REMARKS     : nil
  157.    AUTHOR      : Yogesh
  158.    DATE     : Jan-13-2004
  159. **************************************************************/
  160. #include "MMI_features.h"
  161. #include "stdC.h"
  162. #include "L4Dr1.h"
  163. #include "PixtelDataTypes.h"
  164. #include "Fat_fs.h"
  165. #ifdef __MMI_PICTURE_EDITOR_SUPPORT__
  166. #include "PictureEditorDefs.h"
  167. #include "PictureEditorDecl.h"
  168. #include "PictureEditorProts.h"
  169. #include "CustDataProts.h"
  170. #include "GlobalDefs.h"
  171. #include "NVRAMType.h"
  172. #include "NVRAMProt.h"
  173. #include "NVRAMEnum.h"
  174. #include "DebugInitDef.h"
  175. #include "MainMenuDef.h"
  176. #include "wgui_categories.h"
  177. #include "wgui_categories_inputs.h"
  178. #include "wgui_categories_defs.h"
  179. #include "wgui_categories_PE.h"
  180. #include "wgui_categories_popup.h"
  181. #include "HistoryGprot.h"
  182. #include "CustMenuRes.h"
  183. #include "CommonScreens.h"
  184. #include "Downloaddefs.h"
  185. #include "DownloadProtos.h"
  186. #include "FileMgr.h"    /* Should include FileMgr.h before ProfileMgrGprot.h */
  187. #include "FileSystemDef.h"
  188. #include "FileSystemGProt.h"
  189. #include "SettingProfile.h"
  190. #include "FunAndGamesDefs.h"
  191. #include "ProfileGprots.h"
  192. #include "FileManagerGProt.h"
  193. #include "FileManagerDef.h"
  194. /**********************Defines************************/
  195. /**********************Local Variables************************/
  196. static DYNIMAGEINFO gPicEditorInfo[MAXIMUM_PICTURE_EDITOR_IMAGES];
  197. static S32 g_pe_color_index = 0;
  198. static U8 nSelPEPenSetting;
  199. static U8 nSelPEEditOpt;
  200. static U8 nSelPEViewOpt;
  201. static S32 nInlinePenSize = 0;
  202. static S32 nInlinePenMoveFactor = 0;
  203. static S32 nInlinePenColorIndex = 0;
  204. static U8 *pInlinePenSizeList[MAX_TYPE_PEN_PIXEL];
  205. #ifndef __MMI_TOUCH_SCREEN__    /* PMT MANISH   20050616 */
  206. static U8 *pInlinePenMoveFactorList[MAX_TYPE_PEN_MOVE];
  207. #endif 
  208. static U8 *pInlinePenColorIndexList[MAX_TYPE_PEN_COLOR - 1];
  209. static U8 inlinePERGBlist[MAX_TYPE_PEN_COLOR][3];
  210. static U8 inlineCustomRGB[3];
  211. static mmi_cat91_color_slider_enum highlighted_slider = MMI_CAT91_COLOR_SLIDER_RED_COLOR;
  212. static InlineItem PicEditInLineItems[MAX_RESIZE_INLINE_EDIT];
  213. static S32 nInlinePEScr = PE_SCR_2;
  214. static U8 *pInlinePEScrList[MAX_TYPE_SCR_TYPE];
  215. static U8 nInlinePEScrWidth[4 * ENCODING_LENGTH];
  216. static U8 nInlinePEScrHeight[4 * ENCODING_LENGTH];
  217. /**********************Global Variables************************/
  218. U16 gPEAttrib = 0;
  219. U8 gPicEditCurrPic;
  220. U8 gPicEditSelectedPic;
  221. U8 gPEImageCount = 0;
  222. U8 gPECurrentAction = SEL_PE_EDIT_OPT_SAVE_PIC;
  223. S16 gPEImageWidth = PE_SCR_SIZE_2;
  224. S16 gPEImageHeight = PE_SCR_SIZE_2;
  225. S16 gPEImageWidth_bak = PE_SCR_SIZE_2;
  226. S16 gPEImageHeight_bak = PE_SCR_SIZE_2;
  227. MMI_BOOL gPEImageResized = MMI_FALSE;
  228. /**********************Extern Variables************************/
  229. extern PU8 gpPEBackupDataBuff;
  230. extern PictureEditorPen *gpPicEditPen;
  231. extern PictureEditorPen *gpPicEditBackupPen;
  232. extern PicEditMarkBox gPicEditMark;
  233. extern U8 *gpPEFileBuff;
  234. extern U8 gPEBitsPerPixel;
  235. /* 051605 Calvin added */
  236. #if defined(__MMI_MAINLCD_240X320__)
  237. extern U8 *gpPicEditFillColorIndex;
  238. #endif 
  239. /* Calvin end */
  240. /*****************************************************************************
  241.  * FUNCTION
  242.  *  InitPictureEditor
  243.  * DESCRIPTION
  244.  *  Initializes the NVRAM buffer for Image Editor
  245.  * PARAMETERS
  246.  *  void
  247.  * RETURNS
  248.  *  void
  249.  *****************************************************************************/
  250. void InitPictureEditor(void)
  251. {
  252.     /*----------------------------------------------------------------*/
  253.     /* Local Variables                                                */
  254.     /*----------------------------------------------------------------*/
  255.     /*----------------------------------------------------------------*/
  256.     /* Code Body                                                      */
  257.     /*----------------------------------------------------------------*/
  258.     InitRedoUndoBuffers();
  259.     ReadPicEditListFromNVRAM();
  260. }
  261. /*****************************************************************************
  262.  * FUNCTION
  263.  *  InitPicEditPen
  264.  * DESCRIPTION
  265.  *  Initializes the Image Editor Pen setting to default values
  266.  * PARAMETERS
  267.  *  void
  268.  * RETURNS
  269.  *  void
  270.  *****************************************************************************/
  271. void InitPicEditPen(void)
  272. {
  273.     /*----------------------------------------------------------------*/
  274.     /* Local Variables                                                */
  275.     /*----------------------------------------------------------------*/
  276.     /*----------------------------------------------------------------*/
  277.     /* Code Body                                                      */
  278.     /*----------------------------------------------------------------*/
  279.     gPEAttrib &= ~(PE_IMAGE_EDIT | PE_UNDO_IMAGE | PE_ZOOM_IMAGE | PE_PEN_DOWN | PE_MARK_IMAGE | PE_COPY_IMAGE);
  280.     gPECurrentAction = SEL_PE_EDIT_OPT_SAVE_PIC;
  281.     nInlinePEScr = PE_SCR_2;
  282.     gpPicEditPen->penPixel = PIC_EDIT_PEN_PIXEL_1;
  283.     gpPicEditPen->penColorIndex = PE_COLOR_BLACK;
  284.     gpPicEditPen->penBackgrdColorIndex = PE_COLOR_WHITE;
  285.     gpPicEditPen->penMove = PIC_EDIT_PEN_MOVE_1;
  286. #ifdef __MMI_TOUCH_SCREEN__
  287.     gpPicEditPen->penContextSaved = MMI_FALSE;
  288. #endif 
  289.     gpPicEditBackupPen->penPixel = PIC_EDIT_PEN_PIXEL_1;
  290.     gpPicEditBackupPen->penColorIndex = PE_COLOR_BLACK;
  291.     gpPicEditBackupPen->penBackgrdColorIndex = PE_COLOR_WHITE;
  292.     gpPicEditBackupPen->penMove = PIC_EDIT_PEN_MOVE_1;
  293. #ifdef __MMI_TOUCH_SCREEN__
  294.     gpPicEditBackupPen->penContextSaved = MMI_FALSE;
  295. #endif 
  296. #if defined(__MMI_MAINLCD_240X320__)
  297.     *gpPicEditFillColorIndex = PE_COLOR_WHITE;
  298. #endif 
  299.     gPEColorRGB[PE_COLOR_CUSTOM_1] = 0x00408000;
  300.     SetPicEditPenBoundary();
  301.     SetPicEditPenAtCenter(TRUE);
  302. }
  303. /*****************************************************************************
  304.  * FUNCTION
  305.  *  EntryScr4PicEditSelectMenu
  306.  * DESCRIPTION
  307.  *  Entry function for image editor select image menu
  308.  * PARAMETERS
  309.  *  void
  310.  * RETURNS
  311.  *  void
  312.  *****************************************************************************/
  313. void EntryScr4PicEditSelectMenu(void)
  314. {
  315.     /*----------------------------------------------------------------*/
  316.     /* Local Variables                                                */
  317.     /*----------------------------------------------------------------*/
  318.     U8 *guiBuffer = NULL;
  319.     U8 jCount;
  320.     DYNAMICINFO dynInfo;
  321.     U8 *pPicEditList[MAXIMUM_PICTURE_EDITOR_IMAGES];
  322.     S8 imagePath[100];
  323.     S8 imageData[100 * ENCODING_LENGTH];
  324.     /*----------------------------------------------------------------*/
  325.     /* Code Body                                                      */
  326.     /*----------------------------------------------------------------*/
  327.     InitPicEditPen();
  328.     EntryNewScreen(SCR_PE_SELECT_PIC_MENU, ExitScr4PicEditSelectMenu, NULL, NULL);
  329.     guiBuffer = GetCurrGuiBuffer(SCR_PE_SELECT_PIC_MENU);
  330.     SetParentHandler(0);
  331.     RegisterHighlightHandler(ChangePicEditSelectMenuSoftKey);
  332.     ReadPicEditListFromNVRAM();
  333.     if (guiBuffer == NULL)
  334.     {
  335.         dynInfo.DynInfoType = IMAGEINFO;
  336.         dynInfo.DYNINFOUNION.ImageInfo = gPicEditorInfo;
  337.         dynInfo.NoOfEntries = gPEImageCount;
  338.         memset(imagePath, 0, sizeof(imagePath));
  339.         sprintf(imagePath, "%c:\", MMI_PUBLIC_DRV);
  340.         AnsiiToUnicodeString(imageData, imagePath);
  341.         pfnUnicodeStrcat((S8*) imageData, (S8*) FMGR_DEFAULT_FOLDER_IMAGES);
  342.         SyncPicEditFileSystem(imageData, &dynInfo);
  343.     }
  344.     /*
  345.      * for (jCount=0; jCount<gPEImageCount; jCount++)
  346.      * {
  347.      * pPicEditList[jCount] = (U8*)gPicEditorInfo[jCount].ImageName;
  348.      * }
  349.      * 
  350.      * for (jCount=gPEImageCount; jCount<MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  351.      * {
  352.      * pPicEditList[jCount] = (U8*)GetString(STR_GLOBAL_EMPTY_LIST);
  353.      * }
  354.      */
  355.     for (jCount = 0; jCount < MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  356.     {
  357.         if (((gPicEditorInfo[jCount].ImagesId >= (U16) PICTURE_EDITOR_IMAGE_BASE) &&
  358.              (gPicEditorInfo[jCount].ImagesId <= PICTURE_EDITOR_IMAGE_BASE_END)))
  359.         {
  360.             pPicEditList[jCount] = (U8*) gPicEditorInfo[jCount].ImageName;
  361.         }
  362.         else
  363.         {
  364.             pPicEditList[jCount] = (U8*) GetString(STR_GLOBAL_EMPTY_LIST);
  365.         }
  366.     }
  367.     ShowCategory84Screen(
  368.         STR_PE_DRAW_PICTURE,
  369.         GetRootTitleIcon(MENU_PICTURE_EDITOR),
  370.         STR_GLOBAL_OPTIONS,
  371.         IMG_GLOBAL_OPTIONS,
  372.         STR_GLOBAL_BACK,
  373.         IMG_GLOBAL_BACK,
  374.         MAXIMUM_PICTURE_EDITOR_IMAGES,
  375.         (U8 **) pPicEditList,
  376.         (PU16) gIndexIconsImageList,
  377.         LIST_MENU,
  378.         0,
  379.         guiBuffer);
  380.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  381.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  382.     /* SetExitHandler (SCR_PE_SELECT_PIC_MENU, ExitScr4PicEditSelectMenu); */
  383. }
  384. /*****************************************************************************
  385.  * FUNCTION
  386.  *  ExitScr4PicEditSelectMenu
  387.  * DESCRIPTION
  388.  *  Exit function for EntryScr4PicEditSelectMenu
  389.  * PARAMETERS
  390.  *  void
  391.  * RETURNS
  392.  *  void
  393.  *****************************************************************************/
  394. void ExitScr4PicEditSelectMenu(void)
  395. {
  396.     /*----------------------------------------------------------------*/
  397.     /* Local Variables                                                */
  398.     /*----------------------------------------------------------------*/
  399.     history h;
  400.     S16 nHistory = 0;
  401.     /*----------------------------------------------------------------*/
  402.     /* Code Body                                                      */
  403.     /*----------------------------------------------------------------*/
  404.     h.scrnID = SCR_PE_SELECT_PIC_MENU;
  405.     h.entryFuncPtr = EntryScr4PicEditSelectMenu;
  406.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  407.     GetCategoryHistory(h.guiBuffer);
  408.     AddHistory(h);
  409. }
  410. /*****************************************************************************
  411.  * FUNCTION
  412.  *  ChangePicEditSelectMenuSoftKey
  413.  * DESCRIPTION
  414.  *  Changes softkey according to the selected image
  415.  * PARAMETERS
  416.  *  nIndex      [IN]        
  417.  * RETURNS
  418.  *  void
  419.  *****************************************************************************/
  420. void ChangePicEditSelectMenuSoftKey(S32 nIndex)
  421. {
  422.     /*----------------------------------------------------------------*/
  423.     /* Local Variables                                                */
  424.     /*----------------------------------------------------------------*/
  425.     /*----------------------------------------------------------------*/
  426.     /* Code Body                                                      */
  427.     /*----------------------------------------------------------------*/
  428.     SetPicEditCurrPic(nIndex);
  429.     /* if(gPicEditCurrPic<gPEImageCount) */
  430.     if (gPicEditorInfo[nIndex].ImagesId)
  431.         /* if (((gPicEditorInfo[gPicEditCurrPic].ImagesId>=(U16)PICTURE_EDITOR_IMAGE_BASE)&&(gPicEditorInfo[gPicEditCurrPic].ImagesId<=PICTURE_EDITOR_IMAGE_BASE_END))) */
  432.     {
  433.         ChangeLeftSoftkey(STR_GLOBAL_VIEW, IMG_GLOBAL_OK);
  434.         SetLeftSoftkeyFunction(EntryScr4PicEditShowImage, KEY_EVENT_UP);
  435.         SetKeyHandler(EntryScr4PicEditShowImage, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  436.     }
  437.     else
  438.     {
  439.         ChangeLeftSoftkey(STR_GLOBAL_ADD, IMG_GLOBAL_OK);
  440.         SetLeftSoftkeyFunction(EntryPicEditAddPic, KEY_EVENT_UP);
  441.         SetKeyHandler(EntryPicEditAddPic, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  442.         SET_PE_ADD_IMAGE(gPEAttrib);
  443.     }
  444. }
  445. /*****************************************************************************
  446.  * FUNCTION
  447.  *  EntryPicEditAddPic
  448.  * DESCRIPTION
  449.  *  Entry function for add image
  450.  * PARAMETERS
  451.  *  void
  452.  * RETURNS
  453.  *  void
  454.  *****************************************************************************/
  455. void EntryPicEditAddPic(void)
  456. {
  457.     /*----------------------------------------------------------------*/
  458.     /* Local Variables                                                */
  459.     /*----------------------------------------------------------------*/
  460.     /*----------------------------------------------------------------*/
  461.     /* Code Body                                                      */
  462.     /*----------------------------------------------------------------*/
  463.     InitRedoUndoBuffers();
  464.     InitPicEditPen();
  465.     SetPicEditEmptyImageDataBuff();
  466.     SavePEContext();
  467.     SetCurrentImageParams();
  468.     UNSET_PE_IMAGE_CHANGED(gPEAttrib);
  469.     EntryScr4PicEditEditImage();
  470. }
  471. /*****************************************************************************
  472.  * FUNCTION
  473.  *  ShowPicEditPrevImage
  474.  * DESCRIPTION
  475.  *  Shows previous image on image viewing window
  476.  * PARAMETERS
  477.  *  void
  478.  * RETURNS
  479.  *  void
  480.  *****************************************************************************/
  481. void ShowPicEditPrevImage(void)
  482. {
  483.     /*----------------------------------------------------------------*/
  484.     /* Local Variables                                                */
  485.     /*----------------------------------------------------------------*/
  486.     /*----------------------------------------------------------------*/
  487.     /* Code Body                                                      */
  488.     /*----------------------------------------------------------------*/
  489.     if (gPEImageCount == 1)
  490.     {
  491.         return;
  492.     }
  493.     do
  494.     {
  495.         gPicEditCurrPic = gPicEditCurrPic ? gPicEditCurrPic - 1 : MAXIMUM_PICTURE_EDITOR_IMAGES - 1;
  496.     } while (!gPicEditorInfo[gPicEditCurrPic].ImagesId);
  497.     ShowPicEditImage();
  498. }
  499. /*****************************************************************************
  500.  * FUNCTION
  501.  *  ShowPicEditNextImage
  502.  * DESCRIPTION
  503.  *  Shows Next image on image viewing window
  504.  * PARAMETERS
  505.  *  void
  506.  * RETURNS
  507.  *  void
  508.  *****************************************************************************/
  509. void ShowPicEditNextImage(void)
  510. {
  511.     /*----------------------------------------------------------------*/
  512.     /* Local Variables                                                */
  513.     /*----------------------------------------------------------------*/
  514.     /*----------------------------------------------------------------*/
  515.     /* Code Body                                                      */
  516.     /*----------------------------------------------------------------*/
  517.     if (gPEImageCount == 1)
  518.     {
  519.         return;
  520.     }
  521.     do
  522.     {
  523.         gPicEditCurrPic = (gPicEditCurrPic == (MAXIMUM_PICTURE_EDITOR_IMAGES - 1)) ? 0 : gPicEditCurrPic + 1;
  524.     } while (!gPicEditorInfo[gPicEditCurrPic].ImagesId);
  525.     ShowPicEditImage();
  526. }
  527. /*****************************************************************************
  528.  * FUNCTION
  529.  *  ShowPicEditImage
  530.  * DESCRIPTION
  531.  *  Show image on view image
  532.  * PARAMETERS
  533.  *  void
  534.  * RETURNS
  535.  *  void
  536.  *****************************************************************************/
  537. void ShowPicEditImage(void)
  538. {
  539.     /*----------------------------------------------------------------*/
  540.     /* Local Variables                                                */
  541.     /*----------------------------------------------------------------*/
  542.     /*----------------------------------------------------------------*/
  543.     /* Code Body                                                      */
  544.     /*----------------------------------------------------------------*/
  545.     if (gPicEditorInfo[gPicEditCurrPic].ImagesId)
  546.     {
  547.         ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  548.         SetLeftSoftkeyFunction(EntryScr4PicEditViewOpt, KEY_EVENT_UP);
  549.         SetKeyHandler(EntryScr4PicEditViewOpt, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  550.         SetPicEditImageDataBuff(gPicEditorInfo[gPicEditCurrPic].ImageName);
  551.     }
  552.     else
  553.     {
  554.         ChangeLeftSoftkey((U16) NULL, (U16) NULL);
  555.         ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  556.         nInlinePEScr = PE_SCR_2;
  557.         SetPicEditPenBoundary();
  558.         SetPicEditEmptyImageDataBuff();
  559.     }
  560. #if(UI_DOUBLE_BUFFER_SUPPORT)
  561.     gui_lock_double_buffer();
  562. #endif 
  563.     ShowPicEditImageWindow(&gpPEFileBuff[-MAX_IMAGE_HEADER_LENGTH]);
  564. #if(UI_DOUBLE_BUFFER_SUPPORT)
  565.     gui_unlock_double_buffer();
  566.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  567. #endif /* (UI_DOUBLE_BUFFER_SUPPORT) */ 
  568. }
  569. /*****************************************************************************
  570.  * FUNCTION
  571.  *  EntryScr4PicEditViewOpt
  572.  * DESCRIPTION
  573.  *  Entry function for View image option
  574.  * PARAMETERS
  575.  *  void
  576.  * RETURNS
  577.  *  void
  578.  *****************************************************************************/
  579. void EntryScr4PicEditViewOpt(void)
  580. {
  581.     /*----------------------------------------------------------------*/
  582.     /* Local Variables                                                */
  583.     /*----------------------------------------------------------------*/
  584.     U8 *guiBuffer = NULL;
  585.     U16 nPEViewOptList[13];
  586.     U16 noOfChildren;
  587.     /*----------------------------------------------------------------*/
  588.     /* Code Body                                                      */
  589.     /*----------------------------------------------------------------*/
  590.     noOfChildren = GetNumOfChild(MENU_PE_VIEW_OPT);
  591.     guiBuffer = GetCurrGuiBuffer(SCR_PE_VIEW_OPTION);
  592.     /* ExecuteCurrExitHandler (); */
  593.     EntryNewScreen(SCR_PE_VIEW_OPTION, ExitScr4PicEditViewOpt, NULL, NULL);
  594.     GetSequenceStringIds(MENU_PE_VIEW_OPT, nPEViewOptList);
  595.     SetParentHandler(MENU_PE_VIEW_OPT);
  596.     SetHiliteHandler(MENU_PE_VIEW_OPT_EDIT, SelPEViewOptEdit);
  597.     SetHiliteHandler(MENU_PE_VIEW_OPT_DELETE, SelPEViewOptDelete);
  598.     SetHiliteHandler(MENU_PE_VIEW_OPT_DELETEALL, SelPEViewOptDeleteAll);
  599.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  600.     ShowCategory15Screen(
  601.         STR_GLOBAL_OPTIONS,
  602.         GetRootTitleIcon(MENU_PICTURE_EDITOR),
  603.         STR_GLOBAL_OK,
  604.         IMG_GLOBAL_OK,
  605.         STR_GLOBAL_BACK,
  606.         IMG_GLOBAL_BACK,
  607.         noOfChildren,
  608.         nPEViewOptList,
  609.         (PU16) gIndexIconsImageList,
  610.         1,
  611.         0,
  612.         guiBuffer);
  613.     /* Register function for left soft key */
  614.     SetLeftSoftkeyFunction(EntryPicEditViewOpt, KEY_EVENT_UP);
  615.     /* Register function for right soft key */
  616.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  617.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  618.     /* SetExitHandler (SCR_PE_VIEW_OPTION, ExitScr4PicEditViewOpt); */
  619. }
  620. /*****************************************************************************
  621.  * FUNCTION
  622.  *  ExitScr4PicEditViewOpt
  623.  * DESCRIPTION
  624.  *  Exit function for EntryScr4PicEditViewOpt
  625.  * PARAMETERS
  626.  *  void
  627.  * RETURNS
  628.  *  void
  629.  *****************************************************************************/
  630. void ExitScr4PicEditViewOpt(void)
  631. {
  632.     /*----------------------------------------------------------------*/
  633.     /* Local Variables                                                */
  634.     /*----------------------------------------------------------------*/
  635.     history h;
  636.     S16 nHistory = 0;
  637.     /*----------------------------------------------------------------*/
  638.     /* Code Body                                                      */
  639.     /*----------------------------------------------------------------*/
  640.     h.scrnID = SCR_PE_VIEW_OPTION;
  641.     h.entryFuncPtr = EntryScr4PicEditViewOpt;
  642.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  643.     GetCategoryHistory(h.guiBuffer);
  644.     AddHistory(h);
  645. }
  646. /*****************************************************************************
  647.  * FUNCTION
  648.  *  SelPEViewOptEdit
  649.  * DESCRIPTION
  650.  *  Hilite handler for option screen of view image
  651.  * PARAMETERS
  652.  *  void
  653.  * RETURNS
  654.  *  void
  655.  *****************************************************************************/
  656. void SelPEViewOptEdit(void)
  657. {
  658.     /*----------------------------------------------------------------*/
  659.     /* Local Variables                                                */
  660.     /*----------------------------------------------------------------*/
  661.     /*----------------------------------------------------------------*/
  662.     /* Code Body                                                      */
  663.     /*----------------------------------------------------------------*/
  664.     nSelPEViewOpt = SEL_PE_VIEW_OPT_EDIT;
  665. }
  666. /*****************************************************************************
  667.  * FUNCTION
  668.  *  SelPEViewOptDelete
  669.  * DESCRIPTION
  670.  *  Hilite handler for option screen of view image
  671.  * PARAMETERS
  672.  *  void
  673.  * RETURNS
  674.  *  void
  675.  *****************************************************************************/
  676. void SelPEViewOptDelete(void)
  677. {
  678.     /*----------------------------------------------------------------*/
  679.     /* Local Variables                                                */
  680.     /*----------------------------------------------------------------*/
  681.     /*----------------------------------------------------------------*/
  682.     /* Code Body                                                      */
  683.     /*----------------------------------------------------------------*/
  684.     nSelPEViewOpt = SEL_PE_VIEW_OPT_DELETE;
  685. }
  686. /*****************************************************************************
  687.  * FUNCTION
  688.  *  SelPEViewOptDeleteAll
  689.  * DESCRIPTION
  690.  *  Hilite handler for option screen of view image
  691.  * PARAMETERS
  692.  *  void
  693.  * RETURNS
  694.  *  void
  695.  *****************************************************************************/
  696. void SelPEViewOptDeleteAll(void)
  697. {
  698.     /*----------------------------------------------------------------*/
  699.     /* Local Variables                                                */
  700.     /*----------------------------------------------------------------*/
  701.     /*----------------------------------------------------------------*/
  702.     /* Code Body                                                      */
  703.     /*----------------------------------------------------------------*/
  704.     nSelPEViewOpt = SEL_PE_VIEW_OPT_DELETEALL;
  705. }
  706. /*****************************************************************************
  707.  * FUNCTION
  708.  *  EntryPicEditViewOpt
  709.  * DESCRIPTION
  710.  *  Entry function depending of the selected option of view image
  711.  * PARAMETERS
  712.  *  void
  713.  * RETURNS
  714.  *  void
  715.  *****************************************************************************/
  716. void EntryPicEditViewOpt(void)
  717. {
  718.     /*----------------------------------------------------------------*/
  719.     /* Local Variables                                                */
  720.     /*----------------------------------------------------------------*/
  721.     /*----------------------------------------------------------------*/
  722.     /* Code Body                                                      */
  723.     /*----------------------------------------------------------------*/
  724.     switch (nSelPEViewOpt)
  725.     {
  726.         case SEL_PE_VIEW_OPT_EDIT:  /* Edit */
  727.             UNSET_PE_ADD_IMAGE(gPEAttrib);
  728.             InitRedoUndoBuffers();
  729.             InitPicEditPen();
  730.             if (SetPicEditImageDataBuff(gPicEditorInfo[gPicEditCurrPic].ImageName) == MMI_FALSE)
  731.             {
  732.                 DisplayPopup((U8*) GetString(STR_GLOBAL_NOT_DONE), IMG_GLOBAL_NO, 0, 1000, (U8) ERROR_TONE);
  733.                 break;
  734.             }
  735.             SavePEContext();
  736.             SetCurrentImageParams();
  737.             UNSET_PE_IMAGE_CHANGED(gPEAttrib);
  738.             EntryScr4PicEditEditImage();
  739.             break;
  740.         case SEL_PE_VIEW_OPT_DELETE:    /* Delete */
  741.             EntryScr4PicEditDeleteConfirm();
  742.             break;
  743.         case SEL_PE_VIEW_OPT_DELETEALL: /* Delete All */
  744.             EntryScr4PicEditDeleteAllConfirm();
  745.             break;
  746.         default:
  747.             break;
  748.     }
  749. }
  750. /*****************************************************************************
  751.  * FUNCTION
  752.  *  EntryScr4PicEditDeleteConfirm
  753.  * DESCRIPTION
  754.  *  Entry function for delete image confirmation
  755.  * PARAMETERS
  756.  *  void
  757.  * RETURNS
  758.  *  void
  759.  *****************************************************************************/
  760. void EntryScr4PicEditDeleteConfirm(void)
  761. {
  762.     /*----------------------------------------------------------------*/
  763.     /* Local Variables                                                */
  764.     /*----------------------------------------------------------------*/
  765.     /*----------------------------------------------------------------*/
  766.     /* Code Body                                                      */
  767.     /*----------------------------------------------------------------*/
  768.     DisplayConfirm(
  769.         STR_GLOBAL_YES,
  770.         IMG_GLOBAL_YES,
  771.         STR_GLOBAL_NO,
  772.         IMG_GLOBAL_NO,
  773.         get_string(STR_GLOBAL_DELETE),
  774.         IMG_GLOBAL_QUESTION,
  775.         WARNING_TONE);
  776.     SetLeftSoftkeyFunction(PicEditDeleteImage, KEY_EVENT_UP);
  777.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  778. }
  779. /*****************************************************************************
  780.  * FUNCTION
  781.  *  ExitScr4PicEditDeleteConfirm
  782.  * DESCRIPTION
  783.  *  Exit function for EntryScr4PicEditDeleteConfirm
  784.  * PARAMETERS
  785.  *  void
  786.  * RETURNS
  787.  *  void
  788.  *****************************************************************************/
  789. void ExitScr4PicEditDeleteConfirm(void)
  790. {
  791.     /*----------------------------------------------------------------*/
  792.     /* Local Variables                                                */
  793.     /*----------------------------------------------------------------*/
  794.     history h;  /* Variable to hold the history data */
  795.     S16 nHistory = 0;
  796.     /*----------------------------------------------------------------*/
  797.     /* Code Body                                                      */
  798.     /*----------------------------------------------------------------*/
  799.     stopRequestedTone(WARNING_TONE);
  800.     h.scrnID = SCR_PE_DELETE_CONFIRM;
  801.     h.entryFuncPtr = EntryScr4PicEditDeleteConfirm;
  802.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  803.     GetCategoryHistory(h.guiBuffer);
  804. }
  805. /*****************************************************************************
  806.  * FUNCTION
  807.  *  PicEditDeleteImage
  808.  * DESCRIPTION
  809.  *  Deletes the image and shows a pop up for success
  810.  * PARAMETERS
  811.  *  void
  812.  * RETURNS
  813.  *  void
  814.  *****************************************************************************/
  815. void PicEditDeleteImage(void)
  816. {
  817.     /*----------------------------------------------------------------*/
  818.     /* Local Variables                                                */
  819.     /*----------------------------------------------------------------*/
  820.     /*----------------------------------------------------------------*/
  821.     /* Code Body                                                      */
  822.     /*----------------------------------------------------------------*/
  823.     if (SetDeletePicEditImage() == MMI_FALSE)
  824.     {
  825.         DisplayPopup(
  826.             (U8*) GetString(STR_GLOBAL_UNFINISHED),
  827.             IMG_GLOBAL_UNFINISHED,
  828.             1,
  829.             PE_NOTIFYDURATION,
  830.             WARNING_TONE);
  831.     }
  832.     else
  833.     {
  834.         DisplayPopup((U8*) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  835.     }
  836.     DeleteUptoScrID(SCR_PE_SELECT_PIC_MENU);
  837. }
  838. /*****************************************************************************
  839.  * FUNCTION
  840.  *  SetDeletePicEditImage
  841.  * DESCRIPTION
  842.  *  Sets the image delete in nvram buffers
  843.  * PARAMETERS
  844.  *  void
  845.  * RETURNS
  846.  *  void
  847.  *****************************************************************************/
  848. MMI_BOOL SetDeletePicEditImage(void)
  849. {
  850.     /*----------------------------------------------------------------*/
  851.     /* Local Variables                                                */
  852.     /*----------------------------------------------------------------*/
  853.     S8 *pFileName;
  854.     /*----------------------------------------------------------------*/
  855.     /* Code Body                                                      */
  856.     /*----------------------------------------------------------------*/
  857.     pFileName = GetPictureEditorImageNameWithPathInFileSystem(gPicEditorInfo[gPicEditCurrPic].ImagesId);
  858.     if (pFileName && pfError(pfdelete(pFileName)))
  859.     {
  860.     #ifdef MMI_ON_HARDWARE_P
  861.         if (pfopen((U16*) pFileName, FS_READ_ONLY) < 0)
  862.     #else 
  863.         if (pfopen(pFileName, PFS_READ) < 0)
  864.     #endif 
  865.         {
  866.             DeletePictureEditorImage(gPicEditorInfo[gPicEditCurrPic].ImagesId);
  867.             WritePicEditListToNVRAM();
  868.             return MMI_TRUE;
  869.         }
  870.         PRINT_INFORMATION(("Error Deleting File"));
  871.         return MMI_FALSE;
  872.     }
  873.     else
  874.     {
  875.         DeletePictureEditorImage(gPicEditorInfo[gPicEditCurrPic].ImagesId);
  876.         WritePicEditListToNVRAM();
  877.         return MMI_TRUE;
  878.     }
  879. }
  880. /*****************************************************************************
  881.  * FUNCTION
  882.  *  EntryScr4PicEditDeleteAllConfirm
  883.  * DESCRIPTION
  884.  *  Entry function  for delete all image confirmation
  885.  * PARAMETERS
  886.  *  void
  887.  * RETURNS
  888.  *  void
  889.  *****************************************************************************/
  890. void EntryScr4PicEditDeleteAllConfirm(void)
  891. {
  892. #if (0)
  893. /* under construction !*/
  894. /* under construction !*/
  895. /* under construction !*/
  896. /* under construction !*/
  897. /* under construction !*/
  898. /* under construction !*/
  899. /* under construction !*/
  900. /* under construction !*/
  901. /* under construction !*/
  902. /* under construction !*/
  903. /* under construction !*/
  904. /* under construction !*/
  905. /* under construction !*/
  906. /* under construction !*/
  907. /* under construction !*/
  908. #endif /* (0) */ 
  909.     /*----------------------------------------------------------------*/
  910.     /* Code Body                                                      */
  911.     /*----------------------------------------------------------------*/
  912.     DisplayConfirm(
  913.         STR_GLOBAL_YES,
  914.         IMG_GLOBAL_YES,
  915.         STR_GLOBAL_NO,
  916.         IMG_GLOBAL_NO,
  917.         get_string(STR_GLOBAL_DELETE_ALL),
  918.         IMG_GLOBAL_QUESTION,
  919.         WARNING_TONE);
  920.     SetLeftSoftkeyFunction(PicEditDeleteAllImages, KEY_EVENT_UP);
  921.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  922.     //      playRequestedTone(WARNING_TONE) ;
  923.     //SetExitHandler(SCR_PE_DELETE_ALL_CONFIRM, ExitScr4PicEditDeleteAllConfirm);
  924. }
  925. /*****************************************************************************
  926.  * FUNCTION
  927.  *  ExitScr4PicEditDeleteAllConfirm
  928.  * DESCRIPTION
  929.  *  Exit function for EntryScr4PicEditDeleteAllConfirm
  930.  * PARAMETERS
  931.  *  void
  932.  * RETURNS
  933.  *  void
  934.  *****************************************************************************/
  935. void ExitScr4PicEditDeleteAllConfirm(void)
  936. {
  937.     /*----------------------------------------------------------------*/
  938.     /* Local Variables                                                */
  939.     /*----------------------------------------------------------------*/
  940.     history h;  /* Variable to hold the history data */
  941.     S16 nHistory = 0;
  942.     /*----------------------------------------------------------------*/
  943.     /* Code Body                                                      */
  944.     /*----------------------------------------------------------------*/
  945.     stopRequestedTone(WARNING_TONE);
  946.     h.scrnID = SCR_PE_DELETE_ALL_CONFIRM;
  947.     h.entryFuncPtr = EntryScr4PicEditDeleteAllConfirm;
  948.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  949.     GetCategoryHistory(h.guiBuffer);
  950. }
  951. /*****************************************************************************
  952.  * FUNCTION
  953.  *  PicEditDeleteAllImages
  954.  * DESCRIPTION
  955.  *  Calls a fucntion to delete all images and shows pop up
  956.  * PARAMETERS
  957.  *  void
  958.  * RETURNS
  959.  *  void
  960.  *****************************************************************************/
  961. void PicEditDeleteAllImages(void)
  962. {
  963.     /*----------------------------------------------------------------*/
  964.     /* Local Variables                                                */
  965.     /*----------------------------------------------------------------*/
  966.     /*----------------------------------------------------------------*/
  967.     /* Code Body                                                      */
  968.     /*----------------------------------------------------------------*/
  969.     SetDeleteAllPicEditImage();
  970.     DisplayPopup((U8*) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  971.     DeleteUptoScrID(SCR_PE_SELECT_PIC_MENU);
  972. }
  973. /*****************************************************************************
  974.  * FUNCTION
  975.  *  SetDeleteAllPicEditImage
  976.  * DESCRIPTION
  977.  *  Sets NVRAM buffer for delete all images
  978.  * PARAMETERS
  979.  *  void
  980.  * RETURNS
  981.  *  void
  982.  *****************************************************************************/
  983. void SetDeleteAllPicEditImage(void)
  984. {
  985.     /*----------------------------------------------------------------*/
  986.     /* Local Variables                                                */
  987.     /*----------------------------------------------------------------*/
  988.     S8 *pFileName;
  989.     U8 jCount;
  990.     /*----------------------------------------------------------------*/
  991.     /* Code Body                                                      */
  992.     /*----------------------------------------------------------------*/
  993.     for (jCount = 0; jCount < MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  994.     {
  995.         if (gPicEditorInfo[gPicEditCurrPic].ImagesId)
  996.         {
  997.             pFileName = GetPictureEditorImageNameWithPathInFileSystem(gPicEditorInfo[jCount].ImagesId);
  998.             if (pFileName && pfError(pfdelete(pFileName)))
  999.             {
  1000.                 PRINT_INFORMATION(("Error Deleting File"));
  1001.             }
  1002.         }
  1003.     }
  1004.     memset(&gPicEditorInfo, '', NVRAM_PICTURE_EDITOR_SIZE);
  1005.     WritePicEditListToNVRAM();
  1006. }
  1007. /*****************************************************************************
  1008.  * FUNCTION
  1009.  *  EntryScr4PicEditEditOpt
  1010.  * DESCRIPTION
  1011.  *  Entry function for Options screen for edit image
  1012.  * PARAMETERS
  1013.  *  void
  1014.  * RETURNS
  1015.  *  void
  1016.  *****************************************************************************/
  1017. void EntryScr4PicEditEditOpt(void)
  1018. {
  1019.     /*----------------------------------------------------------------*/
  1020.     /* Local Variables                                                */
  1021.     /*----------------------------------------------------------------*/
  1022.     U8 *guiBuffer = NULL;
  1023.     U16 nPEOptionList[13];
  1024.     U16 noOfChildren;
  1025.     U16 menuId;
  1026.     /*----------------------------------------------------------------*/
  1027.     /* Code Body                                                      */
  1028.     /*----------------------------------------------------------------*/
  1029.     nSelPEEditOpt = gPECurrentAction;
  1030.     if (!IS_PE_ZOOM_IMAGE(gPEAttrib))
  1031.     {
  1032.         if (!IS_PE_MARK_IMAGE(gPEAttrib))
  1033.         {
  1034.             if (!IS_PE_IMAGE_EDIT(gPEAttrib))
  1035.             {
  1036.                 menuId = MENU_PE_EDIT_OPT_1;
  1037.             }
  1038.             else if (!IS_PE_UNDO_IMAGE(gPEAttrib))
  1039.             {
  1040.                 menuId = MENU_PE_EDIT_OPT_2;
  1041.             }
  1042.             else
  1043.             {
  1044.                 menuId = MENU_PE_EDIT_OPT_3;
  1045.             }
  1046.         }
  1047.         else
  1048.         {
  1049.             if (!IS_PE_COPY_IMAGE(gPEAttrib))
  1050.             {
  1051.                 menuId = MENU_PE_EDIT_OPT_4;
  1052.             }
  1053.             else if (!IS_PE_IMAGE_EDIT(gPEAttrib))
  1054.             {
  1055.                 menuId = MENU_PE_EDIT_OPT_5;
  1056.             }
  1057.             else if (!IS_PE_UNDO_IMAGE(gPEAttrib))
  1058.             {
  1059.                 menuId = MENU_PE_EDIT_OPT_6;
  1060.             }
  1061.             else
  1062.             {
  1063.                 menuId = MENU_PE_EDIT_OPT_7;
  1064.             }
  1065.         }
  1066.     }
  1067.     else
  1068.     {
  1069.         if (!IS_PE_MARK_IMAGE(gPEAttrib))
  1070.         {
  1071.             if (!IS_PE_IMAGE_EDIT(gPEAttrib))
  1072.             {
  1073.                 menuId = MENU_PE_EDIT_OPT_8;
  1074.             }
  1075.             else if (!IS_PE_UNDO_IMAGE(gPEAttrib))
  1076.             {
  1077.                 menuId = MENU_PE_EDIT_OPT_9;
  1078.             }
  1079.             else
  1080.             {
  1081.                 menuId = MENU_PE_EDIT_OPT_10;
  1082.             }
  1083.         }
  1084.         else
  1085.         {
  1086.             if (!IS_PE_COPY_IMAGE(gPEAttrib))
  1087.             {
  1088.                 menuId = MENU_PE_EDIT_OPT_11;
  1089.             }
  1090.             else if (!IS_PE_IMAGE_EDIT(gPEAttrib))
  1091.             {
  1092.                 menuId = MENU_PE_EDIT_OPT_12;
  1093.             }
  1094.             else if (!IS_PE_UNDO_IMAGE(gPEAttrib))
  1095.             {
  1096.                 menuId = MENU_PE_EDIT_OPT_13;
  1097.             }
  1098.             else
  1099.             {
  1100.                 menuId = MENU_PE_EDIT_OPT_14;
  1101.             }
  1102.         }
  1103.     }
  1104.     noOfChildren = GetNumOfChild(menuId);
  1105.     guiBuffer = GetCurrGuiBuffer(SCR_PE_EDIT_PIC_OPT);
  1106.     /* ExecuteCurrExitHandler (); */
  1107.     EntryNewScreen(SCR_PE_EDIT_PIC_OPT, ExitScr4PicEditEditOpt, NULL, NULL);
  1108.     GetSequenceStringIds(menuId, nPEOptionList);
  1109.     SetParentHandler(menuId);
  1110.     InitPicEditHiliteHandlers();
  1111.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1112.     ShowCategory52Screen(
  1113.         STR_GLOBAL_OPTIONS,
  1114.         GetRootTitleIcon(MENU_PICTURE_EDITOR),
  1115.         STR_GLOBAL_OK,
  1116.         IMG_GLOBAL_OK,
  1117.         STR_GLOBAL_BACK,
  1118.         IMG_GLOBAL_BACK,
  1119.         noOfChildren,
  1120.         nPEOptionList,
  1121.         (PU16) gIndexIconsImageList,
  1122.         NULL,
  1123.         0,
  1124.         0,
  1125.         guiBuffer);
  1126.     /* Register function for left soft key */
  1127.     SetLeftSoftkeyFunction(EntryPEEditOpt, KEY_EVENT_UP);
  1128.     /* Register function for right soft key */
  1129.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1130.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1131.     /* SetExitHandler (SCR_PE_EDIT_PIC_OPT, ExitScr4PicEditEditOpt); */
  1132. }
  1133. /*****************************************************************************
  1134.  * FUNCTION
  1135.  *  ExitScr4PicEditEditOpt
  1136.  * DESCRIPTION
  1137.  *  Exit function for EntryScr4PicEditEditOpt
  1138.  * PARAMETERS
  1139.  *  void
  1140.  * RETURNS
  1141.  *  void
  1142.  *****************************************************************************/
  1143. void ExitScr4PicEditEditOpt(void)
  1144. {
  1145.     /*----------------------------------------------------------------*/
  1146.     /* Local Variables                                                */
  1147.     /*----------------------------------------------------------------*/
  1148.     history h;
  1149.     S16 nHistory = 0;
  1150.     /*----------------------------------------------------------------*/
  1151.     /* Code Body                                                      */
  1152.     /*----------------------------------------------------------------*/
  1153.     h.scrnID = SCR_PE_EDIT_PIC_OPT;
  1154.     h.entryFuncPtr = EntryScr4PicEditEditOpt;
  1155.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1156.     GetCategoryHistory(h.guiBuffer);
  1157.     AddHistory(h);
  1158. }
  1159. /*****************************************************************************
  1160.  * FUNCTION
  1161.  *  SelPEEditOptSavePic
  1162.  * DESCRIPTION
  1163.  *  Hilite handler fucntion for option screen of edit/draw image
  1164.  * PARAMETERS
  1165.  *  void
  1166.  * RETURNS
  1167.  *  void
  1168.  *****************************************************************************/
  1169. void SelPEEditOptSavePic(void)
  1170. {
  1171.     /*----------------------------------------------------------------*/
  1172.     /* Local Variables                                                */
  1173.     /*----------------------------------------------------------------*/
  1174.     /*----------------------------------------------------------------*/
  1175.     /* Code Body                                                      */
  1176.     /*----------------------------------------------------------------*/
  1177.     nSelPEEditOpt = SEL_PE_EDIT_OPT_SAVE_PIC;
  1178.     SetKeyHandler(EntryPEEditOpt, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1179. }
  1180. /*****************************************************************************
  1181.  * FUNCTION
  1182.  *  SelPEEditOptSavePicAs
  1183.  * DESCRIPTION
  1184.  *  Hilite handler fucntion for option screen of edit/draw image
  1185.  * PARAMETERS
  1186.  *  void
  1187.  * RETURNS
  1188.  *  void
  1189.  *****************************************************************************/
  1190. void SelPEEditOptSavePicAs(void)
  1191. {
  1192.     /*----------------------------------------------------------------*/
  1193.     /* Local Variables                                                */
  1194.     /*----------------------------------------------------------------*/
  1195.     /*----------------------------------------------------------------*/
  1196.     /* Code Body                                                      */
  1197.     /*----------------------------------------------------------------*/
  1198.     nSelPEEditOpt = SEL_PE_EDIT_OPT_SAVE_PIC_AS;
  1199.     SetKeyHandler(EntryPEEditOpt, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1200. }
  1201. /*****************************************************************************
  1202.  * FUNCTION
  1203.  *  SelPEEditOptPenSetting
  1204.  * DESCRIPTION
  1205.  *  Hilite handler fucntion for option screen of edit/draw image
  1206.  * PARAMETERS
  1207.  *  void
  1208.  * RETURNS
  1209.  *  void
  1210.  *****************************************************************************/
  1211. void SelPEEditOptPenSetting(void)
  1212. {
  1213.     /*----------------------------------------------------------------*/
  1214.     /* Local Variables                                                */
  1215.     /*----------------------------------------------------------------*/
  1216.     /*----------------------------------------------------------------*/
  1217.     /* Code Body                                                      */
  1218.     /*----------------------------------------------------------------*/
  1219.     nSelPEEditOpt = SEL_PE_EDIT_OPT_PEN_SETTING;
  1220.     SetKeyHandler(EntryPEEditOpt, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1221. }
  1222. /*****************************************************************************
  1223.  * FUNCTION
  1224.  *  SelPEEditOptFillPic
  1225.  * DESCRIPTION
  1226.  *  Hilite handler fucntion for option screen of edit/draw image
  1227.  * PARAMETERS
  1228.  *  void
  1229.  * RETURNS
  1230.  *  void
  1231.  *****************************************************************************/
  1232. void SelPEEditOptFillPic(void)
  1233. {
  1234.     /*----------------------------------------------------------------*/
  1235.     /* Local Variables                                                */
  1236.     /*----------------------------------------------------------------*/
  1237.     /*----------------------------------------------------------------*/
  1238.     /* Code Body                                                      */
  1239.     /*----------------------------------------------------------------*/
  1240.     nSelPEEditOpt = SEL_PE_EDIT_OPT_FILL_PIC;
  1241.     SetKeyHandler(EntryPEEditOpt, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1242. }
  1243. /*****************************************************************************
  1244.  * FUNCTION
  1245.  *  SelPEEditOptMark
  1246.  * DESCRIPTION
  1247.  *  Hilite handler fucntion for option screen of edit/draw image
  1248.  * PARAMETERS
  1249.  *  void
  1250.  * RETURNS
  1251.  *  void
  1252.  *****************************************************************************/
  1253. void SelPEEditOptMark(void)
  1254. {
  1255.     /*----------------------------------------------------------------*/
  1256.     /* Local Variables                                                */
  1257.     /*----------------------------------------------------------------*/
  1258.     /*----------------------------------------------------------------*/
  1259.     /* Code Body                                                      */
  1260.     /*----------------------------------------------------------------*/
  1261.     nSelPEEditOpt = SEL_PE_EDIT_OPT_MARK;
  1262.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1263. }
  1264. /*****************************************************************************
  1265.  * FUNCTION
  1266.  *  SelPEEditOptCut
  1267.  * DESCRIPTION
  1268.  *  Hilite handler fucntion for option screen of edit/draw image
  1269.  * PARAMETERS
  1270.  *  void
  1271.  * RETURNS
  1272.  *  void
  1273.  *****************************************************************************/
  1274. void SelPEEditOptCut(void)
  1275. {
  1276.     /*----------------------------------------------------------------*/
  1277.     /* Local Variables                                                */
  1278.     /*----------------------------------------------------------------*/
  1279.     /*----------------------------------------------------------------*/
  1280.     /* Code Body                                                      */
  1281.     /*----------------------------------------------------------------*/
  1282.     nSelPEEditOpt = SEL_PE_EDIT_OPT_CUT;
  1283.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1284. }
  1285. /*****************************************************************************
  1286.  * FUNCTION
  1287.  *  SelPEEditOptCopy
  1288.  * DESCRIPTION
  1289.  *  Hilite handler fucntion for option screen of edit/draw image
  1290.  * PARAMETERS
  1291.  *  void
  1292.  * RETURNS
  1293.  *  void
  1294.  *****************************************************************************/
  1295. void SelPEEditOptCopy(void)
  1296. {
  1297.     /*----------------------------------------------------------------*/
  1298.     /* Local Variables                                                */
  1299.     /*----------------------------------------------------------------*/
  1300.     /*----------------------------------------------------------------*/
  1301.     /* Code Body                                                      */
  1302.     /*----------------------------------------------------------------*/
  1303.     nSelPEEditOpt = SEL_PE_EDIT_OPT_COPY;
  1304.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1305. }
  1306. /*****************************************************************************
  1307.  * FUNCTION
  1308.  *  SelPEEditOptPaste
  1309.  * DESCRIPTION
  1310.  *  Hilite handler fucntion for option screen of edit/draw image
  1311.  * PARAMETERS
  1312.  *  void
  1313.  * RETURNS
  1314.  *  void
  1315.  *****************************************************************************/
  1316. void SelPEEditOptPaste(void)
  1317. {
  1318.     /*----------------------------------------------------------------*/
  1319.     /* Local Variables                                                */
  1320.     /*----------------------------------------------------------------*/
  1321.     /*----------------------------------------------------------------*/
  1322.     /* Code Body                                                      */
  1323.     /*----------------------------------------------------------------*/
  1324.     nSelPEEditOpt = SEL_PE_EDIT_OPT_PASTE;
  1325.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1326. }
  1327. /*****************************************************************************
  1328.  * FUNCTION
  1329.  *  SelPEEditOptUndo
  1330.  * DESCRIPTION
  1331.  *  Hilite handler fucntion for option screen of edit/draw image
  1332.  * PARAMETERS
  1333.  *  void
  1334.  * RETURNS
  1335.  *  void
  1336.  *****************************************************************************/
  1337. void SelPEEditOptUndo(void)
  1338. {
  1339.     /*----------------------------------------------------------------*/
  1340.     /* Local Variables                                                */
  1341.     /*----------------------------------------------------------------*/
  1342.     /*----------------------------------------------------------------*/
  1343.     /* Code Body                                                      */
  1344.     /*----------------------------------------------------------------*/
  1345.     nSelPEEditOpt = SEL_PE_EDIT_OPT_UNDO;
  1346.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1347. }
  1348. /*****************************************************************************
  1349.  * FUNCTION
  1350.  *  SelPEEditOptRedo
  1351.  * DESCRIPTION
  1352.  *  Hilite handler fucntion for option screen of edit/draw image
  1353.  * PARAMETERS
  1354.  *  void
  1355.  * RETURNS
  1356.  *  void
  1357.  *****************************************************************************/
  1358. void SelPEEditOptRedo(void)
  1359. {
  1360.     /*----------------------------------------------------------------*/
  1361.     /* Local Variables                                                */
  1362.     /*----------------------------------------------------------------*/
  1363.     /*----------------------------------------------------------------*/
  1364.     /* Code Body                                                      */
  1365.     /*----------------------------------------------------------------*/
  1366.     nSelPEEditOpt = SEL_PE_EDIT_OPT_REDO;
  1367.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1368. }
  1369. /*****************************************************************************
  1370.  * FUNCTION
  1371.  *  SelPEEditOptZoom
  1372.  * DESCRIPTION
  1373.  *  Hilite handler fucntion for option screen of edit/draw image
  1374.  * PARAMETERS
  1375.  *  void
  1376.  * RETURNS
  1377.  *  void
  1378.  *****************************************************************************/
  1379. void SelPEEditOptZoom(void)
  1380. {
  1381.     /*----------------------------------------------------------------*/
  1382.     /* Local Variables                                                */
  1383.     /*----------------------------------------------------------------*/
  1384.     /*----------------------------------------------------------------*/
  1385.     /* Code Body                                                      */
  1386.     /*----------------------------------------------------------------*/
  1387.     nSelPEEditOpt = SEL_PE_EDIT_OPT_ZOOM;
  1388.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1389. }
  1390. /*****************************************************************************
  1391.  * FUNCTION
  1392.  *  SelPEEditOptFullSize
  1393.  * DESCRIPTION
  1394.  *  Hilite handler fucntion for option screen of edit/draw image
  1395.  * PARAMETERS
  1396.  *  void
  1397.  * RETURNS
  1398.  *  void
  1399.  *****************************************************************************/
  1400. void SelPEEditOptFullSize(void)
  1401. {
  1402.     /*----------------------------------------------------------------*/
  1403.     /* Local Variables                                                */
  1404.     /*----------------------------------------------------------------*/
  1405.     /*----------------------------------------------------------------*/
  1406.     /* Code Body                                                      */
  1407.     /*----------------------------------------------------------------*/
  1408.     nSelPEEditOpt = SEL_PE_EDIT_OPT_FULL_SIZE;
  1409.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1410. }
  1411. /*****************************************************************************
  1412.  * FUNCTION
  1413.  *  SelPEEditOptResize
  1414.  * DESCRIPTION
  1415.  *  Hilite handler fucntion for option screen of edit/draw image
  1416.  * PARAMETERS
  1417.  *  void
  1418.  * RETURNS
  1419.  *  void
  1420.  *****************************************************************************/
  1421. void SelPEEditOptResize(void)
  1422. {
  1423.     /*----------------------------------------------------------------*/
  1424.     /* Local Variables                                                */
  1425.     /*----------------------------------------------------------------*/
  1426.     /*----------------------------------------------------------------*/
  1427.     /* Code Body                                                      */
  1428.     /*----------------------------------------------------------------*/
  1429.     nSelPEEditOpt = SEL_PE_EDIT_OPT_RESIZE;
  1430.     SetKeyHandler(EntryPEEditOpt, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1431. }
  1432. /*****************************************************************************
  1433.  * FUNCTION
  1434.  *  SelPEEditOptHelp
  1435.  * DESCRIPTION
  1436.  *  Hilite handler fucntion for option screen of edit/draw image
  1437.  * PARAMETERS
  1438.  *  void
  1439.  * RETURNS
  1440.  *  void
  1441.  *****************************************************************************/
  1442. void SelPEEditOptHelp(void)
  1443. {
  1444.     /*----------------------------------------------------------------*/
  1445.     /* Local Variables                                                */
  1446.     /*----------------------------------------------------------------*/
  1447.     /*----------------------------------------------------------------*/
  1448.     /* Code Body                                                      */
  1449.     /*----------------------------------------------------------------*/
  1450.     nSelPEEditOpt = SEL_PE_EDIT_OPT_HELP;
  1451.     SetKeyHandler(EntryPEEditOpt, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1452. }
  1453. /*****************************************************************************
  1454.  * FUNCTION
  1455.  *  EntryPEEditOpt
  1456.  * DESCRIPTION
  1457.  *  Selects the entry functions depending on the option selected of image edit
  1458.  * PARAMETERS
  1459.  *  void
  1460.  * RETURNS
  1461.  *  void
  1462.  *****************************************************************************/
  1463. void EntryPEEditOpt(void)
  1464. {
  1465.     /*----------------------------------------------------------------*/
  1466.     /* Local Variables                                                */
  1467.     /*----------------------------------------------------------------*/
  1468.     S32 result;
  1469.     /*----------------------------------------------------------------*/
  1470.     /* Code Body                                                      */
  1471.     /*----------------------------------------------------------------*/
  1472.     switch (nSelPEEditOpt)
  1473.     {
  1474.         case SEL_PE_EDIT_OPT_SAVE_PIC:  /* Save */
  1475.             gPECurrentAction = nSelPEEditOpt;
  1476.             result = SavePicEditImageDataBuff();
  1477.             if (result == FS_NO_ERROR)
  1478.             {
  1479.                 DisplayPopup(
  1480.                     (PU8) GetString(STR_GLOBAL_DONE),
  1481.                     IMG_GLOBAL_ACTIVATED,
  1482.                     1,
  1483.                     PE_NOTIFYDURATION,
  1484.                     SUCCESS_TONE);
  1485.             }
  1486.             else
  1487.             {
  1488.                 DisplayPopup(
  1489.                     (U8*) get_string(GetFileSystemErrorString(result)),
  1490.                     IMG_GLOBAL_ERROR,
  1491.                     1,
  1492.                     PE_NOTIFYDURATION,
  1493.                     ERROR_TONE);
  1494.             }
  1495.             DeleteUptoScrID(SCR_PE_SELECT_PIC_MENU);
  1496.             break;
  1497.         case SEL_PE_EDIT_OPT_SAVE_PIC_AS:   /* Save As */
  1498.             gPECurrentAction = nSelPEEditOpt;
  1499.             EntryScr4PicEditSaveAs();
  1500.             break;
  1501.         case SEL_PE_EDIT_OPT_PEN_SETTING:   /* Pen Setting */
  1502.             EntryScr4PicEditPenSetting();
  1503.             break;
  1504.         case SEL_PE_EDIT_OPT_FILL_PIC:      /* Fill Picture */
  1505.             gPECurrentAction = nSelPEEditOpt;
  1506.             /* Pixtel patch */
  1507.             nInlinePenColorIndex = gpPicEditPen->penBackgrdColorIndex - 1;
  1508.             EntryScr4PicEditFillPic();
  1509.             break;
  1510.         case SEL_PE_EDIT_OPT_MARK:          /* Mark */
  1511.             gPECurrentAction = nSelPEEditOpt;
  1512.             gPicEditMark.minX = gpPicEditPen->penX;
  1513.             gPicEditMark.minY = gpPicEditPen->penY;
  1514.             gPicEditMark.maxX = gpPicEditPen->penX;
  1515.             gPicEditMark.maxY = gpPicEditPen->penY;
  1516.             UNSET_PE_PEN_DOWN(gPEAttrib);
  1517.             GoBackHistory();
  1518.             break;
  1519.         case SEL_PE_EDIT_OPT_CUT:           /* Cut */
  1520.             gPECurrentAction = nSelPEEditOpt;
  1521.             SavePEContext();
  1522.             SaveDataBuffer();
  1523.             gpPicEditPen->penColorIndex = gpPicEditPen->penBackgrdColorIndex;
  1524.             PutPixtelInBuff(
  1525.                 gPicEditMark.minX,
  1526.                 gPicEditMark.minY,
  1527.                 (U16) (gPicEditMark.maxX + 1),
  1528.                 (U16) (gPicEditMark.maxY + 1),
  1529.                 &gpPEFileBuff[PIC_EDIT_FILE_HEADER_SIZE]);
  1530.             gpPicEditPen->penColorIndex = gpPicEditBackupPen->penColorIndex;
  1531.             UNSET_PE_PEN_DOWN(gPEAttrib);
  1532.             SET_PE_IMAGE_EDIT(gPEAttrib);
  1533.             SET_PE_COPY_IMAGE(gPEAttrib);
  1534.             GoBackHistory();
  1535.             break;
  1536.         case SEL_PE_EDIT_OPT_COPY:      /* Copy */
  1537.             gPECurrentAction = nSelPEEditOpt;
  1538.             UNSET_PE_PEN_DOWN(gPEAttrib);
  1539.             SaveDataBuffer();
  1540.             SET_PE_COPY_IMAGE(gPEAttrib);
  1541.             GoBackHistory();
  1542.             break;
  1543.         case SEL_PE_EDIT_OPT_PASTE:     /* Paste */
  1544.             gPECurrentAction = nSelPEEditOpt;
  1545.             SavePEContext();
  1546.             PasteBoxInImageBuffer(&gpPEFileBuff[PIC_EDIT_FILE_HEADER_SIZE], gpPEBackupDataBuff);
  1547.             UNSET_PE_PEN_DOWN(gPEAttrib);
  1548.             SET_PE_IMAGE_EDIT(gPEAttrib);
  1549.             GoBackHistory();
  1550.             break;
  1551.         case SEL_PE_EDIT_OPT_UNDO:      /* Undo */
  1552.         case SEL_PE_EDIT_OPT_REDO:      /* Redo */
  1553.             gPECurrentAction = nSelPEEditOpt;
  1554.             ExchangePEContext();
  1555.             SetPicEditZoomWindow(TRUE);
  1556.             GoBackHistory();
  1557.             break;
  1558.         case SEL_PE_EDIT_OPT_ZOOM:      /* Zoom */
  1559.             gPECurrentAction = nSelPEEditOpt;
  1560.             SetPicEditZoomWindow(TRUE);
  1561.             SET_PE_ZOOM_IMAGE(gPEAttrib);
  1562.             GoBackHistory();
  1563.             break;
  1564.         case SEL_PE_EDIT_OPT_FULL_SIZE: /* Full Size */
  1565.             gPECurrentAction = SEL_PE_EDIT_OPT_SAVE_PIC;
  1566.             UNSET_PE_ZOOM_IMAGE(gPEAttrib);
  1567.             GoBackHistory();
  1568.             break;
  1569.         case SEL_PE_EDIT_OPT_RESIZE:    /* Resize */
  1570.             SetResizeInlineItemValues();
  1571.             EntryScr4PicEditScrResize();
  1572.             break;
  1573.         case SEL_PE_EDIT_OPT_HELP:      /* Help */
  1574.             EntryScr4PicEditHelp();
  1575.             break;
  1576.         default:
  1577.             break;
  1578.     }
  1579. }
  1580. /*****************************************************************************
  1581.  * FUNCTION
  1582.  *  PicEditCancelSaveAs
  1583.  * DESCRIPTION
  1584.  *  restore current pic if user cancel "save as" option
  1585.  * PARAMETERS
  1586.  *  void
  1587.  * RETURNS
  1588.  *  void
  1589.  *****************************************************************************/
  1590. void PicEditCancelSaveAs(void)
  1591. {
  1592.     /*----------------------------------------------------------------*/
  1593.     /* Local Variables                                                */
  1594.     /*----------------------------------------------------------------*/
  1595.     /*----------------------------------------------------------------*/
  1596.     /* Code Body                                                      */
  1597.     /*----------------------------------------------------------------*/
  1598.     if (gPicEditSelectedPic != gPicEditCurrPic)
  1599.     {
  1600.         gPicEditCurrPic = gPicEditSelectedPic;
  1601.     }
  1602.     GoBackHistory();
  1603. }
  1604. /*****************************************************************************
  1605.  * FUNCTION
  1606.  *  EntryScr4PicEditSaveAs
  1607.  * DESCRIPTION
  1608.  *  Entry function image editor select image menu for save as
  1609.  * PARAMETERS
  1610.  *  void
  1611.  * RETURNS
  1612.  *  void
  1613.  *****************************************************************************/
  1614. void EntryScr4PicEditSaveAs(void)
  1615. {
  1616.     /*----------------------------------------------------------------*/
  1617.     /* Local Variables                                                */
  1618.     /*----------------------------------------------------------------*/
  1619.     U8 *guiBuffer = NULL;
  1620.     U8 jCount;
  1621.     DYNAMICINFO dynInfo;
  1622.     U8 *pPicEditList[MAXIMUM_PICTURE_EDITOR_IMAGES];
  1623.     /*----------------------------------------------------------------*/
  1624.     /* Code Body                                                      */
  1625.     /*----------------------------------------------------------------*/
  1626.     /* ExecuteCurrExitHandler(); */
  1627.     EntryNewScreen(SCR_PE_EDIT_SAVE_AS, ExitScr4PicEditSaveAs, NULL, NULL);
  1628.     guiBuffer = GetCurrGuiBuffer(SCR_PE_EDIT_SAVE_AS);
  1629.     SetParentHandler(0);
  1630.     gPicEditSelectedPic = gPicEditCurrPic;
  1631.     RegisterHighlightHandler(SetPicEditCurrPic);
  1632.     ReadPicEditListFromNVRAM();
  1633.     if (guiBuffer == NULL)
  1634.     {
  1635.         dynInfo.DynInfoType = IMAGEINFO;
  1636.         dynInfo.DYNINFOUNION.ImageInfo = gPicEditorInfo;
  1637.         dynInfo.NoOfEntries = gPEImageCount;
  1638.         SyncPicEditFileSystem(PICTURE_EDITOR_PATH, &dynInfo);
  1639.     }
  1640.     /*
  1641.      * for (jCount=0; jCount<gPEImageCount; jCount++)
  1642.      * {
  1643.      * pPicEditList[jCount] = (U8*)gPicEditorInfo[jCount].ImageName;
  1644.      * }
  1645.      * 
  1646.      * for (jCount=gPEImageCount; jCount<MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  1647.      * {
  1648.      * pPicEditList[jCount] = (U8*)GetString(STR_GLOBAL_EMPTY);
  1649.      * }
  1650.      */
  1651.     for (jCount = 0; jCount < MAXIMUM_PICTURE_EDITOR_IMAGES; jCount++)
  1652.     {
  1653.         if (((gPicEditorInfo[jCount].ImagesId >= (U16) PICTURE_EDITOR_IMAGE_BASE) &&
  1654.              (gPicEditorInfo[jCount].ImagesId <= PICTURE_EDITOR_IMAGE_BASE_END)))
  1655.         {
  1656.             pPicEditList[jCount] = (U8*) gPicEditorInfo[jCount].ImageName;
  1657.         }
  1658.         else
  1659.         {
  1660.             pPicEditList[jCount] = (U8*) GetString(STR_GLOBAL_EMPTY_LIST);
  1661.         }
  1662.     }
  1663.     ShowCategory84Screen(
  1664.         STR_PE_EDIT_OPT_SAVE_PIC_AS,
  1665.         MAIN_MENU_TITLE_FUNANDGAMES_ICON,
  1666.         STR_GLOBAL_OK,
  1667.         IMG_GLOBAL_OK,
  1668.         STR_GLOBAL_BACK,
  1669.         IMG_GLOBAL_BACK,
  1670.         MAXIMUM_PICTURE_EDITOR_IMAGES,
  1671.         (U8 **) pPicEditList,
  1672.         (PU16) gIndexIconsImageList,
  1673.         LIST_MENU,
  1674.         0,
  1675.         guiBuffer);
  1676.     SetLeftSoftkeyFunction(PicEditSaveImageAs, KEY_EVENT_UP);
  1677.     SetRightSoftkeyFunction(PicEditCancelSaveAs, KEY_EVENT_UP);
  1678.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1679.     /* SetExitHandler (SCR_PE_EDIT_SAVE_AS, ExitScr4PicEditSaveAs); */
  1680. }
  1681. /*****************************************************************************
  1682.  * FUNCTION
  1683.  *  ExitScr4PicEditSaveAs
  1684.  * DESCRIPTION
  1685.  *  Exit function for EntryScr4PicEditSaveAs
  1686.  * PARAMETERS
  1687.  *  void
  1688.  * RETURNS
  1689.  *  void
  1690.  *****************************************************************************/
  1691. void ExitScr4PicEditSaveAs(void)
  1692. {
  1693.     /*----------------------------------------------------------------*/
  1694.     /* Local Variables                                                */
  1695.     /*----------------------------------------------------------------*/
  1696.     history h;
  1697.     S16 nHistory = 0;
  1698.     /*----------------------------------------------------------------*/
  1699.     /* Code Body                                                      */
  1700.     /*----------------------------------------------------------------*/
  1701.     h.scrnID = SCR_PE_EDIT_SAVE_AS;
  1702.     h.entryFuncPtr = EntryScr4PicEditSaveAs;
  1703.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1704.     GetCategoryHistory(h.guiBuffer);
  1705.     AddHistory(h);
  1706. }
  1707. /*****************************************************************************
  1708.  * FUNCTION
  1709.  *  SetPicEditCurrPic
  1710.  * DESCRIPTION
  1711.  *  Sets the global varibale for current image
  1712.  * PARAMETERS
  1713.  *  nIndex      [IN]        
  1714.  * RETURNS
  1715.  *  void
  1716.  *****************************************************************************/
  1717. void SetPicEditCurrPic(S32 nIndex)
  1718. {
  1719.     /*----------------------------------------------------------------*/
  1720.     /* Local Variables                                                */
  1721.     /*----------------------------------------------------------------*/
  1722.     /*----------------------------------------------------------------*/
  1723.     /* Code Body                                                      */
  1724.     /*----------------------------------------------------------------*/
  1725.     PRINT_INFORMATION(("Task # : %d", nIndex));
  1726.     gPicEditCurrPic = (U8) nIndex;
  1727. }
  1728. /*****************************************************************************
  1729.  * FUNCTION
  1730.  *  PicEditSaveImageAs
  1731.  * DESCRIPTION
  1732.  *  Saves Image and shows a pop up for success else if replace image, confirms for replacement
  1733.  * PARAMETERS
  1734.  *  void
  1735.  * RETURNS
  1736.  *  void
  1737.  *****************************************************************************/
  1738. void PicEditSaveImageAs(void)
  1739. {
  1740.     /*----------------------------------------------------------------*/
  1741.     /* Local Variables                                                */
  1742.     /*----------------------------------------------------------------*/
  1743.     /*----------------------------------------------------------------*/
  1744.     /* Code Body                                                      */
  1745.     /*----------------------------------------------------------------*/
  1746.     /* if(gPicEditCurrPic<gPEImageCount) */
  1747.     if (gPicEditorInfo[gPicEditCurrPic].ImagesId)
  1748.     {
  1749.         UNSET_PE_ADD_IMAGE(gPEAttrib);
  1750.         EntryScr4PicEditSaveAsConfirm();
  1751.     }
  1752.     else
  1753.     {
  1754.         S32 result;
  1755.         SET_PE_ADD_IMAGE(gPEAttrib);
  1756.         result = SavePicEditImageDataBuff();
  1757.         if (result == FS_NO_ERROR)
  1758.         {
  1759.             DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  1760.         }
  1761.         else
  1762.         {
  1763.             DisplayPopup(
  1764.                 (U8*) get_string(GetFileSystemErrorString(result)),
  1765.                 IMG_GLOBAL_ERROR,
  1766.                 1,
  1767.                 PE_NOTIFYDURATION,
  1768.                 ERROR_TONE);
  1769.         }
  1770.         DeleteUptoScrID(SCR_PE_SELECT_PIC_MENU);
  1771.     }
  1772. }
  1773. /*****************************************************************************
  1774.  * FUNCTION
  1775.  *  EntryScr4PicEditSaveAsConfirm
  1776.  * DESCRIPTION
  1777.  *  Confirmation screen for confirming to replace selected image
  1778.  * PARAMETERS
  1779.  *  void
  1780.  * RETURNS
  1781.  *  void
  1782.  *****************************************************************************/
  1783. void EntryScr4PicEditSaveAsConfirm(void)
  1784. {
  1785. #if (0)
  1786. /* under construction !*/
  1787. /* under construction !*/
  1788. /* under construction !*/
  1789. /* under construction !*/
  1790. /* under construction !*/
  1791. /* under construction !*/
  1792. /* under construction !*/
  1793. /* under construction !*/
  1794. /* under construction !*/
  1795. /* under construction !*/
  1796. /* under construction !*/
  1797. /* under construction !*/
  1798. /* under construction !*/
  1799. /* under construction !*/
  1800. #endif /* (0) */ 
  1801.     /*----------------------------------------------------------------*/
  1802.     /* Code Body                                                      */
  1803.     /*----------------------------------------------------------------*/
  1804.     DisplayConfirm(
  1805.         STR_GLOBAL_YES,
  1806.         IMG_GLOBAL_YES,
  1807.         STR_GLOBAL_NO,
  1808.         IMG_GLOBAL_NO,
  1809.         get_string(STR_PE_EDIT_OPT_REPLACE),
  1810.         IMG_GLOBAL_QUESTION,
  1811.         WARNING_TONE);
  1812.     SetLeftSoftkeyFunction(ReplacePicEditSelectedImage, KEY_EVENT_UP);
  1813.     SetRightSoftkeyFunction(GoBackPicEditSaveAsConfirmHistory, KEY_EVENT_UP);
  1814.     /* playRequestedTone(WARNING_TONE) ; */
  1815.     /* SetExitHandler(SCR_PE_EDIT_SAVE_AS_CONFIRM, ExitScr4PicEditSaveAsConfirm); */
  1816. }
  1817. /*****************************************************************************
  1818.  * FUNCTION
  1819.  *  ExitScr4PicEditSaveAsConfirm
  1820.  * DESCRIPTION
  1821.  *  Exit function for EntryScr4PicEditFillPicSaveConfirm
  1822.  * PARAMETERS
  1823.  *  void
  1824.  * RETURNS
  1825.  *  void
  1826.  *****************************************************************************/
  1827. void ExitScr4PicEditSaveAsConfirm(void)
  1828. {
  1829.     /*----------------------------------------------------------------*/
  1830.     /* Local Variables                                                */
  1831.     /*----------------------------------------------------------------*/
  1832.     history h;  /* Variable to hold the history data */
  1833.     S16 nHistory = 0;
  1834.     /*----------------------------------------------------------------*/
  1835.     /* Code Body                                                      */
  1836.     /*----------------------------------------------------------------*/
  1837.     stopRequestedTone(WARNING_TONE);
  1838.     h.scrnID = SCR_PE_EDIT_SAVE_AS_CONFIRM;
  1839.     h.entryFuncPtr = EntryScr4PicEditSaveAsConfirm;
  1840.     pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
  1841.     GetCategoryHistory(h.guiBuffer);
  1842. }
  1843. /*****************************************************************************
  1844.  * FUNCTION
  1845.  *  GoBackPicEditSaveAsConfirmHistory
  1846.  * DESCRIPTION
  1847.  *  Go Back history function for the confirmation screen for Save As image
  1848.  * PARAMETERS
  1849.  *  void
  1850.  * RETURNS
  1851.  *  void
  1852.  *****************************************************************************/
  1853. void GoBackPicEditSaveAsConfirmHistory(void)
  1854. {
  1855.     /*----------------------------------------------------------------*/
  1856.     /* Local Variables                                                */
  1857.     /*----------------------------------------------------------------*/
  1858.     /*----------------------------------------------------------------*/
  1859.     /* Code Body                                                      */
  1860.     /*----------------------------------------------------------------*/
  1861.     if (gPicEditSelectedPic != gPicEditCurrPic)
  1862.     {
  1863.         if (!gPicEditorInfo[gPicEditSelectedPic].ImagesId)
  1864.         {
  1865.             SET_PE_ADD_IMAGE(gPEAttrib);
  1866.         }
  1867.         gPicEditCurrPic = gPicEditSelectedPic;
  1868.     }
  1869.     DeleteUptoScrID(SCR_PE_EDIT_PIC_OPT);
  1870.     GoBackHistory();
  1871. }
  1872. /*****************************************************************************
  1873.  * FUNCTION
  1874.  *  ReplacePicEditSelectedImage
  1875.  * DESCRIPTION
  1876.  *  Replace selected image with the current image buffer
  1877.  * PARAMETERS
  1878.  *  void
  1879.  * RETURNS
  1880.  *  void
  1881.  *****************************************************************************/
  1882. void ReplacePicEditSelectedImage(void)
  1883. {
  1884.     /*----------------------------------------------------------------*/
  1885.     /* Local Variables                                                */
  1886.     /*----------------------------------------------------------------*/
  1887.     S32 result;
  1888.     /*----------------------------------------------------------------*/
  1889.     /* Code Body                                                      */
  1890.     /*----------------------------------------------------------------*/
  1891.     result = SavePicEditImageDataBuff();
  1892.     if (result == FS_NO_ERROR)
  1893.     {
  1894.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, PE_NOTIFYDURATION, SUCCESS_TONE);
  1895.     }
  1896.     else
  1897.     {
  1898.         DisplayPopup(
  1899.             (U8*) get_string(GetFileSystemErrorString(result)),
  1900.             IMG_GLOBAL_ERROR,
  1901.             1,
  1902.             PE_NOTIFYDURATION,
  1903.             ERROR_TONE);
  1904.     }
  1905.     DeleteUptoScrID(SCR_PE_SELECT_PIC_MENU);
  1906. }
  1907. /*****************************************************************************
  1908.  * FUNCTION
  1909.  *  PicEditPenColorHiLiteHandler
  1910.  * DESCRIPTION
  1911.  *  hilight handler of category92
  1912.  * PARAMETERS
  1913.  *  index       [IN]        Selected color index
  1914.  * RETURNS
  1915.  *  void
  1916.  *****************************************************************************/
  1917. void PicEditPenColorHiLiteHandler(S32 index)
  1918. {
  1919.     /*----------------------------------------------------------------*/
  1920.     /* Local Variables                                                */
  1921.     /*----------------------------------------------------------------*/
  1922.     /*----------------------------------------------------------------*/
  1923.     /* Code Body                                                      */
  1924.     /*----------------------------------------------------------------*/
  1925.     g_pe_color_index = index;
  1926. }
  1927. /*****************************************************************************
  1928.  * FUNCTION
  1929.  *  SetPicEditPenSettingInlineItemData
  1930.  * DESCRIPTION
  1931.  *  Setup inline item data for Pen Setting
  1932.  * PARAMETERS
  1933.  *  void
  1934.  * RETURNS
  1935.  *  void
  1936.  *****************************************************************************/
  1937. void SetPicEditPenSettingInlineItemData(void)
  1938. {
  1939.     /*----------------------------------------------------------------*/
  1940.     /* Local Variables                                                */
  1941.     /*----------------------------------------------------------------*/
  1942.     S32 i = 0;
  1943.     /*----------------------------------------------------------------*/
  1944.     /* Code Body                                                      */
  1945.     /*----------------------------------------------------------------*/
  1946.     SetInlineItemActivation(&PicEditInLineItems[i], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1947.     SetInlineItemCaption(&PicEditInLineItems[i++], (U8*) (get_string(STR_PE_PEN_SIZE)));
  1948.     SetInlineItemActivation(&PicEditInLineItems[i], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1949.     SetInlineItemSelect(&PicEditInLineItems[i++], MAX_TYPE_PEN_PIXEL, pInlinePenSizeList, &nInlinePenSize);
  1950. #ifndef __MMI_TOUCH_SCREEN__
  1951.     SetInlineItemActivation(&PicEditInLineItems[i], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1952.     SetInlineItemCaption(&PicEditInLineItems[i++], (PU8) (get_string(STR_PE_PEN_MOVE_FACTOR)));
  1953.     SetInlineItemActivation(&PicEditInLineItems[i], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1954.     SetInlineItemSelect(&PicEditInLineItems[i++], MAX_TYPE_PEN_MOVE, pInlinePenMoveFactorList, &nInlinePenMoveFactor);
  1955. #endif /* __MMI_TOUCH_SCREEN__ */ 
  1956.     SetInlineItemActivation(&PicEditInLineItems[i], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1957.     SetInlineItemCaption(&PicEditInLineItems[i++], (PU8) (get_string(STR_PE_PEN_COLOR)));
  1958.     SetInlineItemActivation(&PicEditInLineItems[i], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1959.     SetInlineItemSelect(
  1960.         &PicEditInLineItems[i],
  1961.         MAX_TYPE_PEN_COLOR - 1,
  1962.         pInlinePenColorIndexList,
  1963.         &nInlinePenColorIndex);
  1964.     RegisterInlineSelectHighlightHandler(&PicEditInLineItems[i], PicEditPenColorHiLiteHandler);
  1965.     /* g_cat92_n_items = i; */
  1966. }
  1967. /*****************************************************************************
  1968.  * FUNCTION
  1969.  *  EntryScr4PicEditPenSetting
  1970.  * DESCRIPTION
  1971.  *  Entry function for Pen setting screen
  1972.  * PARAMETERS
  1973.  *  void
  1974.  * RETURNS
  1975.  *  void
  1976.  *****************************************************************************/
  1977. void EntryScr4PicEditPenSetting(void)
  1978. {
  1979.     /*----------------------------------------------------------------*/
  1980.     /* Local Variables                                                */
  1981.     /*----------------------------------------------------------------*/
  1982.     U8 *guiBuffer;
  1983.     U8 *inputBuffer;        /* added for inline edit history */
  1984.     U16 inputBufferSize;    /* added for inline edit history */
  1985.     U8 iCount;
  1986.     /*----------------------------------------------------------------*/
  1987.     /* Code Body                                                      */
  1988.     /*----------------------------------------------------------------*/
  1989.     /* ExecuteCurrExitHandler(); */
  1990.     EntryNewScreen(SCR_PE_PEN_SETTING, ExitScr4PicEditPenSetting, NULL, NULL);
  1991.     guiBuffer = GetCurrGuiBuffer(SCR_PE_PEN_SETTING);
  1992.     InitializeCategory57Screen();
  1993.     for (iCount = 0; iCount < MAX_TYPE_PEN_PIXEL; ++iCount)
  1994.     {
  1995.         pInlinePenSizeList[iCount] = (U8*) GetString((U16) (iCount + STR_PE_PEN_SIZE_1));
  1996.     }
  1997. #ifndef __MMI_TOUCH_SCREEN__    /* PMT MANISH   20050616 */
  1998.     for (iCount = 0; iCount < MAX_TYPE_PEN_MOVE; ++iCount)
  1999.     {
  2000.         pInlinePenMoveFactorList[iCount] = (U8*) GetString((U16) (iCount + STR_PE_PEN_MOVE_1));
  2001.     }
  2002. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2003.     nInlinePenColorIndex = gpPicEditPen->penColorIndex - 1;
  2004.     switch (gpPicEditPen->penPixel)
  2005.     {
  2006.         case PIC_EDIT_PEN_PIXEL_1:
  2007.             nInlinePenSize = 0;
  2008.             break;
  2009.         case PIC_EDIT_PEN_PIXEL_2:
  2010.             nInlinePenSize = 1;
  2011.             break;
  2012.         case PIC_EDIT_PEN_PIXEL_3:
  2013.             nInlinePenSize = 2;
  2014.             break;
  2015.         case PIC_EDIT_PEN_PIXEL_4:
  2016.             nInlinePenSize = 3;
  2017.             break;
  2018.         default: