4b495703938b390cf01d2901611fb44166997fa5
[platform/framework/web/wrt.git] / src / wrt-client / window_data.h
1 /*
2  * Copyright (c) 2011 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  * @file        window_data.h
18  * @author      Jaroslaw Osmanski (j.osmanski@samsung.com)
19  * @version     1.0
20  * @brief       Window data header file.
21  */
22
23 #ifndef WINDOW_INITIALIZE_H_
24 #define WINDOW_INITIALIZE_H_
25
26 #include <dpl/framework_efl.h>
27
28 #include <vector>
29 #include <string>
30 #include <dpl/noncopyable.h>
31 #include <list>
32
33 /*
34  * Current layout structure
35  *
36  * m_win (elm_win)
37  *      m_platform_layout (elm_layout)
38  *          m_navigation (elm_navigation)
39  *              m_user_layout (elm_layout)
40  *                  widget_area (elm_webview)
41  *
42  */
43 namespace {
44 const char *const WRT_OPTION_LABEL_BACKWARD = "Backward";
45 const char *const WRT_OPTION_LABEL_FORWARD = "Forward";
46 const char *const WRT_OPTION_LABEL_RELOAD = "Reload";
47 const char *const WRT_OPTION_LABEL_FULLVIEW = "Full view";
48
49 const char *const WRT_OPTION_ICON_BACKWARD = "/usr/etc/wrt/icon_left_arrow.png";
50 const char *const WRT_OPTION_ICON_FORWARD = "/usr/etc/wrt/icon_right_arrow.png";
51 const char *const WRT_OPTION_ICON_RELOAD  = "/usr/etc/wrt/icon_refresh.png";
52 const char *const WRT_OPTION_ICON_WINDOWVIEW = "/usr/etc/wrt/mp_stop.png";
53 }
54
55 class WindowData : private DPL::Noncopyable
56 {
57   private:
58     typedef void (*CallbackType)(
59             void* data, Evas_Object* obj, void* event_info);
60     typedef void (*EvasCallbackType)(
61             void* data, Evas* evas, Evas_Object* obj, void* event_info);
62
63     struct EventWithFunction
64     {
65         CallbackType function;
66         std::string eventName;
67         EventWithFunction(CallbackType a_function,
68                           const char * a_eventName) :
69             function(a_function),
70             eventName(a_eventName)
71         {
72         }
73     };
74     typedef std::vector<EventWithFunction> EventWithFunctionVector;
75
76   public:
77     Evas_Object* m_win;
78     Evas_Object* m_user_layout;
79
80     bool m_debugMode;
81
82     struct CtxMenuItem
83     {
84         std::string label;
85         std::string icon;
86         Evas_Smart_Cb callback;
87         void* data;
88     };
89     typedef std::list<CtxMenuItem> CtxMenuItems;
90
91     explicit WindowData(unsigned long pid, bool manualInit=false);
92     virtual ~WindowData();
93
94     void init();
95     void setEvasObjectForLayout(Evas_Object* evas_object);
96     void unsetEvasObjectForLayout();
97     void addNaviBackButtonCallback(
98             const char* event,
99             CallbackType callback,
100             const void* data);
101     void* delNaviBackButtonCallback(
102             const char* event,
103             CallbackType callBack);
104     void userlayoutCallbackAdd(
105             const Evas_Callback_Type event,
106             EvasCallbackType callback,
107             const void* data);
108     void* userlayoutCallbackDel(
109             const Evas_Callback_Type event,
110             EvasCallbackType callback);
111     void emitSignalForUserLayout(
112             const char* emission,
113             const char* source);
114
115     void changeViewMode();
116     void createTitleToolbar(CtxMenuItems ctxMenuItems);
117     void createToolbar(CtxMenuItems ctxMenuItems);
118     void showToolbar();
119     void hideToolbar();
120     void createOptionButton();
121     void destroyOptionButton();
122     void setViewMode(
123             const char *title,
124             bool fullscreen,
125             bool indicator,
126             CtxMenuItems ctxMenuItems);
127     void initFullViewMode();
128
129     static void moreButtonCallback(void *data,
130             Evas_Object *obj,
131             void *event_info);
132     static void changeViewModeCallback(void *data,
133             Evas_Object *obj,
134             void *event_info);
135     static void controlHiddenOptionCallback(void *data,
136             Evas_Object *obj,
137             const char *emission,
138             const char *source);
139     static Eina_Bool hideToolbarCallback(void *data);
140     void toggleFullscreen(bool fullscreen);
141
142   protected:
143     Evas_Object* m_conformant;
144     Evas_Object* m_platform_layout;
145     Evas_Object* m_navigation;
146     Evas_Object* m_naviBackButton;
147     bool optionheaderClose;
148     std::string m_title;
149     CtxMenuItems m_ctxMenuItems;
150     Ecore_Timer *m_toolbarTimer;
151     bool m_indicator;
152     bool m_fullscreen;
153
154     Evas_Object* createWindow(unsigned long pid);
155     Evas_Object* createPlatformLayout(Evas_Object* parent);
156     Evas_Object* createNavigationBar(Evas_Object* parent);
157     Evas_Object* createUserLayout(Evas_Object* parent);
158     Evas_Object* createConformant(Evas_Object* parent);
159     Evas_Object* createProgress(Evas_Object* parent);
160     void showHiddenOption(Evas_Object* parent);
161     void hideHiddenOption(Evas_Object* parent);
162
163     void alignProgressPosition();
164     void createTitle(const char* data, CtxMenuItems ctxMenuItems);
165     void showTitle(const char* data);
166     void hideTitle();
167     void createMoreButton();
168     void createTitleButton();
169     void updateTitleButton(const bool display);
170     void toggleIndicator(bool indicator);
171 };
172
173 #endif /* WINDOW_INITIALIZE_H_ */