// Sound the bell
WXDLLIMPEXP_BASE void wxBell();
+#if defined(__WXGTK__) || defined(__WXMSW__) || defined(__WXMAC__) || defined(__X__)
+ // Get the state of a key (true if pressed, false if not)
+ WXDLLIMPEXP_BASE bool wxGetKeyState(wxKeyCode key);
+#endif
+
// Get OS description as a user-readable string
WXDLLIMPEXP_BASE wxString wxGetOsDescription();
return retval;
}
+int wxKeyCodeToMacModifier(wxKeyCode key)
+{
+ switch (key)
+ {
+ case WXK_START:
+ return cmdKey;
+
+ case WXK_SHIFT:
+ return shiftKey;
+
+ case WXK_CAPITAL:
+ return alphaLock;
+
+ case WXK_OPTION:
+ return optionKey;
+
+ case WXK_CONTROL:
+ return controlKey;
+
+ default:
+ return 0;
+ }
+}
+
+bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
+{
+//if OS X > 10.2 (i.e. 10.2.x)
+//a known apple bug prevents the system from determining led
+//states with GetKeys... can only determine caps lock led
+ return !!(GetCurrentKeyModifiers() & wxKeyCodeToMacModifier(key));
+//else
+// KeyMapByteArray keymap;
+// GetKeys((BigEndianLong*)keymap);
+// return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey));
+}
+
#if !TARGET_CARBON
void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
{
return retval;
}
+int wxKeyCodeToMacModifier(wxKeyCode key)
+{
+ switch (key)
+ {
+ case WXK_START:
+ return cmdKey;
+
+ case WXK_SHIFT:
+ return shiftKey;
+
+ case WXK_CAPITAL:
+ return alphaLock;
+
+ case WXK_OPTION:
+ return optionKey;
+
+ case WXK_CONTROL:
+ return controlKey;
+
+ default:
+ return 0;
+ }
+}
+
+bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
+{
+//if OS X > 10.2 (i.e. 10.2.x)
+//a known apple bug prevents the system from determining led
+//states with GetKeys... can only determine caps lock led
+ return !!(GetCurrentKeyModifiers() & wxKeyCodeToMacModifier(key));
+//else
+// KeyMapByteArray keymap;
+// GetKeys((BigEndianLong*)keymap);
+// return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey));
+}
+
#if !TARGET_CARBON
void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
{
return keySym;
}
+bool wxGetKeyState(wxKeyCode key)
+{
+ bool bVirtual;
+ int vkey = wxCharCodeWXToMSW(key, &bVirtual);
+
+ //there aren't WXK_ macros for non-virtual key codes
+ if (bVirtual == false)
+ return false;
+
+ return GetKeyState(vkey) < 0;
+}
+
wxWindow *wxGetActiveWindow()
{
HWND hWnd = GetActiveWindow();
XFlush(m_display);
XSetErrorHandler(m_old);
}
+
private:
Display *m_display;
int (*m_old)(Display*, XErrorEvent *);
}
}
+bool wxGetKeyState(wxKeyCode key)
+{
+ Display *pDisplay = wxApp::GetDisplay();
+ int iKey = wxCharCodeWXToX(key);
+ int iKeyMask = 0;
+ Window wDummy1, wDummy2;
+ int iDummy3, iDummy4, iDummy5, iDummy6;
+ unsigned int iMask;
+ XModifierKeymap* map = XGetModifierMapping(pDisplay);
+ KeyCode keyCode = XKeysymToKeycode(pDisplay,iKey);
+ if(keyCode == NoSymbol) return false;
+ for(int i = 0; i < 8; ++i) {
+ if( map->modifiermap[map->max_keypermod * i] == keyCode) {
+ iKeyMask = 1 << i;
+ }
+ }
+ XQueryPointer(pDisplay, DefaultRootWindow(pDisplay), &wDummy1, &wDummy2,
+ &iDummy3, &iDummy4, &iDummy5, &iDummy6, &iMask );
+ XFreeModifiermap(map);
+ return (iMask & iKeyMask) != 0;
+}
+
#endif