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