2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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.
19 using System.ComponentModel;
20 using Tizen.NUI.BaseComponents;
22 namespace Tizen.NUI.Components
25 /// Dialog class shows a dialog with content.
27 /// <since_tizen> 9 </since_tizen>
28 public class Dialog : Control
30 private View content = null;
33 /// Creates a new instance of Dialog.
35 /// <since_tizen> 9 </since_tizen>
36 public Dialog() : base()
38 Layout = new AbsoluteLayout();
40 this.Relayout += OnRelayout;
44 [EditorBrowsable(EditorBrowsableState.Never)]
45 protected override void Dispose(DisposeTypes type)
52 if (type == DisposeTypes.Explicit)
54 this.Relayout -= OnRelayout;
58 Utility.Dispose(content);
66 /// Popup content of Dialog.
67 /// Content is added as a child of Dialog automatically.
69 /// <since_tizen> 9 </since_tizen>
99 /// Initialize AT-SPI object.
101 [EditorBrowsable(EditorBrowsableState.Never)]
102 public override void OnInitialize()
105 SetAccessibilityConstructor(Role.Dialog);
106 AppendAccessibilityAttribute("sub-role", "Alert");
107 Show(); // calls AddPopup()
111 /// Informs AT-SPI bridge about the set of AT-SPI states associated with this object.
113 [EditorBrowsable(EditorBrowsableState.Never)]
114 protected override AccessibilityStates AccessibilityCalculateStates()
116 var states = base.AccessibilityCalculateStates();
117 states.Set(AccessibilityState.Modal, true);
121 private void OnRelayout(object sender, EventArgs e)
123 //FIXME: Needs to separate GUI implementation codes to style cs file.
124 CalculateContentPosition();
127 private void CalculateContentPosition()
130 var parent = GetParent();
133 if ((parent != null) && (parent is View))
135 parentSize = ((View)parent).Size;
139 parentSize = NUIApplication.GetDefaultWindow().Size;
142 Position2D = new Position2D((parentSize.Width - size.Width) / 2, (parentSize.Height - size.Height) / 2);