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