Merge "Add C# binding for VideoView.Underlay property."
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / FocusManager.cs
1 /*
2  * Copyright(c) 2017 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
18
19 namespace Tizen.NUI
20 {
21
22     using System;
23     using System.Runtime.InteropServices;
24     using Tizen.NUI.BaseComponents;
25     using System.ComponentModel;
26
27     /// <summary>
28     /// Provides the functionality of handling keyboard navigation and maintaining the two-dimensional keyboard focus chain.<br />
29     /// It provides functionality of setting the focus and moving the focus in four directions( i.e., left, right, up, and down).<br />
30     /// It also draws a highlight for the focused view and sends an event when the focus is changed.<br />
31     /// </summary>
32     public class FocusManager : BaseHandle
33     {
34         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35         private CustomAlgorithmInterfaceWrapper _customAlgorithmInterfaceWrapper;
36
37         internal FocusManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicManualPINVOKE.FocusManager_SWIGUpcast(cPtr), cMemoryOwn)
38         {
39             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40         }
41
42         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FocusManager obj)
43         {
44             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45         }
46
47         /// <summary>
48         /// To make the FocusManager instance be disposed.
49         /// </summary>
50         protected override void Dispose(DisposeTypes type)
51         {
52             if(disposed)
53             {
54                 return;
55             }
56
57             if(type == DisposeTypes.Explicit)
58             {
59                 //Called by User
60                 //Release your own managed resources here.
61                 //You should release all of your own disposable objects here.
62             }
63
64             //Release your own unmanaged resources here.
65             //You should not access any managed member here except static instance.
66             //because the execution order of Finalizes is non-deterministic.
67
68             if (_focusedViewEnterKeyEventCallback2 != null)
69             {
70                 FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback2);
71             }
72
73             if (_focusedViewEnterKeyEventCallback != null)
74             {
75                 FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback);
76             }
77
78             if (_focusGroupChangedEventCallback != null)
79             {
80                 FocusGroupChangedSignal().Disconnect(_focusGroupChangedEventCallback);
81             }
82
83             if (_focusChangedEventCallback != null)
84             {
85                 FocusChangedSignal().Disconnect(_focusChangedEventCallback);
86             }
87
88             if (_preFocusChangeCallback != null)
89             {
90                 PreFocusChangeSignal().Disconnect(_preFocusChangeCallback);
91             }
92
93             if (swigCPtr.Handle != global::System.IntPtr.Zero)
94             {
95                 if (swigCMemOwn)
96                 {
97                     swigCMemOwn = false;
98                     NDalicManualPINVOKE.delete_FocusManager(swigCPtr);
99                 }
100                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
101             }
102
103             base.Dispose(type);
104         }
105
106
107         ///<summary>
108         /// Event arguments that passed via the PreFocusChange signal.
109         /// </summary>
110         public class PreFocusChangeEventArgs : EventArgs
111         {
112             private View _current;
113             private View _proposed;
114             private View.FocusDirection _direction;
115
116             /// <summary>
117             /// The current focus view.
118             /// </summary>
119             /// <since_tizen> 3 </since_tizen>
120             public View CurrentView
121             {
122                 get
123                 {
124                     return _current;
125                 }
126                 set
127                 {
128                     _current = value;
129                 }
130             }
131
132             /// <summary>
133             /// The  proposed view.
134             /// </summary>
135             /// <since_tizen> 3 </since_tizen>
136             public View ProposedView
137             {
138                 get
139                 {
140                     return _proposed;
141                 }
142                 set
143                 {
144                     _proposed = value;
145                 }
146             }
147
148             /// <summary>
149             /// The focus move direction.
150             /// </summary>
151             /// <since_tizen> 3 </since_tizen>
152             public View.FocusDirection Direction
153             {
154                 get
155                 {
156                     return _direction;
157                 }
158                 set
159                 {
160                     _direction = value;
161                 }
162             }
163         }
164
165         private EventHandlerWithReturnType<object, PreFocusChangeEventArgs, View> _preFocusChangeEventHandler;
166         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
167         internal delegate IntPtr PreFocusChangeEventCallback(IntPtr current, IntPtr proposed, View.FocusDirection direction);
168         private PreFocusChangeEventCallback _preFocusChangeCallback;
169
170         /// <summary>
171         /// PreFocusChange will be triggered before the focus is going to be changed.<br />
172         /// The FocusManager makes the best guess for which view to focus towards the given direction, but applications might want to change that.<br />
173         /// By connecting with this event, they can check the proposed view to focus and return a different view if they wish.<br />
174         /// This event is only triggered when the navigation key is pressed and KeyboardFocusManager tries to move the focus automatically.<br />
175         /// It won't be emitted for focus movement by calling the SetCurrentFocusView directly.<br />
176         /// </summary>
177         /// <since_tizen> 3 </since_tizen>
178         public event EventHandlerWithReturnType<object, PreFocusChangeEventArgs, View> PreFocusChange
179         {
180             add
181             {
182                 if (_preFocusChangeEventHandler == null)
183                 {
184 #if DEBUG_ON
185                     Tizen.Log.Debug("NUI", "con1) PreFocusChangeSignal().Empty = " + PreFocusChangeSignal().Empty());
186                     Tizen.Log.Debug("NUI", "con2) PreFocusChangeSignal().GetConnectionCount = " + PreFocusChangeSignal().GetConnectionCount());
187 #endif
188                     _preFocusChangeCallback = OnPreFocusChange;
189                     PreFocusChangeSignal().Connect(_preFocusChangeCallback);
190 #if DEBUG_ON
191                     Tizen.Log.Debug("NUI", "con3) PreFocusChangeSignal().Empty = " + PreFocusChangeSignal().Empty());
192                     Tizen.Log.Debug("NUI", "con4) PreFocusChangeSignal().GetConnectionCount = " + PreFocusChangeSignal().GetConnectionCount());
193 #endif
194                 }
195                 _preFocusChangeEventHandler += value;
196             }
197             remove
198             {
199                 _preFocusChangeEventHandler -= value;
200                 if (_preFocusChangeEventHandler == null && PreFocusChangeSignal().Empty() == false)
201                 {
202 #if DEBUG_ON
203                     Tizen.Log.Debug("NUI", "discon1) PreFocusChangeSignal().Empty = " + PreFocusChangeSignal().Empty());
204                     Tizen.Log.Debug("NUI", "discon2) PreFocusChangeSignal().GetConnectionCount = " + PreFocusChangeSignal().GetConnectionCount());
205 #endif
206                     PreFocusChangeSignal().Disconnect(_preFocusChangeCallback);
207 #if DEBUG_ON
208                     Tizen.Log.Debug("NUI", "discon3) PreFocusChangeSignal().Empty = " + PreFocusChangeSignal().Empty());
209                     Tizen.Log.Debug("NUI", "discon4) PreFocusChangeSignal().GetConnectionCount = " + PreFocusChangeSignal().GetConnectionCount());
210 #endif
211                 }
212             }
213         }
214
215         private IntPtr OnPreFocusChange(IntPtr current, IntPtr proposed, View.FocusDirection direction)
216         {
217             View view = null;
218             PreFocusChangeEventArgs e = new PreFocusChangeEventArgs();
219
220             if (current != global::System.IntPtr.Zero)
221             {
222                 e.CurrentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
223             }
224             if (proposed != global::System.IntPtr.Zero)
225             {
226                 e.ProposedView = Registry.GetManagedBaseHandleFromNativePtr(proposed) as View;
227             }
228             e.Direction = direction;
229
230             if (_preFocusChangeEventHandler != null)
231             {
232                 view = _preFocusChangeEventHandler(this, e);
233             }
234
235             if (view)
236             {
237                 return view.GetPtrfromView();
238             }
239             else
240             {
241                 //if (e.ProposedView) return proposed;
242                 //else return current;
243                 return current; //xb.teng
244             }
245         }
246
247         ///<summary>
248         /// Event arguments that passed via the FocusChanged signal.
249         /// </summary>
250         public class FocusChangedEventArgs : EventArgs
251         {
252             private View _current;
253             private View _next;
254
255             /// <summary>
256             /// The current focus view.
257             /// </summary>
258             /// <since_tizen> 3 </since_tizen>
259             public View CurrentView
260             {
261                 get
262                 {
263                     return _current;
264                 }
265                 set
266                 {
267                     _current = value;
268                 }
269             }
270             /// <summary>
271             /// The next focus view.
272             /// </summary>
273             /// <since_tizen> 3 </since_tizen>
274             public View NextView
275             {
276                 get
277                 {
278                     return _next;
279                 }
280                 set
281                 {
282                     _next = value;
283                 }
284             }
285         }
286
287         private EventHandler<FocusChangedEventArgs> _focusChangedEventHandler;
288         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
289         internal delegate void FocusChangedEventCallback(IntPtr current, IntPtr next);
290         private FocusChangedEventCallback _focusChangedEventCallback;
291
292         /// <summary>
293         /// The FocusGroupChanged will be triggered after the current focused view has been changed.
294         /// </summary>
295         /// <since_tizen> 3 </since_tizen>
296         public event EventHandler<FocusChangedEventArgs> FocusChanged
297         {
298             add
299             {
300                 if (_focusChangedEventCallback == null)
301                 {
302                     _focusChangedEventCallback = OnFocusChanged;
303                     FocusChangedSignal().Connect(_focusChangedEventCallback);
304                 }
305                 _focusChangedEventHandler += value;
306             }
307             remove
308             {
309                 _focusChangedEventHandler -= value;
310
311                 if (_focusChangedEventCallback == null && FocusChangedSignal().Empty() == false)
312                 {
313                     FocusChangedSignal().Disconnect(_focusChangedEventCallback);
314                 }
315             }
316         }
317
318         private void OnFocusChanged(IntPtr current, IntPtr next)
319         {
320             FocusChangedEventArgs e = new FocusChangedEventArgs();
321
322             e.CurrentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
323             e.NextView = Registry.GetManagedBaseHandleFromNativePtr(next) as View;
324
325             if (_focusChangedEventHandler != null)
326             {
327                 _focusChangedEventHandler(this, e);
328             }
329         }
330
331         ///<summary>
332         /// Event arguments that passed via the FocusGroupChanged signal.
333         /// </summary>
334         public class FocusGroupChangedEventArgs : EventArgs
335         {
336             private View _current;
337             private bool _forwardDirection;
338
339             /// <summary>
340             /// The current focus view.
341             /// </summary>
342             /// <since_tizen> 3 </since_tizen>
343             public View CurrentView
344             {
345                 get
346                 {
347                     return _current;
348                 }
349                 set
350                 {
351                     _current = value;
352                 }
353             }
354
355             /// <summary>
356             /// The forward direction.
357             /// </summary>
358             /// <since_tizen> 3 </since_tizen>
359             public bool ForwardDirection
360             {
361                 get
362                 {
363                     return _forwardDirection;
364                 }
365                 set
366                 {
367                     _forwardDirection = value;
368                 }
369             }
370         }
371
372         private EventHandler<FocusGroupChangedEventArgs> _focusGroupChangedEventHandler;
373         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
374         private delegate void FocusGroupChangedEventCallback(IntPtr current, bool forwardDirection);
375         private FocusGroupChangedEventCallback _focusGroupChangedEventCallback;
376
377         /// <summary>
378         /// The FocusGroupChanged will be triggered when the focus group has been changed.<br />
379         /// If the current focus group has a parent layout control, the FocusManager will make the best guess for the next focus group to move the focus to in the given direction (forward or backward).<br />
380         /// If not, the application has to set the new focus.<br />
381         /// </summary>
382         /// <since_tizen> 3 </since_tizen>
383         public event EventHandler<FocusGroupChangedEventArgs> FocusGroupChanged
384         {
385             add
386             {
387                 if (_focusGroupChangedEventCallback == null)
388                 {
389                     _focusGroupChangedEventCallback = OnFocusGroupChanged;
390                     FocusGroupChangedSignal().Connect(_focusGroupChangedEventCallback);
391                 }
392                 _focusGroupChangedEventHandler += value;
393             }
394             remove
395             {
396                 _focusGroupChangedEventHandler -= value;
397
398                 if (_focusGroupChangedEventCallback == null && FocusGroupChangedSignal().Empty() == false)
399                 {
400                     FocusGroupChangedSignal().Disconnect(_focusGroupChangedEventCallback);
401                 }
402             }
403         }
404
405         private void OnFocusGroupChanged(IntPtr current, bool forwardDirection)
406         {
407             FocusGroupChangedEventArgs e = new FocusGroupChangedEventArgs();
408
409             e.CurrentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
410             e.ForwardDirection = forwardDirection;
411
412             if (_focusGroupChangedEventHandler != null)
413             {
414                 _focusGroupChangedEventHandler(this, e);
415             }
416         }
417
418         ///<summary>
419         /// Event arguments that passed via the FocusedViewEnterKey signal.
420         /// </summary>
421         public class FocusedViewActivatedEventArgs : EventArgs
422         {
423             private View _view;
424
425             /// <summary>
426             /// View.
427             /// </summary>
428             /// <since_tizen> 3 </since_tizen>
429             public View View
430             {
431                 get
432                 {
433                     return _view;
434                 }
435                 set
436                 {
437                     _view = value;
438                 }
439             }
440         }
441
442         private EventHandler<FocusedViewActivatedEventArgs> _focusedViewEnterKeyEventHandler;
443         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
444         private delegate void FocusedViewEnterKeyEventCallback(IntPtr view);
445         private FocusedViewEnterKeyEventCallback _focusedViewEnterKeyEventCallback;
446
447         /// <summary>
448         /// The FocusedViewActivated will be triggered when the current focused view has the enter key pressed on it.
449         /// </summary>
450         /// <since_tizen> 4 </since_tizen>
451         public event EventHandler<FocusedViewActivatedEventArgs> FocusedViewActivated
452         {
453             add
454             {
455                 if (_focusedViewEnterKeyEventCallback == null)
456                 {
457                     _focusedViewEnterKeyEventCallback = OnFocusedViewEnterKey;
458                     FocusedViewEnterKeySignal().Connect(_focusedViewEnterKeyEventCallback);
459                 }
460                 _focusedViewEnterKeyEventHandler += value;
461             }
462             remove
463             {
464                 _focusedViewEnterKeyEventHandler -= value;
465
466                 if (_focusedViewEnterKeyEventCallback != null && FocusedViewEnterKeySignal().Empty() == false)
467                 {
468                     FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback);
469                 }
470             }
471         }
472
473         private void OnFocusedViewEnterKey(IntPtr view)
474         {
475             FocusedViewActivatedEventArgs e = new FocusedViewActivatedEventArgs();
476
477             e.View = Registry.GetManagedBaseHandleFromNativePtr(view) as View;
478
479             if (_focusedViewEnterKeyEventHandler != null)
480             {
481                 _focusedViewEnterKeyEventHandler(this, e);
482             }
483         }
484
485
486         internal FocusManager() : this(NDalicManualPINVOKE.new_FocusManager(), true)
487         {
488             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489         }
490
491         internal static FocusManager Get()
492         {
493             FocusManager ret = new FocusManager(NDalicManualPINVOKE.FocusManager_Get(), true);
494             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
495             return ret;
496         }
497
498         /// <summary>
499         /// Moves the keyboard focus to the given view.<br />
500         /// Only one view can be focused at the same time.<br />
501         /// The view must be in the stage already and keyboard focusable.<br />
502         /// </summary>
503         /// <param name="view">The view to be focused.</param>
504         /// <returns>Whether the focus is successful or not.</returns>
505         /// <since_tizen> 3 </since_tizen>
506         public bool SetCurrentFocusView(View view)
507         {
508             if(view == null)
509             {
510                 throw new ArgumentNullException("the target view should not be null");
511             }
512
513             bool ret = NDalicManualPINVOKE.FocusManager_SetCurrentFocusActor(swigCPtr, View.getCPtr(view));
514             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
515             return ret;
516         }
517
518         /// <summary>
519         /// Gets the current focused view.
520         /// </summary>
521         /// <returns>A handle to the current focused view or an empty handle if no view is focused.</returns>
522         /// <since_tizen> 3 </since_tizen>
523         public View GetCurrentFocusView()
524         {
525             IntPtr cPtr = NDalicManualPINVOKE.FocusManager_GetCurrentFocusActor(swigCPtr);
526
527             View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
528             return ret;
529         }
530
531         /// <summary>
532         /// Moves the focus to the next focusable view in the focus chain in the given direction (according to the focus traversal order).
533         /// </summary>
534         /// <param name="direction">The direction of the focus movement.</param>
535         /// <returns>True if the movement was successful.</returns>
536         /// <since_tizen> 3 </since_tizen>
537         public bool MoveFocus(View.FocusDirection direction)
538         {
539             bool ret = NDalicManualPINVOKE.FocusManager_MoveFocus(swigCPtr, (int)direction);
540             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
541             return ret;
542         }
543
544         /// <summary>
545         /// Clears the focus from the current focused view if any, so that no view is focused in the focus chain.<br />
546         /// It will emit the FocusChanged event without the current focused view.<br />
547         /// </summary>
548         /// <since_tizen> 3 </since_tizen>
549         public void ClearFocus()
550         {
551             NDalicManualPINVOKE.FocusManager_ClearFocus(swigCPtr);
552             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553         }
554
555         /// <summary>
556         /// Move the focus to previous focused view.
557         /// </summary>
558         /// <since_tizen> 4 </since_tizen>
559         public void MoveFocusBackward()
560         {
561             NDalicManualPINVOKE.FocusManager_MoveFocusBackward(swigCPtr);
562             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
563         }
564
565         /// <summary>
566         /// Gets or sets the status of whether the focus movement should be looped within the same focus group.<br />
567         /// The focus movement is not looped by default.<br />
568         /// </summary>
569         /// <since_tizen> 3 </since_tizen>
570         public bool FocusGroupLoop
571         {
572             set
573             {
574                 SetFocusGroupLoop(value);
575             }
576             get
577             {
578                 return GetFocusGroupLoop();
579             }
580         }
581
582         internal void SetFocusGroupLoop(bool enabled)
583         {
584             NDalicManualPINVOKE.FocusManager_SetFocusGroupLoop(swigCPtr, enabled);
585             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586         }
587
588         internal bool GetFocusGroupLoop()
589         {
590             bool ret = NDalicManualPINVOKE.FocusManager_GetFocusGroupLoop(swigCPtr);
591             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592             return ret;
593         }
594
595         /// <summary>
596         /// Sets whether the view is a focus group that can limit the scope of the focus movement to its child views in the focus chain.<br />
597         /// Layout controls set themselves as focus groups by default.<br />
598         /// </summary>
599         /// <param name="view">The view to be set as a focus group.</param>
600         /// <param name="isFocusGroup">Whether to set the view as a focus group or not.</param>
601         /// <since_tizen> 3 </since_tizen>
602         public void SetAsFocusGroup(View view, bool isFocusGroup)
603         {
604             NDalicManualPINVOKE.FocusManager_SetAsFocusGroup(swigCPtr, View.getCPtr(view), isFocusGroup);
605             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
606         }
607
608         /// <summary>
609         /// Checks whether the view is set as a focus group or not.
610         /// </summary>
611         /// <param name="view">The view to be checked.</param>
612         /// <returns>Whether the view is set as a focus group.</returns>
613         /// <since_tizen> 3 </since_tizen>
614         public bool IsFocusGroup(View view)
615         {
616             bool ret = NDalicManualPINVOKE.FocusManager_IsFocusGroup(swigCPtr, View.getCPtr(view));
617             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618             return ret;
619         }
620
621         /// <summary>
622         /// Returns the closest ancestor of the given view that is a focus group.
623         /// </summary>
624         /// <param name="view">The view to be checked for its focus group.</param>
625         /// <returns>The focus group the given view belongs to or an empty handle if the given view.</returns>
626         /// <since_tizen> 3 </since_tizen>
627         public View GetFocusGroup(View view)
628         {
629             IntPtr cPtr = NDalicManualPINVOKE.FocusManager_GetFocusGroup(swigCPtr, View.getCPtr(view));
630
631             View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
632
633
634             /*View ret = new View(NDalicManualPINVOKE.FocusManager_GetFocusGroup(swigCPtr, View.getCPtr(view)), true);
635             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636             if (ret.HasBody() == false)
637             {
638                 return null;
639             }*/
640
641             return ret;
642         }
643
644         /// <summary>
645         /// Gets or sets the focus indicator view.<br />
646         /// This will replace the default focus indicator view in the FocusManager and will be added to the focused view as a highlight.<br />
647         /// </summary>
648         /// <since_tizen> 3 </since_tizen>
649         public View FocusIndicator
650         {
651             set
652             {
653                 SetFocusIndicatorView(value);
654             }
655             get
656             {
657                 return GetFocusIndicatorView();
658             }
659         }
660
661         internal void SetFocusIndicatorView(View indicator)
662         {
663             NDalicManualPINVOKE.FocusManager_SetFocusIndicatorActor(swigCPtr, View.getCPtr(indicator));
664             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665         }
666
667         internal View GetFocusIndicatorView()
668         {
669             IntPtr cPtr = NDalicManualPINVOKE.FocusManager_GetFocusIndicatorActor(swigCPtr);
670
671             View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
672
673             return ret;
674         }
675
676         /// <summary>
677         /// Provides the implementation of a custom focus algorithm interface to allow the application to define the focus logic.<br />
678         /// </summary>
679         /// <param name="arg0">The user's implementation of ICustomFocusAlgorithm.</param>
680         /// <since_tizen> 3 </since_tizen>
681         public void SetCustomAlgorithm(ICustomFocusAlgorithm arg0)
682         {
683             _customAlgorithmInterfaceWrapper = new CustomAlgorithmInterfaceWrapper();
684             _customAlgorithmInterfaceWrapper.SetFocusAlgorithm(arg0);
685
686             NDalicPINVOKE.SetCustomAlgorithm(swigCPtr, CustomAlgorithmInterface.getCPtr(_customAlgorithmInterfaceWrapper));
687             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
688         }
689
690         internal PreFocusChangeSignal PreFocusChangeSignal()
691         {
692             PreFocusChangeSignal ret = new PreFocusChangeSignal(NDalicManualPINVOKE.FocusManager_PreFocusChangeSignal(swigCPtr), false);
693             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694             return ret;
695         }
696
697         internal FocusChangedSignal FocusChangedSignal()
698         {
699             FocusChangedSignal ret = new FocusChangedSignal(NDalicManualPINVOKE.FocusManager_FocusChangedSignal(swigCPtr), false);
700             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
701             return ret;
702         }
703
704         internal FocusGroupChangedSignal FocusGroupChangedSignal()
705         {
706             FocusGroupChangedSignal ret = new FocusGroupChangedSignal(NDalicManualPINVOKE.FocusManager_FocusGroupChangedSignal(swigCPtr), false);
707             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708             return ret;
709         }
710
711         internal ViewSignal FocusedViewEnterKeySignal()
712         {
713             ViewSignal ret = new ViewSignal(NDalicManualPINVOKE.FocusManager_FocusedActorEnterKeySignal(swigCPtr), false);
714             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715             return ret;
716         }
717
718         private static readonly FocusManager instance = FocusManager.Get();
719
720         /// <summary>
721         /// Gets the singleton of the FocusManager object.
722         /// </summary>
723         /// <since_tizen> 3 </since_tizen>
724         public static FocusManager Instance
725         {
726             get
727             {
728                 return instance;
729             }
730         }
731
732         /// <summary>
733         /// ICustomFocusAlgorithm is used to provide the custom keyboard focus algorithm for retrieving the next focusable view.<br />
734         /// The application can implement the interface and override the keyboard focus behavior.<br />
735         /// If the focus is changing within a layout container, then the layout container is queried first to provide the next focusable view.<br />
736         /// If this does not provide a valid view, then the Keyboard FocusManager will check focusable properties to determine the next focusable actor.<br />
737         /// If focusable properties are not set, then the keyboard FocusManager calls the GetNextFocusableView() method of this interface.<br />
738         /// </summary>
739         /// <since_tizen> 3 </since_tizen>
740         public interface ICustomFocusAlgorithm
741         {
742             /// <summary>
743             /// Get the next focus actor.
744             /// </summary>
745             /// <param name="current">The current focus view.</param>
746             /// <param name="proposed">The proposed focus view</param>
747             /// <param name="direction">The focus move direction</param>
748             /// <returns>The next focus actor.</returns>
749             /// <since_tizen> 3 </since_tizen>
750             View GetNextFocusableView(View current, View proposed, View.FocusDirection direction);
751         }
752
753         private class CustomAlgorithmInterfaceWrapper : CustomAlgorithmInterface
754         {
755             private FocusManager.ICustomFocusAlgorithm _customFocusAlgorithm;
756
757             public CustomAlgorithmInterfaceWrapper()
758             {
759             }
760
761             public void SetFocusAlgorithm(FocusManager.ICustomFocusAlgorithm customFocusAlgorithm)
762             {
763                 _customFocusAlgorithm = customFocusAlgorithm;
764             }
765
766             public override View GetNextFocusableView(View current, View proposed, View.FocusDirection direction)
767             {
768                 return _customFocusAlgorithm.GetNextFocusableView(current, proposed, direction);
769             }
770         }
771
772
773         /// <summary>
774         /// Please do not use! this will be deprecated
775         /// </summary>
776         /// <since_tizen> 3 </since_tizen>
777         //Please do not use! this will be deprecated
778         [EditorBrowsable(EditorBrowsableState.Never)]
779         public class FocusedViewEnterKeyEventArgs : EventArgs
780         {
781             private View _view;
782
783             /// <summary>
784             /// View.
785             /// </summary>
786             public View View
787             {
788                 get
789                 {
790                     return _view;
791                 }
792                 set
793                 {
794                     _view = value;
795                 }
796             }
797         }
798
799         private EventHandler<FocusedViewEnterKeyEventArgs> _focusedViewEnterKeyEventHandler2;
800         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
801         private delegate void FocusedViewEnterKeyEventCallback2(IntPtr view);
802         private FocusedViewEnterKeyEventCallback2 _focusedViewEnterKeyEventCallback2;
803
804         /// <summary>
805         /// [Obsolete("Please do not use! this will be deprecated")]
806         /// </summary>
807         /// <since_tizen> 3 </since_tizen>
808         [Obsolete("Please do not use! this will be deprecated")]
809         public event EventHandler<FocusedViewEnterKeyEventArgs> FocusedViewEnterKeyPressed
810         {
811             add
812             {
813                 if (_focusedViewEnterKeyEventCallback2 == null)
814                 {
815                     _focusedViewEnterKeyEventCallback2 = OnFocusedViewEnterKey2;
816                     FocusedViewEnterKeySignal().Connect(_focusedViewEnterKeyEventCallback2);
817                 }
818                 _focusedViewEnterKeyEventHandler2 += value;
819             }
820             remove
821             {
822                 _focusedViewEnterKeyEventHandler2 -= value;
823
824                 if (_focusedViewEnterKeyEventCallback2 != null && FocusedViewEnterKeySignal().Empty() == false)
825                 {
826                     FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback2);
827                 }
828             }
829         }
830
831         [Obsolete("Please do not use! this will be deprecated")]
832         private void OnFocusedViewEnterKey2(IntPtr view)
833         {
834             FocusedViewActivatedEventArgs e = new FocusedViewActivatedEventArgs();
835
836             e.View = Registry.GetManagedBaseHandleFromNativePtr(view) as View;
837
838             if (_focusedViewEnterKeyEventHandler != null)
839             {
840                 _focusedViewEnterKeyEventHandler(this, e);
841             }
842         }
843     }
844 }