KeyPressSysMsg Class Reference

Represents a key press message that is slightly more abstract than the raw Windows message. This will hopefully aid the porting of this code to other platforms. More...

#include <keypress.h>

List of all members.

Public Member Functions

 KeyPressSysMsg (wxKeyEvent *pMsg)
 The constructor. Creates a key press message object from a raw Windows message block. A valid KeyPressSysMsg is constructed if the message was one of these: WM_KEYDOWN WM_KEYUP WM_SYSKEYDOWN WM_SYSKEYUP WM_CHAR.
BOOL IsValid ()
 Allows you to see if the KeyPressSysMsg was legally constructed.

Public Attributes

KeyPressSysMsgHandle Message
UINT32 VirtKey
UINT32 RepeatCount
UINT32 ScanCode
BOOL Extended: 1
BOOL PrevDown: 1

Private Member Functions

 CC_DECLARE_MEMDUMP (KeyPressSysMsg)

Private Attributes

BOOL Valid: 1

Static Private Attributes

static UINT32 m_LastVirtKey = 0


Detailed Description

Represents a key press message that is slightly more abstract than the raw Windows message. This will hopefully aid the porting of this code to other platforms.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/8/94

Definition at line 150 of file keypress.h.


Constructor & Destructor Documentation

KeyPressSysMsg::KeyPressSysMsg wxKeyEvent *  pMsg  ) 
 

The constructor. Creates a key press message object from a raw Windows message block. A valid KeyPressSysMsg is constructed if the message was one of these: WM_KEYDOWN WM_KEYUP WM_SYSKEYDOWN WM_SYSKEYUP WM_CHAR.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/8/94
Parameters:
pMsg = Ptr to a Windows message block [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: If the Windows message is not key-related, then the member function IsValid() will return FALSE

See also:
KeyPressSysMsg::IsValid

Definition at line 269 of file keypress.cpp.

00270 {
00271     // Assume the message is a key-related one that we want
00272     Valid = TRUE;
00273 
00274     // There doesn't seem to be a need to distinguish between WM_KEY and WM_SYSKEY message
00275     // so map them to the same KM message
00276     if( wxEVT_KEY_DOWN == pMsg->GetEventType() ) 
00277     {
00278         Message = KM_KEYDOWN;
00279     }
00280     else
00281     if( wxEVT_CHAR == pMsg->GetEventType() ) 
00282     {
00283         Message = KM_CHAR;
00284     }
00285     else
00286     if( wxEVT_KEY_UP == pMsg->GetEventType() ) 
00287     {
00288         Message = KM_KEYUP;
00289     }
00290 PORTNOTE("other", "Removed Windows IME usage" )
00291 #ifndef EXCLUDE_FROM_XARALX
00292     case WM_IME_CHAR:
00293         TRACE( _T("IME\n"));
00294         break;
00295 #endif
00296     else
00297     {
00298         // Message was not one we're interested in, so the KeyPressSysMsg object is invalid
00299         Valid = FALSE;
00300     }
00301 
00302     if (Valid)
00303     {
00304         // Now we have a valid Windows message to play with.
00305         // Extract the data and store in a more platform-indy way
00306 
00307         // Get the virtual key code for the key pressed
00308         VirtKey = pMsg->GetKeyCode();
00309 
00310         // Get the key data flags word
00311 //      INT32 KeyData = pMsg->lParam;
00312         
00313         // We NEVER want to intercept Alt-Tab events, so filter them out here
00314         // (N.B. This was only ever a problem on Win16 - NT doesn't send us
00315         // Alt-Tab keydown events, only key-ups, which are ignored.)
00316         if ((VirtKey == CAMKEY(TAB)) && KeyPress::IsAlternativePressed())
00317         {
00318             Valid=FALSE;
00319             return;
00320         }
00321         
00322 PORTNOTE("other", "Removed some keypress mangling" )
00323 #ifndef EXCLUDE_FROM_XARALX
00324         RepeatCount = KeyData & 0xffff;
00325         ScanCode    = (KeyData >> 16) & 0xff;
00326         Extended    = (KeyData & (1<<24)) != 0;
00327         PrevDown    = (KeyData & (1<<30)) != 0;
00328 #else
00329         RepeatCount = 1;
00330         ScanCode    = VirtKey;
00331         Extended    = VirtKey >= WXK_START;
00332         PrevDown    = m_LastVirtKey == VirtKey;
00333 #if FALSE != wxUSE_UNICODE
00334         m_Char      = pMsg->GetUnicodeKey();
00335         TRACEUSER( "jlh92", _T("m_Char = %04x Ext=%d\n"), m_Char, Extended );
00336 #endif
00337 #endif
00338         // Update the last virtual keycode if not a modifier
00339         switch( VirtKey )
00340         {
00341         case WXK_SHIFT:
00342         case WXK_ALT:
00343         case WXK_CONTROL:
00344         case WXK_MENU:
00345             // Skip
00346             break;
00347 
00348         default:
00349             if( KM_KEYUP == Message )
00350                 m_LastVirtKey = 0;
00351             else
00352                 m_LastVirtKey = VirtKey;
00353             break;
00354         }
00355     }
00356 }


Member Function Documentation

KeyPressSysMsg::CC_DECLARE_MEMDUMP KeyPressSysMsg   )  [private]
 

BOOL KeyPressSysMsg::IsValid  ) 
 

Allows you to see if the KeyPressSysMsg was legally constructed.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the KeyPressSysMsg object is a valid one. FALSE otherwise

Errors: -

See also:
KeyPressSysMsg::KeyPressSysMsg

Definition at line 373 of file keypress.cpp.

00374 {
00375     return Valid;
00376 }


Member Data Documentation

BOOL KeyPressSysMsg::Extended
 

Definition at line 167 of file keypress.h.

UINT32 KeyPressSysMsg::m_LastVirtKey = 0 [static, private]
 

Definition at line 174 of file keypress.h.

KeyPressSysMsgHandle KeyPressSysMsg::Message
 

Definition at line 158 of file keypress.h.

BOOL KeyPressSysMsg::PrevDown
 

Definition at line 168 of file keypress.h.

UINT32 KeyPressSysMsg::RepeatCount
 

Definition at line 161 of file keypress.h.

UINT32 KeyPressSysMsg::ScanCode
 

Definition at line 162 of file keypress.h.

BOOL KeyPressSysMsg::Valid [private]
 

Definition at line 171 of file keypress.h.

UINT32 KeyPressSysMsg::VirtKey
 

Definition at line 160 of file keypress.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:55:42 2007 for Camelot by  doxygen 1.4.4