2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
23 public enum DisplayRotation
31 public enum StatusBarMode
34 /// Opacifies the status bar
39 /// Be translucent the status bar
47 /// Transparentizes the status bar
52 public class Window : Widget
54 SmartEvent _deleteRequest;
55 SmartEvent _rotationChanged;
56 HashSet<EvasObject> _referenceHolder = new HashSet<EvasObject>();
58 public Window(string name) : this(null, name)
62 public Window(Window parent, string name)
66 Interop.Elementary.elm_win_indicator_mode_set(Handle, 2 /* ELM_WIN_INDICATOR_SHOW */);
68 _deleteRequest = new SmartEvent(this, "delete,request");
69 _rotationChanged = new SmartEvent(this, "wm,rotation,changed");
70 _deleteRequest.On += (s, e) => CloseRequested?.Invoke(this, EventArgs.Empty);
71 _rotationChanged.On += (s, e) => RotationChanged?.Invoke(this, EventArgs.Empty);
78 public event EventHandler CloseRequested;
79 public event EventHandler RotationChanged;
81 public string Name { get; set; }
83 public Size ScreenSize
88 Interop.Elementary.elm_win_screen_size_get(Handle, out x, out y, out w, out h);
89 return new Size(w, h);
93 public Point ScreenDpi
97 Point point = default(Point);
98 Interop.Elementary.elm_win_screen_dpi_get(Handle, out point.X, out point.Y);
107 return Interop.Elementary.elm_win_rotation_get(Handle);
111 public bool IsRotationSupported
115 return Interop.Elementary.elm_win_wm_rotation_supported_get(Handle);
119 [Obsolete("Sorry, it's error typo of AvailableRotations, please use AvailableRotations")]
120 public DisplayRotation AavailableRotations { get; set; }
122 public DisplayRotation AvailableRotations
127 Interop.Elementary.elm_win_wm_rotation_available_rotations_get(Handle, out rotations);
128 if (rotations == null)
132 return ConvertToDisplayRotation(rotations);
136 Interop.Elementary.elm_win_wm_rotation_available_rotations_set(Handle, ConvertDegreeArray(value));
140 public bool AutoDeletion
144 return Interop.Elementary.elm_win_autodel_get(Handle);
148 Interop.Elementary.elm_win_autodel_set(Handle, value);
152 public StatusBarMode StatusBarMode
156 return (StatusBarMode)Interop.Elementary.elm_win_indicator_opacity_get(Handle);
160 Interop.Elementary.elm_win_indicator_opacity_set(Handle, (int)value);
166 Interop.Elementary.elm_win_activate(Handle);
169 public void AddResizeObject(EvasObject obj)
171 Interop.Elementary.elm_win_resize_object_add(Handle, obj);
174 protected override IntPtr CreateHandle(EvasObject parent)
176 Interop.Elementary.elm_config_accel_preference_set("3d");
177 return Interop.Elementary.elm_win_add(parent != null ? parent.Handle : IntPtr.Zero, Name, 0);
180 internal void AddChild(EvasObject obj)
182 _referenceHolder.Add(obj);
185 internal void RemoveChild(EvasObject obj)
187 _referenceHolder.Remove(obj);
190 static int[] ConvertDegreeArray(DisplayRotation value)
192 List<int> rotations = new List<int>();
193 if (value.HasFlag(DisplayRotation.Degree_0))
195 if (value.HasFlag(DisplayRotation.Degree_90))
197 if (value.HasFlag(DisplayRotation.Degree_180))
199 if (value.HasFlag(DisplayRotation.Degree_270))
201 return rotations.ToArray();
204 static DisplayRotation ConvertToDisplayRotation(int[] values)
207 foreach (int v in values)
209 orientation |= (1 << (v / 90));
211 return (DisplayRotation)orientation;