Blender  V2.59
GHOST_ModifierKeys.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_ModifierKeys.cpp 35152 2011-02-25 11:28:33Z jesterking $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): none yet.
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00042 #include "GHOST_ModifierKeys.h"
00043 
00044 
00045 GHOST_ModifierKeys::GHOST_ModifierKeys()
00046 {
00047         clear();
00048 }
00049 
00050 GHOST_ModifierKeys::~GHOST_ModifierKeys() {}
00051 
00052 
00053 GHOST_TKey GHOST_ModifierKeys::getModifierKeyCode(GHOST_TModifierKeyMask mask)
00054 {
00055         GHOST_TKey key;
00056         switch (mask) {
00057         case GHOST_kModifierKeyLeftShift:               key = GHOST_kKeyLeftShift;              break;
00058         case GHOST_kModifierKeyRightShift:              key = GHOST_kKeyRightShift;             break;
00059         case GHOST_kModifierKeyLeftAlt:                 key = GHOST_kKeyLeftAlt;                break;
00060         case GHOST_kModifierKeyRightAlt:                key = GHOST_kKeyRightAlt;               break;
00061         case GHOST_kModifierKeyLeftControl:             key = GHOST_kKeyLeftControl;    break;
00062         case GHOST_kModifierKeyRightControl:    key = GHOST_kKeyRightControl;   break;
00063         case GHOST_kModifierKeyOS:                      key = GHOST_kKeyOS;             break;
00064         default:
00065                 // Should not happen
00066                 key = GHOST_kKeyUnknown;
00067                 break;
00068         }
00069         return key;
00070 }
00071 
00072 
00073 bool GHOST_ModifierKeys::get(GHOST_TModifierKeyMask mask) const
00074 {
00075     switch (mask) {
00076     case GHOST_kModifierKeyLeftShift:
00077         return m_LeftShift;
00078     case GHOST_kModifierKeyRightShift:
00079         return m_RightShift;
00080     case GHOST_kModifierKeyLeftAlt:
00081         return m_LeftAlt;
00082     case GHOST_kModifierKeyRightAlt:
00083         return m_RightAlt;
00084     case GHOST_kModifierKeyLeftControl:
00085         return m_LeftControl;
00086     case GHOST_kModifierKeyRightControl:
00087         return m_RightControl;
00088     case GHOST_kModifierKeyOS:
00089         return m_OS;
00090     default:
00091         return false;
00092     }
00093 }
00094 
00095 
00096 void GHOST_ModifierKeys::set(GHOST_TModifierKeyMask mask, bool down)
00097 {
00098     switch (mask) {
00099     case GHOST_kModifierKeyLeftShift:
00100         m_LeftShift = down; break;
00101     case GHOST_kModifierKeyRightShift:
00102         m_RightShift = down; break;
00103     case GHOST_kModifierKeyLeftAlt:
00104         m_LeftAlt = down; break;
00105     case GHOST_kModifierKeyRightAlt:
00106         m_RightAlt = down; break;
00107     case GHOST_kModifierKeyLeftControl:
00108         m_LeftControl = down; break;
00109     case GHOST_kModifierKeyRightControl:
00110         m_RightControl = down; break;
00111     case GHOST_kModifierKeyOS:
00112         m_OS = down; break;
00113     default:
00114         break;
00115     }
00116 }
00117 
00118 
00119 void GHOST_ModifierKeys::clear()
00120 {
00121     m_LeftShift = false;
00122     m_RightShift = false;
00123     m_LeftAlt = false;
00124     m_RightAlt = false;
00125     m_LeftControl = false;
00126     m_RightControl = false;
00127     m_OS = false;
00128 }
00129 
00130 
00131 bool GHOST_ModifierKeys::equals(const GHOST_ModifierKeys& keys) const
00132 {
00133         return (m_LeftShift == keys.m_LeftShift) &&
00134                 (m_RightShift == keys.m_RightShift) &&
00135                 (m_LeftAlt == keys.m_LeftAlt) &&
00136                 (m_RightAlt == keys.m_RightAlt) &&
00137                 (m_LeftControl == keys.m_LeftControl) &&
00138                 (m_RightControl == keys.m_RightControl) &&
00139         (m_OS == keys.m_OS);
00140 }