[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Window.cs
1 /*
2  * Copyright (c) 2018 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 using System;
18 using System.Collections.Generic;
19 using System.ComponentModel;
20
21 namespace ElmSharp
22 {
23     /// <summary>
24     /// Enumeration for the display rotation of window.
25     /// </summary>
26     /// <since_tizen> preview </since_tizen>
27     [Flags]
28     public enum DisplayRotation
29     {
30         /// <summary>
31         /// Rotation value of the window is 0 degree.
32         /// </summary>
33         Degree_0 = 1,
34
35         /// <summary>
36         /// Rotation value of the window is 90 degrees.
37         /// </summary>
38         Degree_90 = 2,
39
40         /// <summary>
41         /// Rotation value of the window is 180 degrees.
42         /// </summary>
43         Degree_180 = 4,
44
45         /// <summary>
46         /// Rotation value of the window is 270 degrees.
47         /// </summary>
48         Degree_270 = 8
49     };
50
51     /// <summary>
52     /// Enumeration for the indicator opacity.
53     /// </summary>
54     /// <since_tizen> preview </since_tizen>
55     public enum StatusBarMode
56     {
57         /// <summary>
58         /// Opacifies the status bar.
59         /// </summary>
60         Opaque = 1,
61
62         /// <summary>
63         /// Be translucent the status bar.
64         /// </summary>
65         /// <remarks>
66         /// Not supported.
67         /// </remarks>
68         Translucent = 2,
69
70         /// <summary>
71         /// Transparentizes the status bar.
72         /// </summary>
73         Transparent = 3,
74     }
75
76     /// <summary>
77     /// Enumeration for the keygrab modes of the window.
78     /// </summary>
79     /// <since_tizen> preview </since_tizen>
80     [EditorBrowsable(EditorBrowsableState.Never)]
81     public enum KeyGrabMode
82     {
83         /// <summary>
84         /// Unknown keygrab mode.
85         /// </summary>
86         Shared = 256,
87
88         /// <summary>
89         /// Getting the grabbed-key together with the other client windows.
90         /// </summary>
91         Topmost = 512,
92
93         /// <summary>
94         /// Getting the grabbed-key only when the window is top of the stack.
95         /// </summary>
96         Exclusive = 1024,
97
98         /// <summary>
99         /// Getting the grabbed-key exclusively regardless of the window's position.
100         /// </summary>
101         OverrideExclusive = 2048,
102     }
103
104     /// <summary>
105     /// Enumeration for the indicator mode.
106     /// </summary>
107     /// <since_tizen> preview </since_tizen>
108     public enum IndicatorMode
109     {
110         /// <summary>
111         /// Unknown indicator state.
112         /// </summary>
113         Unknown = 0,
114
115         /// <summary>
116         /// Hides the indicator.
117         /// </summary>
118         Hide,
119
120         /// <summary>
121         /// Shows the indicator.
122         /// </summary>
123         Show,
124     };
125
126     /// <summary>
127     /// Enumeration for the keyboard mode.
128     /// </summary>
129     /// <since_tizen> preview </since_tizen>
130     public enum KeyboardMode
131     {
132         /// <summary>
133         /// Unknown keyboard state.
134         /// </summary>
135         Unknown,
136
137         /// <summary>
138         /// Request to deactivate the keyboard.
139         /// </summary>
140         Off,
141
142         /// <summary>
143         /// Enable keyboard with default layout.
144         /// </summary>
145         On,
146
147         /// <summary>
148         /// Alpha (a-z) keyboard layout.
149         /// </summary>
150         Alpha,
151
152         /// <summary>
153         /// Numeric keyboard layout.
154         /// </summary>
155         Numeric,
156
157         /// <summary>
158         /// Pin keyboard layout.
159         /// </summary>
160         Pin,
161
162         /// <summary>
163         /// Phone keyboard layout.
164         /// </summary>
165         PhoneNumber,
166
167         /// <summary>
168         /// Hexadecimal numeric keyboard layout.
169         /// </summary>
170         Hex,
171
172         /// <summary>
173         /// Full (QWERTY) keyboard layout.
174         /// </summary>
175         QWERTY,
176
177         /// <summary>
178         /// Password keyboard layout.
179         /// </summary>
180         Password,
181
182         /// <summary>
183         /// IP keyboard layout.
184         /// </summary>
185         IP,
186
187         /// <summary>
188         /// Host keyboard layout.
189         /// </summary>
190         Host,
191
192         /// <summary>
193         /// File keyboard layout.
194         /// </summary>
195         File,
196
197         /// <summary>
198         /// URL keyboard layout.
199         /// </summary>
200         URL,
201
202         /// <summary>
203         /// Keypad layout.
204         /// </summary>
205         Keypad,
206
207         /// <summary>
208         /// J2ME keyboard layout.
209         /// </summary>
210         J2ME,
211     };
212
213     /// <summary>
214     /// Enumeration for the window type.
215     /// </summary>
216     /// <since_tizen> preview </since_tizen>
217     public enum WindowType
218     {
219         /// <summary>
220         /// Unknown.
221         /// </summary>
222         Unknown,
223
224         /// <summary>
225         /// A normal window. Indicates a normal, top-level window. Almost every window will be created with this type.
226         /// </summary>
227         Basic,
228
229         /// <summary>
230         /// Used for simple dialog windows.
231         /// </summary>
232         Dialog,
233
234         /// <summary>
235         /// For special desktop windows, like a background window holding desktop icons.
236         /// </summary>
237         Desktop,
238
239         /// <summary>
240         /// The window is used as a dock or panel. Usually would be kept on top of any other window by the Window Manager.
241         /// </summary>
242         Dock,
243
244         /// <summary>
245         /// The window is used to hold a floating toolbar, or similar.
246         /// </summary>
247         Toolbar,
248
249         /// <summary>
250         /// Similar to Toolbar.
251         /// </summary>
252         Menu,
253
254         /// <summary>
255         /// A persistent utility window, like a toolbox or palette.
256         /// </summary>
257         Utility,
258
259         /// <summary>
260         /// Splash window for a starting up application.
261         /// </summary>
262         Splash,
263
264         /// <summary>
265         /// The window is a dropdown menu, as when an entry in a menubar is clicked.
266         /// </summary>
267         DropdownMenu,
268
269         /// <summary>
270         /// Like DropdownMenu, but for the menu triggered by right-clicking an object.
271         /// </summary>
272         PopupMenu,
273
274         /// <summary>
275         /// The window is a tooltip. A short piece of explanatory text that typically appears after the mouse cursor hovers over an object for a while.
276         /// </summary>
277         Tooltip,
278
279         /// <summary>
280         /// A notification window, like a warning about battery life or a new e-mail received.
281         /// </summary>
282         Notification,
283
284         /// <summary>
285         /// A window holding the contents of a combo box.
286         /// </summary>
287         Combo,
288
289         /// <summary>
290         /// Used to indicate the window as a representation of an object being dragged across different windows, or even applications.
291         /// </summary>
292         DragAndDrop,
293
294         /// <summary>
295         /// The window is rendered onto an image buffer. No actual window is created for this type, instead the window and all of its contents will be rendered to an image buffer.
296         /// This allows to have children windows inside a parent one just like any other object would be, and do other things like applying Evas_Map effects to it.
297         /// </summary>
298         InlinedImage,
299
300         /// <summary>
301         /// The window is rendered onto an image buffer and can be shown other process's plug image object.
302         /// No actual window is created for this type, instead the window and all of its contents will be rendered to an image buffer and can be shown other process's plug image object.
303         /// </summary>
304         SocketImage,
305
306         /// <summary>
307         /// This window was created using a pre-existing canvas. The window widget can be deleted, but the canvas must be managed externally.
308         /// </summary>
309         Fake,
310     };
311
312     /// <summary>
313     /// Enumeration of notification window's priority level.
314     /// </summary>
315     /// <since_tizen> preview </since_tizen>
316     public enum NotificationLevel
317     {
318         /// <summary>
319         /// No (reset) notification level. This value makes the window place in normal layer.
320         /// </summary>
321         None = -1,
322
323         /// <summary>
324         /// Default notification level.
325         /// </summary>
326         Default = 10,
327
328         /// <summary>
329         /// Higher notification level than default.
330         /// </summary>
331         Medium = 20,
332
333         /// <summary>
334         /// Higher notification level than medium.
335         /// </summary>
336         High = 30,
337
338         /// <summary>
339         /// The highest notification level.
340         /// </summary>
341         Top = 40,
342     };
343
344     /// <summary>
345     /// Enumeration of screen mode.
346     /// </summary>
347     /// <since_tizen> preview </since_tizen>
348     public enum ScreenMode
349     {
350         /// <summary>
351         /// The mode which turns the screen off after a timeout.
352         /// </summary>
353         Default,
354
355         /// <summary>
356         /// The mode which keeps the screen turned on.
357         /// </summary>
358         AlwaysOn,
359     }
360
361     /// <summary>
362     /// The Window is a container that contains the graphical user interface of a program.
363     /// </summary>
364     /// <since_tizen> preview </since_tizen>
365     public class Window : Widget
366     {
367         SmartEvent _deleteRequest;
368         SmartEvent _rotationChanged;
369         HashSet<EvasObject> _referenceHolder = new HashSet<EvasObject>();
370
371         /// <summary>
372         /// Creates and initializes a new instance of the Window class.
373         /// </summary>
374         /// <param name="name">Window name.</param>
375         /// <since_tizen> preview </since_tizen>
376         public Window(string name) : this(null, name)
377         {
378         }
379
380         /// <summary>
381         /// Creates and initializes a new instance of the Window class.
382         /// </summary>
383         /// <param name="parent">
384         /// Parent widget which this window is created on.
385         /// </param>
386         /// <param name="name">
387         /// Window name.
388         /// </param>
389         /// <remarks>
390         /// Window constructor.show window indicator, set callback
391         /// when closing the window in any way outside the program control,
392         /// and set callback when window rotation is changed.
393         /// </remarks>
394         /// <since_tizen> preview </since_tizen>
395         public Window(Window parent, string name) : this(parent, name, WindowType.Basic)
396         {
397         }
398
399         /// <summary>
400         /// Creates and initializes a new instance of the Window class.
401         /// </summary>
402         /// <param name="parent">
403         /// Parent widget which this window is created on.
404         /// </param>
405         /// <param name="name">
406         /// Window name.
407         /// </param>
408         /// <param name="type">
409         /// Window type.
410         /// </param>
411         /// <remarks>
412         /// Window constructor.show window indicator, set callback
413         /// when closing the window in any way outside the program control,
414         /// and set callback when window rotation is changed.
415         /// </remarks>
416         /// <since_tizen> preview </since_tizen>
417         public Window(Window parent, string name, WindowType type)
418         {
419             Name = name;
420             Type = type;
421             Realize(parent);
422             IndicatorMode = IndicatorMode.Show;
423
424             _deleteRequest = new SmartEvent(this, "delete,request");
425             _rotationChanged = new SmartEvent(this, "wm,rotation,changed");
426             _deleteRequest.On += (s, e) => CloseRequested?.Invoke(this, EventArgs.Empty);
427             _rotationChanged.On += (s, e) => RotationChanged?.Invoke(this, EventArgs.Empty);
428         }
429
430         /// <summary>
431         /// Creates and initializes a new instance of the Window class.
432         /// </summary>
433         /// <since_tizen> preview </since_tizen>
434         protected Window()
435         {
436         }
437
438         /// <summary>
439         /// CloseRequested will be triggered when window is closed.
440         /// </summary>
441         /// <since_tizen> preview </since_tizen>
442         public event EventHandler CloseRequested;
443
444         /// <summary>
445         /// RotationChanged will be triggered when window is rotated.
446         /// </summary>
447         /// <since_tizen> preview </since_tizen>
448         public event EventHandler RotationChanged;
449
450         /// <summary>
451         /// Sets or gets the window name.
452         /// </summary>
453         /// <since_tizen> preview </since_tizen>
454         public string Name { get; set; }
455
456         /// <summary>
457         /// Gets the window type.
458         /// </summary>
459         /// <since_tizen> preview </since_tizen>
460         public WindowType Type { get; } = WindowType.Basic;
461
462         /// <summary>
463         /// Gets the window size with Size value(w,h)
464         /// </summary>
465         /// <since_tizen> preview </since_tizen>
466         public Size ScreenSize
467         {
468             get
469             {
470                 int x, y, w, h;
471                 Interop.Elementary.elm_win_screen_size_get(Handle, out x, out y, out w, out h);
472                 return new Size(w, h);
473             }
474         }
475
476         /// <summary>
477         /// Gets the screen dpi for the screen that the window is on.
478         /// </summary>
479         /// <since_tizen> preview </since_tizen>
480         public Point ScreenDpi
481         {
482             get
483             {
484                 Point point = default(Point);
485                 Interop.Elementary.elm_win_screen_dpi_get(Handle, out point.X, out point.Y);
486                 return point;
487             }
488         }
489
490         /// <summary>
491         /// Gets the rotation of the window. The rotation of the window in degrees (0-360).
492         /// </summary>
493         /// <since_tizen> preview </since_tizen>
494         public int Rotation
495         {
496             get
497             {
498                 return Interop.Elementary.elm_win_rotation_get(Handle);
499             }
500         }
501
502         /// <summary>
503         /// Gets whether the window manager supports window rotation or not.
504         /// </summary>
505         /// <since_tizen> preview </since_tizen>
506         public bool IsRotationSupported
507         {
508             get
509             {
510                 return Interop.Elementary.elm_win_wm_rotation_supported_get(Handle);
511             }
512         }
513
514         /// <summary>
515         /// Sets or gets the available rotation degree.
516         /// </summary>
517         /// <since_tizen> preview </since_tizen>
518         [Obsolete("Sorry, it's error typo of AvailableRotations, please use AvailableRotations")]
519         public DisplayRotation AavailableRotations { get; set; }
520
521         /// <summary>
522         /// Sets or gets the available rotation degree.
523         /// </summary>
524         /// <since_tizen> preview </since_tizen>
525         public DisplayRotation AvailableRotations
526         {
527             get
528             {
529                 int[] rotations;
530                 Interop.Elementary.elm_win_wm_rotation_available_rotations_get(Handle, out rotations);
531                 if (rotations == null)
532                 {
533                     return 0;
534                 }
535                 return ConvertToDisplayRotation(rotations);
536             }
537             set
538             {
539                 Interop.Elementary.elm_win_wm_rotation_available_rotations_set(Handle, ConvertDegreeArray(value));
540             }
541         }
542
543         /// <summary>
544         /// Sets or gets whether the auto deletion function is enabled.
545         /// </summary>
546         /// <remarks>
547         /// If you enable auto deletion, the window is automatically destroyed after the signal is emitted.
548         /// If auto deletion is disabled, the window is not destroyed and the program has to handle it.
549         /// </remarks>
550         /// <since_tizen> preview </since_tizen>
551         public bool AutoDeletion
552         {
553             get
554             {
555                 return Interop.Elementary.elm_win_autodel_get(Handle);
556             }
557             set
558             {
559                 Interop.Elementary.elm_win_autodel_set(Handle, value);
560             }
561         }
562
563         /// <summary>
564         /// Sets or gets the alpha channel state of the window.
565         /// </summary>
566         /// <remarks>
567         /// true if the window alpha channel is enabled, false otherwise.
568         /// If alpha is true, the alpha channel of the canvas will be enabled possibly making parts of the window completely or partially transparent.
569         /// </remarks>
570         /// <since_tizen> preview </since_tizen>
571         public bool Alpha
572         {
573             get
574             {
575                 return Interop.Elementary.elm_win_alpha_get(Handle);
576             }
577             set
578             {
579                 Interop.Elementary.elm_win_alpha_set(Handle, value);
580             }
581         }
582
583         /// <summary>
584         /// Sets or gets the role of the window.
585         /// </summary>
586         /// <remarks>
587         /// The Role will be invalid if a new role is set or if the window is destroyed.
588         /// </remarks>
589         /// <since_tizen> preview </since_tizen>
590         public string Role
591         {
592             get
593             {
594                 return Interop.Elementary.elm_win_role_get(Handle);
595             }
596             set
597             {
598                 Interop.Elementary.elm_win_role_set(Handle, value);
599             }
600         }
601
602         /// <summary>
603         /// Sets or gets the mode of the status bar.
604         /// </summary>
605         /// <since_tizen> preview </since_tizen>
606         public StatusBarMode StatusBarMode
607         {
608             get
609             {
610                 return (StatusBarMode)Interop.Elementary.elm_win_indicator_opacity_get(Handle);
611             }
612             set
613             {
614                 Interop.Elementary.elm_win_indicator_opacity_set(Handle, (int)value);
615             }
616         }
617
618         /// <summary>
619         /// Sets or gets the iconified state of the window.
620         /// </summary>
621         /// <since_tizen> preview </since_tizen>
622         [EditorBrowsable(EditorBrowsableState.Never)]
623         public bool Iconified
624         {
625             get
626             {
627                 return Interop.Elementary.elm_win_iconified_get(RealHandle);
628             }
629             set
630             {
631                 Interop.Elementary.elm_win_iconified_set(RealHandle, value);
632             }
633         }
634
635         /// <summary>
636         /// Gets or sets the window's indicator mode.
637         /// </summary>
638         /// <value>The indicator mode.</value>
639         /// <since_tizen> preview </since_tizen>
640         public IndicatorMode IndicatorMode
641         {
642             get
643             {
644                 return Interop.Elementary.elm_win_indicator_mode_get(RealHandle);
645             }
646             set
647             {
648                 Interop.Elementary.elm_win_indicator_mode_set(RealHandle, value);
649             }
650         }
651
652         /// <summary>
653         /// Gets or sets the aspect ratio of the window.
654         /// </summary>
655         /// <since_tizen> preview </since_tizen>
656         public double Aspect
657         {
658             get
659             {
660                 return Interop.Elementary.elm_win_aspect_get(RealHandle);
661             }
662             set
663             {
664                 Interop.Elementary.elm_win_aspect_set(RealHandle, value);
665             }
666         }
667
668         /// <summary>
669         /// Window's autohide state.
670         /// </summary>
671         /// <since_tizen> preview </since_tizen>
672         public bool AutoHide
673         {
674             get
675             {
676                 return Interop.Elementary.elm_win_autohide_get(RealHandle);
677             }
678             set
679             {
680                 Interop.Elementary.elm_win_autohide_set(RealHandle, value);
681             }
682         }
683
684         /// <summary>
685         /// Gets the borderless state of the window.
686         /// This function requests the Window Manager to not draw any decoration around the window.
687         /// </summary>
688         /// <since_tizen> preview </since_tizen>
689         public bool Borderless
690         {
691             get
692             {
693                 return Interop.Elementary.elm_win_borderless_get(RealHandle);
694             }
695             set
696             {
697                 Interop.Elementary.elm_win_borderless_set(RealHandle, value);
698             }
699         }
700
701         /// <summary>
702         /// Gets or sets the demand attention state of the window.
703         /// </summary>
704         /// <since_tizen> preview </since_tizen>
705         public bool DemandAttention
706         {
707             get
708             {
709                 return Interop.Elementary.elm_win_demand_attention_get(RealHandle);
710             }
711             set
712             {
713                 Interop.Elementary.elm_win_demand_attention_set(RealHandle, value);
714             }
715         }
716
717         /// <summary>
718         /// Gets or sets the floating mode of the window.
719         /// </summary>
720         /// <since_tizen> preview </since_tizen>
721         public bool FloatingMode
722         {
723             get
724             {
725                 return Interop.Elementary.elm_win_floating_mode_get(RealHandle);
726             }
727             set
728             {
729                 Interop.Elementary.elm_win_floating_mode_set(RealHandle, value);
730             }
731         }
732
733         /// <summary>
734         /// Gets or sets the animate status for the focus highlight for this window.
735         /// This function will enable or disable the animation of focus highlight only for the given window, regardless of the global setting for it.
736         /// </summary>
737         /// <since_tizen> preview </since_tizen>
738         public bool FocusHighlightAnimation
739         {
740             get
741             {
742                 return Interop.Elementary.elm_win_focus_highlight_animate_get(RealHandle);
743             }
744             set
745             {
746                 Interop.Elementary.elm_win_focus_highlight_animate_set(RealHandle, value);
747             }
748         }
749
750         /// <summary>
751         /// Gets or sets the enabled status for the focus highlight in the window.
752         /// This function will enable or disable the focus highlight only for the given window, regardless of the global setting for it.
753         /// </summary>
754         /// <since_tizen> preview </since_tizen>
755         public bool FocusHighlightEnabled
756         {
757             get
758             {
759                 return Interop.Elementary.elm_win_focus_highlight_enabled_get(RealHandle);
760             }
761             set
762             {
763                 Interop.Elementary.elm_win_focus_highlight_enabled_set(RealHandle, value);
764             }
765         }
766
767         /// <summary>
768         /// Gets or sets the style for the focus highlight on this window.
769         /// Sets the style to use for theming the highlight of focused objects on the given window. If style is NULL, the default will be used.
770         /// </summary>
771         /// <since_tizen> preview </since_tizen>
772         public string FocusHighlightStyle
773         {
774             get
775             {
776                 return Interop.Elementary.elm_win_focus_highlight_style_get(RealHandle);
777             }
778             set
779             {
780                 Interop.Elementary.elm_win_focus_highlight_style_set(RealHandle, value);
781             }
782         }
783
784         /// <summary>
785         /// Gets the keyboard mode of the window.
786         /// </summary>
787         /// <since_tizen> preview </since_tizen>
788         public KeyboardMode KeyboardMode
789         {
790             get
791             {
792                 return (KeyboardMode)Interop.Elementary.elm_win_keyboard_mode_get(RealHandle);
793             }
794             set
795             {
796                 Interop.Elementary.elm_win_keyboard_mode_set(RealHandle, (int)value);
797             }
798         }
799
800         /// <summary>
801         /// Gets or sets the layer of the window.
802         /// What this means exactly will depend on the underlying engine used.
803         /// In the case of X11 backed engines, the value in layer has the following meanings:
804         /// less than 3 means that the window will be placed below all others,
805         /// more than 5 means that the window will be placed above all others,
806         /// and anything else means that the window will be placed in the default layer.
807         /// </summary>
808         /// <since_tizen> preview </since_tizen>
809         public override int Layer
810         {
811             get
812             {
813                 return Interop.Elementary.elm_win_layer_get(RealHandle);
814             }
815             set
816             {
817                 Interop.Elementary.elm_win_layer_set(RealHandle, value);
818             }
819         }
820
821         /// <summary>
822         /// Gets or sets the modal state of the window.
823         /// </summary>
824         /// <since_tizen> preview </since_tizen>
825         public bool Modal
826         {
827             get
828             {
829                 return Interop.Elementary.elm_win_modal_get(RealHandle);
830             }
831             set
832             {
833                 Interop.Elementary.elm_win_modal_set(RealHandle, value);
834             }
835         }
836
837         /// <summary>
838         /// Gets or sets the noblank property of the window.
839         /// This is a way to request the display on which the window is shown is not blank, screensave, or otherwise hidden or obscure. It is intended for use such as media playback on a television where a user may not want to be interrupted by an idle screen.
840         /// The noblank property may have no effect if the window is iconified/minimized or hidden.
841         /// </summary>
842         /// <since_tizen> preview </since_tizen>
843         public bool NoBlank
844         {
845             get
846             {
847                 return Interop.Elementary.elm_win_noblank_get(RealHandle);
848             }
849             set
850             {
851                 Interop.Elementary.elm_win_noblank_set(RealHandle, value);
852             }
853         }
854
855         /// <summary>
856         /// Gets the profile of the window.
857         /// </summary>
858         /// <since_tizen> preview </since_tizen>
859         public string Profile
860         {
861             get
862             {
863                 return Interop.Elementary.elm_win_profile_get(RealHandle);
864             }
865             set
866             {
867                 Interop.Elementary.elm_win_profile_set(RealHandle, value);
868             }
869         }
870
871         /// <summary>
872         /// Gets the constraints on the maximum width and height of the window relative to the width and height of its screen.
873         /// When this function returns true, object will never resize larger than the screen.
874         /// </summary>
875         /// <since_tizen> preview </since_tizen>
876         public bool ScreenConstrain
877         {
878             get
879             {
880                 return Interop.Elementary.elm_win_screen_constrain_get(RealHandle);
881             }
882             set
883             {
884                 Interop.Elementary.elm_win_screen_constrain_set(RealHandle, value);
885             }
886         }
887
888         /// <summary>
889         /// Gets or sets the base size of the window.
890         /// </summary>
891         /// <since_tizen> preview </since_tizen>
892         public Size BaseSize
893         {
894             get
895             {
896                 int w, h;
897                 Interop.Elementary.elm_win_size_base_get(RealHandle, out w, out h);
898                 return new Size(w, h);
899             }
900             set
901             {
902                 Interop.Elementary.elm_win_size_base_set(RealHandle, value.Width, value.Height);
903             }
904         }
905
906         /// <summary>
907         /// Gets or sets the step size of the window.
908         /// </summary>
909         /// <since_tizen> preview </since_tizen>
910         public Size StepSize
911         {
912             get
913             {
914                 int w, h;
915                 Interop.Elementary.elm_win_size_step_get(RealHandle, out w, out h);
916                 return new Size(w, h);
917             }
918             set
919             {
920                 Interop.Elementary.elm_win_size_step_set(RealHandle, value.Width, value.Height);
921             }
922         }
923
924         /// <summary>
925         /// Gets the screen position X of a window.
926         /// </summary>
927         /// <since_tizen> preview </since_tizen>
928         public int ScreenPositionX
929         {
930             get
931             {
932                 int x, y;
933                 Interop.Elementary.elm_win_screen_position_get(Handle, out x, out y);
934                 return x;
935             }
936         }
937
938         /// <summary>
939         /// Gets the screen position Y of a window.
940         /// </summary>
941         /// <since_tizen> preview </since_tizen>
942         public int ScreenPositionY
943         {
944             get
945             {
946                 int x, y;
947                 Interop.Elementary.elm_win_screen_position_get(Handle, out x, out y);
948                 return y;
949             }
950         }
951
952         /// <summary>
953         /// Gets or sets the title of the window.
954         /// </summary>
955         /// <since_tizen> preview </since_tizen>
956         public string Title
957         {
958             get
959             {
960                 return Interop.Elementary.elm_win_title_get(Handle);
961             }
962             set
963             {
964                 Interop.Elementary.elm_win_title_set(Handle, value);
965             }
966         }
967
968         /// <summary>
969         /// Gets or sets the urgent state of the window.
970         /// </summary>
971         /// <since_tizen> preview </since_tizen>
972         public bool Urgent
973         {
974             get
975             {
976                 return Interop.Elementary.elm_win_urgent_get(Handle);
977             }
978             set
979             {
980                 Interop.Elementary.elm_win_urgent_set(Handle, value);
981             }
982         }
983
984         /// <summary>
985         /// Gets or sets the withdrawn state of the window.
986         /// </summary>
987         /// <since_tizen> preview </since_tizen>
988         public bool Withdrawn
989         {
990             get
991             {
992                 return Interop.Elementary.elm_win_withdrawn_get(Handle);
993             }
994             set
995             {
996                 Interop.Elementary.elm_win_withdrawn_set(Handle, value);
997             }
998         }
999
1000         /// <summary>
1001         /// Gets or sets the priority level for the specified notification window.
1002         /// </summary>
1003         /// <privilege>
1004         /// http://tizen.org/privilege/window.priority.set
1005         /// </privilege>
1006         /// /// <remarks>
1007         /// This can be used for a notification type window only.
1008         /// </remarks>
1009         /// <since_tizen> preview </since_tizen>
1010         public NotificationLevel NotificationLevel
1011         {
1012             get
1013             {
1014                 int level;
1015                 Interop.Eutil.efl_util_get_notification_window_level(Handle, out level);
1016                 return (NotificationLevel)level;
1017             }
1018             set
1019             {
1020                 Interop.Eutil.efl_util_set_notification_window_level(Handle, (int)value);
1021             }
1022         }
1023
1024         /// <summary>
1025         /// Gets or sets the window's screen mode.
1026         /// This API is useful when the application need to keep the display turned on.
1027         /// If the application set the mode to ScreenMode.AlwaysOn to its window and the window is shown wholly or partially,
1028         /// the window manager requests the display system to keep the display on as long as the window is shown.
1029         /// If the window is no longer shown, then the window manger request the display system to go back to normal operation.
1030         /// Default screen mode of window is ScreenMode.Default.
1031         /// </summary>
1032         /// <privilege>
1033         /// http://tizen.org/privilege/display
1034         /// </privilege>
1035         /// <remarks>
1036         /// This needs the privilege. If the application which is not get the privilege use this API, the window manager generates the permission deny error.
1037         /// </remarks>
1038         /// <since_tizen> preview </since_tizen>
1039         public ScreenMode ScreenMode
1040         {
1041             get
1042             {
1043                 int mode;
1044                 Interop.Eutil.efl_util_get_window_screen_mode(Handle, out mode);
1045                 return (ScreenMode)mode;
1046             }
1047             set
1048             {
1049                 Interop.Eutil.efl_util_set_window_screen_mode(Handle, (int)value);
1050             }
1051         }
1052
1053         /// <summary>
1054         /// Gets or sets the user's preferred brightness of the specified window.
1055         /// This is useful when the application need to change the brightness of the screen when it is appeared on the screen.
1056         /// If the application sets the brightness 0 to 100 to its window and the application window is shown wholly or partially,
1057         /// the window manager requests the display system to change the brightness of the screen using user's preferred brightness.
1058         /// If the window is no longer shown, then the window manger request the display system to go back to default brightness.
1059         /// If the brightness is less than 0, this means to use the default screen brightness.
1060         /// </summary>
1061         /// <privilege>
1062         /// http://tizen.org/privilege/display
1063         /// </privilege>
1064         /// <remarks>
1065         /// This needs the privilege. If the application which is not get the privilege use this API, the window manager generates the permission deny error.
1066         /// </remarks>
1067         /// <since_tizen> preview </since_tizen>
1068         public int Brightness
1069         {
1070             get
1071             {
1072                 int brightness;
1073                 Interop.Eutil.efl_util_get_window_brightness(Handle, out brightness);
1074                 return brightness;
1075             }
1076             set
1077             {
1078                 Interop.Eutil.efl_util_set_window_brightness(Handle, value);
1079             }
1080         }
1081
1082         /// <summary>
1083         /// Creates a socket to provide the service for the Plug widget.
1084         /// </summary>
1085         /// <param name="name">A service name.</param>
1086         /// <param name="number">A number (any value, 0 being the common default) to differentiate multiple instances of services with the same name.</param>
1087         /// <param name="systemWide">A boolean that if true, specifies to create a system-wide service all users can connect to, otherwise the service is private to the user ID that created the service.</param>
1088         /// <returns>If true creates successful, otherwise false.</returns>
1089         /// <since_tizen> preview </since_tizen>
1090         public bool CreateServiceSocket(string name, int number, bool systemWide)
1091         {
1092             return Interop.Elementary.elm_win_socket_listen(RealHandle, name, number, systemWide);
1093         }
1094
1095         /// <summary>
1096         /// Sets the rotation of the window.
1097         /// </summary>
1098         /// <param name="degree">The rotation of the window, in degrees (0-360), counter-clockwise.</param>
1099         /// <param name="resize">Resizes the window's contents so that they fit inside the current window geometry.</param>
1100         /// <since_tizen> preview </since_tizen>
1101         public void SetRotation(int degree, bool resize)
1102         {
1103             if (resize)
1104                 Interop.Elementary.elm_win_rotation_with_resize_set(RealHandle, degree);
1105             else
1106                 Interop.Elementary.elm_win_rotation_set(RealHandle, degree);
1107         }
1108
1109         /// <summary>
1110         /// Sets the alpha window's visual state to opaque state.
1111         /// This sets the alpha window's visual state to opaque state.
1112         /// If the alpha window sets the visual state to the opaque,
1113         /// then the window manager could handle it as the opaque window while calculating visibility.
1114         /// This will have no effect when used by a non-alpha window.
1115         /// </summary>
1116         /// <since_tizen> preview </since_tizen>
1117         public void SetOpaqueState()
1118         {
1119             Interop.Eutil.efl_util_set_window_opaque_state(RealHandle, 1);
1120         }
1121
1122         /// <summary>
1123         /// Unsets the alpha window's visual state to opaque state.
1124         /// </summary>
1125         /// <since_tizen> preview </since_tizen>
1126         public void UnsetOpaqueState()
1127         {
1128             Interop.Eutil.efl_util_set_window_opaque_state(RealHandle, 0);
1129         }
1130
1131         /// <summary>
1132         /// Sets the window to be skipped by focus.
1133         /// This sets the window to be skipped by normal input.
1134         /// This means the Windows Manager will be asked to not focus this window as well as omit it from things like the taskbar, pager etc.
1135         /// Call this and enable it on the window BEFORE you show it for the first time, otherwise it may have no effect.
1136         /// Use this for windows that have only output information or might only be interacted with by the mouse or fingers, and never for typing input.
1137         /// Be careful that this may have side-effects like making the window non-accessible in some cases unless the window is specially handled. Use this with care.
1138         /// </summary>
1139         /// <since_tizen> preview </since_tizen>
1140         public void FocusSkip(bool skip)
1141         {
1142             Interop.Elementary.elm_win_prop_focus_skip_set(Handle, skip);
1143         }
1144
1145         /// <summary>
1146         /// Pulls up the window object.
1147         /// Places the window pointed by object at the top of the stack, so that it's not covered by any other window.
1148         /// </summary>
1149         /// <since_tizen> preview </since_tizen>
1150         public void PullUp()
1151         {
1152             Interop.Elementary.elm_win_raise(Handle);
1153         }
1154
1155         /// <summary>
1156         /// Brings down the window object.
1157         /// Places the window pointed by object at the bottom of the stack, so that no other window is covered by it.
1158         /// </summary>
1159         /// <since_tizen> preview </since_tizen>
1160         public void BringDown()
1161         {
1162             Interop.Elementary.elm_win_lower(Handle);
1163         }
1164
1165         /// <summary>
1166         /// This function sends a request to the Windows Manager to activate the window.
1167         /// If honored by the Windows Manager, the window receives the keyboard focus.
1168         /// </summary>
1169         /// <remarks>
1170         /// This is just a request that the Windows Manager may ignore, so calling this function does not ensure
1171         /// in any way that the window is going to be the active one after it.
1172         /// </remarks>
1173         /// <since_tizen> preview </since_tizen>
1174         public void Active()
1175         {
1176             Interop.Elementary.elm_win_activate(Handle);
1177         }
1178
1179         /// <summary>
1180         /// Deletes the subobj as a resize object of the window object.
1181         /// This function removes the object subobj from the resize objects of the window object.
1182         /// It will not delete the object itself, which will be left unmanaged and should be deleted by the developer, manually handled, or set as child of some other container.
1183         /// </summary>
1184         /// <param name="obj">Resize object.</param>
1185         /// <since_tizen> preview </since_tizen>
1186         public void DeleteResizeObject(EvasObject obj)
1187         {
1188             Interop.Elementary.elm_win_resize_object_del(Handle, obj);
1189         }
1190
1191         /// <summary>
1192         /// Adds an object as a resize object of the window.
1193         /// </summary>
1194         /// <remarks>
1195         /// Setting an object as a resize object of the window means that the object child's size and
1196         /// position is controlled by the window directly. That is, the object is resized to match the window size
1197         /// and should never be moved or resized manually by the developer. In addition,
1198         /// resize objects of the window control the minimum size of it as well as whether it can or cannot be resized by the user.
1199         /// </remarks>
1200         /// <param name="obj">
1201         /// Resize object.
1202         /// </param>
1203         /// <since_tizen> preview </since_tizen>
1204         public void AddResizeObject(EvasObject obj)
1205         {
1206             Interop.Elementary.elm_win_resize_object_add(Handle, obj);
1207         }
1208
1209         /// <summary>
1210         /// Sets the keygrab value of the window.
1211         /// This function grabs the key of the window using grab_mode.
1212         /// </summary>
1213         /// <param name="keyname">The keyname to grab.</param>
1214         /// <param name="mode">According to the grabmode, it can grab key differently.</param>
1215         /// <since_tizen> preview </since_tizen>
1216         [EditorBrowsable(EditorBrowsableState.Never)]
1217         public void WinKeyGrab(string keyname, KeyGrabMode mode)
1218         {
1219             Interop.Elementary.elm_win_keygrab_set(RealHandle, keyname, 0, 0, 0, mode);
1220         }
1221
1222         /// <summary>
1223         /// Unsets the keygrab value of the window.
1224         /// This function unsets keygrab value. Ungrab key of the window.
1225         /// </summary>
1226         /// <param name="keyname">The keyname to grab.</param>
1227         /// <since_tizen> preview </since_tizen>
1228         [EditorBrowsable(EditorBrowsableState.Never)]
1229         public void WinKeyUngrab(string keyname)
1230         {
1231             Interop.Elementary.elm_win_keygrab_unset(RealHandle, keyname, 0, 0);
1232         }
1233
1234         /// <summary>
1235         /// Sets the keygrab of the window.
1236         /// </summary>
1237         /// <param name="keyname">The keyname string to set keygrab.</param>
1238         /// <since_tizen> preview </since_tizen>
1239         public void KeyGrabEx(string keyname)
1240         {
1241             Interop.Elementary.eext_win_keygrab_set(RealHandle, keyname);
1242         }
1243
1244         /// <summary>
1245         /// Unsets the keygrab of the window.
1246         /// </summary>
1247         /// <param name="keyname">The keyname string to unset keygrab.</param>
1248         /// <since_tizen> preview </since_tizen>
1249         public void KeyUngrabEx(string keyname)
1250         {
1251             Interop.Elementary.eext_win_keygrab_unset(RealHandle, keyname);
1252         }
1253
1254         /// <summary>
1255         /// Creates a widget handle.
1256         /// </summary>
1257         /// <param name="parent">Parent EvasObject.</param>
1258         /// <returns>Handle IntPtr.</returns>
1259         /// <since_tizen> preview </since_tizen>
1260         protected override IntPtr CreateHandle(EvasObject parent)
1261         {
1262             Interop.Elementary.elm_config_accel_preference_set("3d");
1263             return Interop.Elementary.elm_win_add(parent != null ? parent.Handle : IntPtr.Zero, Name, (int)Type);
1264         }
1265
1266         internal void AddChild(EvasObject obj)
1267         {
1268             _referenceHolder.Add(obj);
1269         }
1270
1271         internal void RemoveChild(EvasObject obj)
1272         {
1273             _referenceHolder.Remove(obj);
1274         }
1275
1276         static int[] ConvertDegreeArray(DisplayRotation value)
1277         {
1278             List<int> rotations = new List<int>();
1279             if (value.HasFlag(DisplayRotation.Degree_0))
1280                 rotations.Add(0);
1281             if (value.HasFlag(DisplayRotation.Degree_90))
1282                 rotations.Add(90);
1283             if (value.HasFlag(DisplayRotation.Degree_180))
1284                 rotations.Add(180);
1285             if (value.HasFlag(DisplayRotation.Degree_270))
1286                 rotations.Add(270);
1287             return rotations.ToArray();
1288         }
1289
1290         static DisplayRotation ConvertToDisplayRotation(int[] values)
1291         {
1292             int orientation = 0;
1293             foreach (int v in values)
1294             {
1295                 orientation |= (1 << (v / 90));
1296             }
1297             return (DisplayRotation)orientation;
1298         }
1299     }
1300 }