07df956930063af64f5bb67ec5c70e5a89dd8589
[profile/tv/apps/native/filebrowser.git] / src / views / FbContextView.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17 #include <AppCommon.h>
18
19 #include "define.h"
20 #include "common.h"
21 #include "i18n.h"
22 #include "FbContextView.h"
23 #include "Dummy/DummyContent.h"
24
25 //#define _GET_PRIV(o) evas_object_data_get(o, "CTMDATA");
26 //#define _SET_PRIV(o, data) evas_object_data_set(o, "CTMDATA", data);
27
28 #define FBR_TEXT_SIZE N_("Size")
29 #define FBR_TEXT_FORMAT N_("Format")
30 #define FBR_TEXT_OPEN N_("OPEN")
31 #define FBR_TEXT_LINK N_("Other linkable apps")
32 #define FBR_TEXT_REL N_("Other apps for this type")
33 #define EMPTY_STR ""
34 #define TOTAL_CONTEXT_BTNS 5
35 #define TABLE_MAX_COL 2
36 #define MIN_LABEL_WIDTH 103
37 #define FBR_CTXT_BTN_WPAD 26
38 #define FBR_CTXT_TABLE_WPAD 14
39 #define FBR_CTXT_TABLE_HPAD 14
40
41
42 struct SContextView {
43         Evas_Object *eoWin;
44         Evas_Object *eoBase;
45         Evas_Object *eoBtnOpen;
46         Evas_Object *rel_first[TABLE_MAX_COL];
47         Evas_Object *rel_last[TABLE_MAX_COL];
48         Evas_Object *link_first[TABLE_MAX_COL];
49         Evas_Object *link_last[TABLE_MAX_COL];
50
51         CExtNameInfo *finfo;
52
53         CDummyContent content;
54
55         SContextView() {
56                 eoWin = NULL;
57                 eoBase = NULL;
58                 eoBtnOpen = NULL;
59                 int a;
60                 for (a = 0; a < TABLE_MAX_COL; a++) {
61                         rel_first[a] = NULL;
62                         rel_last[a] = NULL;
63                         link_first[a] = NULL;
64                         link_last[a] = NULL;
65                 }
66                 finfo = NULL;
67                 pHandlerButton = new SContextView::CHandlerButton(this);
68         }
69         ~SContextView() {
70                 delete pHandlerButton;
71         }
72
73         class CHandlerButton : public CListenerMgr, IMouseMoveListener, IMouseUpListener, ISKeyUpListener {
74                 SContextView *m;
75         public:
76                 CHandlerButton(SContextView *ins) : IMouseMoveListener(this), IMouseUpListener(this), ISKeyUpListener(this) { m = ins; }
77
78                 virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) {
79                         if (!elm_object_focus_get(obj))
80                                 elm_object_focus_set(obj, EINA_TRUE);
81                 }
82                 virtual void OnSKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Up *ev) {
83                         _DBG();
84                         if (m->eoBtnOpen == obj) {
85                                 _DBG();
86                                 if (ev->skey == SKEY_ENTER)
87                                         return;
88
89                                 CViewMgr::GetInstance()->UpdateView(FBR_BASE_VIEW, NULL);
90                         }
91                         else {
92                                 _DBG();
93                                 if (ev->skey == SKEY_ENTER)
94                                         return;
95
96                                 elm_object_signal_emit(obj, FBR_SIGNAL_CONTENT_CLICKED, FBR_CONTEXT_VIEW);
97                         }
98                 }
99                 virtual void OnMouseUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Up *ev) {
100                         _DBG();
101                         if (m->eoBtnOpen == obj) {
102                                 CViewMgr::GetInstance()->UpdateView(FBR_BASE_VIEW, NULL);
103                         }
104                         else {
105                                 elm_object_signal_emit(obj, FBR_SIGNAL_CONTENT_CLICKED, FBR_CONTEXT_VIEW);
106                         }
107                 }
108         } *pHandlerButton;
109 };
110
111
112 extern const char *typestr[];
113
114
115 void CContextView::_lbl_start_slide(Evas_Object *lbl)
116 {
117         elm_label_ellipsis_set(lbl, EINA_FALSE);
118         elm_label_slide_mode_set(lbl, ELM_LABEL_SLIDE_MODE_AUTO);
119         elm_label_slide_go(lbl);
120 }
121
122 void CContextView::_btn_focused(void *data, Evas_Object *obj, void *ev)
123 {
124         _DBG();
125         if (!obj)
126                 return;
127
128         elm_object_signal_emit(obj, FBR_SIGNAL_FOCUSED, FBR_CONTEXT_VIEW);
129
130 }
131
132 void CContextView::_btn_unfocused(void *data, Evas_Object *obj, void *ev)
133 {
134         _DBG();
135         if (!obj)
136                 return;
137
138         elm_object_signal_emit(obj, FBR_SIGNAL_UNFOCUSED, FBR_CONTEXT_VIEW);
139 }
140
141
142 bool CContextView::_add_btn_label(Evas_Object *btn, const char *txt)
143 {
144         Evas_Object *lbl;
145         char buf[MAX_LENGTH];
146
147         if (!btn || !txt)
148                 return false;
149
150         lbl = elm_label_add(btn);
151         if (!lbl) {
152                 _ERR("elm_label_add failed.");
153                 return false;
154         }
155
156         snprintf(buf, sizeof(buf),
157                         "<align=center><color=#FFFFFFFF>"
158                         "<font=%s>"
159                         "<font_size=21>%s</font_size>"
160                         "</font></color></align>", FONT_STYLE_MEDIUM, _(txt));
161         elm_object_text_set(lbl, buf);
162         elm_label_line_wrap_set(lbl, ELM_WRAP_WORD);
163         evas_object_size_hint_min_set(lbl, MIN_LABEL_WIDTH, 0);
164         elm_object_part_content_set(btn, FBR_PART_CTXT_BTNTEXT, lbl);
165
166         return true;
167 }
168
169 bool CContextView::_add_btn_icon(Evas_Object *btn, const char *icon)
170 {
171         Evas_Object *img;
172         char buf[MAX_LENGTH];
173
174         if (!btn || !icon)
175                 return false;
176
177         img = elm_image_add(btn);
178         if (!img) {
179                 _ERR("elm_image_add failed.");
180                 return false;
181         }
182
183         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, icon);
184         elm_image_file_set(img, buf, NULL);
185         elm_object_part_content_set(btn, FBR_PART_CTXT_BTNICON, img);
186
187         return true;
188 }
189
190 bool CContextView::_add_btn_info(Evas_Object *btn, const char *icon, const char *txt)
191 {
192         if (!btn || !icon || !txt)
193                 return false;
194
195         if (!_add_btn_icon(btn, icon))
196                 return false;
197
198         if (!_add_btn_label(btn, txt))
199                 return false;
200
201         return true;
202 }
203
204
205 Evas_Object *CContextView::_add_btnbox(Evas_Object *eoBase)
206 {
207         Evas_Object *box;
208
209         if (!eoBase)
210                 return NULL;
211
212         box = elm_box_add(eoBase);
213         if (!box) {
214                 _ERR(" elm_box_add failed ");
215                 return NULL;
216         }
217
218         elm_box_horizontal_set(box, EINA_TRUE);
219         elm_box_padding_set(box, FBR_CTXT_BTN_WPAD, 0);
220         elm_box_align_set(box, 0, 0.5);
221         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
222                         EVAS_HINT_EXPAND);
223
224         return box;
225 }
226
227 bool CContextView::_get_context_details(CExtNameInfo *pInfo, char **path, char **title, char *subtitle, char *subtitle2)
228 {
229         char buf[MAX_LENGTH];
230         TSize size;
231         double size_mb;
232         int type;
233
234         if (!pInfo)
235                 return false;
236
237         *title = pInfo->Name();
238         *path  = pInfo->ThumbnailPath();
239         size = pInfo->Size();
240
241         size_mb = (double)size / (1024 * 1024); /* Convert to MB */
242
243         snprintf(buf, sizeof(buf), "%s : %f MB", _(FBR_TEXT_SIZE), size_mb);
244         strcpy(subtitle, buf);
245
246         type = pInfo->Type();
247         snprintf(buf, sizeof(buf), "%s : %s", _(FBR_TEXT_FORMAT), _(typestr[type]));
248         strcpy(subtitle2, buf);
249
250         return true;
251 }
252
253 Evas_Object *CContextView::_add_rltv_ctnt(Evas_Object *obj, const char *name, const char *icon)
254 {
255         Evas_Object *ly, *img;
256         char buf[MAX_LENGTH];
257
258         if (!obj) {
259                 _ERR("Invalid argument.");
260                 return NULL;
261         }
262
263         ly = elm_layout_add(obj);
264         if (!ly) {
265                 _ERR("elm_layout_add failed.");
266                 return NULL;
267         }
268
269         elm_layout_file_set(ly, EDJEFILE, FBR_CONTEXT_APP);
270         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
271
272         img = elm_image_add(ly);
273         if (!img) {
274                 _ERR("elm_image_add failed.");
275                 evas_object_del(ly);
276                 return NULL;
277         }
278
279         if (!icon || !strcmp(icon, EMPTY_STR)) {
280                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, FBR_IMAGE_DEFAULT_APP);
281                 elm_image_file_set(img, buf, NULL);
282                 elm_image_no_scale_set(img, EINA_TRUE);
283         } else {
284                 elm_image_file_set(img, icon, NULL);
285                 elm_image_aspect_fixed_set(img, EINA_FALSE);
286         }
287
288         elm_object_part_content_set(ly, FBR_PART_CTXT_RELCTNT_ICON, img);
289         elm_object_part_text_set(ly, FBR_PART_CTXT_RELCTNT_NAME, name);
290         elm_object_focus_allow_set(ly, EINA_TRUE);
291
292         return ly;
293 }
294
295
296 Evas_Object *CContextView::_add_scroller(Evas_Object *eoBase)
297 {
298         Evas_Object *scroller;
299
300         if (!eoBase) {
301                 _ERR("Invalid argument.");
302                 return NULL;
303         }
304
305         scroller = elm_scroller_add(eoBase);
306         if (!scroller) {
307                 _ERR("elm_scroller_add failed.");
308                 return NULL;
309         }
310
311         evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND,
312                         EVAS_HINT_EXPAND);
313         evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL,
314                         EVAS_HINT_FILL);
315
316         return scroller;
317 }
318
319 Evas_Object *CContextView::_add_table(Evas_Object *eoBase)
320 {
321         Evas_Object *table;
322
323         if (!eoBase) {
324                 _ERR("Invalid argument.");
325                 return NULL;
326         }
327
328         table = elm_table_add(eoBase);
329         if (!table) {
330                 _ERR("elm_table_add failed.");
331                 return NULL;
332         }
333
334         elm_table_homogeneous_set(table, EINA_TRUE);
335         elm_table_padding_set(table,
336                         FBR_CTXT_TABLE_WPAD * elm_config_scale_get(),
337                         FBR_CTXT_TABLE_HPAD * elm_config_scale_get());
338         evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
339         evas_object_show(table);
340
341         return table;
342 }
343
344
345 Evas_Object *CContextView::_get_icon(Evas_Object *obj, CExtNameInfo *finfo)
346 {
347         Evas_Object *icon;
348         char *path;
349
350         path = finfo->Path();
351         if (!path)
352                 return NULL;
353
354         icon = elm_icon_add(obj);
355         if (!icon)
356                 return NULL;
357
358         elm_need_ethumb();
359         elm_icon_thumb_set(icon, path, NULL);
360         elm_image_aspect_fixed_set(icon, EINA_FALSE);
361
362         return icon;
363 }
364
365
366 void CContextView::_set_default_thumb(Evas_Object *img, int type)
367 {
368         char buf[MAX_LENGTH];
369
370         if (!img)
371                 return;
372
373         switch (type) {
374         case E_GRP_FOLDER:
375                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
376                                 FBR_IMAGE_FOLDER);
377                 break;
378
379         case E_GRP_VIDEO:
380                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
381                                 FBR_IMAGE_DEFAULT_VIDEO);
382                 break;
383
384         case E_GRP_MUSIC:
385                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
386                                 FBR_IMAGE_DEFAULT_MUSIC);
387                 break;
388
389         default:
390                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
391                                 FBR_IMAGE_DEFAULT_OTHER);
392                 break;
393         }
394
395         elm_image_file_set(img, buf, NULL);
396         elm_image_no_scale_set(img, EINA_TRUE);
397 }
398
399
400 Evas_Object *CContextView::_create_lbl(Evas_Object *ly, char *title)
401 {
402         Evas_Object *lbl;
403         const char *s;
404         char buf[MAX_LENGTH];
405
406         if (!title)
407                 return NULL;
408
409         lbl = elm_label_add(ly);
410         if (!lbl) {
411                 return NULL;
412         }
413
414         elm_object_style_set(lbl, FBR_STYLE_LABEL);
415         elm_label_ellipsis_set(lbl, EINA_TRUE);
416         s = edje_object_data_get(elm_layout_edje_get(ly),
417                         FBR_DATA_TITLE_WIDTH);
418         if (s)
419                 elm_label_wrap_width_set(lbl, atoi(s));
420         else
421                 _ERR("No title width exist");
422
423         snprintf(buf, sizeof(buf),
424                         "<align=left><color=#FFFFFFFF>"
425                         "<font=%s>"
426                         "<font_size=36>%s</font_size>"
427                         "</font></color></align>", FONT_STYLE_BOLD, _(title));
428         elm_object_text_set(lbl, buf);
429         elm_label_slide_speed_set(lbl, FBR_TITLE_SLIDE_SPEED);
430
431         return lbl;
432 }
433
434
435
436 void CContextView::m_SetBtnDownFocus(Evas_Object *btn)
437 {
438         ASSERT(m);
439
440         if (!m->link_first[0] && !m->rel_first[0]) {
441                 elm_object_focus_next_object_set(btn, btn,
442                         ELM_FOCUS_DOWN);
443                 return;
444         }
445
446         if (m->link_first[0])
447                 elm_object_focus_next_object_set(btn, m->link_first[0],
448                 ELM_FOCUS_DOWN);
449         else
450                 elm_object_focus_next_object_set(btn, m->rel_first[0],
451                 ELM_FOCUS_DOWN);
452 }
453
454
455 void CContextView::m_SetLayoutFocusOrder(Evas_Object *btn)
456 {
457         ASSERT(btn);
458
459         int i;
460         Evas_Object *obj;
461
462         if (m->link_first[0]) {
463                 elm_object_focus_next_object_set(m->link_first[0], btn,
464                         ELM_FOCUS_UP);
465                 elm_object_focus_next_object_set(m->link_first[0],
466                         m->rel_first[0], ELM_FOCUS_DOWN);
467                 elm_object_focus_next_object_set(m->link_first[1], btn,
468                         ELM_FOCUS_UP);
469                 elm_object_focus_next_object_set(m->link_first[1],
470                         m->rel_first[0], ELM_FOCUS_DOWN);
471         }
472
473         for (i = 0; i < TABLE_MAX_COL; i++) {
474                 if (!m->rel_first[i])
475                         continue;
476
477                 obj = m->rel_first[i];
478                 if (m->link_first[0])
479                         elm_object_focus_next_object_set(obj, m->link_first[0],
480                         ELM_FOCUS_UP);
481                 else
482                         elm_object_focus_next_object_set(obj, btn,
483                         ELM_FOCUS_UP);
484         }
485 }
486
487
488 Evas_Object *CContextView::m_AddButton(Evas_Object *eoBase)
489 {
490         ASSERT(eoBase);
491
492         Evas_Object *btn;
493
494         btn = elm_layout_add(eoBase);
495         if (!btn) {
496                 _ERR("elm_layout_add failed.");
497                 return NULL;
498         }
499
500         evas_object_size_hint_weight_set(btn,
501                 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
502         evas_object_size_hint_align_set(btn, 0.0, 0.5);
503
504         elm_layout_file_set(btn, EDJEFILE, FBR_CONTEXT_BTN);
505         elm_object_focus_allow_set(btn, EINA_TRUE);
506         elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
507         elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
508         elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT);
509
510         evas_object_smart_callback_add(btn, FBR_SIGNAL_FOCUSED,   _btn_focused, NULL);
511         evas_object_smart_callback_add(btn, FBR_SIGNAL_UNFOCUSED, _btn_unfocused, NULL);
512
513         evas_object_show(btn);
514         elm_object_focus_set(btn, EINA_TRUE);
515
516         return btn;
517 }
518
519
520 bool CContextView::m_AddTableContents(Evas_Object *table, Eina_List *list, enum content_app_type type)
521 {
522         ASSERT(list);
523
524         int row, col;
525         Evas_Object *ly;
526         Eina_List *l;
527         CDummyContent::SRelativeContent *rctnt;
528         void* obj;
529
530         row = 0;
531         col = 0;
532
533         EINA_LIST_FOREACH(list, l, obj) {
534                 rctnt = (CDummyContent::SRelativeContent *)obj;
535                 ly = _add_rltv_ctnt(table, rctnt->title, rctnt->imgpath);
536                 if (!ly)
537                         continue;
538                 //_SET_PRIV(ly, rctnt);
539                 elm_table_pack(table, ly, col, row, 1, 1);
540                 evas_object_show(ly);
541
542                 evas_object_smart_callback_add(ly, FBR_SIGNAL_FOCUSED,       _btn_focused, NULL);
543                 evas_object_smart_callback_add(ly, FBR_SIGNAL_UNFOCUSED,     _btn_unfocused, NULL);
544
545                 m->pHandlerButton->Connect(ly);
546
547                 if (row == 0) {
548                         if (type == APP_LINKED)
549                                 m->link_first[col] = ly;
550                         else
551                                 m->rel_first[col] = ly;
552                 }
553
554                 if (col == 0)
555                         elm_object_focus_next_object_set(ly, ly, ELM_FOCUS_LEFT);
556                 else if (col == TABLE_MAX_COL - 1)
557                         elm_object_focus_next_object_set(ly, ly, ELM_FOCUS_RIGHT);
558
559                 if (type == APP_LINKED)
560                         m->link_last[col] = ly;
561                 else
562                         m->rel_last[col] = ly;
563
564                 col++;
565                 if (col >= TABLE_MAX_COL) {
566                         row++;
567                         col = 0;
568                 }
569         }
570
571         return true;
572 }
573
574
575 bool CContextView::m_CreateContentApps(Eina_List *list, enum content_app_type type)
576 {
577         if (!list)
578                 return false;
579
580         Evas_Object *scroller, *table;
581         int r;
582
583         scroller = _add_scroller(m->eoBase);
584         if (!scroller) {
585                 _ERR("_add_scroller failed.");
586                 return false;
587         }
588
589         table = _add_table(scroller);
590         if (!table) {
591                 _ERR("_add_table failed.");
592                 evas_object_del(scroller);
593                 return false;
594         }
595
596         r = m_AddTableContents(table, list, type);
597         if (!r) {
598                 _ERR("m_AddTableContents failed.");
599                 evas_object_del(scroller);
600                 return false;
601         }
602
603         elm_object_content_set(scroller, table);
604
605         if (type == APP_LINKED)
606                 elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_LINK_AREA,
607                 scroller);
608         else
609                 elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_REL_AREA,
610                 scroller);
611
612         return true;
613 }
614
615
616 bool CContextView::m_CreateBtnsPart(void)
617 {
618         Evas_Object *btn, *box;
619         box = _add_btnbox(m->eoBase);
620         if (!box)
621                 return false;
622
623         btn = m_AddButton(box);
624         if (!btn) {
625                 evas_object_del(box);
626                 return false;
627         }
628         if (!_add_btn_info(btn, FBR_IMAGE_CTXT_OPEN, FBR_TEXT_OPEN)) {
629                 evas_object_del(box);
630                 return false;
631         }
632
633         m_SetBtnDownFocus(btn);
634         m_SetLayoutFocusOrder(btn);
635         elm_box_pack_end(box, btn);
636         m->eoBtnOpen = btn;
637
638         m->pHandlerButton->Connect(m->eoBtnOpen);
639
640         elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_BTNAREA, box);
641
642         return true;
643 }
644
645
646 bool CContextView::m_CreateInfoPart(void)
647 {
648         Evas_Object *img = NULL;
649         char *title = NULL;
650
651         char subtitle[MAX_LENGTH];
652         char subtitle2[MAX_LENGTH];
653
654         char *path = NULL;
655         Eina_List *rltvlist = NULL;
656         Eina_List *linkapplist = NULL;
657         int type;
658         Evas_Object *lbl = NULL;
659
660         if (!_get_context_details(m->finfo, &path, &title, subtitle, subtitle2))
661                 return false;
662
663         type = m->finfo->Type();
664         if (!path) {
665                 if (type == E_GRP_PHOTO) {
666                         img = _get_icon(m->eoBase, m->finfo);
667                         if (!img)
668                                 goto finish;
669                 } else {
670                         img = elm_image_add(m->eoBase);
671                         if (!img)
672                                 goto finish;
673                         _set_default_thumb(img, type);
674                 }
675         } else {
676                 img = elm_image_add(m->eoBase);
677                 if (!img)
678                         goto finish;
679                 elm_image_file_set(img, path, NULL);
680                 elm_image_aspect_fixed_set(img, EINA_FALSE);
681         }
682
683         elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_ICON, img);
684
685         lbl = _create_lbl(m->eoBase, title);
686         if (lbl) {
687                 elm_object_part_content_set(m->eoBase, FBR_PART_CTXT_TITLE, lbl);
688                 _lbl_start_slide(lbl);
689         }
690
691         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_SUBTITLE,  subtitle);
692         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_SUBTITLE2, subtitle2);
693
694         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_LINK_TEXT, _(FBR_TEXT_LINK));
695         linkapplist = CDummyContent::ListLinkApp(type);
696         if (linkapplist)
697                 m_CreateContentApps(linkapplist, APP_LINKED);
698
699         elm_object_part_text_set(m->eoBase, FBR_PART_CTXT_REL_TEXT, _(FBR_TEXT_REL));
700         rltvlist = CDummyContent::ListRelative(type);
701         if (rltvlist)
702                 m_CreateContentApps(rltvlist, APP_OTHER);
703
704 finish:
705
706         return true;
707 }
708
709
710 void CContextView::sm_CbKeyPressed(void *dt, Evas *e, Evas_Object *obj, void *ei)
711 {
712         _DBG();
713         Evas_Event_Key_Down *ev;
714
715         if (!dt || !ei)
716                 return;
717
718         ev = (Evas_Event_Key_Down *)ei;
719
720         if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE))
721         {
722                 CViewMgr::GetInstance()->PopView();
723         }
724         else if (!strcmp(ev->keyname, KEY_EXIT))
725                 elm_exit();
726 }
727
728 void CContextView::t_OnShow(void)
729 {
730         evas_object_show(m->eoBase);
731 }
732
733 void CContextView::t_OnHide(void)
734 {
735         evas_object_hide(m->eoBase);
736 }
737
738 bool CContextView::Create(void *data)
739 {
740         ASSERT(!m);
741
742         Evas_Object *eoBase = NULL;
743         Evas_Object *eoWin = CViewMgr::GetInstance()->Window();
744
745
746         _CREATE_BEGIN{
747                 _CHECK(m = new SContextView)
748                 _CHECK(eoBase = elm_layout_add(eoWin))
749                 _CHECK(elm_layout_file_set(eoBase, EDJEFILE, FBR_CONTEXT_VIEW))
750                 _COMMAND{ m->eoWin = eoWin; m->eoBase = eoBase; m->finfo = (CExtNameInfo*)data; }
751                 _CHECK(m_CreateInfoPart())
752                 _CHECK(m_CreateBtnsPart())
753
754                 _WHEN_SUCCESS{
755                         evas_object_event_callback_add(eoBase, EVAS_CALLBACK_KEY_DOWN, sm_CbKeyPressed, m);
756                 }
757
758                 _CHECK_FAIL{ /* m_CreateBtnsPart */ }
759                 _CHECK_FAIL{ /* m_CreateInfoPart */ }
760                 _CHECK_FAIL{}
761                 _CHECK_FAIL{ evas_object_del(eoBase);  }
762                 _CHECK_FAIL{ delete m; m = NULL; }
763         } _CREATE_END_AND_CATCH{ return false; }
764
765         return true;
766 }
767
768 void CContextView::Destroy(void)
769 {
770         ASSERT(m);
771
772         evas_object_del(m->eoBase);
773         delete m;
774         m = NULL;
775 }
776
777 Evas_Object* CContextView::Base(void)
778 {
779         ASSERT(m);
780
781         return m->eoBase;
782 }