3b6648760101f8c78dcba6f2aa93a55d78dcc8ef
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Popup.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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 Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
21 using System.ComponentModel;
22
23 namespace Tizen.NUI.Components
24 {
25     /// <summary>
26     /// Popup is one kind of common component, it can be used as popup window.
27     /// User can handle Popup button count, head title and content area.
28     /// </summary>
29     /// <since_tizen> 6 </since_tizen>
30     [Obsolete("Deprecated in API8; Will be removed in API10")]
31     public class Popup : Control
32     {
33         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
34         [EditorBrowsable(EditorBrowsableState.Never)]
35         public static readonly BindableProperty ButtonHeightProperty = BindableProperty.Create(nameof(ButtonHeight), typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
36         {
37             var instance = (Popup)bindable;
38             if (newValue != null && instance?.Style?.Buttons?.Size != null )
39             {
40                 instance.Style.Buttons.Size.Height = (int)newValue;
41                 instance.btGroup.Itemheight = (int)newValue;
42                 instance.UpdateView();
43             }
44         },
45         defaultValueCreator: (bindable) =>
46         {
47             var instance = (Popup)bindable;
48             return (int)(instance.Style?.Buttons?.Size?.Height ?? 0);
49         });
50
51         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
52         [EditorBrowsable(EditorBrowsableState.Never)]
53         public static readonly BindableProperty ButtonTextPointSizeProperty = BindableProperty.Create(nameof(ButtonTextPointSize), typeof(float), typeof(Popup), default(float), propertyChanged: (bindable, oldValue, newValue) =>
54         {
55             var instance = (Popup)bindable;
56             if (newValue != null)
57             {
58                 if (instance.Style?.Buttons?.Text != null)
59                 {
60                     instance.Style.Buttons.Text.PointSize = (float)newValue;
61                 }
62                 instance.btGroup.ItemPointSize = (float)newValue;
63             }
64         },
65         defaultValueCreator: (bindable) =>
66         {
67             var instance = (Popup)bindable;
68             return instance.Style?.Buttons?.Text?.PointSize?.All ?? 0;
69         });
70
71         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         public static readonly BindableProperty ButtonFontFamilyProperty = BindableProperty.Create(nameof(ButtonFontFamily), typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
74         {
75             var instance = (Popup)bindable;
76             if (newValue != null)
77             {
78                 instance.Style.Buttons.Text.FontFamily = (string)newValue;
79                 instance.btGroup.ItemFontFamily = (string)newValue;
80             }
81         },
82         defaultValueCreator: (bindable) =>
83         {
84             var instance = (Popup)bindable;
85             return instance.Style?.Buttons?.Text?.FontFamily.All;
86         });
87
88         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
89         [EditorBrowsable(EditorBrowsableState.Never)]
90         public static readonly BindableProperty ButtonTextColorProperty = BindableProperty.Create(nameof(ButtonTextColor), typeof(Color), typeof(Popup), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
91         {
92             var instance = (Popup)bindable;
93             if (newValue != null)
94             {  
95                 if (instance.Style?.Buttons?.Text != null)
96                 {
97                     instance.Style.Buttons.Text.TextColor = (Color)newValue;
98                 }
99                 instance.btGroup.ItemTextColor = (Color)newValue;
100             }
101         },
102         defaultValueCreator: (bindable) =>
103         {
104             var instance = (Popup)bindable;
105             return instance.Style?.Buttons?.Text?.TextColor?.All;
106         });
107
108         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
109         [EditorBrowsable(EditorBrowsableState.Never)]
110         public static readonly BindableProperty ButtonOverLayBackgroundColorSelectorProperty = BindableProperty.Create(nameof(ButtonOverLayBackgroundColorSelector), typeof(Selector<Color>), typeof(Popup), new Selector<Color>(), propertyChanged: (bindable, oldValue, newValue) =>
111         {
112             var instance = (Popup)bindable;
113             if (newValue != null)
114             {
115                 instance.Style.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
116                 instance.btGroup.OverLayBackgroundColorSelector = (Selector<Color>)newValue;
117             }
118         },
119         defaultValueCreator: (bindable) =>
120         {
121             var instance = (Popup)bindable;
122             return instance.Style?.Buttons?.Overlay?.BackgroundColor;
123         });
124
125         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public static readonly BindableProperty ButtonTextAlignmentProperty = BindableProperty.Create(nameof(ButtonTextAlignment), typeof(HorizontalAlignment), typeof(Popup), new HorizontalAlignment(), propertyChanged: (bindable, oldValue, newValue) =>
128         {
129             var instance = (Popup)bindable;
130             if (newValue != null)
131             {
132                 instance.Style.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
133                 instance.btGroup.ItemTextAlignment = (HorizontalAlignment)newValue;
134             }
135         },
136         defaultValueCreator: (bindable) =>
137         {
138             var instance = (Popup)bindable;
139             return instance.Style?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
140         });
141
142         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public static readonly BindableProperty ButtonBackgroundProperty = BindableProperty.Create(nameof(ButtonBackground), typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
145         {
146             var instance = (Popup)bindable;
147             if (newValue != null)
148             {
149                 if (instance.Style.Buttons.BackgroundImage == null)
150                 {
151                     instance.Style.Buttons.BackgroundImage = new Selector<string>();
152                 }
153                 instance.btGroup.ItemBackgroundImageUrl = (string)newValue;
154                 instance.Style.Buttons.BackgroundImage = (string)newValue;
155             }
156         },
157         defaultValueCreator: (bindable) =>
158         {
159             var instance = (Popup)bindable;
160             return instance.Style?.Buttons?.BackgroundImage?.All;
161         });
162
163         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
164         [EditorBrowsable(EditorBrowsableState.Never)]
165         public static readonly BindableProperty ButtonBackgroundBorderProperty = BindableProperty.Create(nameof(ButtonBackgroundBorder), typeof(Rectangle), typeof(Popup), new Rectangle(0, 0, 0, 0), propertyChanged: (bindable, oldValue, newValue) =>
166         {
167             var instance = (Popup)bindable;
168             if (newValue != null)
169             {
170                 if (instance.Style.Buttons.BackgroundImageBorder == null)
171                 {
172                     instance.Style.Buttons.BackgroundImageBorder = new Selector<Rectangle>();
173                 }
174                 instance.Style.Buttons.BackgroundImageBorder = (Rectangle)newValue;
175                 instance.btGroup.ItemBackgroundBorder = (Rectangle)newValue;
176             }
177         },
178         defaultValueCreator: (bindable) =>
179         {
180             var instance = (Popup)bindable;
181             return instance.Style?.Buttons?.BackgroundImageBorder?.All;
182         });
183
184         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
185         [EditorBrowsable(EditorBrowsableState.Never)]
186         public static readonly BindableProperty ButtonImageShadowProperty = BindableProperty.Create(nameof(ButtonImageShadow), typeof(ImageShadow), typeof(Popup), null, propertyChanged: (bindable, oldValue, newValue) =>
187         {
188             var instance = (Popup)bindable;
189             ImageShadow shadow = (ImageShadow)newValue;
190             instance.btGroup.ItemImageShadow = new ImageShadow(shadow);
191             instance.Style.Buttons.ImageShadow = new ImageShadow(shadow);
192         },
193         defaultValueCreator: (bindable) =>
194         {
195             var instance = (Popup)bindable;
196             return instance.Style?.Buttons?.ImageShadow?.All;
197         });
198
199
200         private TextLabel titleText;
201         private ButtonGroup btGroup = null;
202         private Window window = null;
203         private Layer container = new Layer();
204         static Popup() { }
205
206         /// <summary>
207         /// Creates a new instance of a Popup.
208         /// </summary>
209         /// <since_tizen> 6 </since_tizen>
210         [Obsolete("Deprecated in API8; Will be removed in API10")]
211         public Popup() : base()
212         {
213             Initialize();
214         }
215
216         /// <summary>
217         /// Creates a new instance of a Popup with style.
218         /// </summary>
219         /// <param name="style">Create Popup by special style defined in UX.</param>
220         [EditorBrowsable(EditorBrowsableState.Never)]
221         public Popup(string style) : base(style)
222         {
223             Initialize();
224         }
225
226         /// <summary>
227         /// Creates a new instance of a Popup with style.
228         /// </summary>
229         /// <param name="popupStyle">Create Popup by style customized by user.</param>
230         [EditorBrowsable(EditorBrowsableState.Never)]
231         public Popup(PopupStyle popupStyle) : base(popupStyle)
232         {
233             Initialize();
234         }
235
236         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
237         [EditorBrowsable(EditorBrowsableState.Never)]
238         public virtual void Post(Window targetWindow)
239         {
240             if (targetWindow == null)
241             {
242                 return;
243             }
244
245             window = targetWindow;
246             window.AddLayer(container);
247             container.RaiseToTop();
248         }
249
250         /// <summary>
251         /// Dismiss the dialog
252         /// </summary>
253         [EditorBrowsable(EditorBrowsableState.Never)]
254         public virtual void Dismiss()
255         {
256             if (window == null)
257             {
258                 return;
259             }
260
261             window.RemoveLayer(container);
262             window = null;
263         }
264
265         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
266         [EditorBrowsable(EditorBrowsableState.Never)]
267         public void AddButton(string buttonText)
268         {
269             if (Style.Buttons != null)
270             {
271                 Button btn = new Button(Style.Buttons);
272                 btn.Style.Text.Text = buttonText;
273                 btn.ClickEvent += ButtonClickEvent;
274                 btGroup.AddItem(btn);
275                 UpdateView();
276             }
277         }
278
279         /// <summary>
280         /// Add button by style's name.
281         /// </summary>
282         [EditorBrowsable(EditorBrowsableState.Never)]
283         public void AddButton(string buttonText, string style)
284         {
285             AddButton(buttonText);
286         }
287
288         /// <summary>
289         /// Add button by style.
290         /// </summary>
291         [EditorBrowsable(EditorBrowsableState.Never)]
292         public void AddButton(string buttonText, ButtonStyle style)
293         {
294             if (Style.Buttons != null && style != null)
295             {
296                 Style.Buttons.CopyFrom(style);
297                 AddButton(buttonText);
298             }
299         }
300
301         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
302         [EditorBrowsable(EditorBrowsableState.Never)]
303         public Button GetButton(int index)
304         {
305             return btGroup.GetItem(index);
306         }
307
308         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
309         [EditorBrowsable(EditorBrowsableState.Never)]
310         public void RemoveButton(int index)
311         {
312             btGroup.RemoveItem(index);
313         }
314
315         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
316         [EditorBrowsable(EditorBrowsableState.Never)]
317         public void AddContentText(View childView)
318         {
319             if (null != ContentView)
320             {
321                 ContentView.Add(childView);
322             }
323             UpdateView();
324         }
325
326         /// <summary>
327         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
328         /// </summary>
329         /// <since_tizen> 6 </since_tizen>
330         [Obsolete("Deprecated in API8; Will be removed in API10")]
331         public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
332
333         /// <summary>
334         /// Get style of popup.
335         /// </summary>
336         [EditorBrowsable(EditorBrowsableState.Never)]
337         public new PopupStyle Style => ViewStyle as PopupStyle;
338
339         /// <summary>
340         /// Popup Title.
341         /// </summary>
342         [EditorBrowsable(EditorBrowsableState.Never)]
343         public TextLabel Title
344         {
345             get
346             {
347                 if (null == titleText)
348                 {
349                     titleText = new TextLabel();
350                     Add(titleText);
351                 }
352                 return titleText;
353             }
354             internal set
355             {
356                 titleText = value;
357             }
358         }
359
360         /// <summary>
361         /// Title text string in Popup.
362         /// </summary>
363         /// <since_tizen> 6 </since_tizen>
364         [Obsolete("Deprecated in API8; Will be removed in API10")]
365         public string TitleText
366         {
367             get
368             {
369                 return Style?.Title?.Text?.All;
370             }
371             set
372             {
373                 if (value != null)
374                 {
375                     if (Style?.Title != null)
376                     {
377                         Style.Title.Text = value;
378                     }
379                 }
380             }
381         }
382
383         /// <summary>
384         /// Title text point size in Popup.
385         /// </summary>
386         /// <since_tizen> 6 </since_tizen>
387         [Obsolete("Deprecated in API8; Will be removed in API10")]
388         public float TitlePointSize
389         {
390             get
391             {
392                 return Style?.Title?.PointSize?.All ?? 0;
393             }
394             set
395             {
396                 if (Style?.Title != null)
397                 {
398                     Style.Title.PointSize = value;
399                 }
400             }
401         }
402
403         /// <summary>
404         /// Title text color in Popup.
405         /// </summary>
406         /// <since_tizen> 6 </since_tizen>
407         [Obsolete("Deprecated in API8; Will be removed in API10")]
408         public Color TitleTextColor
409         {
410             get
411             {
412                 return Style?.Title?.TextColor?.All;
413             }
414             set
415             {
416                 if (Style?.Title != null)
417                 {
418                     Style.Title.TextColor = value;
419                 }
420             }
421         }
422
423         /// <summary>
424         /// Title text horizontal alignment in Popup.
425         /// </summary>
426         /// <since_tizen> 6 </since_tizen>
427         [Obsolete("Deprecated in API8; Will be removed in API10")]
428         public HorizontalAlignment TitleTextHorizontalAlignment
429         {
430             get
431             {
432                 return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
433             }
434             set
435             {
436                 Style.Title.HorizontalAlignment = value;
437             }
438         }
439
440         /// <summary>
441         /// Title text's position in Popup.
442         /// </summary>
443         /// <since_tizen> 6 </since_tizen>
444         [Obsolete("Deprecated in API8; Will be removed in API10")]
445         public Position TitleTextPosition
446         {
447             get
448             {
449                 return Style?.Title?.Position ?? new Position(0, 0, 0);
450             }
451             set
452             {
453                 Style.Title.Position = value;
454             }
455         }
456
457         /// <summary>
458         /// Title text's height in Popup.
459         /// </summary>
460         /// <since_tizen> 6 </since_tizen>
461         [Obsolete("Deprecated in API8; Will be removed in API10")]
462         public int TitleHeight
463         {
464             get
465             {
466                 return (int)(Style?.Title?.Size?.Height ?? 0);
467             }
468             set
469             {
470                 if (Style?.Title?.Size != null)
471                 {
472                      Style.Title.Size.Height = value;
473                 }
474             }
475         }
476
477         /// <summary>
478         /// Content view in Popup, only can be gotten.
479         /// </summary>
480         /// <since_tizen> 6 </since_tizen>
481         [Obsolete("Deprecated in API8; Will be removed in API10")]
482         public View ContentView
483         {
484             get;
485             private set;
486         }
487
488         /// <summary>
489         /// Button count in Popup.
490         /// </summary>
491         /// <since_tizen> 6 </since_tizen>
492         [Obsolete("Deprecated in API8; Will be removed in API10")]
493         public int ButtonCount
494         {
495             get;
496             set;
497         }
498
499         /// <summary>
500         /// Button height in Popup.
501         /// </summary>
502         /// <since_tizen> 6 </since_tizen>
503         [Obsolete("Deprecated in API8; Will be removed in API10")]
504         public int ButtonHeight
505         {
506             get
507             {
508                 return (int)GetValue(ButtonHeightProperty);
509             }
510             set
511             {
512                 SetValue(ButtonHeightProperty, value);
513             }
514         }
515
516         /// <summary>
517         /// Button text point size in Popup.
518         /// </summary>
519         /// <since_tizen> 6 </since_tizen>
520         [Obsolete("Deprecated in API8; Will be removed in API10")]
521         public float ButtonTextPointSize
522         {
523             get
524             {
525                 return (float)GetValue(ButtonTextPointSizeProperty);
526             }
527             set
528             {
529                 SetValue(ButtonTextPointSizeProperty, value);
530             }
531         }
532
533         /// <summary>
534         /// Button text font family in Popup.
535         /// </summary>
536         /// <since_tizen> 6 </since_tizen>
537         [Obsolete("Deprecated in API8; Will be removed in API10")]
538         public string ButtonFontFamily
539         {
540             get
541             {           
542                 return (string)GetValue(ButtonFontFamilyProperty);
543             }
544             set
545             {
546                 SetValue(ButtonFontFamilyProperty, value);
547             }
548         }
549
550         /// <summary>
551         /// Button text color in Popup.
552         /// </summary>
553         /// <since_tizen> 6 </since_tizen>
554         [Obsolete("Deprecated in API8; Will be removed in API10")]
555         public Color ButtonTextColor
556         {
557             get
558             {
559                 return (Color)GetValue(ButtonTextColorProperty);
560             }
561             set
562             {
563                 SetValue(ButtonTextColorProperty, value);
564             }
565         }
566
567         /// <summary>
568         /// Button overlay background color selector in Popup.
569         /// </summary>
570         /// <since_tizen> 6 </since_tizen>
571         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
572         [EditorBrowsable(EditorBrowsableState.Never)]
573         public Selector<Color> ButtonOverLayBackgroundColorSelector
574         {
575             get
576             {
577                 return (Selector<Color>)GetValue(ButtonOverLayBackgroundColorSelectorProperty);
578             }
579             set
580             {
581                 SetValue(ButtonOverLayBackgroundColorSelectorProperty, value);
582             }
583         }
584
585         /// <summary>
586         /// Button text horizontal alignment in Popup.
587         /// </summary>
588         /// <since_tizen> 6 </since_tizen>
589         [Obsolete("Deprecated in API8; Will be removed in API10")]
590         public HorizontalAlignment ButtonTextAlignment
591         {
592             get
593             {   
594                 return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
595             }
596             set
597             {
598                 SetValue(ButtonTextAlignmentProperty, value);
599             }
600         }
601
602         /// <summary>
603         /// Button background image's resource url in Popup.
604         /// </summary>
605         /// <since_tizen> 6 </since_tizen>
606         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
607         [EditorBrowsable(EditorBrowsableState.Never)]
608         public string ButtonBackground
609         {
610             get
611             {     
612                 return (string)GetValue(ButtonBackgroundProperty);
613             }
614             set
615             {
616                 SetValue(ButtonBackgroundProperty, value);
617             }
618         }
619
620         /// <summary>
621         /// Button background image's border in Popup.
622         /// </summary>
623         /// <since_tizen> 6 </since_tizen>
624         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
625         [EditorBrowsable(EditorBrowsableState.Never)]
626         public Rectangle ButtonBackgroundBorder
627         {
628             get
629             {
630                 
631                 return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
632             }
633             set
634             {
635                 SetValue(ButtonBackgroundBorderProperty, value);
636             }
637         }
638
639         /// <summary>
640         /// Button's image shadow in Popup.
641         /// </summary>
642         /// <since_tizen> 6 </since_tizen>
643         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
644         [EditorBrowsable(EditorBrowsableState.Never)]
645         public ImageShadow ButtonImageShadow
646         {
647             get => (ImageShadow)GetValue(ButtonImageShadowProperty);
648             set => SetValue(ButtonImageShadowProperty, value);
649         }
650
651
652         /// <summary>
653         /// Set button text by index.
654         /// </summary>
655         /// <param name="index">Button index.</param>
656         /// <param name="text">Button text string.</param>
657         /// <since_tizen> 6 </since_tizen>
658         [Obsolete("Deprecated in API8; Will be removed in API10")]
659         public void SetButtonText(int index, string text)
660         {
661             AddButton(text);
662         }
663
664         /// <summary>
665         /// Dispose Popup and all children on it.
666         /// </summary>
667         /// <param name="type">Dispose type.</param>
668         /// <since_tizen> 6 </since_tizen>
669         [Obsolete("Deprecated in API8; Will be removed in API10")]
670         protected override void Dispose(DisposeTypes type)
671         {
672             if (disposed)
673             {
674                 return;
675             }
676
677             if (type == DisposeTypes.Explicit)
678             {
679                 if (titleText != null)
680                 {
681                     Remove(titleText);
682                     titleText.Dispose();
683                     titleText = null;
684                 }
685                 if (ContentView != null)
686                 {
687                     Remove(ContentView);
688                     ContentView.Dispose();
689                     ContentView = null;
690                 }
691
692                 if (btGroup != null)
693                 {
694                     btGroup.Dispose();
695                     btGroup = null;
696                 }
697             }
698
699             base.Dispose(type);
700         }
701
702         /// <summary>
703         /// Focus gained callback.
704         /// </summary>
705         /// <since_tizen> 6 </since_tizen>
706         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
707         [EditorBrowsable(EditorBrowsableState.Never)]
708         public override void OnFocusGained()
709         {
710             base.OnFocusGained();
711         }
712
713         /// <summary>
714         /// Focus lost callback.
715         /// </summary>
716         /// <since_tizen> 6 </since_tizen>
717         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
718         [EditorBrowsable(EditorBrowsableState.Never)]
719         public override void OnFocusLost()
720         {
721             base.OnFocusLost();
722         }
723
724         /// <summary>
725         /// Apply style to popup.
726         /// </summary>
727         /// <param name="viewStyle">The style to apply.</param>
728         [EditorBrowsable(EditorBrowsableState.Never)]
729         public override void ApplyStyle(ViewStyle viewStyle)
730         {
731             base.ApplyStyle(viewStyle);
732             PopupStyle ppStyle = viewStyle as PopupStyle;
733             if (null != ppStyle)
734             {
735                 Title.ApplyStyle(ppStyle.Title);
736                 Title.RaiseToTop();
737             }
738         }
739
740         /// <summary>
741         /// Get Popup style.
742         /// </summary>
743         /// <returns>The default popup style.</returns>
744         [EditorBrowsable(EditorBrowsableState.Never)]
745         protected override ViewStyle CreateViewStyle()
746         {
747             return new PopupStyle();
748         }
749
750         /// <summary>
751         /// Theme change callback when theme is changed, this callback will be trigger.
752         /// </summary>
753         /// <param name="sender">The sender</param>
754         /// <param name="e">The event data</param>
755         [EditorBrowsable(EditorBrowsableState.Never)]
756         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
757         {
758             PopupStyle popupStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle;
759             if (popupStyle != null)
760             {
761                 string strSaveTitleText = TitleText;
762                 Style.CopyFrom(popupStyle);
763                 Style.Title.Text = strSaveTitleText;
764                 UpdateView();
765             }
766         }
767
768         private void Initialize()
769         {
770             container.Add(this);
771             container.SetTouchConsumed(true);
772             container.SetHoverConsumed(true);
773
774             LeaveRequired = true;
775             PropertyChanged += PopupStylePropertyChanged;
776
777             // ContentView
778             ContentView = new View()
779             {
780                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
781                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
782                 PositionUsesPivotPoint = true
783             };
784             Add(ContentView);
785             ContentView.RaiseToTop();
786
787             // Button
788             btGroup = new ButtonGroup(this);
789         }
790
791         private void UpdateView()
792         {
793             btGroup.UpdateButton(Style.Buttons);
794             UpdateContentView();
795             UpdateTitle();
796         }
797
798         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
799         {
800             if (PopupButtonClickEvent != null && btGroup.Count > 0)
801             {
802                 Button button = sender as Button;
803                 for (int i = 0; i < btGroup.Count; i++)
804                 {
805                     if (button == GetButton(i))
806                     {
807                         ButtonClickEventArgs args = new ButtonClickEventArgs();
808                         args.ButtonIndex = i;
809                         PopupButtonClickEvent(this, args);
810                     }
811                 }
812             }
813         }
814
815         private void PopupStylePropertyChanged(object sender, PropertyChangedEventArgs e)
816         {
817             if (e.PropertyName.Equals("LayoutDirection"))
818             {
819                 btGroup.UpdateButton(Style.Buttons);
820             }
821         }
822
823         private void UpdateContentView()
824         {
825             int titleX = 0;
826             int titleY = 0;
827             int titleH = 0;
828             int buttonH = 0;
829             string strText = Style.Title.Text.All;
830             if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
831             {
832                 titleH = (int)titleText.Size.Height;
833             }
834
835             if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
836             {
837                 titleX = (int)Style.Title.Position.X;
838                 titleY = (int)Style.Title.Position.Y;
839             }
840
841             if (btGroup.Count != 0 && Style?.Buttons?.Size != null )
842             {
843                 buttonH = (int)Style.Buttons.Size.Height;
844             }
845             ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
846             ContentView.Position = new Position(titleX, titleY + titleH);
847             ContentView.RaiseToTop();
848         }
849
850         private void UpdateTitle()
851         {
852             if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
853             {
854                 titleText.RaiseToTop();
855             }
856         }
857         /// <summary>
858         /// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.
859         /// </summary>
860         /// <since_tizen> 6 </since_tizen>
861         [Obsolete("Deprecated in API8; Will be removed in API10")]
862         public class ButtonClickEventArgs : EventArgs
863         {
864             /// <summary> Button index which is clicked in Popup </summary>
865             /// <since_tizen> 6 </since_tizen>
866             [Obsolete("Deprecated in API8; Will be removed in API10")]
867             public int ButtonIndex;
868         }
869     }
870 }