47bf8d9109c3a65d7cd4f5e5968d7dcf8b9f244b
[apps/home/wrt-setting.git] / webapp-detail / view.cpp
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 <Evas.h>
18 #include <dpl/assert.h>
19 #include "view.h"
20
21 namespace WebAppDetailSetting {
22
23 void delCb(void *data,
24         Evas */*e*/,
25         Evas_Object */*eo*/,
26         void */*event_info*/)
27 {
28     View *v;
29
30     v = static_cast<View *>(data);
31     Assert(v);
32     v->onDel();
33     v->resetBase();
34 }
35
36 void showCb(void *data,
37         Evas */*e*/,
38         Evas_Object */*eo*/,
39         void */*event_info*/)
40 {
41     View *v;
42
43     v = static_cast<View *>(data);
44     Assert(v);
45     v->onShow();
46 }
47
48 void hideCb(void *data,
49         Evas */*e*/,
50         Evas_Object */*eo*/,
51         void */*event_info*/)
52 {
53     View *v;
54
55     v = static_cast<View *>(data);
56     Assert(v);
57     v->onHide();
58 }
59
60 void View::resetBase(Evas_Object *base)
61 {
62     if (m_base) {
63         evas_object_event_callback_del_full(m_base, EVAS_CALLBACK_DEL, delCb, this);
64         evas_object_event_callback_del_full(m_base, EVAS_CALLBACK_SHOW, showCb, this);
65         evas_object_event_callback_del_full(m_base, EVAS_CALLBACK_HIDE, hideCb, this);
66     }
67
68     m_base = base;
69
70     if (m_base) {
71             evas_object_event_callback_add(base, EVAS_CALLBACK_DEL, delCb, this);
72             evas_object_event_callback_add(base, EVAS_CALLBACK_SHOW, showCb, this);
73             evas_object_event_callback_add(base, EVAS_CALLBACK_HIDE, hideCb, this);
74     }
75 }
76
77 View::~View(void)
78 {
79     if (m_base) {
80         evas_object_event_callback_del_full(m_base, EVAS_CALLBACK_DEL, delCb, this);
81         evas_object_event_callback_del_full(m_base, EVAS_CALLBACK_SHOW, showCb, this);
82         evas_object_event_callback_del_full(m_base, EVAS_CALLBACK_HIDE, hideCb, this);
83         evas_object_del(m_base);
84     }
85 }
86
87 } /* WebAppDetailSetting */