wg_message.cpp

00001 // wg_message.cpp
00002 //
00003 // CMessage class implementation
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022 //
00023 
00024 
00025 #include "wgui_include_config.h"
00026 #include "wg_message.h"
00027 #include "wutil_debug.h"
00028 #include "std_ex.h"
00029 
00030 
00031 namespace wGui
00032 {
00033 
00034 CMessage::CMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource) :
00035      m_MessageType(MessageType),
00036      m_pDestination(pDestination),
00037      m_pSource(pSource)
00038 {
00039 
00040 }
00041 
00042 
00043 CSDLMessage::CSDLMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource, SDL_Event SDLEvent) :
00044      CMessage(MessageType, pDestination, pSource),
00045      SDLEvent(SDLEvent)
00046 {
00047 
00048 }
00049 
00050 
00051 CKeyboardMessage::CKeyboardMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource,
00052           unsigned char ScanCode, SDLMod Modifiers, SDLKey Key, Uint16 Unicode) :
00053      CMessage(MessageType, pDestination, pSource),
00054      ScanCode(ScanCode),
00055      Modifiers(Modifiers),
00056      Key(Key),
00057      Unicode(Unicode)
00058 {
00059 
00060 }
00061 
00062 
00063 CMouseMessage::CMouseMessage(const EMessageType MessageType, const CMessageClient* pDestination, const CMessageClient* pSource,
00064           CPoint Point, CPoint Relative, unsigned int Button) :
00065      CMessage(MessageType, pDestination, pSource),
00066      Point(Point),
00067      Relative(Relative),
00068      Button(Button)
00069 {
00070 
00071 }
00072 
00073 
00074 unsigned int CMouseMessage::TranslateSDLButton(Uint8 SDLButton)
00075 {
00076      unsigned int Button = 0;
00077      switch (SDLButton)
00078      {
00079      case SDL_BUTTON_LEFT:
00080           Button = LEFT;
00081           break;
00082      case SDL_BUTTON_RIGHT:
00083           Button = RIGHT;
00084           break;
00085      case SDL_BUTTON_MIDDLE:
00086           Button = MIDDLE;
00087           break;
00088      case SDL_BUTTON_WHEELUP:
00089           Button = WHEELUP;
00090           break;
00091      case SDL_BUTTON_WHEELDOWN:
00092           Button = WHEELDOWN;
00093           break;
00094      default:
00095           wUtil::Trace(L"Untranslated SDL Button # " + stdex::itoa(SDLButton));
00096           break;
00097      }
00098 
00099      return Button;
00100 }
00101 
00102 
00103 unsigned int CMouseMessage::TranslateSDLButtonState(Uint8 SDLButtonState)
00104 {
00105      unsigned int Button = 0;
00106      if (SDLButtonState & SDL_BUTTON(1))
00107      {
00108           Button |= LEFT;
00109      }
00110      if (SDLButtonState & SDL_BUTTON(2))
00111      {
00112           Button |= RIGHT;
00113      }
00114      if (SDLButtonState & SDL_BUTTON(3))
00115      {
00116           Button |= MIDDLE;
00117      }
00118      if (SDLButtonState & SDL_BUTTON(4))
00119      {
00120           Button |= WHEELUP;
00121      }
00122      if (SDLButtonState & SDL_BUTTON(5))
00123      {
00124           Button |= WHEELDOWN;
00125      }
00126 
00127      return Button;
00128 }
00129 
00130 
00131 }
00132 
00133 

Generated on Wed May 16 23:11:26 2007 for wGui by  doxygen 1.5.1