00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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