[NUI.Components] Fix build warnings (#1233)
[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(nameof(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(nameof(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(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.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(nameof(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(nameof(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(nameof(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(nameof(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(nameof(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(nameof(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             if (null == win) return;
269             window = win;
270             window.Add(this);
271         }
272
273         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
274         [EditorBrowsable(EditorBrowsableState.Never)]
275         public void AddButton(string buttonText)
276         {
277             if (Style.Buttons != null)
278             {
279                 Button btn = new Button(Style.Buttons);
280                 btn.Style.Text.Text = buttonText;
281                 btn.ClickEvent += ButtonClickEvent;
282                 btGroup.AddItem(btn);
283                 UpdateView();
284             }
285         }
286
287         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
288         [EditorBrowsable(EditorBrowsableState.Never)]
289         public void AddButton(string buttonText, string style)
290         {
291             AddButton(buttonText);
292         }
293
294         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
295         [EditorBrowsable(EditorBrowsableState.Never)]
296         public void AddButton(string buttonText, ButtonStyle style)
297         {
298             if (Style.Buttons != null && style != null)
299             {
300                 Style.Buttons.CopyFrom(style);
301                 AddButton(buttonText);
302             }
303         }
304
305         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
306         [EditorBrowsable(EditorBrowsableState.Never)]
307         public Button GetButton(int index)
308         {
309             return btGroup.GetItem(index);
310         }
311
312         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
313         [EditorBrowsable(EditorBrowsableState.Never)]
314         public void RemoveButton(int index)
315         {
316             btGroup.RemoveItem(index);
317         }
318
319         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
320         [EditorBrowsable(EditorBrowsableState.Never)]
321         public void AddContentText(View childView)
322         {
323             if (null != ContentView)
324             {
325                 ContentView.Add(childView);
326             }
327             UpdateView();
328         }
329
330         /// <summary>
331         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
332         /// </summary>
333         /// <since_tizen> 6 </since_tizen>
334         public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
335
336         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
337         [EditorBrowsable(EditorBrowsableState.Never)]
338         public new PopupStyle Style => ViewStyle as PopupStyle;
339
340         /// <summary>
341         /// Title text string in Popup.
342         /// </summary>
343         /// <since_tizen> 6 </since_tizen>
344         public string TitleText
345         {
346             get
347             {
348                 return Style?.Title?.Text?.All;
349             }
350             set
351             {
352                 if (value != null)
353                 {
354                     if (Style.Title.Text == null)
355                     {
356                         Style.Title.Text = new Selector<string>();
357                     }
358                     Style.Title.Text.All = value;
359                 }
360             }
361         }
362
363         /// <summary>
364         /// Title text point size in Popup.
365         /// </summary>
366         /// <since_tizen> 6 </since_tizen>
367         public float TitlePointSize
368         {
369             get
370             {
371                 return Style?.Title?.PointSize?.All ?? 0;
372             }
373             set
374             {
375                 if (Style.Title.PointSize == null)
376                 {
377                     Style.Title.PointSize = new Selector<float?>();
378                 }
379                 Style.Title.PointSize.All = value;
380             }
381         }
382
383         /// <summary>
384         /// Title text color in Popup.
385         /// </summary>
386         /// <since_tizen> 6 </since_tizen>
387         public Color TitleTextColor
388         {
389             get
390             {
391                 return Style?.Title?.TextColor?.All;
392             }
393             set
394             {
395                 if (Style.Title.TextColor == null)
396                 {
397                     Style.Title.TextColor = new Selector<Color>();
398                 }
399                 Style.Title.TextColor.All = value;
400             }
401         }
402
403         /// <summary>
404         /// Title text horizontal alignment in Popup.
405         /// </summary>
406         /// <since_tizen> 6 </since_tizen>
407         public HorizontalAlignment TitleTextHorizontalAlignment
408         {
409             get
410             {
411                 return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
412             }
413             set
414             {
415                 Style.Title.HorizontalAlignment = value;
416             }
417         }
418
419         /// <summary>
420         /// Title text's position in Popup.
421         /// </summary>
422         /// <since_tizen> 6 </since_tizen>
423         public Position TitleTextPosition
424         {
425             get
426             {
427                 return Style?.Title?.Position ?? new Position(0, 0, 0);
428             }
429             set
430             {
431                 Style.Title.Position = value;
432             }
433         }
434
435         /// <summary>
436         /// Title text's height in Popup.
437         /// </summary>
438         /// <since_tizen> 6 </since_tizen>
439         public int TitleHeight
440         {
441             get
442             {
443                 return (int)(Style?.Title?.Size?.Height ?? 0);
444             }
445             set
446             {
447                 Style.Title.Size.Height = value;
448             }
449         }
450
451         /// <summary>
452         /// Content view in Popup, only can be gotten.
453         /// </summary>
454         /// <since_tizen> 6 </since_tizen>
455         public View ContentView
456         {
457             get;
458             private set;
459         }
460
461         /// <summary>
462         /// Button count in Popup.
463         /// </summary>
464         /// <since_tizen> 6 </since_tizen>
465         public int ButtonCount
466         {
467             get;
468             set;
469         }
470
471         /// <summary>
472         /// Shadow offset in Popup, including left, right, up and bottom offset.
473         /// </summary>
474         /// <since_tizen> 6 </since_tizen>
475         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
476         [EditorBrowsable(EditorBrowsableState.Never)]
477         public Vector4 ShadowOffset
478         {
479             get;
480             set;
481         }
482
483         /// <summary>
484         /// Button height in Popup.
485         /// </summary>
486         /// <since_tizen> 6 </since_tizen>
487         public int ButtonHeight
488         {
489             get
490             {
491                 return (int)GetValue(ButtonHeightProperty);
492             }
493             set
494             {
495                 SetValue(ButtonHeightProperty, value);
496             }
497         }
498
499         /// <summary>
500         /// Button text point size in Popup.
501         /// </summary>
502         /// <since_tizen> 6 </since_tizen>
503         public float ButtonTextPointSize
504         {
505             get
506             {
507                 return (float)GetValue(ButtonTextPointSizeProperty);
508             }
509             set
510             {
511                 SetValue(ButtonTextPointSizeProperty, value);
512             }
513         }
514
515         /// <summary>
516         /// Button text font family in Popup.
517         /// </summary>
518         /// <since_tizen> 6 </since_tizen>
519         public string ButtonFontFamily
520         {
521             get
522             {           
523                 return (string)GetValue(ButtonFontFamilyProperty);
524             }
525             set
526             {
527                 SetValue(ButtonFontFamilyProperty, value);
528             }
529         }
530
531         /// <summary>
532         /// Button text color in Popup.
533         /// </summary>
534         /// <since_tizen> 6 </since_tizen>
535         public Color ButtonTextColor
536         {
537             get
538             {
539                 return (Color)GetValue(ButtonTextColorProperty);
540             }
541             set
542             {
543                 SetValue(ButtonTextColorProperty, value);
544             }
545         }
546
547         /// <summary>
548         /// Button overlay background color selector in Popup.
549         /// </summary>
550         /// <since_tizen> 6 </since_tizen>
551         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
552         [EditorBrowsable(EditorBrowsableState.Never)]
553         public Selector<Color> ButtonOverLayBackgroundColorSelector
554         {
555             get
556             {
557                 return (Selector<Color>)GetValue(ButtonOverLayBackgroundColorSelectorProperty);
558             }
559             set
560             {
561                 SetValue(ButtonOverLayBackgroundColorSelectorProperty, value);
562             }
563         }
564
565         /// <summary>
566         /// Button text horizontal alignment in Popup.
567         /// </summary>
568         /// <since_tizen> 6 </since_tizen>
569         public HorizontalAlignment ButtonTextAlignment
570         {
571             get
572             {   
573                 return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
574             }
575             set
576             {
577                 SetValue(ButtonTextAlignmentProperty, value);
578             }
579         }
580
581         /// <summary>
582         /// Button background image's resource url in Popup.
583         /// </summary>
584         /// <since_tizen> 6 </since_tizen>
585         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
586         [EditorBrowsable(EditorBrowsableState.Never)]
587         public string ButtonBackground
588         {
589             get
590             {     
591                 return (string)GetValue(ButtonBackgroundProperty);
592             }
593             set
594             {
595                 SetValue(ButtonBackgroundProperty, value);
596             }
597         }
598
599         /// <summary>
600         /// Button background image's border in Popup.
601         /// </summary>
602         /// <since_tizen> 6 </since_tizen>
603         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
604         [EditorBrowsable(EditorBrowsableState.Never)]
605         public Rectangle ButtonBackgroundBorder
606         {
607             get
608             {
609                 
610                 return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
611             }
612             set
613             {
614                 SetValue(ButtonBackgroundBorderProperty, value);
615             }
616         }
617
618         /// <summary>
619         /// Button shadow's resource url in Popup.
620         /// </summary>
621         /// <since_tizen> 6 </since_tizen>
622         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
623         [EditorBrowsable(EditorBrowsableState.Never)]
624         public string ButtonShadow
625         {
626             get
627             {
628                 return (string)GetValue(ButtonShadowProperty);
629             }
630             set
631             {
632                 SetValue(ButtonShadowProperty, value);
633             }
634         }
635
636         /// <summary>
637         /// Button shadow's border in Popup.
638         /// </summary>
639         /// <since_tizen> 6 </since_tizen>
640         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
641         [EditorBrowsable(EditorBrowsableState.Never)]
642         public Rectangle ButtonShadowBorder
643         {
644             get
645             {
646
647                 return (Rectangle)GetValue(ButtonShadowBorderProperty);
648             }
649             set
650             {
651                 SetValue(ButtonShadowBorderProperty, value);
652             }
653         }
654
655         /// <summary>
656         /// Set button text by index.
657         /// </summary>
658         /// <param name="index">Button index.</param>
659         /// <param name="text">Button text string.</param>
660         /// <since_tizen> 6 </since_tizen>
661         public void SetButtonText(int index, string 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         protected override void Dispose(DisposeTypes type)
670         {
671             if (disposed)
672             {
673                 return;
674             }
675
676             if (type == DisposeTypes.Explicit)
677             {
678                 if (titleText != null)
679                 {
680                     Remove(titleText);
681                     titleText.Dispose();
682                     titleText = null;
683                 }
684                 if (ContentView != null)
685                 {
686                     Remove(ContentView);
687                     ContentView.Dispose();
688                     ContentView = null;
689                 }
690
691                 if (btGroup != null)
692                 {
693                     btGroup.Dispose();
694                     btGroup = null;
695                 }
696             }
697
698             base.Dispose(type);
699         }
700
701         /// <summary>
702         /// Focus gained callback.
703         /// </summary>
704         /// <since_tizen> 6 </since_tizen>
705         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
706         [EditorBrowsable(EditorBrowsableState.Never)]
707         public override void OnFocusGained()
708         {
709             base.OnFocusGained();
710         }
711
712         /// <summary>
713         /// Focus lost callback.
714         /// </summary>
715         /// <since_tizen> 6 </since_tizen>
716         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
717         [EditorBrowsable(EditorBrowsableState.Never)]
718         public override void OnFocusLost()
719         {
720             base.OnFocusLost();
721         }
722
723         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
724         [EditorBrowsable(EditorBrowsableState.Never)]
725         public override void ApplyStyle(ViewStyle viewStyle)
726         {
727             base.ApplyStyle(viewStyle);
728             PopupStyle ppStyle = viewStyle as PopupStyle;
729             if (null != ppStyle)
730             {
731                 if (null == titleText)
732                 {
733                     titleText = new TextLabel();
734                     Add(titleText);
735                 }
736                 titleText.RaiseToTop();
737                 titleText.ApplyStyle(ppStyle.Title);
738             }
739         }
740
741         /// <summary>
742         /// Get Popup attribues.
743         /// </summary>
744         /// <since_tizen> 6 </since_tizen>
745         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
746         [EditorBrowsable(EditorBrowsableState.Never)]
747         protected override ViewStyle GetViewStyle()
748         {
749             return new PopupStyle();
750         }
751
752         /// <summary>
753         /// Theme change callback when theme is changed, this callback will be trigger.
754         /// </summary>
755         /// <since_tizen> 6 </since_tizen>
756         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
757         [EditorBrowsable(EditorBrowsableState.Never)]
758         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
759         {
760             PopupStyle tempAttributes = StyleManager.Instance.GetViewStyle(style) as PopupStyle;
761             if (tempAttributes != null)
762             {
763                 string strSaveTitleText = TitleText;
764                 Style.CopyFrom(tempAttributes);
765                 Style.Title.Text = strSaveTitleText;
766                 UpdateView();
767             }
768         }
769
770         private void Initialize()
771         {
772             LeaveRequired = true;
773             PropertyChanged += PopupAttributesPropertyChanged;
774
775             // ContentView
776             ContentView = new View()
777             {
778                 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
779                 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
780                 PositionUsesPivotPoint = true
781             };
782             Add(ContentView);
783             ContentView.RaiseToTop();
784
785             // Title
786             if (null == titleText)
787             {
788                 titleText = new TextLabel();
789                 titleText.RaiseToTop();
790                 Add(titleText);
791             }
792
793             // Button
794             btGroup = new ButtonGroup(this);
795         }
796
797         private void UpdateView()
798         {
799             UpdateShadowExtens();
800             btGroup.UpdateButton(Style.Buttons);
801             UpdateContentView();
802             UpdateTitle();
803         }
804
805         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
806         {
807             if (PopupButtonClickEvent != null && btGroup.Count > 0)
808             {
809                 Button button = sender as Button;
810                 for (int i = 0; i < btGroup.Count; i++)
811                 {
812                     if (button == GetButton(i))
813                     {
814                         ButtonClickEventArgs args = new ButtonClickEventArgs();
815                         args.ButtonIndex = i;
816                         PopupButtonClickEvent(this, args);
817                     }
818                 }
819             }
820         }
821
822         private void PopupAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
823         {
824             if (e.PropertyName.Equals("LayoutDirection"))
825             {
826                 btGroup.UpdateButton(Style.Buttons);
827             }
828         }
829
830         private void UpdateContentView()
831         {
832             int titleX = 0;
833             int titleY = 0;
834             int titleH = 0;
835             int buttonH = 0;
836             string strText = Style.Title.Text.All;
837             if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
838             {
839                 titleH = (int)titleText.Size.Height;
840             }
841
842             if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
843             {
844                 titleX = (int)Style.Title.Position.X;
845                 titleY = (int)Style.Title.Position.Y;
846             }
847
848             if (btGroup.Count != 0)
849             {
850                 buttonH = (int)Style.Buttons.Size.Height;
851             }
852             ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
853             ContentView.Position = new Position(titleX, titleY + titleH);
854             ContentView.RaiseToTop();
855         }
856
857         private void UpdateShadowExtens()
858         {
859             if (Style.ShadowExtents != null)
860             {
861                 Style.Shadow.Size = new Size(Size.Width + Style.ShadowExtents.Start + Style.ShadowExtents.End, Size.Height + Style.ShadowExtents.Top + Style.ShadowExtents.Bottom);
862             }
863         }
864
865         private void UpdateTitle()
866         {
867             if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
868             {
869                 titleText.RaiseToTop();
870             }
871         }
872         /// <summary>
873         /// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.
874         /// </summary>
875         /// <since_tizen> 6 </since_tizen>
876         public class ButtonClickEventArgs : EventArgs
877         {
878             /// <summary> Button index which is clicked in Popup </summary>
879             /// <since_tizen> 6 </since_tizen>
880             public int ButtonIndex;
881         }
882     }
883 }