bug fix: TC-1152
[profile/ivi/ico-uxf-homescreen.git] / src / homescreen / CicoHSMenuWindow.cpp
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9 /**
10  * @brief   Menu Window class
11  *
12  * @date    Aug-08-2013
13  */
14 #include "CicoHSMenuWindow.h"
15 #include "CicoHSMenuTouch.h"
16 #include "CicoResourceConfig.h"
17 #include "CicoHomeScreen.h"
18 #include "CicoHSSystemState.h"
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <tzplatform_config.h>
22
23 /*============================================================================*/
24 /* static members                                                             */
25 /*============================================================================*/
26 CicoHSMenuWindow *CicoHSMenuWindow::menu_window_instance;
27 int  CicoHSMenuWindow::menu_tile_width = 290;
28 int  CicoHSMenuWindow::menu_tile_height = 290;
29
30 /*============================================================================*/
31 /* functions                                                                  */
32 /*============================================================================*/
33 /*--------------------------------------------------------------------------*/
34 /**
35  * @brief   CicoHSMenuWindow::CicoHSMenuWindo
36  *          Constractor
37  *
38  * @param[in]   none
39  * @return      none
40  */
41 /*--------------------------------------------------------------------------*/
42 CicoHSMenuWindow::CicoHSMenuWindow(void)
43 {
44     /*initialzie values*/
45     terminate_mode = false;
46
47     /*get menu background image*/
48     CicoGKeyFileConfig config;
49     config.Initialize(ICO_HOMESCREEN_CONFIG_FILE, ICO_SYC_PACKAGE_HOMESCREEN);
50
51     transparent_background = true;
52     const char *menu_back = config.ConfigGetFilePath("homescreen", "menu",
53                                                      ICO_SYC_CONFIGPATH_HOME_IMAGE,
54                                                      ICO_SYC_PACKAGE_HOMESCREEN
55                                                        "/" ICO_SYC_CONFIGPATH_PACKAGE_IMAGE,
56                                                      NULL);
57     if (menu_back)  {
58         strncpy(menu_img_path, menu_back, sizeof(menu_img_path)-1);
59         menu_img_path[sizeof(menu_img_path)-1] = 0;
60         transparent_background = false;
61     }
62
63     InitAppTiles();
64
65     evas = NULL;
66     canvas = NULL;
67     rectangle = NULL;
68
69     for (int ii = 0;ii < ICO_HS_MENU_MAX_TILE_NUM;ii++) {
70         menu_tile[ii] = NULL;
71     }
72     for (int ii = 0;ii < ICO_HS_MENU_MAX_MENU_PAGE_NUM;ii++) {
73         page_pointer[ii] = NULL;
74     }
75
76     surface = 0;
77
78     menu_window_instance = this;
79
80     life_cycle_controller = CicoHSLifeCycleController::getInstance();
81
82     CicoResourceConfig::GetImagePath(img_dir_path, ICO_HS_MAX_PATH_BUFF_LEN);
83
84     m_showState = false;
85 }
86
87 /*--------------------------------------------------------------------------*/
88 /**
89  * @brief   CicoHSMenuWindow::~CicoHSMenuWindo
90  *          Destractor
91  *
92  * @param[in]   none
93  * @return      none
94  */
95 /*--------------------------------------------------------------------------*/
96 CicoHSMenuWindow::~CicoHSMenuWindow(void)
97 {
98     /* Do not somthing to do */
99 }
100
101 /*--------------------------------------------------------------------------*/
102 /**
103  * @brief   CicoHSMenuWindow::SetMenuBack
104  *          create object and show (background of menu)
105  *
106  * @param[in]   none
107  * @return      ERROR or OK
108  */
109 /*--------------------------------------------------------------------------*/
110 int
111 CicoHSMenuWindow::SetMenuBack(void)
112 {
113     /* set menu back */
114     /* set object*/
115     if (transparent_background) {
116         /* image file name*/
117         snprintf(menu_img_path, sizeof(menu_img_path), "%s%s",
118                  img_dir_path, ICO_HS_IMAGE_FILE_MENU_BACK_GROUND);
119
120         rectangle = evas_object_rectangle_add(evas);
121         if (true == CicoHSSystemState::getInstance()->getNightMode()) {
122             evas_object_color_set(rectangle,0,0,0,178);
123         }
124         else {
125             evas_object_color_set(rectangle,120,120,120,178);
126         }
127         evas_object_move(rectangle, 0, 0);
128         evas_object_resize(rectangle, width, height);
129         evas_object_show(rectangle);
130     }
131
132     /* set object*/
133     canvas = evas_object_image_filled_add(evas);
134     evas_object_image_file_set(canvas, menu_img_path, NULL);
135     int err = evas_object_image_load_error_get(canvas);
136     if (err != EVAS_LOAD_ERROR_NONE) {
137         ICO_ERR("CicoHSMenuWindow::SetMenuBack: backgound image(%s) is not exist",
138                 menu_img_path);
139         ICO_TRA("CicoHSMenuWindow::SetMenuBack Leave(ERR)");
140         evas_object_del(canvas);
141         return ICO_ERROR;
142     }
143     evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
144                                    CicoHSMenuTouch::TouchDownMenu,NULL);
145     evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
146                                    CicoHSMenuTouch::TouchUpMenu,NULL);
147     evas_event_callback_add(evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT,
148                             CicoHSMenuTouch::FocusOutEvas, (void *)canvas);
149     evas_object_move(canvas, 0, 0);
150     evas_object_resize(canvas, width, height);
151     evas_object_show(canvas);
152
153     ICO_TRA("CicoHSMenuWindow::SetMenuBack Leave(EOK)");
154     return ICO_OK;
155 }
156
157 /*--------------------------------------------------------------------------*/
158 /**
159  * @brief   CicoHSMenuWindow::FreeMenuBack
160  *          free object (background of menu)
161  *
162  * @param[in]   none
163  * @return      none
164  */
165 /*--------------------------------------------------------------------------*/
166 void
167 CicoHSMenuWindow::FreeMenuBack(void)
168 {
169     evas_object_del(canvas);
170     if (transparent_background)
171         evas_object_del(rectangle);
172 }
173
174 /*--------------------------------------------------------------------------*/
175 /**
176  * @brief   CicoHSMenuWindow::GetLayout
177  *          read layout file
178  *
179  * @param[in]   filename   layout file name
180  * @param[out]   layout   layout data
181  * @param[out]   num      num of tile
182  * @return      none
183  */
184 /*--------------------------------------------------------------------------*/
185 void
186 CicoHSMenuWindow::GetLayout(const char *filename,CicoLayoutInfo *layout,int *num)
187 {
188     int ret;
189     FILE *fp;
190     *num = 0;
191     fp = fopen(filename,"r");
192     if(fp == NULL){
193         return;
194     }
195     int idx =0;
196     while( ( ret = fscanf( fp, "%d,%d,%d,%d,%d",
197         &layout[idx].appidx, &layout[idx].page, &layout[idx].position,
198         &layout[idx].tile_width, &layout[idx].tile_height ) ) != EOF ){
199         idx++;
200     }
201     *num = idx;
202     fclose(fp);
203
204 }
205
206 /*--------------------------------------------------------------------------*/
207 /**
208  * @brief   CicoHSMenuWindow::GetCategory
209  *          read category file
210  *
211  * @param[in]   filename   category file name
212  * @param[out]  category   category data
213  * @param[out]  num        num of category
214  * @return      none
215  */
216 /*--------------------------------------------------------------------------*/
217 void
218 CicoHSMenuWindow::GetCategory(const char *filename, int *category, int *num)
219 {
220     int ret;
221     FILE *fp;
222     *num = 0;
223     fp = fopen(filename,"r");
224     if(fp == NULL){
225         return;
226     }
227     int idx =0;
228     while( ( ret = fscanf( fp, "%d", &category[idx]
229         ) ) != EOF ){
230         idx++;
231     }
232     *num = idx;
233     fclose(fp);
234 }
235
236 /*--------------------------------------------------------------------------*/
237 /**
238  * @brief   CicoHSMenuWindow::SetLayout
239  *          write layout file
240  *
241  * @param[in]   filename   layout file name
242  * @param[in]   layout   layout data
243  * @param[in]   num      num of tile
244  * @return      none
245  */
246 /*--------------------------------------------------------------------------*/
247 void
248 CicoHSMenuWindow::SetLayout(const char *filename,CicoLayoutInfo *layout,int num)
249 {
250     int ret;
251     FILE *fp;
252
253     fp = fopen(filename,"w+");
254     if (fp == NULL) {
255         return;
256     }
257     for (int ii = 0;ii < num;ii++) {
258        ret = fprintf(fp, "%d,%d,%d,%d,%d\n",
259                      layout[ii].appidx,layout[ii].page,layout[ii].position,
260                      layout[ii].tile_width,layout[ii].tile_height);
261        if (ret < 0) {
262            break;
263        }
264     }
265     fclose(fp);
266 }
267
268 /*--------------------------------------------------------------------------*/
269 /**
270  * @brief   CicoHSMenuWindow::InitAppTiles
271  *          Initialization object (tiles)
272  *
273  * @param[in]   none
274  * @return      none
275  */
276 /*--------------------------------------------------------------------------*/
277 void
278 CicoHSMenuWindow::InitAppTiles(void)
279 {
280     ICO_TRA("CicoHSMenuWindow::InitAppTiles Enter");
281
282     current_page = 0;
283     subcurrent_page = 0;
284
285     for (int ii = 0; ii < ICO_HS_MENU_MAX_MENU_CATEGORY_NUM; ii++){
286         category_info[ii].id= 0;
287         category_info[ii].page = 0;
288         category_info[ii].subpage_max = 0;
289         category_info[ii].tile_num = 0;
290     }
291
292     all_tile_num = 0;
293     all_page_num = 0;
294
295     ICO_TRA("CicoHSMenuWindow::InitAppTiles Leave");
296 }
297
298 /*--------------------------------------------------------------------------*/
299 /**
300  * @brief   CicoHSMenuWindow::SetAppTiles
301  *          create object and show (tiles)
302  *
303  * @param[in]   none
304  * @return      ERROR or OK
305  */
306 /*--------------------------------------------------------------------------*/
307 int
308 CicoHSMenuWindow::SetAppTiles(void)
309 {
310     int tile_num = 0;
311     int category_num = 0;
312     int category[ICO_HS_MENU_MAX_TILE_NUM];
313     int ctg_idx = 0;
314     int position = 0;
315     int page = 0;
316     int subpage = 0;
317     current_page = 0;
318
319     /* get APP information */
320     std::vector<CicoAilItems> aillist =
321         life_cycle_controller->getAilList();
322
323     /* get category infomation */
324     const char *category_path = tzplatform_mkpath3(TZ_USER_HOME,
325                                                    ICO_SYC_CONFIGPATH_HOME_CONFIG,
326                                                    ICO_HS_MENU_CATEGORY_FILE_NAME);
327     ICO_DBG("CicoHSMenuWindow::SetAppTiles category_path(%s)", category_path);
328     if (access(category_path, R_OK) != 0)   {
329         category_path = tzplatform_mkpath(TZ_SYS_RO_APP,
330                                           ICO_HS_DEFAULT_MENU_CATEGORY_FILE_PATH);
331     }
332     GetCategory(category_path, category, &category_num);
333     ICO_DBG("CicoHSMenuWindow::SetAppTiles :category_num %d", category_num);
334
335     for (int ii = 0; ii < category_num ; ii++) {
336        ICO_DBG("CicoHSMenuWindow::SetAppTiles :category[%d] %d", ii, category[ii]);
337     }
338
339     /* other category add */
340     all_category_num = category_num + 1;
341
342     /* page set */
343     for (int ii = 0; ii < all_category_num ; ii++) {
344         if(ii == 0) {
345             /* other category */
346             category_info[ii].id = ICO_HS_MENU_OTHER_CATEGORY_ID;
347             category_info[ii].page = ii;
348         }
349         else {
350             /* category */
351             category_info[ii].id = category[ii - 1];
352             category_info[ii].page = ii;
353         }
354     }
355
356     /*first time layout*/
357     for (unsigned int ii = 0; ii < aillist.size(); ii++) {
358
359         /*all application num*/
360         if((aillist[ii].m_noIcon) ||
361                 (strcmp(aillist[ii].m_group.c_str(),
362                 ICO_HS_GROUP_SPECIAL) == 0)) {
363             ICO_DBG("CicoHSMenuWindow::SetAppTiles :ignore app appid = [%s] noIcon = [%d]",
364                     aillist[ii].m_appid.c_str(),aillist[ii].m_noIcon);
365             continue;
366         }
367         ICO_DBG("CicoHSMenuWindow::SetAppTiles :SetApp appid = [%s] noIcon =[%d]",
368                 aillist[ii].m_appid.c_str(),aillist[ii].m_noIcon);
369         ICO_DBG("CicoHSMenuWindow::SetAppTile :aillist[%d].m_categoryID = [%d]",
370                 ii, aillist[ii].m_categoryID);
371
372         /* Categories */
373         for (ctg_idx = 0; ctg_idx < category_num ; ctg_idx++ ) {
374             if (aillist[ii].m_categoryID == category[ctg_idx]) {
375                 SetCategoryInfo(category[ctg_idx]);
376                 GetTileInfo(category[ctg_idx], &page, &subpage, &position);
377                 break;
378             }
379         }
380
381         /* Other categories */
382         if (ctg_idx == category_num) {
383             SetCategoryInfo(ICO_HS_MENU_OTHER_CATEGORY_ID);
384             GetTileInfo(ICO_HS_MENU_OTHER_CATEGORY_ID,
385                         &page, &subpage, &position);
386         }
387
388         /* put tile */
389         menu_tile[tile_num] =
390             new CicoHSMenuTile(aillist[ii].m_appid.c_str(),
391             aillist[ii].m_icon.c_str(),page, subpage, position,
392             CicoHSMenuWindow::Tile_Width(), CicoHSMenuWindow::Tile_Height());
393
394         tile_num++;
395     }
396
397     /*menu num*/
398     all_tile_num = tile_num;
399     all_page_num = all_category_num;
400
401     for (int ii = 0; ii < all_category_num ; ii++) {
402         ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].id = [%d]",
403                 ii, category_info[ii].id);
404         ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].subpage_max = [%d]",
405                 ii, category_info[ii].subpage_max);
406         ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].page = [%d]",
407                 ii, category_info[ii].page);
408         ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].tile_num = [%d]",
409                 ii , category_info[ii].tile_num);
410     }
411
412     /*in case of over max num*/
413     if (all_page_num > ICO_HS_MENU_MAX_MENU_PAGE_NUM) {
414        all_page_num = ICO_HS_MENU_MAX_MENU_PAGE_NUM;
415     }
416
417     /*make tiles*/
418     for (int ii = 0; ii < tile_num; ii++) {
419         if (menu_tile[ii] == NULL) {
420             continue;
421         }
422         menu_tile[ii]->CreateObject(evas);
423         if (menu_tile[ii]->GetPage() != 0) {
424             /*out of window*/
425             menu_tile[ii]->OffsetMove(width,0);
426         }
427         if (menu_tile[ii]->GetSubPage() != 0) {
428             /*out of window*/
429             menu_tile[ii]->OffsetMove(height,0);
430         }
431     }
432     return ICO_OK;
433 }
434
435 /*--------------------------------------------------------------------------*/
436 /**
437  * @brief   CicoHSMenuWindow::FreeAppTiles
438  *          free object (tiles)
439  *
440  * @param[in]   none
441  * @return      none
442  */
443 /*--------------------------------------------------------------------------*/
444 void
445 CicoHSMenuWindow::FreeAppTiles(void)
446 {
447     for (int ii = 0; ii < all_tile_num; ii++) {
448         if (menu_tile[ii] == NULL) {
449             continue;
450         }
451         menu_tile[ii]->FreeObject();
452         delete menu_tile[ii];
453     }
454 }
455
456 /*--------------------------------------------------------------------------*/
457 /**
458  * @brief   CicoHSMenuWindow::RenewAppTiles
459  *          renewal of a menu
460  *
461  * @param   none
462  * @return  none
463  */
464 /*--------------------------------------------------------------------------*/
465 void
466 CicoHSMenuWindow::RenewAppTiles(void)
467 {
468     ICO_TRA("CicoHSMenuWindow::RenewAppTiles Enter");
469
470     int cnt, cnt2;
471     int ret;
472
473     /* backup old data */
474     int all_tile_num_org = all_tile_num;
475     CicoHSMenuTile *menu_tile_org[ICO_HS_MENU_MAX_TILE_NUM];
476     for (cnt=0; cnt < all_tile_num_org; cnt++) {
477         menu_tile_org[cnt]=menu_tile[cnt];
478     }
479
480     /* initialization */
481     InitAppTiles();
482
483     /* set app tiles */
484     ret = SetAppTiles();
485     if(ret != ICO_OK){
486         ICO_ERR("CicoHSMenuWindow::RenewAppTiles: could not make tiles.");
487     }
488
489     /* update app info list */
490     CicoHomeScreen::RenewAppInfoList();
491
492     /* set thumbnail from org */
493     for (cnt=0; cnt < all_tile_num; cnt++) {
494         if (menu_tile[cnt] == NULL) {
495             continue;
496         }
497         for (cnt2=0; cnt2 < all_tile_num_org; cnt2++) {
498             if (menu_tile_org[cnt2] == NULL) {
499                 continue;
500             }
501             if (strncmp(menu_tile[cnt]->GetAppId(),
502                         menu_tile_org[cnt2]->GetAppId(), ICO_HS_MAX_PROCESS_NAME) == 0) {
503                 menu_tile[cnt]->SetOrgThumbnail( menu_tile_org[cnt2] );
504                 break;
505             }
506         }
507     }
508
509     /* free org app tiles */
510     for (cnt2=0; cnt2 < all_tile_num_org; cnt2++) {
511         if (menu_tile_org[cnt2] == NULL) {
512             continue;
513         }
514         menu_tile_org[cnt2]->FreeObject();
515         delete menu_tile_org[cnt2];
516     }
517
518     ICO_TRA("CicoHSMenuWindow::RenewAppTiles Leave");
519 }
520
521 /*--------------------------------------------------------------------------*/
522 /**
523  * @brief   CicoHSMenuWindow::SetPagePointer
524  *          create object and show (page pointer)
525  *
526  * @param[in]   none
527  * @return      ERROR or OK
528  */
529 /*--------------------------------------------------------------------------*/
530 int
531 CicoHSMenuWindow::SetPagePointer(void)
532 {
533     /*debug*/
534     for (int ii = 0; ii < all_page_num; ii++) {
535
536         char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
537         /* set menu back */
538         /* image file name*/
539         if(ii == current_page){
540             snprintf(img_path,sizeof(img_path),"%s%s",
541                      img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
542         }else{
543             snprintf(img_path,sizeof(img_path),"%s%s",
544                      img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
545         }
546         /* set object*/
547         page_pointer[ii] = evas_object_image_filled_add(evas);
548         evas_object_image_file_set(page_pointer[ii], img_path, NULL);
549         int err = evas_object_image_load_error_get(page_pointer[ii]);
550         if (err != EVAS_LOAD_ERROR_NONE) {
551             ICO_ERR("CicoHSMenuWindow::SetPagePointer: page pointer image is not exist");
552             evas_object_del(page_pointer[ii]);
553             return ICO_ERROR;
554         }
555         evas_object_event_callback_add(page_pointer[ii],
556                                        EVAS_CALLBACK_MOUSE_DOWN,
557                                        CicoHSMenuTouch::TouchDownMenu,NULL);
558         evas_object_event_callback_add(page_pointer[ii],
559                                        EVAS_CALLBACK_MOUSE_UP,
560                                        CicoHSMenuTouch::TouchUpMenu,NULL);
561
562         int pos_x = ICO_HS_MENU_PAGE_POINTER_START_POS_X +
563                     (((width - ICO_HS_MENU_PAGE_POINTER_START_POS_X * 2) /
564                     all_page_num ) * ii) +
565                     (((width - ICO_HS_MENU_PAGE_POINTER_START_POS_X * 2) /
566                     all_page_num ) / 2)  -
567                     (ICO_HS_MENU_PAGE_POINTER_WIDTH / 2);
568         evas_object_move(page_pointer[ii], pos_x,
569                          ICO_HS_MENU_PAGE_POINTER_START_POS_Y);
570         evas_object_resize(page_pointer[ii],
571                          ICO_HS_MENU_PAGE_POINTER_WIDTH,
572                          ICO_HS_MENU_PAGE_POINTER_HEIGHT);
573         evas_object_show(page_pointer[ii]);
574     }
575     return ICO_OK;
576 }
577
578 /*--------------------------------------------------------------------------*/
579 /**
580  * @brief   CicoHSMenuWindow::FreePagePointer
581  *          free object (page pointer)
582  *
583  * @param[in]   none
584  * @return      none
585  */
586 /*--------------------------------------------------------------------------*/
587 void
588 CicoHSMenuWindow::FreePagePointer(void)
589 {
590     for (int ii = 0; ii < all_page_num; ii++) {
591         evas_object_del(page_pointer[ii]);
592     }
593 }
594
595 /*--------------------------------------------------------------------------*/
596 /**
597  * @brief   CicoHSMenuWindow::SetTerminateButton
598  *          create object and show (terminate button)
599  *
600  * @param[in]   none
601  * @return      ERROR or OK
602  */
603 /*--------------------------------------------------------------------------*/
604 int
605 CicoHSMenuWindow::SetTerminateButton(void)
606 {
607     int err;
608     char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
609     /* set menu back */
610     /* image file name*/
611
612     /* set object*/
613     terminate_back = evas_object_rectangle_add(evas);
614     evas_object_color_set(terminate_back,0,0,0,178);
615     evas_object_move(terminate_back, 0, 0);
616     evas_object_resize(terminate_back, width, height);
617     evas_object_layer_set(terminate_back, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
618     /* set object*/
619     snprintf(img_path,sizeof(img_path),"%s%s",
620                      img_dir_path,ICO_HS_IMAGE_FILE_MENU_TERMINATE_YES);
621     terminate_button_yes = evas_object_image_filled_add(evas);
622     evas_object_image_file_set(terminate_button_yes, img_path, NULL);
623     err = evas_object_image_load_error_get(terminate_button_yes);
624     if (err != EVAS_LOAD_ERROR_NONE) {
625         ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
626         evas_object_del(terminate_button_yes);
627         return ICO_ERROR;
628     }
629     evas_object_event_callback_add(terminate_button_yes, EVAS_CALLBACK_MOUSE_UP,
630                                        CicoHSMenuTouch::TouchUpTerminateYes,
631                                        NULL);
632     evas_object_move(terminate_button_yes, width / 2  - 100 - 64,
633                                            height / 2 + 100);
634     evas_object_resize(terminate_button_yes,100,64);
635     evas_object_layer_set(terminate_button_yes, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
636
637     /* set object*/
638     snprintf(img_path,sizeof(img_path),"%s%s",
639                      img_dir_path, ICO_HS_IMAGE_FILE_MENU_TERMINATE_NO);
640     terminate_button_no = evas_object_image_filled_add(evas);
641     evas_object_image_file_set(terminate_button_no, img_path, NULL);
642     err = evas_object_image_load_error_get(terminate_button_no);
643     if (err != EVAS_LOAD_ERROR_NONE) {
644         ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
645         evas_object_del(terminate_button_no);
646         return ICO_ERROR;
647     }
648     evas_object_event_callback_add(terminate_button_no, EVAS_CALLBACK_MOUSE_UP,
649                                        CicoHSMenuTouch::TouchUpTerminateNo,
650                                        NULL);
651     evas_object_move(terminate_button_no, width / 2  + 64,
652                                            height / 2 + 100);
653     evas_object_resize(terminate_button_no,100,64);
654     evas_object_layer_set(terminate_button_no, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
655
656     /* set object*/
657     snprintf(img_path,sizeof(img_path),"%s%s",
658                      img_dir_path,ICO_HS_IMAGE_FILE_MENU_TERMINATE_REALLY);
659     terminate_really = evas_object_image_filled_add(evas);
660     evas_object_image_file_set(terminate_really, img_path, NULL);
661     err = evas_object_image_load_error_get(terminate_really);
662     if (err != EVAS_LOAD_ERROR_NONE) {
663         ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
664         evas_object_del(terminate_really);
665         return ICO_ERROR;
666     }
667     evas_object_move(terminate_really, width / 2 - 100,
668                                           height / 2 - 100);
669     evas_object_resize(terminate_really,200,64);
670     evas_object_layer_set(terminate_really, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
671
672     return ICO_OK;
673 }
674
675 /*--------------------------------------------------------------------------*/
676 /**
677  * @brief   CicoHSMenuWindow::FreeTeiminateButton
678  *          free object (terminate button)
679  *
680  * @param[in]   none
681  * @return      none
682  */
683 /*--------------------------------------------------------------------------*/
684 void
685 CicoHSMenuWindow::FreeTerminateButton(void)
686 {
687     evas_object_del(terminate_back);
688     evas_object_del(terminate_really);
689     evas_object_del(terminate_button_yes);
690     evas_object_del(terminate_button_no);
691 }
692
693 /*--------------------------------------------------------------------------*/
694 /**
695  * @brief   CicoHSMenuWindow::ShowTerminateButton
696  *          show terminate button
697  *
698  * @param[in]   none
699  * @return      ERROR or OK
700  */
701 /*--------------------------------------------------------------------------*/
702 void
703 CicoHSMenuWindow::ShowTerminateButton(void)
704 {
705    evas_object_show(terminate_back);
706    evas_object_show(terminate_really);
707    evas_object_show(terminate_button_yes);
708    evas_object_show(terminate_button_no);
709 }
710
711 /*--------------------------------------------------------------------------*/
712 /**
713  * @brief   CicoHSMenuWindow::HideTerminateButton
714  *          show terminate button
715  *
716  * @param[in]   none
717  * @return      none
718  */
719 /*--------------------------------------------------------------------------*/
720 void
721 CicoHSMenuWindow::HideTerminateButton(void)
722 {
723    evas_object_hide(terminate_back);
724    evas_object_hide(terminate_really);
725    evas_object_hide(terminate_button_yes);
726    evas_object_hide(terminate_button_no);
727 }
728
729 /*--------------------------------------------------------------------------*/
730 /**
731  * @brief   CicoHSMenuWindow::SetPageCursor
732  *          create object and show (page cursor)
733  *
734  * @param[in]   none
735  * @return      ERROR or OK
736  */
737 /*--------------------------------------------------------------------------*/
738 int
739 CicoHSMenuWindow::SetPageCursor(void)
740 {
741     char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
742
743     /* up cursor */
744     snprintf(img_path,sizeof(img_path),"%s%s",
745                  img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGE_UP_CURSOR);
746
747     /* set object*/
748     page_up_cursor = evas_object_image_filled_add(evas);
749     evas_object_image_file_set(page_up_cursor, img_path, NULL);
750     int err = evas_object_image_load_error_get(page_up_cursor);
751     if (err != EVAS_LOAD_ERROR_NONE) {
752         ICO_ERR("CicoHSMenuWindow::SetPagePointer: page up cursor image is not exist");
753         evas_object_del(page_up_cursor);
754         return ICO_ERROR;
755     }
756
757     evas_object_move(page_up_cursor, ICO_HS_MENU_PAGE_UP_CURSOR_START_POS_X,
758                      ICO_HS_MENU_PAGE_UP_CURSOR_START_POS_Y);
759     evas_object_resize(page_up_cursor,
760                      ICO_HS_MENU_PAGE_UP_CURSOR_WIDTH,
761                      ICO_HS_MENU_PAGE_UP_CURSOR_HEIGHT);
762
763     /* down cursor */
764     snprintf(img_path,sizeof(img_path),"%s%s",
765                  img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGE_DOWN_CURSOR);
766
767     /* set object*/
768     page_down_cursor = evas_object_image_filled_add(evas);
769     evas_object_image_file_set(page_down_cursor, img_path, NULL);
770     err = evas_object_image_load_error_get(page_down_cursor);
771     if (err != EVAS_LOAD_ERROR_NONE) {
772         ICO_ERR("CicoHSMenuWindow::SetPagePointer: page down cursor image is not exist");
773         evas_object_del(page_down_cursor);
774         return ICO_ERROR;
775     }
776
777     evas_object_move(page_down_cursor, ICO_HS_MENU_PAGE_DOWN_CURSOR_START_POS_X,
778                      ICO_HS_MENU_PAGE_DOWN_CURSOR_START_POS_Y);
779     evas_object_resize(page_down_cursor,
780                      ICO_HS_MENU_PAGE_DOWN_CURSOR_WIDTH,
781                      ICO_HS_MENU_PAGE_DOWN_CURSOR_HEIGHT);
782
783     DspCtrlPageCursor();
784
785     return ICO_OK;
786 }
787
788 /*--------------------------------------------------------------------------*/
789 /**
790  * @brief   CicoHSMenuWindow::FreePageCursor
791  *          free object (page cursor)
792  *
793  * @param[in]   none
794  * @return      none
795  */
796 /*--------------------------------------------------------------------------*/
797 void
798 CicoHSMenuWindow::FreePageCursor(void)
799 {
800     evas_object_del(page_up_cursor);
801     evas_object_del(page_down_cursor);
802 }
803
804 /*--------------------------------------------------------------------------*/
805 /**
806  * @brief   CicoHSMenuWindow::CreateMenuWindow
807  *          Create menu window (page pointer)
808  *
809  * @param[in]   pos_x   window position x
810  * @param[in]   pos_y   window position y
811  * @param[in]   width   window width
812  * @param[in]   height  window height
813  * @return      none
814  */
815 /*--------------------------------------------------------------------------*/
816 int
817 CicoHSMenuWindow::CreateMenuWindow(int pos_x, int pos_y, int width, int height)
818 {
819     int ret;
820
821     /*create window*/
822     ret = CreateWindow(ICO_HS_MENU_WINDOW_TITLE,
823                        pos_x, pos_y, width, height, EINA_TRUE);
824     if(ret != ICO_OK){
825        return ret;
826     }
827
828     /* set tile size    */
829     CicoHSMenuWindow::menu_tile_width = (width - (ICO_HS_MENUTILE_START_POS_X * 2)
830                                          - (ICO_HS_MENUTILE_SPACE_TILE_AND_TILE
831                                              * (ICO_HS_MENUTILE_ROW-1)))
832                                         / ICO_HS_MENUTILE_ROW;
833     if (CicoHSMenuWindow::menu_tile_width < 150)    {
834         CicoHSMenuWindow::menu_tile_width = 150;
835     }
836     CicoHSMenuWindow::menu_tile_height = (height - (ICO_HS_STATUSBAR_WINDOW_HEIGHT
837                                                     + ICO_HS_CONTROLBAR_WINDOW_HEIGHT
838                                                     + ICO_HS_MENUTILE_HEIGHT + 8)
839                                           - (ICO_HS_MENUTILE_SPACE_TILE_AND_TILE
840                                              * (ICO_HS_MENUTILE_COLUMN-1)))
841                                          / ICO_HS_MENUTILE_COLUMN;
842     if (CicoHSMenuWindow::menu_tile_height < 150)   {
843         CicoHSMenuWindow::menu_tile_height = 150;
844     }
845     ICO_DBG("CicoHSMenuWindow::CreateMenuWindow: tile size(w/h)=%d/%d",
846             CicoHSMenuWindow::menu_tile_width, CicoHSMenuWindow::menu_tile_height);
847     if (CicoHSMenuWindow::menu_tile_width > CicoHSMenuWindow::menu_tile_height) {
848         CicoHSMenuWindow::menu_tile_width = CicoHSMenuWindow::menu_tile_height;
849     }
850     else    {
851         CicoHSMenuWindow::menu_tile_height = CicoHSMenuWindow::menu_tile_width;
852     }
853
854     /*get evas*/
855     evas = ecore_evas_get(window);
856     if (!evas) {
857         ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not get evas.");
858         return ICO_ERROR;
859     }
860
861     /* MenuBack */
862     ret = SetMenuBack();
863     if(ret != ICO_OK){
864         ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make back ground.");
865         FreeWindow();
866         return ICO_ERROR;
867     }
868     /* App tiles*/
869     ret = SetAppTiles();
870     if(ret != ICO_OK){
871         ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make tiles.");
872         FreeMenuBack();
873         FreeWindow();
874         return ICO_ERROR;
875     }
876
877     /* Page Pointer */
878     ret = SetPagePointer();
879     if(ret != ICO_OK){
880         ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make page pointer.");
881         FreeAppTiles();
882         FreeMenuBack();
883         FreeWindow();
884         return ICO_ERROR;
885     }
886
887     /* Page Cursor */
888     ret = SetPageCursor();
889     if(ret != ICO_OK){
890         ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make page cursor.");
891         FreePagePointer();
892         FreeAppTiles();
893         FreeMenuBack();
894         FreeWindow();
895         return ICO_ERROR;
896     }
897
898     /* Terminate Button */
899     ret = SetTerminateButton();
900     if(ret != ICO_OK){
901         ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make teminate button.");
902         FreePageCursor();
903         FreePagePointer();
904         FreeAppTiles();
905         FreeMenuBack();
906         FreeWindow();
907         return ICO_ERROR;
908     }
909
910     /* Initialize Action*/
911     CicoHSMenuTouch::Initialize(this);
912
913     return ICO_OK;
914 }
915
916 /*--------------------------------------------------------------------------*/
917 /**
918  * @brief   CicoHSMenuWindow::FreeMenuWindow
919  *          free menu window
920  *
921  * @param[in]   none
922  * @return      none
923  */
924 /*--------------------------------------------------------------------------*/
925 void
926 CicoHSMenuWindow::FreeMenuWindow(void)
927 {
928     FreeTerminateButton();
929     FreePageCursor();
930     FreePagePointer();
931     FreeAppTiles();
932     FreeMenuBack();
933     FreeWindow();
934 }
935
936 /*--------------------------------------------------------------------------*/
937 /**
938  * @brief   CicoHSMenuWindow::MoveToNextAnimation
939  *          animation parts (move to next)
940  *
941  * @param[in]   data
942  * @param[in]   pos
943  * @return      EINA_TRUE
944  */
945 /*--------------------------------------------------------------------------*/
946 Eina_Bool
947 CicoHSMenuWindow::MoveToNextAnimation(void *data,double pos)
948 {
949     int current_page;
950     double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
951     current_page = reinterpret_cast<intptr_t>(data);
952
953     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
954         if (menu_window_instance->menu_tile[ii] == NULL) {
955             continue;
956         }
957         if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page -1) ||
958             (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
959             continue;
960         }
961         menu_window_instance->menu_tile[ii]->OffsetMove(-1 *
962                               (menu_window_instance->width * frame),0);
963     }
964
965     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
966         if (menu_window_instance->menu_tile[ii] == NULL) {
967             continue;
968         }
969         if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page) ||
970             (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
971             continue;
972         }
973         menu_window_instance->menu_tile[ii]->
974             OffsetMove(menu_window_instance->width
975                        - (menu_window_instance->width * frame),0);
976     }
977     return EINA_TRUE;
978 }
979
980 /*--------------------------------------------------------------------------*/
981 /**
982  * @brief   CicoHSMenuWindow::MoveToBackAnimation
983  *          animation parts (move to back)
984  *
985  * @param[in]   data
986  * @param[in]   pos
987  * @return      EINA_TRUE
988  */
989 /*--------------------------------------------------------------------------*/
990 Eina_Bool
991 CicoHSMenuWindow::MoveToBackAnimation(void *data,double pos)
992 {
993     int current_page;
994     double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
995     current_page = reinterpret_cast<intptr_t>(data);
996
997     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
998         if (menu_window_instance->menu_tile[ii] == NULL) {
999             continue;
1000         }
1001         if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page) ||
1002             (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
1003             continue;
1004         }
1005         menu_window_instance->menu_tile[ii]->OffsetMove(-1 *
1006                                  menu_window_instance->width +
1007                                  (menu_window_instance->width * frame),0);
1008     }
1009     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1010         if (menu_window_instance->menu_tile[ii] == NULL) {
1011             continue;
1012         }
1013         if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page + 1) ||
1014             (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
1015             continue;
1016         }
1017         menu_window_instance->menu_tile[ii]->
1018             OffsetMove(menu_window_instance->width * frame,0);
1019     }
1020     return EINA_TRUE;
1021 }
1022
1023 /*--------------------------------------------------------------------------*/
1024 /**
1025  * @brief   CicoHSMenuWindow::MoveToNextSubAnimation
1026  *          animation parts (move to next)
1027  *
1028  * @param[in]   data
1029  * @param[in]   pos
1030  * @return      EINA_TRUE
1031  */
1032 /*--------------------------------------------------------------------------*/
1033 Eina_Bool
1034 CicoHSMenuWindow::MoveToNextSubAnimation(void *data,double pos)
1035 {
1036     CicoCurrentPage *current_info;
1037     double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
1038     current_info = (CicoCurrentPage *)(data);
1039
1040     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1041         if (menu_window_instance->menu_tile[ii] == NULL) {
1042             continue;
1043         }
1044         if (menu_window_instance->menu_tile[ii]->GetSubPage()
1045             != current_info->subcurrent_page -1) {
1046             continue;
1047         }
1048         if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1049             continue;
1050         }
1051         menu_window_instance->menu_tile[ii]->
1052             OffsetMove(0, -1 * (menu_window_instance->height * frame));
1053     }
1054
1055     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1056         if (menu_window_instance->menu_tile[ii] == NULL) {
1057             continue;
1058         }
1059         if (menu_window_instance->menu_tile[ii]->GetSubPage()
1060             != current_info->subcurrent_page) {
1061             continue;
1062         }
1063
1064         if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1065             continue;
1066         }
1067         menu_window_instance->menu_tile[ii]->OffsetMove(0, menu_window_instance->height -
1068                                    (menu_window_instance->height * frame));
1069     }
1070     return EINA_TRUE;
1071 }
1072
1073 /*--------------------------------------------------------------------------*/
1074 /**
1075  * @brief   CicoHSMenuWindow::MoveToBackAnimation
1076  *          animation parts (move to back)
1077  *
1078  * @param[in]   data
1079  * @param[in]   pos
1080  * @return      EINA_TRUE
1081  */
1082 /*--------------------------------------------------------------------------*/
1083 Eina_Bool
1084 CicoHSMenuWindow::MoveToBackSubAnimation(void *data,double pos)
1085 {
1086
1087     CicoCurrentPage *current_info;
1088     double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
1089     current_info = (CicoCurrentPage *)(data);
1090
1091     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1092         if (menu_window_instance->menu_tile[ii] == NULL) {
1093             continue;
1094         }
1095         if (menu_window_instance->menu_tile[ii]->GetSubPage()
1096             != current_info->subcurrent_page) {
1097             continue;
1098         }
1099         if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1100             continue;
1101         }
1102         menu_window_instance->menu_tile[ii]->
1103             OffsetMove(0, -1 * menu_window_instance->height +
1104                        (menu_window_instance->height * frame));
1105     }
1106     for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1107         if (menu_window_instance->menu_tile[ii] == NULL) {
1108             continue;
1109         }
1110         if (menu_window_instance->menu_tile[ii]->GetSubPage()
1111             != current_info->subcurrent_page + 1) {
1112             continue;
1113         }
1114         if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1115             continue;
1116         }
1117         menu_window_instance->menu_tile[ii]->
1118             OffsetMove(0, menu_window_instance->height * frame);
1119     }
1120     return EINA_TRUE;
1121 }
1122
1123 /*--------------------------------------------------------------------------*/
1124 /**
1125  * @brief   CicoHSMenuWindow::GoNextMenu
1126  *          menu change to next
1127  *
1128  * @param[in]   none
1129  * @return      none
1130  */
1131 /*--------------------------------------------------------------------------*/
1132 void
1133 CicoHSMenuWindow::GoNextMenu(void)
1134 {
1135     char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
1136
1137     if ((current_page >= all_page_num -1) || (subcurrent_page > 0)) {
1138         return;
1139     }
1140
1141     /*page pointer*/
1142     snprintf(img_path, sizeof(img_path), "%s%s",
1143              img_dir_path, ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
1144     evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1145
1146     /* increment*/
1147     ++current_page;
1148
1149     /* display cursor */
1150     DspCtrlPageCursor();
1151
1152     /*page pointer*/
1153     snprintf(img_path, sizeof(img_path), "%s%s",
1154              img_dir_path, ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
1155     evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1156
1157     /*tile*/
1158     ecore_animator_frametime_set(1.0f / 30);
1159     ecore_animator_timeline_add(0.4, MoveToNextAnimation,
1160                                 reinterpret_cast<void*>(current_page));
1161 }
1162
1163 /*--------------------------------------------------------------------------*/
1164 /**
1165  * @brief   CicoHSMenuWindow::GoNextMenu
1166  *          menu change to back
1167  *
1168  * @param[in]   none
1169  * @return      none
1170  */
1171 /*--------------------------------------------------------------------------*/
1172 void
1173 CicoHSMenuWindow::GoBackMenu(void)
1174 {
1175     char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
1176
1177     if((current_page <= 0) || (subcurrent_page > 0)){
1178         return;
1179     }
1180
1181     /*page pointer*/
1182     snprintf(img_path,sizeof(img_path),"%s%s",img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
1183     evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1184
1185     /*decrement*/
1186     --current_page;
1187
1188     /* display cursor */
1189     DspCtrlPageCursor();
1190
1191     /*page pointer*/
1192     snprintf(img_path,sizeof(img_path),"%s%s",img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
1193     evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1194
1195     /*tile*/
1196     ecore_animator_frametime_set(1.0f / 30);
1197     ecore_animator_timeline_add(0.4, MoveToBackAnimation,
1198                                 reinterpret_cast<void*>(current_page));
1199
1200 }
1201
1202 /*--------------------------------------------------------------------------*/
1203 /**
1204  * @brief   CicoHSMenuWindow::DownNextMenu
1205  *          menu change to next
1206  *
1207  * @param[in]   none
1208  * @return      none
1209  */
1210 /*--------------------------------------------------------------------------*/
1211 void
1212 CicoHSMenuWindow::DownNextMenu(void)
1213 {
1214     for (int i = 0; i < all_category_num; i++) {
1215         if (current_page == category_info[i].page) {
1216             if (subcurrent_page >= category_info[i].subpage_max){
1217                 return;
1218             }
1219         }
1220     }
1221
1222     /* increment*/
1223     ++subcurrent_page;
1224
1225     /* display cursor */
1226     DspCtrlPageCursor();
1227
1228     /* current page set */
1229     current_info.current_page = current_page;
1230     current_info.subcurrent_page = subcurrent_page;
1231
1232     /*tile*/
1233     ecore_animator_frametime_set(1.0f / 30);
1234     ecore_animator_timeline_add(0.4, MoveToNextSubAnimation,
1235                                 (void*)(&current_info));
1236 }
1237
1238 /*--------------------------------------------------------------------------*/
1239 /**
1240  * @brief   CicoHSMenuWindow::UpBackMenu
1241  *          menu change to back
1242  *
1243  * @param[in]   none
1244  * @return      none
1245  */
1246 /*--------------------------------------------------------------------------*/
1247 void
1248 CicoHSMenuWindow::UpBackMenu(void)
1249 {
1250     if(subcurrent_page <= 0){
1251         return;
1252     }
1253
1254     /*decrement*/
1255     --subcurrent_page;
1256
1257     /* display cursor */
1258     DspCtrlPageCursor();
1259
1260     /* current page set */
1261     current_info.current_page = current_page;
1262     current_info.subcurrent_page = subcurrent_page;
1263
1264     /*tile*/
1265     ecore_animator_frametime_set(1.0f / 30);
1266     ecore_animator_timeline_add(0.4, MoveToBackSubAnimation,
1267                                 (void*)(&current_info));
1268 }
1269
1270 /*--------------------------------------------------------------------------*/
1271 /**
1272  * @brief   CicoHSMenuWindow::DspCtrlPageCursor
1273  *          display control page cursor
1274  *
1275  * @param[in]   none
1276  * @return      none
1277  */
1278 /*--------------------------------------------------------------------------*/
1279 void
1280 CicoHSMenuWindow::DspCtrlPageCursor(void)
1281 {
1282     int subpage_max = 0;
1283     for (int i = 0; i < all_category_num ; i++) {
1284         if (current_page == category_info[i].page) {
1285             subpage_max = category_info[i].subpage_max;
1286             break;
1287         }
1288     }
1289
1290     if (subcurrent_page > 0) {
1291         evas_object_show(page_up_cursor);
1292     }
1293     else {
1294         evas_object_hide(page_up_cursor);
1295     }
1296
1297     if (subcurrent_page < subpage_max) {
1298         evas_object_show(page_down_cursor);
1299     }
1300     else {
1301         evas_object_hide(page_down_cursor);
1302     }
1303 }
1304
1305 /*--------------------------------------------------------------------------*/
1306 /**
1307  * @brief   CicoHSMenuWindow::SetCategoryInfo
1308  *          set category info
1309  *
1310  * @param[in]         id         menu category id
1311  * @return            none
1312  */
1313 /*--------------------------------------------------------------------------*/
1314 void
1315 CicoHSMenuWindow::SetCategoryInfo(int id)
1316 {
1317     for (int i = 0; i < all_category_num ; i++) {
1318         if (category_info[i].id == id) {
1319             /* sub page max */
1320             category_info[i].subpage_max =
1321                 category_info[i].tile_num / ICO_HS_MENUTILE_NUM;
1322
1323             /* tile num */
1324             category_info[i].tile_num++;
1325         }
1326     }
1327 }
1328
1329 /*--------------------------------------------------------------------------*/
1330 /**
1331  * @brief   CicoHSMenuWindow::GetTileInfo
1332  *          get tile info
1333  *
1334  * @param[in]       id         menu category id
1335  * @param[out]      page       menu page
1336  * @param[out]      subpage    menu sub page
1337  * @param[out]      position   menu tile position
1338  * @return          none
1339  */
1340 /*--------------------------------------------------------------------------*/
1341 void
1342 CicoHSMenuWindow::GetTileInfo(int id, int *page, int *subpage, int *position)
1343 {
1344     for (int i = 0; i < all_category_num ; i++) {
1345         if (category_info[i].id == id) {
1346             if (category_info[i].tile_num == 0) {
1347                 ICO_ERR("CicoHSMenuWindow::GetTileInfo: number of tiles is 0.");
1348                 return;
1349             }
1350
1351             /* page */
1352             *page = category_info[i].page;
1353             /* sub page */
1354             *subpage = (category_info[i].tile_num -1) / ICO_HS_MENUTILE_NUM;
1355             /* pasition */
1356             *position = (category_info[i].tile_num -1) % ICO_HS_MENUTILE_NUM;
1357         }
1358     }
1359 }
1360
1361 /*--------------------------------------------------------------------------*/
1362 /**
1363  * @brief   CicoHSMenuWindow::SetMenuWindowID
1364  *          set appid and surface
1365  *
1366  * @param[in]   none
1367  * @return      none
1368  */
1369 /*--------------------------------------------------------------------------*/
1370 void
1371 CicoHSMenuWindow::SetMenuWindowID(const char *appid,int surface)
1372 {
1373     strncpy(this->appid,appid,ICO_HS_MAX_PROCESS_NAME);
1374     this->surface = surface;
1375 }
1376
1377 /*--------------------------------------------------------------------------*/
1378 /**
1379  * @brief   CicoHSMenuWindow::Show
1380  *          show menu window
1381  *
1382  * @param[in]   none
1383  * @return      none
1384  */
1385 /*--------------------------------------------------------------------------*/
1386 void
1387 CicoHSMenuWindow::Show(ico_syc_animation_t *animation)
1388 {
1389     ICO_TRA("CicoHSMenuWindow::Show Enter");
1390
1391     // if regulation == true, forbid show window.
1392     if (true == CicoHSSystemState::getInstance()->getRegulation()) {
1393         return;
1394     }
1395     m_showState = true;
1396
1397     if (true == life_cycle_controller->isAilRenew()) {
1398         ICO_DBG("CicoHSMenuWindow::Show : renew app tiles");
1399         RenewAppTiles();
1400         life_cycle_controller->ailRenewFlagOff();
1401     }
1402
1403     // Show menu tiles
1404     for (int ii = 0; ii < all_tile_num; ii++) {
1405         if (menu_tile[ii])  {
1406             menu_tile[ii]->ShowMenu(true);
1407         }
1408     }
1409
1410     ico_syc_show(appid, surface, animation);
1411
1412     ICO_TRA("CicoHSMenuWindow::Show Leave");
1413 }
1414
1415 /*--------------------------------------------------------------------------*/
1416 /**
1417  * @brief   CicoHSMenuWindow::Hide
1418  *          hide menu window
1419  *
1420  * @param[in]   none
1421  * @return      none
1422  */
1423 /*--------------------------------------------------------------------------*/
1424 void
1425 CicoHSMenuWindow::Hide(ico_syc_animation_t *animation)
1426 {
1427     ICO_TRA("CicoHSMenuWindow::Hide Enter");
1428
1429     if(terminate_mode == true){
1430         ChangeNormalMode();
1431     }
1432     m_showState = false;
1433     if (surface)    {
1434         ico_syc_hide(appid, surface, animation);
1435     }
1436
1437     // Hide menu tiles
1438     for (int ii = 0; ii < all_tile_num; ii++) {
1439         if (menu_tile[ii])  {
1440             menu_tile[ii]->ShowMenu(false);
1441         }
1442     }
1443     ICO_TRA("CicoHSMenuWindow::Hide Leave");
1444 }
1445
1446 /*--------------------------------------------------------------------------*/
1447 /**
1448  * @brief   CicoHSMenuWindow::ExecuteApp
1449  *          execute application
1450  *
1451  * @param[in]   appid   application id
1452  * @return      none
1453  */
1454 /*--------------------------------------------------------------------------*/
1455 void
1456 CicoHSMenuWindow::ExecuteApp(const char *appid)
1457 {
1458     if(terminate_mode == true){
1459         ICO_DBG("CicoHSMenuWindow::ExecuteApp: exet %s but terminate_mode", appid);
1460         return;
1461     }
1462     CicoHomeScreen::ExecuteApp(appid);
1463 }
1464
1465 /*--------------------------------------------------------------------------*/
1466 /**
1467  * @brief   CicoHSMenuWindow::TerminateApp
1468  *          teminate application
1469  *
1470  * @param[in]   appid   application id
1471  * @return      none
1472  */
1473 /*--------------------------------------------------------------------------*/
1474 void
1475 CicoHSMenuWindow::TerminateApp(const char *appid)
1476 {
1477     CicoHomeScreen::TerminateApp(appid);
1478
1479     HideTerminateButton();
1480     ChangeNormalMode();
1481 }
1482
1483 /*--------------------------------------------------------------------------*/
1484 /**
1485  * @brief   CicoHSMenuWindow::ChangeTerminateMode
1486  *          change to terminate mode
1487  *
1488  * @param[in]   none
1489  * @return      none
1490  */
1491 /*--------------------------------------------------------------------------*/
1492 void
1493 CicoHSMenuWindow::ChangeTerminateMode(void)
1494 {
1495     bool check = false;
1496
1497     /*check */
1498     for (int ii = 0; ii < all_tile_num; ii++) {
1499         if(menu_tile[ii] == NULL){
1500             continue;
1501         }
1502         if(CicoHomeScreen::GetAppStatus(menu_tile[ii]->GetAppId()) == true){
1503             check = true;
1504             break;
1505         }
1506     }
1507     if(check == false){
1508         return;
1509     }
1510
1511     /*show term icon*/
1512     for (int ii = 0; ii < all_tile_num; ii++) {
1513         if(menu_tile[ii] == NULL){
1514             continue;
1515         }
1516         if(CicoHomeScreen::GetAppStatus(menu_tile[ii]->GetAppId()) == false){
1517             continue;
1518         }
1519         menu_tile[ii]->ShowTermIcon();
1520     }
1521     terminate_mode = true;
1522     ICO_DBG("CicoHSMenuWindow::ChangeTerminateMode: change to terminate mode");
1523 }
1524
1525 /*--------------------------------------------------------------------------*/
1526 /**
1527  * @brief   CicoHSMenuWindow::ChangeNormalMode
1528  *          change to terminate mode
1529  *
1530  * @param[in]   none
1531  * @return      none
1532  */
1533 /*--------------------------------------------------------------------------*/
1534 void
1535 CicoHSMenuWindow::ChangeNormalMode(void)
1536 {
1537     /*hide term icon*/
1538     for (int ii = 0; ii < all_tile_num; ii++) {
1539         if(menu_tile[ii] == NULL){
1540             continue;
1541         }
1542         menu_tile[ii]->HideTermIcon();
1543     }
1544     terminate_mode = false;
1545     ICO_DBG("CicoHSMenuWindow::ChangeNormalMode: change to normal mode");
1546 }
1547
1548 /*--------------------------------------------------------------------------*/
1549 /**
1550  * @brief   CicoHSMenuWindow::ValidMenuIcon
1551  *          tile is icon
1552  *
1553  * @param[in]   appid    application ID
1554  * @return      none
1555  */
1556 /*--------------------------------------------------------------------------*/
1557 void
1558 CicoHSMenuWindow::ValidMenuIcon(const char *appid)
1559 {
1560     ICO_DBG("CicoHSMenuWindow::ValidMenuIcon(%s)", appid ? appid : "(NULL)" );
1561     for (int ii = 0; ii < all_tile_num; ii++) {
1562         if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1563             menu_tile[ii]->ValidMenuIcon();
1564             break;
1565         }
1566     }
1567 }
1568
1569 /*--------------------------------------------------------------------------*/
1570 /**
1571  * @brief   CicoHSMenuWindow::ValidThumbnail
1572  *          tile is thumbnail
1573  *
1574  * @param[in]   appid    application ID
1575  * @param[in]   surface  surface
1576  * @return      none
1577  */
1578 /*--------------------------------------------------------------------------*/
1579 void
1580 CicoHSMenuWindow::ValidThumbnail(const char *appid, int surface)
1581 {
1582     for (int ii = 0; ii < all_tile_num; ii++) {
1583         if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1584             menu_tile[ii]->ValidThumbnail(surface);
1585             break;
1586         }
1587     }
1588 }
1589
1590 /*--------------------------------------------------------------------------*/
1591 /**
1592  * @brief   CicoHSMenuWindow::SetThumbnail
1593  *          tile is thumbnail
1594  *
1595  * @param[in]   appid    application ID
1596  * @param[in]   info     thumbnail information
1597  * @return      none
1598  */
1599 /*--------------------------------------------------------------------------*/
1600 void
1601 CicoHSMenuWindow::SetThumbnail(const char *appid, ico_syc_thumb_info_t *info)
1602 {
1603     for (int ii = 0; ii < all_tile_num; ii++) {
1604         if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1605             menu_tile[ii]->SetThumbnail(info);
1606             break;
1607         }
1608     }
1609 }
1610
1611 /*--------------------------------------------------------------------------*/
1612 /**
1613  * @brief   CicoHSMenuWindow::SetNightMode
1614  *          set night mode color theme chagne
1615  *
1616  * @param   none
1617  * @return  none
1618  */
1619 /*--------------------------------------------------------------------------*/
1620 void
1621 CicoHSMenuWindow::SetNightMode(void)
1622 {
1623     ICO_TRA("CicoHSMenuWindow::SetNightMode Enter");
1624     if (transparent_background) {
1625         if (true == CicoHSSystemState::getInstance()->getNightMode()) {
1626             evas_object_color_set(rectangle,0,0,0,178);
1627         }
1628         else {
1629             evas_object_color_set(rectangle,120,120,120,178);
1630         }
1631     }
1632     ICO_TRA("CicoHSMenuWindow::SetNightMode Leave");
1633 }
1634
1635 /*--------------------------------------------------------------------------*/
1636 /**
1637  * @brief   CicoHSMenuWindow::Tile_Width
1638  *          menu tile width
1639  *
1640  * @param   none
1641  * @return  tile width
1642  */
1643 /*--------------------------------------------------------------------------*/
1644 int
1645 CicoHSMenuWindow::Tile_Width(void)
1646 {
1647     return CicoHSMenuWindow::menu_tile_width;
1648 }
1649
1650 /*--------------------------------------------------------------------------*/
1651 /**
1652  * @brief   CicoHSMenuWindow::Tile_Height
1653  *          menu tile height
1654  *
1655  * @param   none
1656  * @return  tile height
1657  */
1658 /*--------------------------------------------------------------------------*/
1659 int
1660 CicoHSMenuWindow::Tile_Height(void)
1661 {
1662     return CicoHSMenuWindow::menu_tile_height;
1663 }
1664 // vim: set expandtab ts=4 sw=4: