Title & Indicator policy has been changed.
[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
48 const char *const WRT_OPTION_ICON_BACKWARD = "/usr/etc/wrt/icon_left_arrow.png";
49 const char *const WRT_OPTION_ICON_FORWARD = "/usr/etc/wrt/icon_right_arrow.png";
50 const char *const WRT_OPTION_ICON_RELOAD  = "/usr/etc/wrt/icon_refresh.png";
51 }
52
53 class WindowData : private DPL::Noncopyable
54 {
55   private:
56     typedef void (*CallbackType)(
57             void* data, Evas_Object* obj, void* event_info);
58     typedef void (*EvasCallbackType)(
59             void* data, Evas* evas, Evas_Object* obj, void* event_info);
60
61     struct EventWithFunction
62     {
63         CallbackType function;
64         std::string eventName;
65         EventWithFunction(CallbackType a_function,
66                           const char * a_eventName) :
67             function(a_function),
68             eventName(a_eventName)
69         {
70         }
71     };
72     typedef std::vector<EventWithFunction> EventWithFunctionVector;
73
74   public:
75     Evas_Object* m_win;
76     Evas_Object* m_user_layout;
77
78     bool m_debugMode;
79
80     struct CtxMenuItem
81     {
82         std::string label;
83         std::string icon;
84         Evas_Smart_Cb callback;
85         void* data;
86     };
87     typedef std::list<CtxMenuItem> CtxMenuItems;
88
89     explicit WindowData(unsigned long pid, bool manualInit=false);
90     virtual ~WindowData();
91
92     void init();
93     void setEvasObjectForLayout(Evas_Object* evas_object);
94     void unsetEvasObjectForLayout();
95     void addNaviBackButtonCallback(
96             const char* event,
97             CallbackType callback,
98             const void* data);
99     void* delNaviBackButtonCallback(
100             const char* event,
101             CallbackType callBack);
102     void userlayoutCallbackAdd(
103             const Evas_Callback_Type event,
104             EvasCallbackType callback,
105             const void* data);
106     void* userlayoutCallbackDel(
107             const Evas_Callback_Type event,
108             EvasCallbackType callback);
109     void emitSignalForUserLayout(
110             const char* emission,
111             const char* source);
112
113     void changeViewMode();
114     void createToolbar(CtxMenuItems ctxMenuItems);
115     void showToolbar();
116     void hideToolbar();
117     void createOptionButton();
118     void destroyOptionButton();
119     void setViewMode(
120             bool fullscreen,
121             CtxMenuItems ctxMenuItems);
122     void initFullViewMode();
123
124     static void moreButtonCallback(void *data,
125             Evas_Object *obj,
126             void *event_info);
127     static void changeViewModeCallback(void *data,
128             Evas_Object *obj,
129             void *event_info);
130     static void controlHiddenOptionCallback(void *data,
131             Evas_Object *obj,
132             const char *emission,
133             const char *source);
134     static Eina_Bool hideToolbarCallback(void *data);
135     void toggleFullscreen(bool fullscreen);
136
137   protected:
138     Evas_Object* m_conformant;
139     Evas_Object* m_platform_layout;
140     Evas_Object* m_navigation;
141     Evas_Object* m_naviBackButton;
142     bool optionheaderClose;
143     std::string m_title;
144     CtxMenuItems m_ctxMenuItems;
145     Ecore_Timer *m_toolbarTimer;
146     bool m_indicator;
147     bool m_fullscreen;
148
149     Evas_Object* createWindow(unsigned long pid);
150     Evas_Object* createPlatformLayout(Evas_Object* parent);
151     Evas_Object* createNavigationBar(Evas_Object* parent);
152     Evas_Object* createUserLayout(Evas_Object* parent);
153     Evas_Object* createConformant(Evas_Object* parent);
154     Evas_Object* createProgress(Evas_Object* parent);
155     void showHiddenOption(Evas_Object* parent);
156     void hideHiddenOption(Evas_Object* parent);
157
158     void alignProgressPosition();
159     void toggleIndicator(bool fullscreen);
160 };
161
162 #endif /* WINDOW_INITIALIZE_H_ */