Removed dead code from SimpleUI
[profile/tv/apps/web/browser.git] / services / SimpleUI / CustomPopup.cpp
1 #include "CustomPopup.h"
2 #include "BrowserLogger.h"
3
4 CustomPopup::CustomPopup(Evas_Object* main_layout) :
5     m_popup(NULL),
6     m_content(NULL),
7     m_mainLayout(main_layout)
8 {
9
10 }
11
12 CustomPopup::CustomPopup(Evas_Object *main_layout, Evas_Object *content, const char *message, char* title, char* okButtonText, char* cancelButtonText) :
13     m_popup(NULL),
14     m_mainLayout(main_layout),
15     m_content(content),
16     m_message(message),
17     m_title(title),
18     m_okButtonText(okButtonText),
19     m_cancelButtonText(cancelButtonText)
20 {
21
22 }
23
24 void CustomPopup::setTitle(const std::string& title)
25 {
26     m_title = title;
27 }
28
29 void CustomPopup::setMessage(const std::string& message)
30 {
31     m_message = message;
32 }
33
34 void CustomPopup::setContent(Evas_Object* content)
35 {
36     m_content = content;
37 }
38
39 void CustomPopup::setOkButtonText(const std::string& okButtonText)
40 {
41     m_okButtonText = okButtonText;
42 }
43
44 void CustomPopup::setCancelButtonText(const std::string& cancelButtonText)
45 {
46     m_cancelButtonText = cancelButtonText;
47 }
48
49 void CustomPopup::show()
50 {
51     BROWSER_LOGD("[%s],", __func__);
52     std::string edjePath = std::string(EDJE_DIR);
53     edjePath.append("SimpleUI/CustomPopup.edj");
54     elm_theme_extension_add(0, edjePath.c_str());
55     m_popup = elm_layout_add(m_mainLayout);
56     if(m_content)
57         elm_layout_file_set(m_popup, edjePath.c_str(), "own_popup_long");
58     else
59         elm_layout_file_set(m_popup, edjePath.c_str(), "own_popup");
60     BROWSER_LOGI("PATH: %s", edjePath.c_str());
61     elm_object_part_text_set(m_popup, "title_text", m_title.c_str());
62
63     Evas_Object *buttonsBox = elm_box_add(m_popup);
64     elm_box_horizontal_set(buttonsBox, EINA_TRUE);
65
66     if (!m_okButtonText.empty())
67     {
68         BROWSER_LOGD("Button1, %s", edjePath.c_str());
69         Evas_Object *btn1 = elm_button_add(buttonsBox);
70         evas_object_size_hint_weight_set(btn1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
71         evas_object_size_hint_align_set(btn1, 0.5, 0.5);
72         elm_object_style_set(btn1, "standard_button");
73         elm_object_part_text_set(btn1, "elm.text", m_okButtonText.c_str());
74         elm_box_pack_end(buttonsBox, btn1);
75         evas_object_smart_callback_add(btn1, "clicked", popup_ok_cb, (void*)this);
76         evas_object_show(btn1);
77     }
78
79     if (!m_cancelButtonText.empty())
80     {
81         BROWSER_LOGD("Button2");
82         Evas_Object *btn2 = elm_button_add(buttonsBox);
83         evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
84         evas_object_size_hint_align_set(btn2, 0.5, 0.5);
85         elm_object_style_set(btn2, "standard_button");
86         elm_object_part_text_set(btn2, "elm.text", m_cancelButtonText.c_str());
87         elm_box_pack_end(buttonsBox, btn2);
88         evas_object_smart_callback_add(btn2, "clicked", popup_cancel_cb, (void*)this);
89         evas_object_show(btn2);
90     }
91
92     if(!m_message.empty())
93         elm_object_part_text_set(m_popup, "elm.text", m_message.c_str());
94
95     evas_object_show(buttonsBox);
96     elm_object_part_content_set(m_popup, "buttons", buttonsBox);
97     elm_object_part_content_set(m_popup, "content", m_content);
98     elm_object_part_content_set(m_mainLayout, "popup", m_popup);
99
100     elm_object_signal_emit(m_mainLayout, "elm,state,show", "elm");
101 }
102
103 void CustomPopup::hide()
104 {
105     elm_object_signal_emit(m_mainLayout, "elm,state,hide", "elm");
106 }
107
108 void CustomPopup::popup_ok_cb(void *data, Evas_Object *btn, void*)
109 {
110     BROWSER_LOGD("[%s],", __func__);
111     CustomPopup *ownPopup = static_cast<CustomPopup*>(data);
112     ownPopup->on_ok(ownPopup->m_content);
113 }
114 void CustomPopup::popup_cancel_cb(void *data, Evas_Object *btn, void*)
115 {
116     BROWSER_LOGD("[%s],", __func__);
117     CustomPopup *ownPopup = static_cast<CustomPopup*>(data);
118     ownPopup->on_cancel(ownPopup->m_content);
119 }
120