[Release] wrt_0.8.213
[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
32 /*
33  * Current layout structure
34  *
35  * m_win (elm_win)
36  *      m_platform_layout (elm_layout)
37  *          m_navigation (elm_navigation)
38  *              m_user_layout (elm_layout)
39  *                  widget_area (elm_webview)
40  *
41  */
42
43 class WindowData : private DPL::Noncopyable
44 {
45   private:
46     typedef void (*CallbackType)(
47         void* data, Evas_Object* obj, void* event_info);
48     typedef void (*EvasCallbackType)(
49         void* data, Evas* evas, Evas_Object* obj, void* event_info);
50     typedef void (*NaviframePopCallbackType)(
51         void* data, Elm_Object_Item* it);
52
53     struct EventWithFunction
54     {
55         CallbackType function;
56         std::string eventName;
57         EventWithFunction(CallbackType a_function,
58                           const char * a_eventName) :
59             function(a_function),
60             eventName(a_eventName)
61         {}
62     };
63     typedef std::vector<EventWithFunction> EventWithFunctionVector;
64
65   public:
66     Evas_Object* m_win;
67     Evas_Object* m_user_layout;
68
69     explicit WindowData(unsigned long pid, bool manualInit = false);
70     virtual ~WindowData();
71
72     void init();
73     void setEvasObjectForLayout(Evas_Object* evas_object);
74     void unsetEvasObjectForLayout();
75     void addNaviframeItemPopCallback(
76         NaviframePopCallbackType callback,
77         void* data);
78     void addFloatBackButtonCallback(
79         const char* event,
80         CallbackType callback,
81         const void* data);
82     void* delFloatBackButtonCallback(
83         const char* event,
84         CallbackType callBack);
85     void userlayoutCallbackAdd(
86         const Evas_Callback_Type event,
87         EvasCallbackType callback,
88         const void* data);
89     void* userlayoutCallbackDel(
90         const Evas_Callback_Type event,
91         EvasCallbackType callback);
92     void emitSignalForUserLayout(
93         const char* emission,
94         const char* source);
95
96     void setViewMode(
97         bool fullscreen,
98         bool backbutton);
99
100     void toggleFullscreen(bool fullscreen);
101     void toggleToolbar(bool enable);
102     bool isFullscreen();
103     static void winProfileChangedCallback(void *data,
104                                           Evas_Object * obj,
105                                           void *event_info);
106     void updateProgress(double value);
107
108   protected:
109     Evas_Object* m_conformant;
110     Evas_Object* m_platform_layout;
111     Evas_Object* m_navigation;
112     Evas_Object* m_naviframeBackButton;
113     Evas_Object* m_floatBackButton;
114     Evas_Object* m_progressbar;
115     bool m_fullscreen;
116     bool m_initialized;
117
118     Evas_Object* createWindow(unsigned long pid);
119     Evas_Object* createConformant(Evas_Object* parent);
120     Evas_Object* createPlatformLayout(Evas_Object* parent);
121     Evas_Object* createNavigationBar(Evas_Object* parent);
122     Evas_Object* createNaviframeBackbutton(Evas_Object* parent);
123     Evas_Object* createUserLayout(Evas_Object* parent);
124     Evas_Object* createProgressBar(Evas_Object* window, Evas_Object* parent);
125
126     void alignProgressPosition();
127     void toggleIndicator(bool fullscreen);
128     void createFloatBackButton();
129     void setDesktopIcon();
130 };
131
132 #endif /* WINDOW_INITIALIZE_H_ */