Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CAT/CATKeystroke.h Source File

CATKeystroke.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 /// \file CATKeystroke.h
00003 /// \brief Generic keystroke information
00004 /// \ingroup CAT
00005 /// 
00006 /// Copyright (c) 2003-2008 by Michael Ellison.
00007 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00008 ///
00009 // $Author: mikeellison $
00010 // $Date: 2008-01-21 08:33:12 -0600 (Mon, 21 Jan 2008) $
00011 // $Revision:   $
00012 // $NoKeywords: $
00013 //
00014 //---------------------------------------------------------------------------
00015 #ifndef _CATKeystroke_H_
00016 #define _CATKeystroke_H_
00017 
00018 #include "CATTypes.h"
00019 
00020 /// Platform neutral key defs
00021 enum CATKEY_SPECIAL
00022 {
00023     CATKEY_NONE,
00024 
00025     CATKEY_LEFT,
00026     CATKEY_RIGHT,
00027     CATKEY_UP,
00028     CATKEY_DOWN,
00029     CATKEY_HOME,
00030     CATKEY_END,
00031     CATKEY_INSERT,
00032     CATKEY_DELETE,
00033     CATKEY_NEXT,
00034     CATKEY_PRIOR,
00035     CATKEY_F1,
00036     CATKEY_F2,
00037     CATKEY_F3,
00038     CATKEY_F4,
00039     CATKEY_F5,
00040     CATKEY_F6,
00041     CATKEY_F7,
00042     CATKEY_F8,
00043     CATKEY_F9,
00044     CATKEY_F10,
00045     CATKEY_F11,
00046     CATKEY_F12,
00047 
00048     //-----
00049     CATKEY_SPECIAL_COUNT
00050 };
00051 
00052 /// \class CATKeystroke
00053 /// \brief generic keystroke class
00054 /// \ingroup CAT
00055 class CATKeystroke
00056 {
00057 public:
00058     CATKeystroke()
00059     {
00060         fKey = 0;
00061         fSpecial = CATKEY_NONE;
00062         fModKey =  CATMODKEY_NONE;
00063     }
00064 
00065     CATKeystroke(CATUInt32 key, CATKEY_SPECIAL special, CATMODKEY modKey)
00066     {
00067         fKey = key;
00068         fSpecial = special;
00069         fModKey = modKey;
00070     }
00071 
00072     ~CATKeystroke()
00073     {
00074     }
00075 
00076     // For overrides, just return fKey
00077     operator CATUInt32 () const
00078     {
00079         return (CATUInt32)fKey;
00080     }
00081 
00082     CATKeystroke& operator=(char theChar)
00083     {
00084         fKey = theChar;
00085         fSpecial = CATKEY_NONE;
00086         fModKey = CATMODKEY_NONE;
00087         return *this;
00088     }
00089 
00090     CATKeystroke& operator=(CATUInt32 theChar)
00091     {
00092         fKey = theChar;
00093         fSpecial = CATKEY_NONE;
00094         fModKey = CATMODKEY_NONE;
00095         return *this;
00096     }
00097 
00098     CATKeystroke& operator=(CATKEY_SPECIAL specialChar)
00099     {
00100         fKey = 0;
00101         fSpecial = specialChar;
00102         fModKey = CATMODKEY_NONE;
00103         return *this;
00104     }
00105 
00106     bool IsNormal() const
00107     {
00108         return (fKey != 0);
00109     }
00110 
00111     bool IsSpecial() const
00112     {
00113         return (fSpecial != CATKEY_NONE);
00114     }
00115 
00116     bool CtrlDown() const
00117     {
00118         return (fModKey & CATMODKEY_CTRL)?true:false;
00119     }
00120 
00121     bool AltDown() const
00122     {
00123         return  (fModKey & CATMODKEY_ALT)?true:false;
00124     }
00125 
00126     bool ShiftDown() const
00127     {
00128         return (fModKey & CATMODKEY_SHIFT)?true:false;
00129     }
00130 
00131     void Set(CATUInt32 key, CATKEY_SPECIAL special, CATMODKEY modKey)
00132     {
00133         fKey     = key;
00134         fSpecial = special;
00135         fModKey = modKey;
00136     }
00137 
00138     CATKEY_SPECIAL GetSpecialKey() const
00139     {
00140         return fSpecial;
00141     }
00142 
00143     CATUInt32       GetNormalKey() const
00144     {
00145         return fKey;
00146     }
00147 
00148 private:
00149     CATUInt32           fKey;
00150     CATKEY_SPECIAL      fSpecial;
00151     CATMODKEY           fModKey;
00152 };
00153 
00154 #endif // _CATKeystroke_H_
00155 
00156 

Generated on Mon Feb 11 04:09:44 2008 for Game Accessibility Suite by doxygen 1.5.4