#include <keypress.h>
Public Member Functions | |
| KeyPress (KeyPressSysMsg *pKeySysMsg, WCHAR UnicodeChar) | |
| Constructs a KeyPress object from the given parameters. | |
| KeyPress (UINT32 VirtKey, BOOL PlusAdjust=FALSE, BOOL PlusConstrain=FALSE, BOOL PlusAlternative=FALSE, BOOL ExtendedKey=FALSE, BOOL WorksInDragsKey=FALSE) | |
| Constructs a KeyPress object from the given parameters This constructor is for use by systems that deal with "hot keys", i.e. ones that are only interested in the physical key that is being pressed. | |
| KeyPress (const KeyPress &c) | |
| BOOL | IsValid () |
| Allows you to see if the KeyPress is legal. The default KeyPress constuctor will always create invalid instances. It is up to other constructors, or member functions, to generate valid ones. | |
| UINT32 | GetVirtKey () |
| WCHAR | GetUnicode () |
| BOOL | IsAdjust () |
| BOOL | IsConstrain () |
| BOOL | IsAlternative () |
| BOOL | IsOption () |
| BOOL | IsModified () |
| BOOL | IsExtended () |
| BOOL | IsRepeat () |
| BOOL | IsRightHand () |
| BOOL | IsRelease () |
| BOOL | IsChar () |
| BOOL | IsPress () |
| BOOL | IsOkInDrags () |
| INT32 | operator== (const KeyPress &) |
| KeyPress == operator Two KeyPress objects are equal if 1) They have the same virtual key code 2) Have the same modifier settings 3) Have the same extended flag settings 4) Have the same validity (i.e. both valid OR both invalid). | |
Static Public Member Functions | |
| static BOOL | Init () |
| Initialises the KeyPress class. | |
| static FilePath | GetHotKeysFilename () |
| static BOOL | DispatchKeyEvent (UINT32 nMsgID, UINT32 nChar, UINT32 nRepCnt, UINT32 nFlags) |
| Packages an MFC key-stroke message into a form suitable for the kernel and calls the keyboard system with the event. | |
| static BOOL | TranslateMessage (wxKeyEvent *pMsg) |
| Called from a low-level PreTranslateMessage() routine to allow key presses to be processed If it is a key press message, it generates a KeyPress object and sends it off to Application::OnKeyPress(). | |
| static void | ResetModifierKeys () |
| Maintain integrity of our key modifier status. Win32S doesn't always tell us what key events have occured - notably when the user uses Alt-TAB to switch tasks. Hence this gets called whenever our main window is deactivated or activated. The temporary tool is updated if required. | |
| static BOOL | GenerateCharMessage (wxKeyEvent *pMsg) |
| This tries to see if the keypress message can generate a WM_CHAR message. | |
| static BOOL | IsAdjustPressed () |
| Tests status of the "Adjust" key. | |
| static BOOL | IsConstrainPressed () |
| Tests status of the "Constrain" key. | |
| static BOOL | IsAlternativePressed () |
| Tests status of the "Alternative" key. | |
| static BOOL | IsEscapePressed () |
| Lets you see if an escape key combination is currently being pressed, or has been pressed since the last call to this routine. | |
| static BOOL | IsKeyPressed (UINT32 VirtKey) |
| General async keypress func call. | |
| static BOOL | ModifierChanged () |
| static BOOL | IsGalleryShiftPressed (void) |
| Tests status of the "Gallery Shift" key This is a special method for use by galleries, which must emulate the action of windows list boxes. "Gallery Shift" is the key used to select multiple items at once. | |
| static BOOL | IsGalleryCtrlPressed (void) |
| Tests status of the "Gallery Ctrl" key This is a special method for use by galleries, which must emulate the action of windows list boxes. "Gallery Ctrl" is the key used to add/remove single items to/from a selection. | |
| static KeyPress * | ConstructVK (TCHAR ch) |
| Constructs a keypress that represents the keypress required to generate the specified character. The Virtual Code will be CAMKEY(CC_NONE) if the key cannot be generated. | |
| static BOOL | AddVirtualKeyCode (UINT32 VCode, WCHAR Unicode) |
| Adds the given virtual key code to the list that Camelot knows about and send around internally (rather than ignoring). | |
| static void | RemoveVirtualKeyCode (UINT32 VCode, WCHAR Unicode) |
| Removes the given virtual key code that generates the givne unicode value from the list of additional virtual key codes. Only the first occurace is removed. | |
Private Member Functions | |
| CC_DECLARE_MEMDUMP (KeyPress) | |
| KeyPress () | |
| Default constructor. Creates an invalid keypress object. The KeyPress class will have one or more public constructors or static member functions for creating valid KeyPress objects. | |
| void | Initialise () |
| Initialises all member variables of the KeyPress object to sensible values. | |
Static Private Member Functions | |
| static BOOL | GenerateKeyPress (wxKeyEvent *pMsg, KeyPress **ppKeyPress) |
| Generates a legal, platform-independent key press object from the raw platform-dependent data provided. | |
| static INT32 | GenerateUnicode (UINT32 VirtKey, UINT32 ScanCode, BYTE *pKeyState, WCHAR *pWideCharBuf, UINT32 WideCharBufSize) |
| Converts a virtual key code into a Unicode char. This is a layer on top of the Windows ToUnicode() function that will generate Unicodes in the corporate user zone for keys that do not have a standard Unicode evivalent (e.g. function keys). | |
| static BOOL | IgnoreKeyMessage (KeyPressSysMsg *pKeySysMsg) |
| This filters out any invalid key messages that we may get from Windows, such as auto-repeated modifier (shift, ctrl, alt) keys. | |
| static BOOL | IsModifier (UINT32 VirtKey) |
| Central modifier key identifying routine. The modifiers are as follows : Both Alt keys Both Shift keys Both Ctrl keys. | |
| static void | UpdateModifierStatus (KeyPressSysMsg *pKeySysMsg) |
| If the message is a modifier key press, the static status vars for the modifier keys in the KeyPress class are updated. | |
| static KeyPress * | MakeKeyPress (KeyPressSysMsg *pKeySysMsg) |
| Makes a KeyPress from a KeyPressSysMsg. | |
| static BOOL | EscapePressed (KeyPress *pKeyPress) |
| Deals with an Escape key press. | |
Private Attributes | |
| UINT32 | VirtKey |
| WCHAR | Unicode |
| BOOL | Adjust: 1 |
| BOOL | Constrain: 1 |
| BOOL | Alternative: 1 |
| BOOL | Option: 1 |
| BOOL | Extended: 1 |
| BOOL | Repeat: 1 |
| BOOL | RightHand: 1 |
| BOOL | Release: 1 |
| BOOL | m_fIsChar: 1 |
| BOOL | Valid: 1 |
| BOOL | WorksInDrag: 1 |
Static Private Attributes | |
| static BOOL | AdjustStateLeft = FALSE |
| static BOOL | AdjustStateRight = FALSE |
| static BOOL | ConstrainStateLeft = FALSE |
| static BOOL | ConstrainStateRight = FALSE |
| static BOOL | AlternativeStateLeft = FALSE |
| static BOOL | AlternativeStateRight = FALSE |
| static BOOL | OptionStateLeft = FALSE |
| static BOOL | OptionStateRight = FALSE |
| static BOOL | fModifierChanged = FALSE |
| static INT32 | AsciiVal = -1 |
| static BOOL | ValidAsciiVal = FALSE |
| static BYTE | LastLeadByte = 0 |
| static List | AdditionalVirtKeys |
Definition at line 187 of file keypress.h.
|
||||||||||||
|
Constructs a KeyPress object from the given parameters.
Definition at line 516 of file keypress.cpp. 00517 { 00518 VirtKey = pKeySysMsg->VirtKey; 00519 Unicode = UnicodeChar; 00520 00521 Adjust = KeyPress::AdjustStateLeft | KeyPress::AdjustStateRight; 00522 Constrain = KeyPress::ConstrainStateLeft | KeyPress::ConstrainStateRight; 00523 Alternative = KeyPress::AlternativeStateLeft | KeyPress::AlternativeStateRight; 00524 Option = KeyPress::OptionStateLeft | KeyPress::OptionStateRight; 00525 00526 Extended = pKeySysMsg->Extended; 00527 00528 // Interpret Alt+Ctrl as Extended Alt, because AltGr (UK right hand Alt) produces an additional 00529 // Ctrl key press that is indistinguishable from a left hand Ctrl. 00530 // This means that left hand Alt+Ctrl will appear the same as right hand AltGr to Camelot. 00531 // E.g. Alt+Ctrl+Spacebar == AltGr+Spacebar 00532 if (Alternative && Constrain) 00533 { 00534 Extended = TRUE; 00535 Constrain = FALSE; 00536 } 00537 00538 Repeat = pKeySysMsg->PrevDown; 00539 RightHand = pKeySysMsg->Extended; 00540 Release = (pKeySysMsg->Message == KM_KEYUP); 00541 m_fIsChar = (pKeySysMsg->Message == KM_CHAR); 00542 00543 Valid = TRUE; // This is now a valid KeyPress object. 00544 }
|
|
||||||||||||||||||||||||||||
|
Constructs a KeyPress object from the given parameters This constructor is for use by systems that deal with "hot keys", i.e. ones that are only interested in the physical key that is being pressed.
Definition at line 572 of file keypress.cpp. 00574 { 00575 Initialise(); 00576 00577 VirtKey = ThisVirtKey; 00578 Adjust = PlusAdjust; 00579 Constrain = PlusConstrain; 00580 Alternative = PlusAlternative; 00581 Extended = ExtendedKey; 00582 WorksInDrag = WorksInDragsKey; 00583 Valid = TRUE; 00584 }
|
|
|
Definition at line 218 of file keypress.h. 00218 : // Copy constructor as CCObject's is private which prevents synthesis working 00219 VirtKey(c.VirtKey), Unicode(c.Unicode), Adjust(c.Adjust), Constrain(c.Constrain), 00220 Alternative(c.Alternative), Option(c.Option), Extended(c.Extended), Repeat(c.Repeat), 00221 RightHand(c.RightHand), Valid(c.Valid) {}
|
|
|
Default constructor. Creates an invalid keypress object. The KeyPress class will have one or more public constructors or static member functions for creating valid KeyPress objects.
Definition at line 495 of file keypress.cpp. 00496 { 00497 Initialise(); 00498 }
|
|
||||||||||||
|
Adds the given virtual key code to the list that Camelot knows about and send around internally (rather than ignoring).
Definition at line 1789 of file keypress.cpp. 01790 { 01791 // Construct a list item 01792 AdditionalVirtKey* pNew = new AdditionalVirtKey; 01793 01794 if (pNew != NULL) 01795 { 01796 pNew->VirtualKeyCode = VCode; 01797 pNew->UnicodeValue = Unicode; 01798 01799 AdditionalVirtKeys.AddHead(pNew); 01800 } 01801 01802 return (pNew != NULL); 01803 }
|
|
|
|
|
|
Constructs a keypress that represents the keypress required to generate the specified character. The Virtual Code will be CAMKEY(CC_NONE) if the key cannot be generated.
Definition at line 604 of file keypress.cpp. 00605 { 00606 // PORTNOTETRACE( "other", "KeyPress::ConstructVK - do nothing" ); 00607 KeyPress* pNew = new KeyPress(); 00608 00609 #if !defined(EXCLUDE_FROM_XARALX) 00610 if (pNew != NULL) 00611 { 00612 INT8 Result = ::VkKeyScan(ch); 00613 BYTE LowByte = Result & 0xFF; 00614 BYTE HighByte = (Result >> 8) & 0xFF; 00615 00616 if ((HighByte == 0xFF) && (LowByte == 0xFF)) 00617 { 00618 pNew->VirtKey = CAMKEY(CC_NONE); 00619 } 00620 else 00621 { 00622 pNew->VirtKey = LowByte; 00623 pNew->Adjust = HighByte & 1; 00624 pNew->Constrain = HighByte & 2; 00625 pNew->Alternative = HighByte & 4; 00626 } 00627 } 00628 #endif 00629 00630 return pNew; 00631 }
|
|
||||||||||||||||||||
|
Packages an MFC key-stroke message into a form suitable for the kernel and calls the keyboard system with the event.
Definition at line 454 of file keypress.cpp. 00455 { 00456 // Make sure the kernel knows which view/doc the event applies to, if any. 00457 if (Document::GetSelected() != NULL) Document::GetSelected()->SetCurrent(); 00458 if (DocView::GetSelected() != NULL) DocView::GetSelected()->SetCurrent(); 00459 00460 PORTNOTETRACE("other,", "BaseTextClass::PreOpProcessing - do nothing" ); 00461 #ifndef EXCLUDE_FROM_XARALX 00462 // For compatibility with existing code we must repackage the unpacked message. 00463 // NB. the RHS of the lParam expression will work for Win16 as well. 00464 MSG msg; 00465 msg.message = nMsgID; 00466 msg.wParam = nChar; 00467 msg.lParam = (nRepCnt & 0xFFFF) | ((((LPARAM) nFlags) & 0xFFFF) << 16); 00468 00469 // Call the key-press system. 00470 return TranslateMessage(&msg); 00471 #else 00472 return true; 00473 #endif 00474 }
|
|
|
Deals with an Escape key press.
if it was an escape key press, it is processed in a relevent way At the moment, this just means that the current drag is terminated, if there is one. If it's an escape key press, and it was acted upon (e.g. a drag was terminated), TRUE is returned. Otherwise FALSE is returned
Definition at line 1447 of file keypress.cpp. 01448 { 01449 ENSURE(pKeyPress->IsValid(),"Invalid KeyPress given"); 01450 01451 BOOL Processed = FALSE; 01452 UINT32 VirtKey = pKeyPress->GetVirtKey(); 01453 01454 // Only check non-auto-repeat "key down" key presses 01455 if (pKeyPress->IsPress() && !pKeyPress->IsRepeat()) 01456 { 01457 if (VirtKey == CAMKEY(ESCAPE) || VirtKey == WXK_CANCEL) 01458 { 01459 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 01460 // MarkN I've moved this code in an attempt to stop the selection being 01461 // cleared after a bar drag cancel - Chris. 01462 if (!Processed) 01463 Processed = BaseBar::EscPressed(TRUE); 01464 01465 // cancel any drag manager drags (and say that we have done so!!!) 01466 // stops the selection being cleared when you cancel a 01467 // colour or sprite (or any) DragManagerOp drag 01468 if(!Processed && DragManagerOp::GetCurrentManager() != NULL) 01469 { 01470 DragManagerOp::AbortDrag(); 01471 Processed = TRUE; 01472 } 01473 #endif 01474 01475 if (!Processed && Operation::GetCurrentDragOp() != NULL) 01476 { 01477 OilCoord PointerPos(0,0); 01478 ClickModifiers ClickMods; 01479 // Spread* pSpread = NULL; 01480 01481 DocView* pDocView = DocView::GetSelected(); 01482 if (pDocView) 01483 pDocView->DragFinished(Operation::GetCurrentDragOp(), PointerPos, ClickMods, FALSE); 01484 01485 // We've done something with this escape key press so set Processed to TRUE 01486 // to prevent it from being passed on 01487 Processed = (Operation::GetCurrentDragOp() == NULL); 01488 } 01489 01490 if (!Processed && Operation::GetCurrentDragOp() != NULL) 01491 { 01492 DocCoord PointerPos(0,0); 01493 ClickModifiers ClickMods; 01494 Spread* pSpread = NULL; 01495 01496 Operation::GetCurrentDragOp()->DragFinished(PointerPos, ClickMods, pSpread, FALSE, FALSE); 01497 01498 // We've done something with this escape key press so set Processed to TRUE 01499 // to prevent it from being passed on 01500 Processed = TRUE; 01501 } 01502 01503 // This gives Chris a chance to terminate his bar dragging. This was necessary as his former 01504 // way of detecting Escape (via KeyMsg broadcasts) no longer works because Escape is now a hot key, and 01505 // as such gets in there before a KeyMsg is broadcast. 01506 // (MarkN 27/4/95) 01507 /*if (!Processed) 01508 Processed = BaseBar::EscPressed(TRUE); 01509 */ 01510 // Throw away all pending key messages 01511 PORTNOTE( "other", "Remove PeekMessage" ) 01512 #if !defined(EXCLUDE_FROM_XARALX) 01513 MSG msg; 01514 while(PeekMessage( &msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE )) 01515 ; 01516 #endif 01517 } 01518 } 01519 01520 return Processed; 01521 }
|
|
|
This tries to see if the keypress message can generate a WM_CHAR message.
We have to do this ourselves because we get less messages generated in Win 3.1 than we do in NT, so the NT solution (act upon the auto generated WM_CHAR message) won't work an all target platforms (pain in the butt or what?). The ideal solution is to find out exactly why we don't get this extra WM_CHAR message in Win3.1, but I've traced paths of key press messages under NT and have found no obvious reason why the Win3.1 should behave differently. As we don't have single stepping technology under Win3.1, it's almost impossible to determine what's going on. So, the time honoured CC tradition, if the OS doesn't do it, we'll do it ourselves.
Definition at line 1556 of file keypress.cpp. 01557 { 01558 BOOL Processed = FALSE; 01559 01560 // Get the virtual key code for the key pressed 01561 UINT32 VirtKey = pMsg->GetKeyCode(); 01562 01563 //DumpKeyMessage(pMsg); 01564 01565 if( wxEVT_KEY_DOWN == pMsg->GetEventType() ) 01566 { 01567 if (VirtKey == CAMKEY(MENU)) 01568 { 01569 // Trap ALL Alt key down messages 01570 01571 if (!KeyPress::ValidAsciiVal) 01572 { 01573 // Initialise a ASCII value entry 01574 //TRACE( _T("-*-*-*-- Starting valid ascii val\n")); 01575 KeyPress::ValidAsciiVal = TRUE; 01576 KeyPress::AsciiVal = -1; 01577 } 01578 } 01579 else if (KeyPress::ValidAsciiVal && ((VirtKey < CAMKEY(NUMPAD0)) || (VirtKey > WXK_NUMPAD9))) 01580 { 01581 // If the key down message is not a num pad key between '0' and '9' 01582 // invalidate the ASCII value 01583 //TRACE( _T("-*-*-*-- (keydown) Invalidating ascii val\n")); 01584 KeyPress::ValidAsciiVal = FALSE; 01585 } 01586 } 01587 else 01588 if( wxEVT_KEY_UP == pMsg->GetEventType() ) 01589 { 01590 if (KeyPress::ValidAsciiVal) 01591 { 01592 // Only try to produce an ASCII value if the last set of key presses has generated 01593 // a valid value 01594 01595 if (VirtKey == CAMKEY(MENU)) 01596 { 01597 // We've received a Alt key up message, so post ourselves a WM_CHAR message that 01598 // contains the generated ASCII value 01599 01600 if (KeyPress::AsciiVal >= 0) 01601 { 01602 // Only post the ASCII value if one's been specified via the Num key pad 01603 // (i.e. the value >= 0) 01604 //TRACE( _T("-*-*-*-- Posting WM_CHAR. Val = %ld\n"),KeyPress::AsciiVal); 01605 PORTNOTE("other", "Removed PostMessage usage - WM_CHAR from ascii code" ) 01606 #ifndef EXCLUDE_FROM_XARALX 01607 Processed = ::PostMessage(pMsg->hwnd,WM_CHAR,KeyPress::AsciiVal % 256,1); 01608 #endif 01609 } 01610 //TRACE( _T("-*-*-*-- (keyup) Invalidating ascii val. Val = %ld\n"),KeyPress::AsciiVal); 01611 KeyPress::ValidAsciiVal = FALSE; 01612 } 01613 else if ((VirtKey >= CAMKEY(NUMPAD0)) && (VirtKey <= WXK_NUMPAD9)) 01614 { 01615 // We've got a num key pad key up event 01616 // We have to do this bit on key up events, because for some reason under NT (and possibly 01617 // other OSs) we don't get a key down event for the first key that's pressed while the 01618 // Alt key is auto-repeating (wierd - any ideas welcome) 01619 01620 // If this is the first one (i.e. ASCII val is currently < 0), reset the value to 0 01621 if (KeyPress::AsciiVal < 0) 01622 KeyPress::AsciiVal = 0; 01623 01624 // Shift the current value up, and add in the digit of the num key pad key. 01625 KeyPress::AsciiVal = ((KeyPress::AsciiVal*10)+(VirtKey-CAMKEY(NUMPAD0))); 01626 01627 // We've processed this key press 01628 Processed = TRUE; 01629 01630 //TRACE( _T("-*-*-*-- ascii val digit received. Val = %ld\n"),KeyPress::AsciiVal); 01631 } 01632 } 01633 } 01634 01635 return Processed; 01636 }
|
|
||||||||||||
|
Generates a legal, platform-independent key press object from the raw platform-dependent data provided.
Definition at line 1109 of file keypress.cpp. 01110 { 01111 // Ensure *ppKeyPress is valid, just in case we have to exit the function early 01112 *ppKeyPress = NULL; 01113 01114 // Create a platform-indy key press message object 01115 KeyPressSysMsg KeySysMsg(pMsg); 01116 01117 if (KeySysMsg.IsValid()) 01118 { 01119 // If it's a key press message that we can ignore, then ignore it, pretending we have processed it 01120 01121 if (!IgnoreKeyMessage(&KeySysMsg)) 01122 { 01123 // We like the look of this key press event 01124 01125 // Ensure the modifier key states are up to date 01126 UpdateModifierStatus(&KeySysMsg); 01127 01128 // Make a KeyPress object 01129 *ppKeyPress = MakeKeyPress(&KeySysMsg); 01130 01131 // If the mods have changed, and we were able to make a keypress object, send 01132 // a "modifiers have changed message" 01133 if (KeyPress::fModifierChanged && *ppKeyPress != NULL) 01134 { 01135 BROADCAST_TO_ALL(KeyMsg(KeyMsg::MODIFIERCHANGED,*ppKeyPress)); 01136 } 01137 } 01138 01139 #ifdef _DEBUG 01140 /* 01141 if (*ppKeyPress != NULL) 01142 { 01143 char s[1000]; 01144 _stprintf(s,"Mess = %d, Virtkey = 0x%lx, Ext = %d, PrevD = %d, Shift = %d, Ctrl = %d, Alt = %d, AShift = 0x%x, ACtrl = 0x%x, AAlt = 0x%x, IsAd = %d, IsCon = %d, IsAlt = %d", 01145 KeySysMsg.Message, 01146 KeySysMsg.VirtKey, 01147 KeySysMsg.Extended, 01148 KeySysMsg.PrevDown, 01149 KeyPress::AdjustStateLeft | KeyPress::AdjustStateRight, 01150 KeyPress::ConstrainStateLeft | KeyPress::ConstrainStateRight, 01151 KeyPress::AlternativeStateLeft | KeyPress::AlternativeStateRight, 01152 AsyncShift, 01153 AsyncCtrl, 01154 AsyncAlt, 01155 (*ppKeyPress)->IsAdjust(), 01156 (*ppKeyPress)->IsConstrain(), 01157 (*ppKeyPress)->IsAlternative() 01158 ); 01159 ENSURE(FALSE,s); 01160 } 01161 */ 01162 //DumpKeyMessage(pMsg); 01163 01164 #endif // _DEBUG 01165 01166 // Return TRUE to say that it really was a keyboard message 01167 return TRUE; 01168 } 01169 else 01170 return FALSE; // Not a keybaord type event that we're interested in 01171 }
|
|
||||||||||||||||||||||||
|
Converts a virtual key code into a Unicode char. This is a layer on top of the Windows ToUnicode() function that will generate Unicodes in the corporate user zone for keys that do not have a standard Unicode evivalent (e.g. function keys). > static INT32 KeyPress::GenerateUnicode(UINT32 VirtKey,UINT32 ScanCode,BYTE* pKeyState,WCHAR* pWideCharBuf,INT32 WideCharBufSize)
Definition at line 749 of file keypress.cpp. 00750 { 00751 #if defined(__WXMSW__) 00752 // Make sure we have a buffer to use 00753 ENSURE(WideCharBufSize >= 2,"The wide char buffer size should be at least 2"); 00754 if (WideCharBufSize < 2) return 0; 00755 00756 INT32 NumChars = ToUnicode(VirtKey,ScanCode,pKeyState,pWideCharBuf,WideCharBufSize,0); 00757 00758 // NumChars == 0 if ToUnicode() failed to generate a code for the keypress 00759 00760 // If no direct eqivalent Unicode char, see if we can generate one with the ASCII value for the VirtKey 00761 // or look one up in our extra Unicode table 00762 if (NumChars == 0) 00763 { 00764 WORD pWordBuf[10]; 00765 00766 // See if ToAscii() can make a Latin I ASCII char out of it 00767 INT32 NumASCIIChars = ToAscii(VirtKey,ScanCode,pKeyState,pWordBuf,0); 00768 00769 if (NumASCIIChars == 1) 00770 { 00771 // Map the lower byte ASCII value onto the equivalent Unicode char 00772 pWideCharBuf[0] = pWordBuf[0] & 0xff; 00773 NumChars = 1; 00774 } 00775 } 00776 00777 if (NumChars == 0) 00778 { 00779 // ToAscii() failed, so lets have a look in our table 00780 00781 INT32 i=0; 00782 BOOL finished = FALSE; 00783 00784 do 00785 { 00786 // We've finished if we've reached the ungeneratable VK code 00787 finished = (ExtraUnicodes[i].VirtKey == CAMKEY(CC_NONE)); 00788 00789 if (!finished && ExtraUnicodes[i].VirtKey == VirtKey) 00790 { 00791 // We have found an entry in our table for the given virtual key 00792 00793 // Stuff the Unicode value into the buffer and set the num chars generated to 1 00794 pWideCharBuf[0] = ExtraUnicodes[i].Unicode; 00795 NumChars = 1; 00796 finished = TRUE; 00797 } 00798 i++; 00799 } while (!finished); 00800 00801 // Check the runtime list too 00802 if (NumChars != 1) 00803 { 00804 finished = FALSE; 00805 AdditionalVirtKey* pKey = (AdditionalVirtKey*)AdditionalVirtKeys.GetHead(); 00806 while (!finished && (pKey != NULL)) 00807 { 00808 if (pKey->VirtualKeyCode == VirtKey) 00809 { 00810 pWideCharBuf[0] = pKey->UnicodeValue; 00811 NumChars = 1; 00812 finished = TRUE; 00813 } 00814 00815 pKey = (AdditionalVirtKey*)AdditionalVirtKeys.GetNext(pKey); 00816 } 00817 } 00818 } 00819 00820 if (NumChars == 0) 00821 { 00822 // If the virt key is obviously one that should be handled (i.e. an alphabetical key), 00823 // we automatically generate a code. 00824 // This Unicode code will be the same as the one generated by Ctrl+<alphabetical key> 00825 // 00826 // "Why do we need this?" I hear you scream. This is because ToUnicode() fails when you do a 00827 // Ctrl+Alt+<key>. As this is an important modifier combo used by the hot key system, we need to make it work. 00828 // 00829 // Markn - 11/1/95 00830 00831 if (VirtKey >= 'A' && VirtKey <= 'Z') 00832 { 00833 pWideCharBuf[0] = VirtKey - 'A'; 00834 NumChars = 1; 00835 } 00836 } 00837 00838 #ifdef _DEBUG 00839 /* 00840 if (IsUserName("MarkN") && (NumChars == 0)) 00841 { 00842 Beep(); 00843 TRACE( _T("\n***\nVirtKey %lx has no Unicode equivalent!\n***\n"),VirtKey); 00844 } 00845 */ 00846 #endif 00847 00848 // Return the number of Unicode chars that have been dumped into the buffer 00849 return NumChars; 00850 #else 00851 return 0; 00852 #endif 00853 }
|
|
|
Definition at line 421 of file keypress.cpp. 00422 { 00423 FilePath result; 00424 00425 wxStandardPaths Paths; 00426 wxString strPath( Paths.GetUserConfigDir() ); 00427 strPath += _T("/.xaralx/hotkeys"); 00428 00429 if (wxFile::Exists(strPath)) 00430 result.SetPathName(strPath, FALSE); 00431 00432 return result; 00433 }
|
|
|
Definition at line 230 of file keypress.h. 00230 { return Unicode; } // Returns the unicode char generated by the virtual key
|
|
|
Definition at line 229 of file keypress.h. 00229 { return VirtKey; } // Returns the virtual key code
|
|
|
This filters out any invalid key messages that we may get from Windows, such as auto-repeated modifier (shift, ctrl, alt) keys.
Definition at line 873 of file keypress.cpp. 00874 { 00875 // PORTNOTETRACE( "other", "KeyPress::IgnoreKeyMessage - do nothing" ); 00876 00877 ENSURE(pKeySysMsg->IsValid(),"Invalid KeyPressSysMsg given"); 00878 00879 // Ignore if it's a key down msg, and the key is a modifier, and it's an auto-repeat message 00880 BOOL Ignore = (pKeySysMsg->Message == KM_KEYDOWN && KeyPress::IsModifier(pKeySysMsg->VirtKey) && pKeySysMsg->PrevDown); 00881 00882 #if !defined(EXCLUDE_FROM_XARALX) 00883 KeyPress* pNew = new KeyPress(); 00884 if (UnicodeManager::IsDBCSOS()) 00885 { 00886 // handling for DBCS characters; they roll up as two sepearte WM_CHAR messages 00887 if (!Ignore && pKeySysMsg->Message==KM_CHAR) 00888 { 00889 if (LastLeadByte==0 && IsDBCSLeadByte(pKeySysMsg->VirtKey)) 00890 { 00891 // It's a lead byte so store it away for the next message and ignore this one 00892 TRACE( _T("Lead byte %d\n"), pKeySysMsg->VirtKey); 00893 LastLeadByte = pKeySysMsg->VirtKey; 00894 Ignore = TRUE; 00895 } 00896 } 00897 } 00898 #endif 00899 00900 return Ignore; 00901 }
|
|
|
Initialises the KeyPress class.
Definition at line 401 of file keypress.cpp. 00402 { 00403 return TRUE; 00404 }
|
|
|
Initialises all member variables of the KeyPress object to sensible values.
Definition at line 649 of file keypress.cpp. 00650 { 00651 // Some highly unlikely Unicode char 00652 Unicode = 0xffff; 00653 00654 // A highly unlikely virtual key 00655 VirtKey = CAMKEY(CC_NONE); 00656 00657 // Set all the flags to FALSE 00658 Adjust = FALSE; 00659 Constrain = FALSE; 00660 Alternative = FALSE; 00661 Option = FALSE; 00662 00663 Extended = FALSE; 00664 00665 Repeat = FALSE; 00666 RightHand = FALSE; 00667 Release = FALSE; 00668 m_fIsChar = FALSE; 00669 00670 // This is an invalid KeyPress object at the moment 00671 Valid = FALSE; 00672 }
|
|
|
Definition at line 233 of file keypress.h. 00233 { return Adjust; }
|
|
|
Tests status of the "Adjust" key.
Definition at line 1225 of file keypress.cpp. 01226 { 01227 return ::wxGetKeyState(CAMKEY(CC_MOD_ADJUST)); 01228 }
|
|
|
Definition at line 235 of file keypress.h. 00235 { return Alternative; }
|
|
|
Tests status of the "Alternative" key.
Definition at line 1265 of file keypress.cpp. 01266 { 01267 return ::wxGetKeyState(CAMKEY(CC_MOD_ALTERNATIVE)); 01268 }
|
|
|
Definition at line 243 of file keypress.h. 00243 { return m_fIsChar; }
|
|
|
Definition at line 234 of file keypress.h. 00234 { return Constrain; }
|
|
|
Tests status of the "Constrain" key.
Definition at line 1245 of file keypress.cpp. 01246 { 01247 return ::wxGetKeyState(CAMKEY(CC_MOD_CONSTRAIN)); 01248 }
|
|
|
Lets you see if an escape key combination is currently being pressed, or has been pressed since the last call to this routine.
GetAsyncKeyState() returns the current key state AND whether the key was pressed since the last call to GetAsyncKeyState(). Note: If TRUE is returned, all pending key messages will have been removed before hand. using PeekMessage(...WM_KEYFIRST,WM_KEYLAST,PM_REMOVE)
Definition at line 1368 of file keypress.cpp. 01369 { 01370 PORTNOTE("other", "KeyPress::IsEscapePressed - do nothing" ) 01371 #ifndef EXCLUDE_FROM_XARALX 01372 // TRACE( _T("Warning - KeyPress::IsEscapePressed called") ); 01373 /* BOOL EscapePressed = (GetAsyncKeyState(CAMKEY(ESCAPE)) != 0); 01374 BOOL Pressed = EscapePressed || (GetAsyncKeyState(CAMKEY(CANCEL)) != 0); 01375 01376 if (Pressed) 01377 { 01378 BOOL EscapeKeyDown = FALSE; 01379 01380 // Throw away all pending key messages 01381 MSG msg; 01382 while(PeekMessage( &msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE )) 01383 { 01384 // |