Task TT-75 Implement "Main page loading UI" view
[profile/tv/apps/web/browser.git] / services / SimpleUI / BookmarksManager.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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 #ifndef BOOKSMARK_MANAGER_H
18 #define BOOKSMARK_MANAGER_H
19 #include <Evas.h>
20 #include <Elementary.h>
21 #include <string>
22 #include <list>
23 #include <map>
24 #include <memory>
25 #include <ostream>
26 #include <deque>
27
28 #include "Action.h"
29 #include "MenuButton.h"
30
31 namespace tizen_browser
32 {
33 namespace base_ui
34 {
35
36 struct BookmarksManagerItem{
37     std::shared_ptr<Action> action;
38     BookmarksManagerItem();
39     BookmarksManagerItem(std::shared_ptr<Action> action);
40     BookmarksManagerItem(const BookmarksManagerItem& source);
41     BookmarksManagerItem(const BookmarksManagerItem* source);
42     ~BookmarksManagerItem();
43 };
44
45
46 class BookmarksManager: public MenuButton
47 {
48 public:
49     BookmarksManager(std::shared_ptr< Evas_Object > mainWindow, Evas_Object* parentButton);
50     ~BookmarksManager();
51     virtual Evas_Object *getContent();
52     virtual ListSize calculateSize();
53     virtual Evas_Object* getFirstFocus();
54     void addAction(sharedAction action);
55     void onEnabledChanged(sharedAction action);
56     void refreshAction(sharedAction action);
57     void setPointerModeEnabled (bool enabled);
58     void showPopup();
59     void hidePopup();
60     bool isPopupShown();
61     virtual bool canBeDismissed();
62 private:
63     static char        *gridTextGet(void *data, Evas_Object* obj, const char *part);
64     static Evas_Object *gridOptionLabelGet(void* data, Evas_Object* /*obj*/, const char* part);
65     static void itemClicked(void *data, Evas_Object *o, void *event_info);
66     static void block_clicked(void *data, Evas_Object *obj, void *event_info);
67
68     void showInternalPopup(Elm_Object_Item* parent);
69     static void dismissedCtxPopup(void* data, Evas_Object* obj, void* event_info);
70     static void radioChanged(void *data, Evas_Object *obj, void *event_info);
71
72 private:
73     Evas_Object *m_popup;
74     Evas_Object *m_genlist;
75     Evas_Object *m_internalPopup;
76     Elm_Object_Item *m_trackedItem;
77     Elm_Genlist_Item_Class *m_itemClass;
78     bool m_internalPopupVisible;
79     bool m_pointerModeEnabled;
80     std::map<Elm_Object_Item*, std::shared_ptr<BookmarksManagerItem>> m_bookmarks_managerItemsMap;
81     std::map<sharedAction, Elm_Object_Item*> m_actionButtonMap;
82     enum CheckState{
83         CheckStateOn=1
84        ,CheckStateOff=2
85     };
86     CheckState m_checkState;
87     void realShow(Evas_Object* popup);
88     void unbindFocus();
89     bool m_isPopupShown;
90
91     static void focusItem(void* data, Evas_Object* obj, void* event_info);
92     static void unFocusItem(void* data, Evas_Object* obj, void* event_info);
93 };
94
95 }//namespace base_ui
96
97 }//namespace tizen_browser
98
99 #endif // BOOKSMARK_MANAGER_H