nux-0.9.48

Nux/Focusable.h

Go to the documentation of this file.
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 
00022 #ifndef FOCUSABLE_H
00023 #define FOCUSABLE_H
00024 
00025 namespace nux
00026 {
00027   typedef enum
00028   {
00029     FOCUS_DIRECTION_NONE,
00030     FOCUS_DIRECTION_NEXT,
00031     FOCUS_DIRECTION_PREV,
00032     FOCUS_DIRECTION_UP,
00033     FOCUS_DIRECTION_DOWN,
00034     FOCUS_DIRECTION_LEFT,
00035     FOCUS_DIRECTION_RIGHT,
00036   } FocusDirection;
00037 
00038   typedef enum
00039   {
00040     FOCUS_EVENT_NONE,
00041     FOCUS_EVENT_ACTIVATE,
00042     FOCUS_EVENT_DIRECTION
00043   } FocusEventType;
00044 
00045   class Focusable
00046   {
00047   public:
00048     bool GetFocused ();
00049     void SetFocused (bool focused);
00050     bool CanFocus ();
00051     void ActivateFocus ();
00052 
00053     static FocusEventType GetFocusableEventType (unsigned long    eventType,
00054                                                  unsigned long    keysym,
00055                                                  const char* character,
00056                                                  FocusDirection *direction
00057                                                 );
00058   protected:
00059     virtual bool DoGetFocused ();
00060     virtual void DoSetFocused (bool focused);
00061     virtual bool DoCanFocus ();
00062     virtual void DoActivateFocus ();
00063   };
00064 
00065 
00066 };
00067 #endif // FOCUSABLE_H