2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 using System.Runtime.InteropServices;
23 public class KeyboardFocusManager : BaseHandle {
24 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26 internal KeyboardFocusManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicManualPINVOKE.KeyboardFocusManager_SWIGUpcast(cPtr), cMemoryOwn) {
27 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
30 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(KeyboardFocusManager obj) {
31 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
34 ~KeyboardFocusManager() {
38 public override void Dispose() {
40 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
43 NDalicManualPINVOKE.delete_KeyboardFocusManager(swigCPtr);
45 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
47 global::System.GC.SuppressFinalize(this);
54 * @brief Event arguments that passed via FocusChanged signal
57 public class FocusChangedEventArgs : EventArgs
59 private Actor _actorCurrent;
60 private Actor _actorNext;
63 * @brief Actor - is the original focused Actor
66 public Actor ActorCurrent
74 _actorCurrent = value;
79 * @brief Actor - is the current focused Actor
82 public Actor ActorNext
96 * @brief Event arguments that passed via FocusGroupChanged signal
99 public class FocusGroupChangedEventArgs : EventArgs
101 private Actor _currentFocusedActor;
102 private bool _forwardDirection;
105 * @brief Actor - is the current focused Actor
108 public Actor CurrentFocusedActor
112 return _currentFocusedActor;
116 _currentFocusedActor = value;
121 * @brief ForwardDirection - is the direction (forward or backward) in which to move the focus next
124 public bool ForwardDirection
128 return _forwardDirection;
132 _forwardDirection = value;
138 * @brief Event arguments that passed via FocusedActorEnterKey signal
141 public class FocusedActorEnterKeyEventArgs : EventArgs
143 private Actor _actor;
146 * @brief Actor - is the current focused Actor which has the enter key pressed on it.
163 * @brief Event arguments that passed via PreFocusChange signal
166 public class PreFocusChangeEventArgs : EventArgs
168 private Actor _current;
169 private Actor _proposed;
170 private View.KeyboardFocus.Direction _direction;
173 * @brief Actor - is the current focused Actor.
189 * @brief Actor - is the proposed focused Actor.
192 public Actor Proposed
205 * @brief Direction - is the direction of Focus change.
208 public View.KeyboardFocus.Direction Direction
221 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
222 public delegate void FocusChangedEventHandler(object source, FocusChangedEventArgs e);
224 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
225 public delegate void FocusGroupChangedEventHandler(object source, FocusGroupChangedEventArgs e);
227 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
228 public delegate void FocusedActorEnterKeyEventHandler(object source, FocusedActorEnterKeyEventArgs e);
230 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
231 public delegate Actor PreFocusChangeEventHandler(object source, PreFocusChangeEventArgs e);
233 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
234 public delegate IntPtr PreFocusChangeEventCallbackDelegate(IntPtr current, IntPtr proposed, View.KeyboardFocus.Direction direction);
235 private PreFocusChangeEventHandler _keyboardFocusManagerPreFocusChangeEventHandler;
236 private PreFocusChangeEventCallbackDelegate _keyboardFocusManagerPreFocusChangeEventCallbackDelegate;
238 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
239 private delegate void FocusChangedEventCallbackDelegate(IntPtr actorCurrent, IntPtr actorNext);
240 private FocusChangedEventHandler _keyboardFocusManagerFocusChangedEventHandler;
241 private FocusChangedEventCallbackDelegate _keyboardFocusManagerFocusChangedEventCallbackDelegate;
243 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
244 private delegate void FocusGroupChangedEventCallbackDelegate(IntPtr currentFocusedActor, bool forwardDirection);
245 private FocusGroupChangedEventHandler _keyboardFocusManagerFocusGroupChangedEventHandler;
246 private FocusGroupChangedEventCallbackDelegate _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate;
248 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
249 private delegate void FocusedActorEnterKeyEventCallbackDelegate(IntPtr actor);
250 private FocusedActorEnterKeyEventHandler _keyboardFocusManagerFocusedActorEnterKeyEventHandler;
251 private FocusedActorEnterKeyEventCallbackDelegate _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate;
253 public event PreFocusChangeEventHandler PreFocusChange
259 // Restricted to only one listener
260 if (_keyboardFocusManagerPreFocusChangeEventHandler == null)
262 _keyboardFocusManagerPreFocusChangeEventHandler += value;
264 _keyboardFocusManagerPreFocusChangeEventCallbackDelegate = new PreFocusChangeEventCallbackDelegate(OnPreFocusChange);
265 this.PreFocusChangeSignal().Connect(_keyboardFocusManagerPreFocusChangeEventCallbackDelegate);
274 if (_keyboardFocusManagerPreFocusChangeEventHandler != null)
276 this.PreFocusChangeSignal().Disconnect(_keyboardFocusManagerPreFocusChangeEventCallbackDelegate);
279 _keyboardFocusManagerPreFocusChangeEventHandler -= value;
284 // Callback for KeyboardFocusManager PreFocusChangeSignal
285 private IntPtr OnPreFocusChange(IntPtr current, IntPtr proposed, View.KeyboardFocus.Direction direction)
288 PreFocusChangeEventArgs e = new PreFocusChangeEventArgs();
290 // Populate all members of "e" (PreFocusChangeEventArgs) with real data
291 e.Current = Actor.GetActorFromPtr(current);
292 e.Proposed = Actor.GetActorFromPtr(proposed);
293 e.Direction = direction;
295 if (_keyboardFocusManagerPreFocusChangeEventHandler != null)
297 //here we send all data to user event handlers
298 actor = _keyboardFocusManagerPreFocusChangeEventHandler(this, e);
301 return actor.GetPtrfromActor();
305 * @brief Event for FocusChanged signal which can be used to subscribe/unsubscribe the event handler
306 * (in the type of FocusChangedEventHandler) provided by the user.
307 * FocusChanged signal is emitted after the current focused actor has been changed.
309 public event FocusChangedEventHandler FocusChanged
315 // Restricted to only one listener
316 if (_keyboardFocusManagerFocusChangedEventHandler == null)
318 _keyboardFocusManagerFocusChangedEventHandler += value;
320 _keyboardFocusManagerFocusChangedEventCallbackDelegate = new FocusChangedEventCallbackDelegate(OnFocusChanged);
321 this.FocusChangedSignal().Connect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
330 if (_keyboardFocusManagerFocusChangedEventHandler != null)
332 this.FocusChangedSignal().Disconnect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
335 _keyboardFocusManagerFocusChangedEventHandler -= value;
340 // Callback for KeyboardFocusManager FocusChangedSignal
341 private void OnFocusChanged(IntPtr actorCurrent, IntPtr actorNext)
343 FocusChangedEventArgs e = new FocusChangedEventArgs();
345 // Populate all members of "e" (FocusChangedEventArgs) with real data
346 e.ActorCurrent = Actor.GetActorFromPtr(actorCurrent);
347 e.ActorNext = Actor.GetActorFromPtr(actorNext);
349 if (_keyboardFocusManagerFocusChangedEventHandler != null)
351 //here we send all data to user event handlers
352 _keyboardFocusManagerFocusChangedEventHandler(this, e);
357 * @brief Event for FocusGroupChanged signal which can be used to subscribe/unsubscribe the event handler
358 * (in the type of FocusGroupChangedEventHandler) provided by the user.
359 * FocusGroupChanged signal is emitted when the focus group has been changed.
361 public event FocusGroupChangedEventHandler FocusGroupChanged
367 // Restricted to only one listener
368 if (_keyboardFocusManagerFocusGroupChangedEventHandler == null)
370 _keyboardFocusManagerFocusGroupChangedEventHandler += value;
372 _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate = new FocusGroupChangedEventCallbackDelegate(OnFocusGroupChanged);
373 this.FocusGroupChangedSignal().Connect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
382 if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
384 this.FocusGroupChangedSignal().Disconnect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
387 _keyboardFocusManagerFocusGroupChangedEventHandler -= value;
392 // Callback for KeyboardFocusManager FocusGroupChangedSignal
393 private void OnFocusGroupChanged(IntPtr currentFocusedActor, bool forwardDirection)
395 FocusGroupChangedEventArgs e = new FocusGroupChangedEventArgs();
397 // Populate all members of "e" (FocusGroupChangedEventArgs) with real data
398 e.CurrentFocusedActor = Actor.GetActorFromPtr(currentFocusedActor);
399 e.ForwardDirection = forwardDirection;
401 if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
403 //here we send all data to user event handlers
404 _keyboardFocusManagerFocusGroupChangedEventHandler(this, e);
409 * @brief Event for FocusedActorEnterKeyPressed signal which can be used to subscribe/unsubscribe the event handler
410 * (in the type of FocusedActorEnterKeyEventHandler) provided by the user.
411 * FocusedActorEnterKeyPressed signal is emitted when the current focused actor has the enter key pressed on it.
413 public event FocusedActorEnterKeyEventHandler FocusedActorEnterKeyPressed
419 // Restricted to only one listener
420 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler == null)
422 _keyboardFocusManagerFocusedActorEnterKeyEventHandler += value;
424 _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate = new FocusedActorEnterKeyEventCallbackDelegate(OnFocusedActorEnterKey);
425 this.FocusedActorEnterKeySignal().Connect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
434 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
436 this.FocusedActorEnterKeySignal().Disconnect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
439 _keyboardFocusManagerFocusedActorEnterKeyEventHandler -= value;
444 // Callback for KeyboardFocusManager FocusedActorEnterKeySignal
445 private void OnFocusedActorEnterKey(IntPtr actor)
447 FocusedActorEnterKeyEventArgs e = new FocusedActorEnterKeyEventArgs();
449 // Populate all members of "e" (FocusedActorEnterKeyEventArgs) with real data
450 e.Actor = Actor.GetActorFromPtr(actor);
452 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
454 //here we send all data to user event handlers
455 _keyboardFocusManagerFocusedActorEnterKeyEventHandler(this, e);
459 public KeyboardFocusManager() : this(NDalicManualPINVOKE.new_KeyboardFocusManager(), true) {
460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463 public static KeyboardFocusManager Get() {
464 KeyboardFocusManager ret = new KeyboardFocusManager(NDalicManualPINVOKE.KeyboardFocusManager_Get(), true);
465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469 public bool SetCurrentFocusActor(Actor actor) {
470 bool ret = NDalicManualPINVOKE.KeyboardFocusManager_SetCurrentFocusActor(swigCPtr, Actor.getCPtr(actor));
471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
475 public Actor GetCurrentFocusActor() {
476 Actor ret = new Actor(NDalicManualPINVOKE.KeyboardFocusManager_GetCurrentFocusActor(swigCPtr), true);
477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
481 public bool MoveFocus(View.KeyboardFocus.Direction direction) {
482 bool ret = NDalicManualPINVOKE.KeyboardFocusManager_MoveFocus(swigCPtr, (int)direction);
483 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
487 public void ClearFocus() {
488 NDalicManualPINVOKE.KeyboardFocusManager_ClearFocus(swigCPtr);
489 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492 public void SetFocusGroupLoop(bool enabled) {
493 NDalicManualPINVOKE.KeyboardFocusManager_SetFocusGroupLoop(swigCPtr, enabled);
494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
497 public bool GetFocusGroupLoop() {
498 bool ret = NDalicManualPINVOKE.KeyboardFocusManager_GetFocusGroupLoop(swigCPtr);
499 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
503 public void SetAsFocusGroup(Actor actor, bool isFocusGroup) {
504 NDalicManualPINVOKE.KeyboardFocusManager_SetAsFocusGroup(swigCPtr, Actor.getCPtr(actor), isFocusGroup);
505 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 public bool IsFocusGroup(Actor actor) {
509 bool ret = NDalicManualPINVOKE.KeyboardFocusManager_IsFocusGroup(swigCPtr, Actor.getCPtr(actor));
510 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514 public Actor GetFocusGroup(Actor actor) {
515 Actor ret = new Actor(NDalicManualPINVOKE.KeyboardFocusManager_GetFocusGroup(swigCPtr, Actor.getCPtr(actor)), true);
516 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
520 public void SetFocusIndicatorActor(Actor indicator) {
521 NDalicManualPINVOKE.KeyboardFocusManager_SetFocusIndicatorActor(swigCPtr, Actor.getCPtr(indicator));
522 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
525 public Actor GetFocusIndicatorActor() {
526 Actor ret = new Actor(NDalicManualPINVOKE.KeyboardFocusManager_GetFocusIndicatorActor(swigCPtr), true);
527 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
531 public KeyboardPreFocusChangeSignal PreFocusChangeSignal() {
532 KeyboardPreFocusChangeSignal ret = new KeyboardPreFocusChangeSignal(NDalicManualPINVOKE.KeyboardFocusManager_PreFocusChangeSignal(swigCPtr), false);
533 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
537 public FocusChangedSignal FocusChangedSignal() {
538 FocusChangedSignal ret = new FocusChangedSignal(NDalicManualPINVOKE.KeyboardFocusManager_FocusChangedSignal(swigCPtr), false);
539 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543 public FocusGroupChangedSignal FocusGroupChangedSignal() {
544 FocusGroupChangedSignal ret = new FocusGroupChangedSignal(NDalicManualPINVOKE.KeyboardFocusManager_FocusGroupChangedSignal(swigCPtr), false);
545 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
549 public ActorSignal FocusedActorEnterKeySignal() {
550 ActorSignal ret = new ActorSignal(NDalicManualPINVOKE.KeyboardFocusManager_FocusedActorEnterKeySignal(swigCPtr), false);
551 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();