nux-1.16.0
Focusable.cpp
00001 /*
00002  * Copyright 2011 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License version 3, as
00006  * published by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Gordon Allott <gord.allott@canonical.com>
00019  *
00020  */
00021 #include "Nux.h"
00022 #include "NuxGraphics/Events.h"
00023 #include "Focusable.h"
00024 
00025 namespace nux
00026 {
00027   bool Focusable::GetFocused ()
00028   {
00029     return DoGetFocused ();
00030   }
00031   void Focusable::SetFocused (bool focused)
00032   {
00033     DoSetFocused (focused);
00034   }
00035   bool Focusable::CanFocus ()
00036   {
00037     return DoCanFocus ();
00038   }
00039   void Focusable::ActivateFocus ()
00040   {
00041     DoActivateFocus ();
00042   }
00043 
00044   FocusEventType Focusable::GetFocusableEventType (unsigned long    eventType,
00045                                                   unsigned long    keysym,
00046                                                   const char* character,
00047                                                   FocusDirection *direction)
00048   {
00049     FocusEventType type = FOCUS_EVENT_NONE;
00050     *direction = FOCUS_DIRECTION_NONE;
00051     if (eventType == NUX_KEYDOWN)
00052     {
00053       switch (keysym)
00054       {
00055         case NUX_VK_ENTER:
00056         case NUX_KP_ENTER:
00057           type = FOCUS_EVENT_ACTIVATE;
00058           //g_debug ("focus key activated");
00059           break;
00060         case NUX_VK_UP:
00061           type = FOCUS_EVENT_DIRECTION;
00062           *direction = FOCUS_DIRECTION_UP;
00063           //g_debug ("direction up");
00064           break;
00065         case NUX_VK_DOWN:
00066           type = FOCUS_EVENT_DIRECTION;
00067           *direction = FOCUS_DIRECTION_DOWN;
00068           //g_debug ("direction down");
00069           break;
00070         case NUX_VK_LEFT:
00071           type = FOCUS_EVENT_DIRECTION;
00072           *direction = FOCUS_DIRECTION_LEFT;
00073           //g_debug ("direction left");
00074           break;
00075         case NUX_VK_RIGHT:
00076           type = FOCUS_EVENT_DIRECTION;
00077           *direction = FOCUS_DIRECTION_RIGHT;
00078           //g_debug ("direction right");
00079           break;
00080               case NUX_VK_LEFT_TAB:
00081                 type = FOCUS_EVENT_DIRECTION;
00082                 *direction = FOCUS_DIRECTION_PREV;
00083                 break;
00084         case NUX_VK_TAB:
00085           type = FOCUS_EVENT_DIRECTION;
00086           *direction = FOCUS_DIRECTION_NEXT;
00087           break;
00088         default:
00089           type = FOCUS_EVENT_NONE;
00090           *direction = FOCUS_DIRECTION_NONE;
00091           break;
00092 
00093       }
00094     }
00095     return type;
00096   }
00097 
00098   bool Focusable::DoGetFocused ()
00099   {
00100     return false;
00101   }
00102 
00103   void Focusable::DoSetFocused (bool focused)
00104   {
00105   }
00106 
00107   bool Focusable::DoCanFocus ()
00108   {
00109     g_debug ("Focusable DoCanFocus");
00110     return false;
00111   }
00112 
00113   void Focusable::DoActivateFocus ()
00114   {
00115   }
00116 
00117 };
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends