59241fbcc50e2f4f265b7e91b56e6886af786603
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / manual / csharp / KeyboardFocusManager.cs
1 namespace Dali {
2
3 using System;
4 using System.Runtime.InteropServices;
5
6 public class KeyboardFocusManager : BaseHandle {
7   private global::System.Runtime.InteropServices.HandleRef swigCPtr;
8
9   internal KeyboardFocusManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicManualPINVOKE.KeyboardFocusManager_SWIGUpcast(cPtr), cMemoryOwn) {
10     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
11   }
12
13   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(KeyboardFocusManager obj) {
14     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
15   }
16
17   ~KeyboardFocusManager() {
18     Dispose();
19   }
20
21   public override void Dispose() {
22     lock(this) {
23       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
24         if (swigCMemOwn) {
25           swigCMemOwn = false;
26           NDalicManualPINVOKE.delete_KeyboardFocusManager(swigCPtr);
27         }
28         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
29       }
30       global::System.GC.SuppressFinalize(this);
31       base.Dispose();
32     }
33   }
34
35
36 /**
37   * @brief Event arguments that passed via FocusChanged signal
38   *
39   */
40 public class FocusChangedEventArgs : EventArgs
41 {
42    private Actor _actorCurrent;
43    private Actor _actorNext;
44
45    /**
46      * @brief Actor - is the original focused Actor
47      *
48      */
49    public Actor ActorCurrent
50    {
51       get
52       {
53          return _actorCurrent;
54       }
55       set
56       {
57          _actorCurrent = value;
58       }
59    }
60
61    /**
62      * @brief Actor - is the current focused Actor
63      *
64      */
65    public Actor ActorNext
66    {
67       get
68       {
69          return _actorNext;
70       }
71       set
72       {
73          _actorNext = value;
74       }
75    }
76 }
77
78 /**
79   * @brief Event arguments that passed via FocusGroupChanged signal
80   *
81   */
82 public class FocusGroupChangedEventArgs : EventArgs
83 {
84    private Actor _currentFocusedActor;
85    private bool _forwardDirection;
86
87    /**
88      * @brief Actor - is the current focused Actor
89      *
90      */
91    public Actor CurrentFocusedActor
92    {
93       get
94       {
95          return _currentFocusedActor;
96       }
97       set
98       {
99          _currentFocusedActor = value;
100       }
101    }
102
103    /**
104      * @brief ForwardDirection - is the direction (forward or backward) in which to move the focus next
105      *
106      */
107    public bool ForwardDirection
108    {
109       get
110       {
111          return _forwardDirection;
112       }
113       set
114       {
115          _forwardDirection = value;
116       }
117    }
118 }
119
120 /**
121   * @brief Event arguments that passed via FocusedActorEnterKey signal
122   *
123   */
124 public class FocusedActorEnterKeyEventArgs : EventArgs
125 {
126    private Actor _actor;
127
128    /**
129      * @brief Actor - is the current focused Actor which has the enter key pressed on it.
130      *
131      */
132    public Actor Actor
133    {
134       get
135       {
136          return _actor;
137       }
138       set
139       {
140          _actor = value;
141       }
142    }
143 }
144
145 /**
146   * @brief Event arguments that passed via PreFocusChange signal
147   *
148   */
149 public class PreFocusChangeEventArgs : EventArgs
150 {
151    private Actor _current;
152    private Actor _proposed;
153    private Control.KeyboardFocus.Direction _direction;
154
155    /**
156     * @brief Actor - is the current focused Actor.
157     *
158     */
159    public Actor Current
160    {
161       get
162       {
163          return _current;
164       }
165       set
166       {
167           _current = value;
168       }
169    }
170
171     /**
172     * @brief Actor - is the proposed focused Actor.
173     *
174     */
175     public Actor Proposed
176     {
177         get
178         {
179             return _proposed;
180         }
181         set
182         {
183             _proposed = value;
184         }
185     }
186
187     /**
188     * @brief Direction - is the direction of Focus change.
189     *
190     */
191     public Control.KeyboardFocus.Direction Direction
192     {
193         get
194         {
195             return _direction;
196         }
197         set
198         {
199             _direction = value;
200         }
201     }
202 }
203
204   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
205   public delegate void FocusChangedEventHandler(object source, FocusChangedEventArgs e);
206
207   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
208   public delegate void FocusGroupChangedEventHandler(object source, FocusGroupChangedEventArgs e);
209
210   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
211   public delegate void FocusedActorEnterKeyEventHandler(object source, FocusedActorEnterKeyEventArgs e);
212
213   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
214   public delegate Actor PreFocusChangeEventHandler(object source, PreFocusChangeEventArgs e);
215
216   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
217   public delegate IntPtr PreFocusChangeEventCallbackDelegate(IntPtr current, IntPtr proposed, Control.KeyboardFocus.Direction direction);
218   private PreFocusChangeEventHandler _keyboardFocusManagerPreFocusChangeEventHandler;
219   private PreFocusChangeEventCallbackDelegate _keyboardFocusManagerPreFocusChangeEventCallbackDelegate;
220
221   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
222   private delegate void FocusChangedEventCallbackDelegate(IntPtr actorCurrent, IntPtr actorNext);
223   private FocusChangedEventHandler _keyboardFocusManagerFocusChangedEventHandler;
224   private FocusChangedEventCallbackDelegate _keyboardFocusManagerFocusChangedEventCallbackDelegate;
225
226   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
227   private delegate void FocusGroupChangedEventCallbackDelegate(IntPtr currentFocusedActor, bool forwardDirection);
228   private FocusGroupChangedEventHandler _keyboardFocusManagerFocusGroupChangedEventHandler;
229   private FocusGroupChangedEventCallbackDelegate _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate;
230
231   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
232   private delegate void FocusedActorEnterKeyEventCallbackDelegate(IntPtr actor);
233   private FocusedActorEnterKeyEventHandler _keyboardFocusManagerFocusedActorEnterKeyEventHandler;
234   private FocusedActorEnterKeyEventCallbackDelegate _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate;
235
236   public event PreFocusChangeEventHandler PreFocusChange
237   {
238      add
239      {
240         lock(this)
241         {
242            // Restricted to only one listener
243            if (_keyboardFocusManagerPreFocusChangeEventHandler == null)
244            {
245                _keyboardFocusManagerPreFocusChangeEventHandler += value;
246
247                _keyboardFocusManagerPreFocusChangeEventCallbackDelegate = new PreFocusChangeEventCallbackDelegate(OnPreFocusChange);
248               this.PreFocusChangeSignal().Connect(_keyboardFocusManagerPreFocusChangeEventCallbackDelegate);
249            }
250         }
251      }
252
253      remove
254      {
255         lock(this)
256         {
257            if (_keyboardFocusManagerPreFocusChangeEventHandler != null)
258            {
259               this.PreFocusChangeSignal().Disconnect(_keyboardFocusManagerPreFocusChangeEventCallbackDelegate);
260            }
261
262            _keyboardFocusManagerPreFocusChangeEventHandler -= value;
263         }
264      }
265   }
266
267   // Callback for KeyboardFocusManager PreFocusChangeSignal
268   private IntPtr OnPreFocusChange(IntPtr current, IntPtr proposed, Control.KeyboardFocus.Direction direction)
269   {
270       Actor actor = null;
271       PreFocusChangeEventArgs e = new PreFocusChangeEventArgs();
272
273       // Populate all members of "e" (PreFocusChangeEventArgs) with real data
274       e.Current = Actor.GetActorFromPtr(current);
275       e.Proposed = Actor.GetActorFromPtr(proposed);
276       e.Direction = direction;
277
278       if (_keyboardFocusManagerPreFocusChangeEventHandler != null)
279       {
280         //here we send all data to user event handlers
281           actor = _keyboardFocusManagerPreFocusChangeEventHandler(this, e);
282       }
283
284       return actor.GetPtrfromActor();
285   }
286
287   /**
288     * @brief Event for FocusChanged signal which can be used to subscribe/unsubscribe the event handler
289     * (in the type of FocusChangedEventHandler) provided by the user.
290     * FocusChanged signal is emitted after the current focused actor has been changed.
291     */
292   public event FocusChangedEventHandler FocusChanged
293   {
294      add
295      {
296         lock(this)
297         {
298            // Restricted to only one listener
299            if (_keyboardFocusManagerFocusChangedEventHandler == null)
300            {
301               _keyboardFocusManagerFocusChangedEventHandler += value;
302
303               _keyboardFocusManagerFocusChangedEventCallbackDelegate = new FocusChangedEventCallbackDelegate(OnFocusChanged);
304               this.FocusChangedSignal().Connect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
305            }
306         }
307      }
308
309      remove
310      {
311         lock(this)
312         {
313            if (_keyboardFocusManagerFocusChangedEventHandler != null)
314            {
315               this.FocusChangedSignal().Disconnect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
316            }
317
318            _keyboardFocusManagerFocusChangedEventHandler -= value;
319         }
320      }
321   }
322
323   // Callback for KeyboardFocusManager FocusChangedSignal
324   private void OnFocusChanged(IntPtr actorCurrent, IntPtr actorNext)
325   {
326      FocusChangedEventArgs e = new FocusChangedEventArgs();
327
328      // Populate all members of "e" (FocusChangedEventArgs) with real data
329      e.ActorCurrent = Actor.GetActorFromPtr(actorCurrent);
330      e.ActorNext = Actor.GetActorFromPtr(actorNext);
331
332      if (_keyboardFocusManagerFocusChangedEventHandler != null)
333      {
334         //here we send all data to user event handlers
335         _keyboardFocusManagerFocusChangedEventHandler(this, e);
336      }
337   }
338
339   /**
340     * @brief Event for FocusGroupChanged signal which can be used to subscribe/unsubscribe the event handler
341     * (in the type of FocusGroupChangedEventHandler) provided by the user.
342     * FocusGroupChanged signal is emitted when the focus group has been changed.
343     */
344   public event FocusGroupChangedEventHandler FocusGroupChanged
345   {
346      add
347      {
348         lock(this)
349         {
350            // Restricted to only one listener
351            if (_keyboardFocusManagerFocusGroupChangedEventHandler == null)
352            {
353               _keyboardFocusManagerFocusGroupChangedEventHandler += value;
354
355               _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate = new FocusGroupChangedEventCallbackDelegate(OnFocusGroupChanged);
356               this.FocusGroupChangedSignal().Connect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
357            }
358         }
359      }
360
361      remove
362      {
363         lock(this)
364         {
365            if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
366            {
367               this.FocusGroupChangedSignal().Disconnect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
368            }
369
370            _keyboardFocusManagerFocusGroupChangedEventHandler -= value;
371         }
372      }
373   }
374
375   // Callback for KeyboardFocusManager FocusGroupChangedSignal
376   private void OnFocusGroupChanged(IntPtr currentFocusedActor, bool forwardDirection)
377   {
378      FocusGroupChangedEventArgs e = new FocusGroupChangedEventArgs();
379
380      // Populate all members of "e" (FocusGroupChangedEventArgs) with real data
381      e.CurrentFocusedActor = Actor.GetActorFromPtr(currentFocusedActor);
382      e.ForwardDirection = forwardDirection;
383
384      if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
385      {
386         //here we send all data to user event handlers
387         _keyboardFocusManagerFocusGroupChangedEventHandler(this, e);
388      }
389   }
390
391   /**
392     * @brief Event for FocusedActorEnterKeyPressed signal which can be used to subscribe/unsubscribe the event handler
393     * (in the type of FocusedActorEnterKeyEventHandler) provided by the user.
394     * FocusedActorEnterKeyPressed signal is emitted when the current focused actor has the enter key pressed on it.
395     */
396   public event FocusedActorEnterKeyEventHandler FocusedActorEnterKeyPressed
397   {
398      add
399      {
400         lock(this)
401         {
402            // Restricted to only one listener
403            if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler == null)
404            {
405               _keyboardFocusManagerFocusedActorEnterKeyEventHandler += value;
406
407               _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate = new FocusedActorEnterKeyEventCallbackDelegate(OnFocusedActorEnterKey);
408               this.FocusedActorEnterKeySignal().Connect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
409            }
410         }
411      }
412
413      remove
414      {
415         lock(this)
416         {
417            if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
418            {
419               this.FocusedActorEnterKeySignal().Disconnect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
420            }
421
422            _keyboardFocusManagerFocusedActorEnterKeyEventHandler -= value;
423         }
424      }
425   }
426
427   // Callback for KeyboardFocusManager FocusedActorEnterKeySignal
428   private void OnFocusedActorEnterKey(IntPtr actor)
429   {
430      FocusedActorEnterKeyEventArgs e = new FocusedActorEnterKeyEventArgs();
431
432      // Populate all members of "e" (FocusedActorEnterKeyEventArgs) with real data
433      e.Actor = Actor.GetActorFromPtr(actor);
434
435      if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
436      {
437         //here we send all data to user event handlers
438         _keyboardFocusManagerFocusedActorEnterKeyEventHandler(this, e);
439      }
440   }
441
442   public KeyboardFocusManager() : this(NDalicManualPINVOKE.new_KeyboardFocusManager(), true) {
443     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444   }
445
446   public static KeyboardFocusManager Get() {
447     KeyboardFocusManager ret = new KeyboardFocusManager(NDalicManualPINVOKE.KeyboardFocusManager_Get(), true);
448     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
449     return ret;
450   }
451
452   public bool SetCurrentFocusActor(Actor actor) {
453     bool ret = NDalicManualPINVOKE.KeyboardFocusManager_SetCurrentFocusActor(swigCPtr, Actor.getCPtr(actor));
454     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
455     return ret;
456   }
457
458   public Actor GetCurrentFocusActor() {
459     Actor ret = new Actor(NDalicManualPINVOKE.KeyboardFocusManager_GetCurrentFocusActor(swigCPtr), true);
460     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
461     return ret;
462   }
463
464   public bool MoveFocus(Control.KeyboardFocus.Direction direction) {
465     bool ret = NDalicManualPINVOKE.KeyboardFocusManager_MoveFocus(swigCPtr, (int)direction);
466     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467     return ret;
468   }
469
470   public void ClearFocus() {
471     NDalicManualPINVOKE.KeyboardFocusManager_ClearFocus(swigCPtr);
472     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
473   }
474
475   public void SetFocusGroupLoop(bool enabled) {
476     NDalicManualPINVOKE.KeyboardFocusManager_SetFocusGroupLoop(swigCPtr, enabled);
477     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478   }
479
480   public bool GetFocusGroupLoop() {
481     bool ret = NDalicManualPINVOKE.KeyboardFocusManager_GetFocusGroupLoop(swigCPtr);
482     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
483     return ret;
484   }
485
486   public void SetAsFocusGroup(Actor actor, bool isFocusGroup) {
487     NDalicManualPINVOKE.KeyboardFocusManager_SetAsFocusGroup(swigCPtr, Actor.getCPtr(actor), isFocusGroup);
488     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489   }
490
491   public bool IsFocusGroup(Actor actor) {
492     bool ret = NDalicManualPINVOKE.KeyboardFocusManager_IsFocusGroup(swigCPtr, Actor.getCPtr(actor));
493     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
494     return ret;
495   }
496
497   public Actor GetFocusGroup(Actor actor) {
498     Actor ret = new Actor(NDalicManualPINVOKE.KeyboardFocusManager_GetFocusGroup(swigCPtr, Actor.getCPtr(actor)), true);
499     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
500     return ret;
501   }
502
503   public void SetFocusIndicatorActor(Actor indicator) {
504     NDalicManualPINVOKE.KeyboardFocusManager_SetFocusIndicatorActor(swigCPtr, Actor.getCPtr(indicator));
505     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506   }
507
508   public Actor GetFocusIndicatorActor() {
509     Actor ret = new Actor(NDalicManualPINVOKE.KeyboardFocusManager_GetFocusIndicatorActor(swigCPtr), true);
510     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
511     return ret;
512   }
513
514   public KeyboardPreFocusChangeSignal PreFocusChangeSignal() {
515     KeyboardPreFocusChangeSignal ret = new KeyboardPreFocusChangeSignal(NDalicManualPINVOKE.KeyboardFocusManager_PreFocusChangeSignal(swigCPtr), false);
516     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
517     return ret;
518   }
519
520   public FocusChangedSignal FocusChangedSignal() {
521     FocusChangedSignal ret = new FocusChangedSignal(NDalicManualPINVOKE.KeyboardFocusManager_FocusChangedSignal(swigCPtr), false);
522     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
523     return ret;
524   }
525
526   public FocusGroupChangedSignal FocusGroupChangedSignal() {
527     FocusGroupChangedSignal ret = new FocusGroupChangedSignal(NDalicManualPINVOKE.KeyboardFocusManager_FocusGroupChangedSignal(swigCPtr), false);
528     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529     return ret;
530   }
531
532   public ActorSignal FocusedActorEnterKeySignal() {
533     ActorSignal ret = new ActorSignal(NDalicManualPINVOKE.KeyboardFocusManager_FocusedActorEnterKeySignal(swigCPtr), false);
534     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535     return ret;
536   }
537
538 }
539
540 }