diff options
-rw-r--r-- | include/timeout_handler.h | 26 | ||||
-rw-r--r-- | include/view_maincatalog.h | 2 | ||||
-rw-r--r-- | include/view_sublist.h | 36 | ||||
-rw-r--r-- | include/view_system_clock.h | 33 | ||||
-rw-r--r-- | include/view_uigadget.h | 35 | ||||
-rw-r--r-- | src/settingviewmgr.cpp | 56 | ||||
-rw-r--r-- | src/timeout_handler.cpp | 112 | ||||
-rw-r--r-- | src/view_sublist.cpp | 295 | ||||
-rw-r--r-- | src/view_system_clock.cpp | 398 | ||||
-rw-r--r--[-rwxr-xr-x] | src/view_uigadget.cpp | 225 |
10 files changed, 534 insertions, 684 deletions
diff --git a/include/timeout_handler.h b/include/timeout_handler.h index 5b0aaad..ee94854 100644 --- a/include/timeout_handler.h +++ b/include/timeout_handler.h @@ -17,15 +17,33 @@ #ifndef __TIMEOUT_HANDLER_H__ #define __TIMEOUT_HANDLER_H__ + #define TIMEOUT_SECS 60 -struct timeout_handler; + +class CTimeoutHandler { +private: + struct STimeoutHandler *m; + +public: + CTimeoutHandler() : m(0) {} + virtual ~CTimeoutHandler() {} + + bool Create(double val); + virtual void Destroy(void); + + void FreezeTimer(void); + void ThawTimer(void); + void ChangeInterval(double val); +}; +/*struct timeout_handler; void timeout_handler_freeze_timer(struct timeout_handler *data); void timeout_handler_thaw_timer(struct timeout_handler *data); -void timeout_handler_change_interval(struct timeout_handler *data, - double val); +void timeout_handler_change_interval(struct timeout_handler *data, double val); + struct timeout_handler *timeout_handler_init(double val); -void timeout_handler_fini(struct timeout_handler *data); +void timeout_handler_fini(struct timeout_handler *data);*/ + #endif /* __TIMEOUT_HANDLER_H__ */ diff --git a/include/view_maincatalog.h b/include/view_maincatalog.h index 22ae52b..6ab5aef 100644 --- a/include/view_maincatalog.h +++ b/include/view_maincatalog.h @@ -40,9 +40,7 @@ public: virtual void LangChanged(void); virtual void Frozen(void); virtual void Active(void); - }; -//struct setting_class *view_maincatalog_get_vclass(void); #endif /* __VIEW_MAINMENU_H__ */ diff --git a/include/view_sublist.h b/include/view_sublist.h index 9733191..1f7ffcf 100644 --- a/include/view_sublist.h +++ b/include/view_sublist.h @@ -19,36 +19,36 @@ #include "settingviewmgr.h" +#include "InputHandler.h" class CSublistView : - public CSettingBaseView { + public CSettingBaseView, + public IFocusedListener, + public IUnfocusedListener, + public IMouseClickedListener, + public IKeyDownListener, + public CListenerMgr { private: struct SSublistView *m; private: - static void sm_CbSubitemBtnClicked(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemBtnClicked(Evas_Object *obj, void *ev); - - static void sm_CbSubitemKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei); - void m_OnSubitemKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); - - static void sm_CbSubitemFocusOut(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemFocusOut(Evas_Object *obj, void *ev); - - static void sm_CbSubitemFocusIn(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemFocusIn(Evas_Object *obj, void *ev); - static void sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev); void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev); - int m_DrawSublist(void); + bool m_DrawSublist(void); void m_ExitView(void); void m_SetSelectedValue(Evas_Object *obj); int m_DrawListItems(Eina_List *list); public: - CSublistView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} + CSublistView(const char *pViewId) : + CSettingBaseView(pViewId), + IFocusedListener(this), + IUnfocusedListener(this), + IMouseClickedListener(this), + IKeyDownListener(this), + m(0) {} virtual ~CSublistView() {} Evas_Object *Base(void); @@ -57,6 +57,12 @@ public: virtual void Show(void); virtual void Hide(void); virtual void Destroy(void); + +public: + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); }; diff --git a/include/view_system_clock.h b/include/view_system_clock.h index 2881ff5..2ffee89 100644 --- a/include/view_system_clock.h +++ b/include/view_system_clock.h @@ -19,30 +19,36 @@ #include "settingviewmgr.h" +#include "InputHandler.h" class CSystemClockView : - public CSettingBaseView { + public CSettingBaseView, + public IFocusedListener, + public IUnfocusedListener, + public IMouseClickedListener, + public IKeyDownListener, + public CListenerMgr { private: struct SSystemClockView *m; private: - static void sm_CbSubitemClicked(void *priv, Evas_Object *obj, void *ev); - void m_OnSubitemClicked(Evas_Object *obj, void *ev); - - static void sm_CbSubitemKeypress(void *priv, Evas *e, Evas_Object *obj, void *ei); - void m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ei); - static void sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev); void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev); void m_ExitView(void); - int m_DrawSysclkSublist(void); - int m_AddSysclkSublistItem(Eina_List *list, const char *selval); + bool m_DrawSysclkSublist(void); + bool m_AddSysclkSublistItem(Eina_List *list, const char *selval); public: - CSystemClockView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} + CSystemClockView(const char *pViewId) : + CSettingBaseView(pViewId), + IFocusedListener(this), + IUnfocusedListener(this), + IMouseClickedListener(this), + IKeyDownListener(this), + m(0) {} virtual ~CSystemClockView() {} Evas_Object *Base(void); @@ -52,6 +58,13 @@ public: virtual void Refresh(void); virtual void Hide(void); virtual void Destroy(void); + +public: + // If buttons are clicked + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); }; diff --git a/include/view_uigadget.h b/include/view_uigadget.h index 88359e0..367c256 100644 --- a/include/view_uigadget.h +++ b/include/view_uigadget.h @@ -22,17 +22,39 @@ #include "settingviewmgr.h" +class CUiGadget { +private: + ui_gadget_h m_handler; +private: + static void sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv); + static void sm_CbResult(ui_gadget_h ug, service_h result, void *priv); + static void sm_CbDestroy(ui_gadget_h ug, void *priv); + static void sm_CbEnd(ui_gadget_h ug, void *priv); + +protected: + + virtual void t_OnLayout(ui_gadget_h ug, ug_mode mode) {} + virtual void t_OnResult(ui_gadget_h ug, service_h result) {} + virtual void t_OnDestroy(ui_gadget_h ug) {} + virtual void t_OnEnd(ui_gadget_h ug) {} + +public: + CUiGadget() : m_handler(0) {} + + bool Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service); + virtual void Destroy(void); +}; + class CUiGadgetView : - public CSettingBaseView { + public CSettingBaseView, + public CUiGadget { private: struct SUiGadgetView *m; -private: - static void sm_CbUgLayout(ui_gadget_h ug, enum ug_mode mode, void *priv); - static void sm_CbUgResult(ui_gadget_h ug, service_h result, void *priv); - static void sm_CbUgDestroy(ui_gadget_h ug, void *priv); - void m_OnUgDestroy(ui_gadget_h ug); +protected: + virtual void t_OnDestroy(ui_gadget_h ug); +private: bool m_Load(void); void m_BackToMainview(void); @@ -48,4 +70,5 @@ public: virtual void Destroy(void); }; + #endif /* __VIEW_UIGADGET_H__ */ diff --git a/src/settingviewmgr.cpp b/src/settingviewmgr.cpp index 0666250..674f3bf 100644 --- a/src/settingviewmgr.cpp +++ b/src/settingviewmgr.cpp @@ -18,6 +18,7 @@ #include <Eina.h> #include "dbg.h" +#include "AppCommon.h" #include "settingviewmgr.h" #include "data_wrapper.h" #include "timeout_handler.h" @@ -41,7 +42,7 @@ struct SSettingMgr { Eina_List *view_list; struct settingmgr_data *data; Eina_Array *item_path; - struct timeout_handler *handler; + CTimeoutHandler *handler; Eina_Bool is_freeze; }; @@ -324,41 +325,25 @@ CSettingMgr *CSettingMgr::instance = NULL; bool CSettingMgr::Initialize(Evas_Object *win) { ASSERT(!instance); - - instance = new CSettingMgr; - if (!instance) { - return false; - } - instance->m = new SSettingMgr; - if (!instance->m) { - delete instance; - return false; - } + ASSERT(win); struct settingmgr_data *data; - struct timeout_handler *handler; + CTimeoutHandler *handler; - if (!win) - return NULL; + _CREATE_BEGIN{ + _CHECK(instance = new CSettingMgr); + _CHECK(instance->m = new SSettingMgr); + _CHECK(data = viewmgr_data_init()); + _CHECK(handler = new CTimeoutHandler); + _CHECK(handler->Create(TIMEOUT_SECS)); - data = viewmgr_data_init(); - if (!data) { - _ERR("viewmgr_data_init failed!"); - delete instance->m; - delete instance; - instance = NULL; - return false; - } - handler = timeout_handler_init(TIMEOUT_SECS); - if (!handler) { - _ERR("Fail to init timeout handler"); - viewmgr_data_fini(data); - delete instance->m; - delete instance; - instance = NULL; - return false; - } + _CHECK_FAIL{ handler->Destroy(); } + _CHECK_FAIL{ delete handler; } + _CHECK_FAIL{ viewmgr_data_fini(data); } + _CHECK_FAIL{ delete instance->m; } + _CHECK_FAIL{ delete instance; instance = NULL; } + } _CREATE_END_AND_CATCH{ return false; } g_func_map[0].style = STYLE_UIGADGET; g_func_map[0].view = new CUiGadgetView(VCLASS_TITLE_UG); @@ -378,7 +363,7 @@ bool CSettingMgr::Initialize(Evas_Object *win) instance->m->win = win; instance->m->depth = 0; instance->m->data = data; - instance->m->handler = handler; + instance->m->handler = handler; instance->m->is_freeze = EINA_FALSE; instance->m->view_list = NULL; instance->m->item_path = NULL; @@ -415,7 +400,8 @@ void CSettingMgr::Finalize(void) eina_array_free(instance->m->item_path); viewmgr_data_fini(instance->m->data); - timeout_handler_fini(instance->m->handler); + instance->m->handler->Destroy(); + delete instance->m->handler; delete instance->m; delete instance; @@ -779,7 +765,7 @@ void CSettingMgr::FreezeTimeout(void) ASSERT(m); m->is_freeze = EINA_TRUE; - timeout_handler_freeze_timer(m->handler); + m->handler->FreezeTimer(); } /** @@ -792,7 +778,7 @@ void CSettingMgr::ThawTimeout(void) { ASSERT(m); - timeout_handler_thaw_timer(m->handler); + m->handler->ThawTimer(); m->is_freeze = EINA_FALSE; } diff --git a/src/timeout_handler.cpp b/src/timeout_handler.cpp index e516484..db39007 100644 --- a/src/timeout_handler.cpp +++ b/src/timeout_handler.cpp @@ -21,9 +21,11 @@ #include "stdbool.h" #include "timeout_handler.h" + #define EVENT_HANDLER_NUM 6 -struct timeout_handler { + +struct STimeoutHandler { Ecore_Event_Handler * event_handler[EVENT_HANDLER_NUM]; Ecore_Timer *timer; }; @@ -45,14 +47,14 @@ struct timeout_handler { */ static Eina_Bool _event_occrued_cb(void *data, int type, void *event) { - struct timeout_handler *handler; + struct STimeoutHandler *handler; if (!data) { _ERR("Invalid argument"); return EINA_FALSE; } - handler = (struct timeout_handler *) data; + handler = (struct STimeoutHandler *) data; ecore_timer_reset(handler->timer); @@ -79,114 +81,104 @@ static Eina_Bool _timer_expired_cb(void *data) /** * Freeze given ecore timer. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @return void. */ -void timeout_handler_freeze_timer(struct timeout_handler *data) +void CTimeoutHandler::FreezeTimer(void) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } - ecore_timer_freeze(data->timer); + ecore_timer_freeze(m->timer); } /** * Thaw given ecore timer. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @return void. */ -void timeout_handler_thaw_timer(struct timeout_handler *data) +void CTimeoutHandler::ThawTimer(void) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } - ecore_timer_thaw(data->timer); - ecore_timer_reset(data->timer); + ecore_timer_thaw(m->timer); + ecore_timer_reset(m->timer); } /** * Change timer interval value. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @param val [in] New interval value to be set. * @return void. */ -void timeout_handler_change_interval(struct timeout_handler *data, - double val) +void CTimeoutHandler::ChangeInterval(double val) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } if (val == 0.0) { - ecore_timer_freeze(data->timer); + ecore_timer_freeze(m->timer); } else if (val > 0.0) { - ecore_timer_interval_set(data->timer, val); - ecore_timer_reset(data->timer); - ecore_timer_thaw(data->timer); + ecore_timer_interval_set(m->timer, val); + ecore_timer_reset(m->timer); + ecore_timer_thaw(m->timer); } } /** -* Create and init timeout_handler data. +* Create and init STimeoutHandler data. * * @param val [in] Timer interval value. -* @return The timeout_handler data pointer, NULL if error. +* @return The STimeoutHandler data pointer, NULL if error. */ -struct timeout_handler *timeout_handler_init(double val) +bool CTimeoutHandler::Create(double val) { - struct timeout_handler *data; + ASSERT(!m); - data = (struct timeout_handler *) calloc(1, sizeof(*data)); - if (!data) { + m = new STimeoutHandler; + if (!m) { _ERR("Fail to allocate memory for timeout handler"); - return NULL; + return false; } - data->event_handler[0] = ecore_event_handler_add( - ECORE_EVENT_KEY_DOWN, _event_occrued_cb, data); - data->event_handler[1] = ecore_event_handler_add( - ECORE_EVENT_KEY_UP, _event_occrued_cb, data); - data->event_handler[2] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_BUTTON_DOWN, - _event_occrued_cb, data); - data->event_handler[3] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_BUTTON_UP, - _event_occrued_cb, data); - data->event_handler[4] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, data); - data->event_handler[5] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, data); - - data->timer = ecore_timer_add(val, _timer_expired_cb, NULL); - - return data; + m->event_handler[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _event_occrued_cb, m); + m->event_handler[1] = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _event_occrued_cb, m); + m->event_handler[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,_event_occrued_cb, m); + m->event_handler[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _event_occrued_cb, m); + m->event_handler[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, m); + m->event_handler[5] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, m); + + m->timer = ecore_timer_add(val, _timer_expired_cb, NULL); + + return true; } -/** -* Release given timeout_handler data. -* -* @param data [in] The timeout_handler data pointer. -* @return void. -*/ -void timeout_handler_fini(struct timeout_handler *data) + +void CTimeoutHandler::Destroy(void) { - int i; + ASSERT(m); - if (!data) { - _ERR("Invalid argument"); - return; - } + int i; for (i = 0; i < EVENT_HANDLER_NUM; i++) - ecore_event_handler_del(data->event_handler[i]); + ecore_event_handler_del(m->event_handler[i]); - ecore_timer_del(data->timer); - free(data); + ecore_timer_del(m->timer); + delete m; + m = NULL; } diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index 5c3c6be..fbe642f 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -24,7 +24,11 @@ #include "view_sublist.h" #include "settingviewmgr.h" -#define DATA_ID "SUBLISTDATA" + +enum EId { + ID_BTNS, +}; + #define MAX_ITEMS 8 #define ITEMID "itemdata" @@ -221,125 +225,6 @@ static void _scroll_event_cb(void *data, Evas_Object *obj, void *event) elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_BOTH_ARROW, ""); } -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object get focus. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemFocusIn(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemFocusIn(obj, ev); -} - - -void CSublistView::m_OnSubitemFocusIn(Evas_Object *obj, void *ev) -{ - char *val, *sel; - - if (!obj) { - _ERR("Invalid arguments\n"); - return; - } - - val = (char *) evas_object_data_get(obj, ITEMID); - if (!val) { - _ERR("Get value from btn failed\n"); - return; - } - - sel = _get_selected_value(m); - if (!sel) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(sel, val, strlen(sel))) - elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, - CTXPOPUPBTN_ICON_SOURCE); - - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(sel); -} - -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object lose focus. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemFocusOut(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemFocusOut(obj, ev); -} - - -void CSublistView::m_OnSubitemFocusOut(Evas_Object *obj, void *ev) -{ - char *val, *sel; - - if (!obj) { - _ERR("Invalid arguments\n"); - return; - } - - val = (char *) evas_object_data_get(obj, ITEMID); - if (!val) { - _ERR("Get value from btn failed\n"); - return; - } - - sel = _get_selected_value(m); - if (!sel) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(sel, val, strlen(sel))) - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, - CTXPOPUPBTN_BUTTON_SOURCE); - else - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(sel); -} - -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object be clicked. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemBtnClicked(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemBtnClicked(obj, ev); -} - - -void CSublistView::m_OnSubitemBtnClicked(Evas_Object *obj, void *ev) -{ - if (!obj) - return; - - m_SetSelectedValue(obj); - - m_ExitView(); -} /** * This function is a @Evas_Smart_Cb type callback, it will be invoked if @@ -363,29 +248,6 @@ void CSublistView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) m_ExitView(); } -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if occurred -* key press event. -* -* @param data [in] The user data. -* @param e [in] The evas handler. -* @param obj [in] The corresponding object which event occurred. -* @param ei [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemKeyPressed(e, obj, (Evas_Event_Key_Down*)ei); -} - - -void CSublistView::m_OnSubitemKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) -{ - if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) - m_ExitView(); -} /** * This function is invoked to draw ctxpopup layout. @@ -519,14 +381,12 @@ int CSublistView::m_DrawListItems(Eina_List *list) evas_object_data_set(btn, ITEMID, val); - evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, - sm_CbSubitemFocusIn, this); - evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED, - sm_CbSubitemFocusOut, this); - evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED, - sm_CbSubitemBtnClicked, this); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - sm_CbSubitemKeyPressed, this); + Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN); + + //evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, sm_CbSubitemFocusIn, this); + //evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED, sm_CbSubitemFocusOut, this); + //evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED, sm_CbSubitemBtnClicked, this); + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, sm_CbSubitemKeyPressed, this); elm_box_pack_end(m->popup_box, btn); eina_array_push(btns, btn); @@ -551,7 +411,7 @@ int CSublistView::m_DrawListItems(Eina_List *list) * @param data [in] The _sublist_data data pointer. * @return 0 if success, -1 if fail. */ -int CSublistView::m_DrawSublist(void) +bool CSublistView::m_DrawSublist(void) { struct settingview_data *view; Eina_List *list; @@ -561,7 +421,7 @@ int CSublistView::m_DrawSublist(void) if (!m->sublist_view || !m->geometry_data) { _ERR("Invalid argument\n"); - return -1; + return false; } view = m->sublist_view; @@ -570,19 +430,19 @@ int CSublistView::m_DrawSublist(void) list = _get_list_data(view, &cnt); if (!list) { _ERR("Get item list failed"); - return -1; + return false; } m->sub_items_count = cnt; if (_draw_ctxpopup_layout(m) == -1) { _ERR("Fail to draw ctxpopup layout"); - return -1; + return false; } if (m_DrawListItems(list) == -1) { _ERR("Fail to draw list items"); - return -1; + return false; } screen_h = WIN_HEIGHT; @@ -592,7 +452,7 @@ int CSublistView::m_DrawSublist(void) w = param->width; if (w <= 0) { _ERR("Fail to get clicked button width"); - return -1; + return false; } ratio = (w - SUBLIST_WIDTH - SUBLIST_OFFSET) / w; @@ -616,7 +476,7 @@ int CSublistView::m_DrawSublist(void) utils_set_focus_directions(m->sub_btn_array, m->sub_items_count); - return 0; + return true; } @@ -684,9 +544,7 @@ bool CSublistView::Create(struct settingview_data *view, void *prev) m->ctxpopup = ctxpopup; m->sublist_view = view; - evas_object_data_set(base, DATA_ID, m); - - if (m_DrawSublist() == -1) { + if (!m_DrawSublist()) { _ERR("Error in drawing items function\n"); evas_object_del(base); evas_object_del(ctxpopup); @@ -752,31 +610,96 @@ void CSublistView::Hide(void) evas_object_hide(m->ctxpopup); } -#if 0 - -static struct setting_class _vclass = { - VCLASS_TITLE_SUBLIST, - _create, - _show, - NULL, - NULL, - NULL, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; -/** -* This function is invoked to get sub list view class object. -* -* @return The setting_class data static pointer, NULL on error. -*/ -struct setting_class *view_sublist_get_vclass(void) +void CSublistView::OnMouseClicked(int id, Evas_Object *obj) +{ + if (id != ID_BTNS) + return; + + if (!obj) + return; + + m_SetSelectedValue(obj); + + m_ExitView(); +} + + +void CSublistView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + if (id != ID_BTNS) + return; + + char *val, *sel; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + val = (char *)evas_object_data_get(obj, ITEMID); + if (!val) { + _ERR("Get value from btn failed\n"); + return; + } + + sel = _get_selected_value(m); + if (!sel) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(sel, val, strlen(sel))) + elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, + CTXPOPUPBTN_ICON_SOURCE); + + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(sel); +} + + +void CSublistView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + if (id != ID_BTNS) + return; + + char *val, *sel; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + val = (char *)evas_object_data_get(obj, ITEMID); + if (!val) { + _ERR("Get value from btn failed\n"); + return; + } + + sel = _get_selected_value(m); + if (!sel) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(sel, val, strlen(sel))) + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, + CTXPOPUPBTN_BUTTON_SOURCE); + else + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(sel); +} + + +void CSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { - return &_vclass; + if (id != ID_BTNS) + return; + + if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) + m_ExitView(); } -#endif
\ No newline at end of file diff --git a/src/view_system_clock.cpp b/src/view_system_clock.cpp index cf57833..8a3f915 100644 --- a/src/view_system_clock.cpp +++ b/src/view_system_clock.cpp @@ -40,6 +40,10 @@ #define SIG_UNFOCUSED "unfocused" #define SIG_CLICKED "clicked" +enum EId { + ID_BTNS, +}; + struct SSystemClockView { Evas_Object *win; Evas_Object *base; @@ -159,195 +163,7 @@ static void _set_selected_value(SSystemClockView *data, Evas_Object *obj) } } -/** -* Evas_Smart_Cb type callback for handling foucs in event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the foucs in event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _subitem_focusin_cb(void *priv, Evas_Object *obj, void *ev) -{ - SSystemClockView *data; - char *value; - char *selval; - - if (!obj || !priv) { - _ERR("Invalid arguments\n"); - return; - } - - data = (SSystemClockView *) priv; - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("Get value from btn failed\n"); - return; - } - - selval = _get_selected_value(data); - if (!selval) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(selval, value, strlen(selval))) { - elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, - CTXPOPUPBTN_ICON_SOURCE); - } - - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(selval); -} - -/** -* Evas_Smart_Cb type callback for handling focus out event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the focus out event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _subitem_focusout_cb(void *priv, Evas_Object *obj, void *ev) -{ - SSystemClockView *data; - char *value; - char *selval; - - if (!obj || !priv) { - _ERR("Invalid arguments\n"); - return; - } - - data = (SSystemClockView *) priv; - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("Get value from btn failed\n"); - return; - } - - selval = _get_selected_value(data); - if (!selval) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(selval, value, strlen(selval))) - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, - CTXPOPUPBTN_BUTTON_SOURCE); - else - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(selval); -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -void CSystemClockView::sm_CbSubitemClicked(void *priv, Evas_Object *obj, void *ev) -{ - CSystemClockView *root = (CSystemClockView*)priv; - if (root) - root->m_OnSubitemClicked(obj, ev); -} - -void CSystemClockView::m_OnSubitemClicked(Evas_Object *obj, void *ev) -{ - struct settingitem *item; - Eina_List *list; - char *value; - const char *id; - const char *name; - - if (!obj) - return; - - _set_selected_value(m, obj); - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("get value from obj failed. DATA_ID: %s", ITEMID); - return; - } - - if (!strncmp(value, MANUAL, BUF_SIZE)) { - Hide(); - - list = viewdata_get_childitems_list(m->vdata); - if (!list) { - _ERR("list of clock is null."); - return; - } - - item = (struct settingitem *) eina_list_nth(list, CLOCK_ITEM); - if (!item) { - _ERR("there is no clock_mode item in list."); - return; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("get item id failed."); - return; - } - - name = settingitem_get_display_name(item); - if (!name) { - _ERR("get display_name failed."); - return; - } - - m->ugd.display_name = name; - - m->mgr->ViewPush(id, (void *)&m->ugd); - } else { - m_ExitView(); - } -} - -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: priv : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -void CSystemClockView::sm_CbSubitemKeypress(void *priv, Evas *e, Evas_Object *obj, void *ei) -{ - CSystemClockView *root = (CSystemClockView*)priv; - if (root) - root->m_OnSubitemKeypress(e, obj, (Evas_Event_Key_Down*)ei); -} - - -void CSystemClockView::m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) -{ - if (!ev) - return; - - if (!ev->keyname) - return; - - if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE) || !strncmp(ev->keyname, KEY_BACK_REMOTE, BUF_SIZE)) - m_ExitView(); -} /** * Create system clock sublist items. @@ -358,7 +174,7 @@ void CSystemClockView::m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event * * @return: 0 - Success, -1 - Fail. */ -int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval) +bool CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval) { Evas_Object *box, *cp, *btn, *del_btn; Eina_Array *array; @@ -371,7 +187,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval if (!list || !m->ctxpopup || !selval) { _ERR("invalid arguments."); - return -1; + return false; } cp = m->ctxpopup; @@ -379,7 +195,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval box = utils_add_box(cp); if (!box) { _ERR("utils add box to ctxpopup failed."); - return -1; + return false; } elm_object_content_set(cp, box); @@ -388,7 +204,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval if (!array) { _ERR("eina array new failed."); evas_object_del(box); - return -1; + return false; } i = idx = 0; @@ -420,15 +236,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval } evas_object_data_set(btn, ITEMID, value); - - evas_object_smart_callback_add(btn, SIG_FOCUSED, - _subitem_focusin_cb, m); - evas_object_smart_callback_add(btn, SIG_UNFOCUSED, - _subitem_focusout_cb, m); - evas_object_smart_callback_add(btn, SIG_CLICKED, - sm_CbSubitemClicked, this); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - sm_CbSubitemKeypress, this); + Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN); elm_box_pack_end(box, btn); eina_array_push(array, btn); @@ -443,7 +251,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval m->array = array; m->sel_idx = idx; - return 0; + return true; error: EINA_ARRAY_ITER_NEXT(array, j, obj, aiter) { @@ -455,7 +263,7 @@ error: evas_object_del(box); eina_array_free(array); - return -1; + return false; } /** @@ -465,19 +273,19 @@ error: * * @return: 0 - Success, -1 - Fail. */ -int CSystemClockView::m_DrawSysclkSublist(void) +bool CSystemClockView::m_DrawSysclkSublist(void) { Evas_Object *ctxpopup; char *selval; struct settingview_data *vdata; struct obj_geometry_data *ogd; Eina_List *itlist; - int xpos, ypos, height, count, r; + int xpos, ypos, height, count; double ratio; if (!m->ctxpopup || !m->ogd || !m->vdata) { _ERR("Invalid argument\n"); - return -1; + return false; } ctxpopup = m->ctxpopup; @@ -488,7 +296,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) itlist = _get_item_list(vdata, &count); if (!itlist) { _ERR("Get item list failed"); - return -1; + return false; } m->count = count; @@ -496,7 +304,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) selval = _get_selected_value(m); if (!selval) { _ERR("Get selected value failed"); - return -1; + return false; } if (count > MAX_ITEMS) { @@ -504,8 +312,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) goto error; } - r = m_AddSysclkSublistItem(itlist, selval); - if (r != 0) { + if (!m_AddSysclkSublistItem(itlist, selval)) { _ERR("add system clock sublist items failed."); goto error; } @@ -530,11 +337,11 @@ int CSystemClockView::m_DrawSysclkSublist(void) provider_release_list_value(selval); - return 0; + return true; error: provider_release_list_value(selval); - return -1; + return false; } /** @@ -566,7 +373,6 @@ void CSystemClockView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) } - Evas_Object* CSystemClockView::Base(void) { ASSERT(m); @@ -575,7 +381,6 @@ Evas_Object* CSystemClockView::Base(void) } - /** * Create all the UI components of system clock sublist view. * @@ -599,6 +404,7 @@ bool CSystemClockView::Create(struct settingview_data *view, void *prev) struct obj_geometry_data *ogd; CSettingMgr *mgr = CSettingMgr::GetInstance(); + ugd = (struct evas_obj_data *) prev; ogd = (struct obj_geometry_data *) evas_object_data_get(ugd->cur_btn, DATA_ID); @@ -643,7 +449,7 @@ bool CSystemClockView::Create(struct settingview_data *view, void *prev) evas_object_data_set(base, DATA_ID, m); - if (m_DrawSysclkSublist() == -1) { + if (!m_DrawSysclkSublist()) { _ERR("Error in drawing items function\n"); evas_object_del(base); evas_object_del(ctxpopup); @@ -726,37 +532,141 @@ void CSystemClockView::Refresh(void) } -#if 0 +void CSystemClockView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + char *value; + char *selval; -/** -* view class of system clock view. -*/ -static struct setting_class _vclass = { - VCLASS_TITLE_SYSTEM_CLOCK, - _create, - _show, - NULL, - NULL, - _refresh, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } -/** -* Return view class of system clock view. -* -* @param: void. -* -* @return: the view class of system clock view. -*/ -struct setting_class *view_system_clock_get_vclass(void) + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("Get value from btn failed\n"); + return; + } + + selval = _get_selected_value(m); + if (!selval) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(selval, value, strlen(selval))) { + elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, + CTXPOPUPBTN_ICON_SOURCE); + } + + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(selval); +} + + +void CSystemClockView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) { - return &_vclass; + char *value; + char *selval; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("Get value from btn failed\n"); + return; + } + + selval = _get_selected_value(m); + if (!selval) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(selval, value, strlen(selval))) + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, + CTXPOPUPBTN_BUTTON_SOURCE); + else + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(selval); +} + + +void CSystemClockView::OnMouseClicked(int oid, Evas_Object *obj) +{ + if (oid != ID_BTNS) + return; + + struct settingitem *item; + Eina_List *list; + char *value; + const char *id; + const char *name; + + if (!obj) + return; + + _set_selected_value(m, obj); + + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("get value from obj failed. DATA_ID: %s", ITEMID); + return; + } + + if (!strncmp(value, MANUAL, BUF_SIZE)) { + Hide(); + + list = viewdata_get_childitems_list(m->vdata); + if (!list) { + _ERR("list of clock is null."); + return; + } + + item = (struct settingitem *) eina_list_nth(list, CLOCK_ITEM); + if (!item) { + _ERR("there is no clock_mode item in list."); + return; + } + + id = settingitem_get_id(item); + if (!id) { + _ERR("get item id failed."); + return; + } + + name = settingitem_get_display_name(item); + if (!name) { + _ERR("get display_name failed."); + return; + } + + m->ugd.display_name = name; + + m->mgr->ViewPush(id, (void *)&m->ugd); + } + else { + m_ExitView(); + } +} + + +void CSystemClockView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (id != ID_BTNS) + return; + + if (!ev->keyname) + return; + + if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE) || !strncmp(ev->keyname, KEY_BACK_REMOTE, BUF_SIZE)) + m_ExitView(); } -#endif
\ No newline at end of file diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp index a3aacde..2f699ff 100755..100644 --- a/src/view_uigadget.cpp +++ b/src/view_uigadget.cpp @@ -20,7 +20,93 @@ #include "def.h" #include "settingviewmgr.h" -#define DATA_ID "ugdata" + +/** + * This callback function is invoked with base layout for layout arrangement + * after UI Gadget create create operation is completed. + * + * @param ug [in] The handler data representing a UI gadget. + * @param mode [in] The UI gadget mode. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnLayout(ug, mode); +} + + +/** + * After UG module invoke ug_send_message to send result, + * UG library call this callback function registered by calling ug_create. + * + * @param ug [in] The handler data representing a UI gadget. + * @param result [in] The Service handler. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbResult(ui_gadget_h ug, service_h result, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnResult(ug, result); +} + + + +/** + * Send the destroy request, use ug_destroy_me, + * then UG library calls this callback function registered by UG caller. + * + * @param ug [in] The handler data representing a UI gadget. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbDestroy(ui_gadget_h ug, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnDestroy(ug); +} + + +void CUiGadget::sm_CbEnd(ui_gadget_h ug, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnEnd(ug); +} + + +bool CUiGadget::Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service) +{ + ASSERT(!m_handler); + + struct ug_cbs cbs = { + sm_CbLayout, + sm_CbResult, + sm_CbDestroy, + sm_CbEnd + }; + cbs.priv = this; + + m_handler = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs); + + return m_handler ? true : false; +} + + +void CUiGadget::Destroy(void) +{ + if (!m_handler) + return; + + ug_destroy(m_handler); + m_handler = NULL; +} + struct SUiGadgetView { Evas_Object *win; @@ -30,8 +116,6 @@ struct SUiGadgetView { Evas_Object *subitem_box; const char *display_name; - ui_gadget_h ug_handler; - Eina_Bool ug_is_existed; CSettingMgr *mgr; struct settingview_data *view; }; @@ -62,31 +146,6 @@ void CUiGadgetView::m_BackToMainview(void) m->mgr->ViewPop(); } -/** -* This callback function is invoked with base layout for layout arrangement -* after UI Gadget create create operation is completed. -* -* @param ug [in] The handler data representing a UI gadget. -* @param mode [in] The UI gadget mode. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgLayout(ui_gadget_h ug, enum ug_mode mode, void *priv) -{ -} - -/** -* After UG module invoke ug_send_message to send result, -* UG library call this callback function registered by calling ug_create. -* -* @param ug [in] The handler data representing a UI gadget. -* @param result [in] The Service handler. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgResult(ui_gadget_h ug, service_h result, void *priv) -{ -} /** * This function is invoked to show sub item buttons evas object. @@ -118,23 +177,8 @@ static void _show_item_btns(Evas_Object *box) eina_list_free(list); } -/** -* Send the destroy request, use ug_destroy_me, -* then UG library calls this callback function registered by UG caller. -* -* @param ug [in] The handler data representing a UI gadget. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgDestroy(ui_gadget_h ug, void *priv) -{ - CUiGadgetView *root = (CUiGadgetView*)priv; - if (root) - root->m_OnUgDestroy(ug); -} - -void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) +void CUiGadgetView::t_OnDestroy(ui_gadget_h ug) { if (!ug) { _ERR("Invalid parameters in ug destroy callback."); @@ -146,8 +190,8 @@ void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) elm_object_focus_set(m->subbtn, EINA_TRUE); elm_object_part_text_set(m->base, UG_TITLE_TEXT, ""); - ug_destroy(ug); - m->ug_is_existed = EINA_FALSE; + CUiGadget::Destroy(); + m_BackToMainview(); } @@ -159,37 +203,23 @@ void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) */ bool CUiGadgetView::m_Load(void) { - ui_gadget_h ug; const char *name; struct settingitem *parent; - struct ug_cbs cbs = { - sm_CbUgLayout, - sm_CbUgResult, - sm_CbUgDestroy, - NULL - }; - - cbs.priv = this; - parent = viewdata_get_parentitem(m->view); name = settingitem_get_settingui_name(parent); - elm_object_part_text_set(m->base, - UG_TITLE_TEXT, m->display_name); + elm_object_part_text_set(m->base, UG_TITLE_TEXT, m->display_name); - ug = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs); - if (!ug) { - _ERR("ug create failed."); + if (!CUiGadget::Create(NULL, name, UG_MODE_FRAMEVIEW, NULL)) { return false; - } else { - m->ug_is_existed = EINA_TRUE; - m->ug_handler = ug; - m->mgr->FreezeTimeout(); } + m->mgr->FreezeTimeout(); + return true; } + /** * This function is invoked to hide sub item buttons evas object. * @@ -223,7 +253,6 @@ static void _hide_item_btns(Evas_Object *box) } - Evas_Object *CUiGadgetView::Base(void) { ASSERT(m); @@ -232,7 +261,6 @@ Evas_Object *CUiGadgetView::Base(void) } - /** * This function is invoked to create UG launcher view layout. * @@ -253,14 +281,10 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) CSettingMgr *mgr = CSettingMgr::GetInstance(); param = (struct evas_obj_data *) prev; - _hide_item_btns(param->subitem_box); win = mgr->Window(); - if (!win) { - _ERR("Invalid argument"); - return NULL; - } + ASSERT(win); m = new SUiGadgetView; if (!m) { @@ -278,16 +302,13 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) elm_layout_file_set(base, EDJ_FILE, UG_GROUP); - m->win = win; + m->win = win; m->base = base; - m->mgr = mgr; + m->mgr = mgr; m->view = view; - m->subitem_box = param->subitem_box; + m->subitem_box = param->subitem_box; m->display_name = param->display_name; - m->subbtn = param->cur_btn; - m->ug_is_existed = EINA_FALSE; - - evas_object_data_set(base, DATA_ID, m); + m->subbtn = param->cur_btn; if (!m_Load()) { _ERR("load ui gadget failed."); @@ -301,12 +322,7 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) return true; } -/** -* This function is invoked to show view layout. -* -* @param base [in] The view layout evas object. -* @return void. -*/ + void CUiGadgetView::Show(void) { ASSERT(m); @@ -314,18 +330,12 @@ void CUiGadgetView::Show(void) evas_object_show(m->base); } -/** -* This function is invoked to destroy view layout. -* -* @param base [in] The view layout evas object. -* @return void. -*/ + void CUiGadgetView::Destroy(void) { ASSERT(m); - if (m->ug_is_existed == EINA_TRUE) - ug_destroy(m->ug_handler); + CUiGadget::Destroy(); if (m->view) viewdata_release(m->view); @@ -334,32 +344,3 @@ void CUiGadgetView::Destroy(void) delete m; m = NULL; } - -#if 0 - -static struct setting_class _vclass = { - VCLASS_TITLE_UG, - _create, - _show, - NULL, - NULL, - NULL, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; - -/** -* This function is invoked to get UI Gadget launcher view class object. -* -* @return The setting_class data static pointer, NULL on error. -*/ -struct setting_class *view_uigadget_get_vclass(void) -{ - return &_vclass; -} -#endif |