Blender V2.61 - r43446

GHOST_ModifierKeys.cpp

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