Implemented progressbar for web application
[platform/framework/web/crosswalk-tizen.git] / runtime / browser / native_window.h
1 /*
2  * Copyright (c) 2015 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 #ifndef XWALK_RUNTIME_BROWSER_NATIVE_WINDOW_H_
18 #define XWALK_RUNTIME_BROWSER_NATIVE_WINDOW_H_
19
20 #include <Elementary.h>
21
22 #include <functional>
23 #include <map>
24
25 namespace runtime {
26
27 class NativeWindow {
28  public:
29   enum class ScreenOrientation {
30     PORTRAIT_PRIMARY = 0,
31     PORTRAIT_SECONDARY = 1,
32     LANDSCAPE_PRIMARY = 2,
33     LANDSCAPE_SECONDARY = 3,
34     NATURAL = 4,
35     ANY = 5
36   };
37   enum class Type {
38     NORMAL = 0,
39     NOTIFICATION = 1
40   };
41   typedef std::function<void(int)> RotationHandler;
42   NativeWindow();
43   virtual ~NativeWindow();
44
45   void Initialize();
46
47   bool initialized() const { return initialized_; }
48   Evas_Object* evas_object() const;
49   void SetContent(Evas_Object* content);
50   void SetRotationLock(int degree);
51   void SetRotationLock(ScreenOrientation orientation);
52   void SetAutoRotation();
53   void SetCurrentViewModeFullScreen(bool mode);
54   int AddRotationHandler(RotationHandler handler);
55   void RemoveRotationHandler(int id);
56   int rotation() const { return rotation_; }
57   ScreenOrientation orientation() const;
58   void Show();
59   void Active();
60   void InActive();
61   void FullScreen(bool enable);
62   ScreenOrientation natural_orientation() const { return natural_orientation_;}
63   Type type() const { return window_type_;}
64 #ifdef MANUAL_ROTATE_FEATURE_SUPPORT
65   void EnableManualRotation(bool enable);
66   void ManualRotationDone();
67 #endif  // MANUAL_ROTATE_FEATURE_SUPPORT
68 #ifdef PROFILE_MOBILE
69   void SignalEmit(const char* emission, const char* source);
70   void UpdateProgress(double value);
71 #endif
72
73  protected:
74   virtual Evas_Object* CreateWindowInternal() = 0;
75   Evas_Object* window_;
76   Type window_type_;
77
78  private:
79   static void DidDeleteRequested(void* data, Evas_Object* obj,
80                                  void* event_info);
81   static void DidProfileChanged(void* data, Evas_Object* obj, void* event_info);
82   void DidRotation(int degree);
83   void DidFocusChanged(bool got);
84
85   bool initialized_;
86   bool currentViewModeFullScreen_;
87   Evas_Object* focus_;
88   Evas_Object* content_;
89 #ifdef PROFILE_MOBILE
90   Evas_Object* progressbar_;
91   Evas_Object* top_layout_;
92 #endif
93   int rotation_;
94   int handler_id_;
95   ScreenOrientation natural_orientation_;
96   std::map<int, RotationHandler> handler_table_;
97 };
98
99 }  // namespace runtime
100
101
102 #endif  // XWALK_RUNTIME_BROWSER_NATIVE_WINDOW_H_