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