64c827b67c80f5119a90d65dda4c4debb3e2d733
[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
51     struct EventWithFunction
52     {
53         CallbackType function;
54         std::string eventName;
55         EventWithFunction(CallbackType a_function,
56                           const char * a_eventName) :
57             function(a_function),
58             eventName(a_eventName)
59         {
60         }
61     };
62     typedef std::vector<EventWithFunction> EventWithFunctionVector;
63
64   public:
65     Evas_Object* m_win;
66     Evas_Object* m_user_layout;
67
68     explicit WindowData(unsigned long pid, bool manualInit=false);
69     virtual ~WindowData();
70
71     void init();
72     void setEvasObjectForLayout(Evas_Object* evas_object);
73     void unsetEvasObjectForLayout();
74     void addNaviBackButtonCallback(
75             const char* event,
76             CallbackType callback,
77             const void* data);
78     void* delNaviBackButtonCallback(
79             const char* event,
80             CallbackType callBack);
81     void addFloatBackButtonCallback(
82             const char* event,
83             CallbackType callback,
84             const void* data);
85     void* delFloatBackButtonCallback(
86             const char* event,
87             CallbackType callBack);
88     void userlayoutCallbackAdd(
89             const Evas_Callback_Type event,
90             EvasCallbackType callback,
91             const void* data);
92     void* userlayoutCallbackDel(
93             const Evas_Callback_Type event,
94             EvasCallbackType callback);
95     void emitSignalForUserLayout(
96             const char* emission,
97             const char* source);
98
99     void setViewMode(
100             bool fullscreen,
101             bool backbutton);
102
103     void toggleFullscreen(bool fullscreen);
104
105   protected:
106     Evas_Object* m_conformant;
107     Evas_Object* m_platform_layout;
108     Evas_Object* m_navigation;
109     Evas_Object* m_naviBackButton;
110     Evas_Object* m_floatBackButton;
111     bool m_fullscreen;
112
113     Evas_Object* createWindow(unsigned long pid);
114     Evas_Object* createPlatformLayout(Evas_Object* parent);
115     Evas_Object* createNavigationBar(Evas_Object* parent);
116     Evas_Object* createUserLayout(Evas_Object* parent);
117     Evas_Object* createConformant(Evas_Object* parent);
118
119     void alignProgressPosition();
120     void toggleIndicator(bool fullscreen);
121     void createFloatBackButton();
122 };
123
124 #endif /* WINDOW_INITIALIZE_H_ */