]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/uiaction.cpp
Get the page title from the IHtmlDocument rather than the bowser as it actually retur...
[wxWidgets.git] / src / msw / uiaction.cpp
index 6bbbf1abdc1f17675e7ce1afe6ea4d1de4c4a4b6..eb5bfd1e34567522b04efbf19496fce891cdd85b 100644 (file)
@@ -1,50 +1,49 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        src/msw/uiaction.cpp
 // Purpose:     wxUIActionSimulator implementation
-// Author:      Kevin Ollivier
+// Author:      Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
 // Modified by:
 // Created:     2010-03-06
-// RCS-ID:      $Id: menu.cpp 54129 2008-06-11 19:30:52Z SC $
+// RCS-ID:      $Id$
 // Copyright:   (c) Kevin Ollivier
+//              (c) 2010 Steven Lamerton
+//              (c) 2010 Vadim Zeitlin
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/wxprec.h"
 
-#ifndef WX_PRECOMP
-#include "wx/defs.h"
-#endif
+#if wxUSE_UIACTIONSIMULATOR
 
 #include "wx/uiaction.h"
+#include "wx/msw/wrapwin.h"
 
-#include <windows.h>
+#include "wx/msw/private/keyboard.h"
+
+namespace
+{
 
 DWORD EventTypeForMouseButton(int button, bool isDown)
 {
     switch (button)
     {
         case wxMOUSE_BTN_LEFT:
-            if (isDown)
-                return MOUSEEVENTF_LEFTDOWN;
-            else
-                return MOUSEEVENTF_LEFTUP;
+            return isDown ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
+
         case wxMOUSE_BTN_RIGHT:
-            if (isDown)
-                return MOUSEEVENTF_RIGHTDOWN;
-            else
-                return MOUSEEVENTF_RIGHTUP;
+            return isDown ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
+
         case wxMOUSE_BTN_MIDDLE:
-            if (isDown)
-                return MOUSEEVENTF_MIDDLEDOWN;
-            else
-                return MOUSEEVENTF_MIDDLEUP;
-            
+            return isDown ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
+
         default:
             wxFAIL_MSG("Unsupported button passed in.");
-            return -1;
+            return (DWORD)-1;
     }
 }
 
+} // anonymous namespace
+
 bool wxUIActionSimulator::MouseDown(int button)
 {
     POINT p;
@@ -54,8 +53,14 @@ bool wxUIActionSimulator::MouseDown(int button)
 }
 
 bool wxUIActionSimulator::MouseMove(long x, long y)
-{   
-    mouse_event(MOUSEEVENTF_MOVE, x, y, 0, 0);
+{
+    // Because MOUSEEVENTF_ABSOLUTE takes measurements scaled between 0 & 65535
+    // we need to scale our input too
+    int displayx, displayy, scaledx, scaledy;
+    wxDisplaySize(&displayx, &displayy);
+    scaledx = ((float)x / displayx) * 65535;
+    scaledy = ((float)y / displayy) * 65535;
+    mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, scaledx, scaledy, 0, 0);
     return true;
 }
 
@@ -67,12 +72,21 @@ bool wxUIActionSimulator::MouseUp(int button)
     return true;
 }
 
-bool wxUIActionSimulator::Key(int keycode, bool isDown, bool shiftDown, bool cmdDown, bool altDown)
+bool
+wxUIActionSimulator::DoKey(int keycode, int WXUNUSED(modifiers), bool isDown)
 {
+    bool isExtended;
+    DWORD vkkeycode = wxMSWKeyboard::WXToVK(keycode, &isExtended);
+
     DWORD flags = 0;
-    if (!isDown)
-        flags = KEYEVENTF_KEYUP;
-    keybd_event(keycode, 0, flags, 0);
+    if ( isExtended )
+        flags |= KEYEVENTF_EXTENDEDKEY;
+    if ( !isDown )
+        flags |= KEYEVENTF_KEYUP;
+
+    keybd_event(vkkeycode, 0, flags, 0);
+
     return true;
 }
 
+#endif // wxUSE_UIACTIONSIMULATOR