From wxWidgets master 81570ae070b35c9d52de47b1f14897f3ff1a66c7. include/wx/defs.h -- __w64 warning disable patch by comex brought forward. include/wx/msw/window.h -- added GetContentScaleFactor() which was not implemented on Windows but is necessary for wxBitmap scaling on Mac OS X so it needs to work to avoid #ifdef-ing the code. src/gtk/window.cpp -- Modified DoSetClientSize() to direct call wxWindowGTK::DoSetSize() instead of using public wxWindowBase::SetSize() which now prevents derived classes (like wxAuiToolbar) intercepting the call and breaking it. This matches Windows which does NOT need to call DoSetSize internally. End result is this fixes Dolphin's debug tools toolbars on Linux. src/osx/window_osx.cpp -- Same fix as for GTK since it has the same issue. src/msw/radiobox.cpp -- Hacked to fix display in HiDPI (was clipping off end of text). Updated CMakeLists for Linux and Mac OS X. Small code changes to Dolphin to fix debug error boxes, deprecation warnings, and retain previous UI behavior on Windows.
263 lines
6.9 KiB
C++
263 lines
6.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: src/osx/uiaction_osx.cpp
|
|
// Purpose: wxUIActionSimulator implementation
|
|
// Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
|
|
// Modified by:
|
|
// Created: 2010-03-06
|
|
// Copyright: (c) Kevin Ollivier
|
|
// (c) 2010 Steven Lamerton
|
|
// (c) 2010 Vadim Zeitlin
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
#ifndef WX_PRECOMP
|
|
#include "wx/object.h"
|
|
#endif
|
|
|
|
#if wxUSE_UIACTIONSIMULATOR
|
|
|
|
#include "wx/uiaction.h"
|
|
|
|
#include "wx/log.h"
|
|
|
|
#include "wx/osx/private.h"
|
|
#include "wx/osx/core/cfref.h"
|
|
|
|
#include "wx/evtloop.h"
|
|
|
|
namespace
|
|
{
|
|
|
|
CGEventTapLocation tap = kCGSessionEventTap;
|
|
|
|
CGEventType CGEventTypeForMouseButton(int button, bool isDown)
|
|
{
|
|
switch ( button )
|
|
{
|
|
case wxMOUSE_BTN_LEFT:
|
|
return isDown ? kCGEventLeftMouseDown : kCGEventLeftMouseUp;
|
|
|
|
case wxMOUSE_BTN_RIGHT:
|
|
return isDown ? kCGEventRightMouseDown : kCGEventRightMouseUp;
|
|
|
|
// All the other buttons use the constant OtherMouseDown but we still
|
|
// want to check for invalid parameters so assert first
|
|
default:
|
|
wxFAIL_MSG("Unsupported button passed in.");
|
|
wxFALLTHROUGH;// fall back to the only known remaining case
|
|
|
|
case wxMOUSE_BTN_MIDDLE:
|
|
return isDown ? kCGEventOtherMouseDown : kCGEventOtherMouseUp;
|
|
}
|
|
}
|
|
|
|
CGEventType CGEventTypeForMouseDrag(int button)
|
|
{
|
|
switch ( button )
|
|
{
|
|
case wxMOUSE_BTN_LEFT:
|
|
return kCGEventLeftMouseDragged;
|
|
break;
|
|
|
|
case wxMOUSE_BTN_RIGHT:
|
|
return kCGEventRightMouseDragged;
|
|
break;
|
|
|
|
// All the other buttons use the constant OtherMouseDown but we still
|
|
// want to check for invalid parameters so assert first
|
|
default:
|
|
wxFAIL_MSG("Unsupported button passed in.");
|
|
wxFALLTHROUGH;// fall back to the only known remaining case
|
|
|
|
case wxMOUSE_BTN_MIDDLE:
|
|
return kCGEventOtherMouseDragged;
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
CGMouseButton CGButtonForMouseButton(int button)
|
|
{
|
|
switch ( button )
|
|
{
|
|
case wxMOUSE_BTN_LEFT:
|
|
return kCGMouseButtonLeft;
|
|
|
|
case wxMOUSE_BTN_RIGHT:
|
|
return kCGMouseButtonRight;
|
|
|
|
// All the other buttons use the constant OtherMouseDown but we still
|
|
// want to check for invalid parameters so assert first
|
|
default:
|
|
wxFAIL_MSG("Unsupported button passed in.");
|
|
wxFALLTHROUGH;// fall back to the only known remaining case
|
|
|
|
case wxMOUSE_BTN_MIDDLE:
|
|
return kCGMouseButtonCenter;
|
|
}
|
|
}
|
|
|
|
CGPoint GetMousePosition()
|
|
{
|
|
int x, y;
|
|
wxGetMousePosition(&x, &y);
|
|
|
|
CGPoint pos;
|
|
pos.x = x;
|
|
pos.y = y;
|
|
|
|
return pos;
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
bool wxUIActionSimulator::MouseDown(int button)
|
|
{
|
|
CGEventType type = CGEventTypeForMouseButton(button, true);
|
|
wxCFRef<CGEventRef> event(
|
|
CGEventCreateMouseEvent(NULL, type, GetMousePosition(), CGButtonForMouseButton(button)));
|
|
|
|
if ( !event )
|
|
return false;
|
|
|
|
CGEventSetType(event, type);
|
|
CGEventPost(tap, event);
|
|
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
|
if (loop)
|
|
loop->SetShouldWaitForEvent(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool wxUIActionSimulator::MouseMove(long x, long y)
|
|
{
|
|
CGPoint pos;
|
|
pos.x = x;
|
|
pos.y = y;
|
|
|
|
CGEventType type = kCGEventMouseMoved;
|
|
wxCFRef<CGEventRef> event(
|
|
CGEventCreateMouseEvent(NULL, type, pos, kCGMouseButtonLeft));
|
|
|
|
if ( !event )
|
|
return false;
|
|
|
|
CGEventSetType(event, type);
|
|
CGEventPost(tap, event);
|
|
|
|
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
|
if (loop)
|
|
loop->SetShouldWaitForEvent(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool wxUIActionSimulator::MouseUp(int button)
|
|
{
|
|
CGEventType type = CGEventTypeForMouseButton(button, false);
|
|
wxCFRef<CGEventRef> event(
|
|
CGEventCreateMouseEvent(NULL, type, GetMousePosition(), CGButtonForMouseButton(button)));
|
|
|
|
if ( !event )
|
|
return false;
|
|
|
|
CGEventSetType(event, type);
|
|
CGEventPost(tap, event);
|
|
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
|
if (loop)
|
|
loop->SetShouldWaitForEvent(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool wxUIActionSimulator::MouseDblClick(int button)
|
|
{
|
|
CGEventType downtype = CGEventTypeForMouseButton(button, true);
|
|
CGEventType uptype = CGEventTypeForMouseButton(button, false);
|
|
wxCFRef<CGEventRef> event(
|
|
CGEventCreateMouseEvent(NULL, downtype, GetMousePosition(), CGButtonForMouseButton(button)));
|
|
|
|
if ( !event )
|
|
return false;
|
|
|
|
CGEventSetType(event,downtype);
|
|
CGEventPost(tap, event);
|
|
|
|
CGEventSetType(event, uptype);
|
|
CGEventPost(tap, event);
|
|
|
|
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 2);
|
|
CGEventSetType(event, downtype);
|
|
CGEventPost(tap, event);
|
|
|
|
CGEventSetType(event, uptype);
|
|
CGEventPost(tap, event);
|
|
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
|
if (loop)
|
|
loop->SetShouldWaitForEvent(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
|
|
int button)
|
|
{
|
|
CGPoint pos1,pos2;
|
|
pos1.x = x1;
|
|
pos1.y = y1;
|
|
pos2.x = x2;
|
|
pos2.y = y2;
|
|
|
|
CGEventType downtype = CGEventTypeForMouseButton(button, true);
|
|
CGEventType uptype = CGEventTypeForMouseButton(button, false);
|
|
CGEventType dragtype = CGEventTypeForMouseDrag(button) ;
|
|
|
|
wxCFRef<CGEventRef> event(
|
|
CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pos1, CGButtonForMouseButton(button)));
|
|
|
|
if ( !event )
|
|
return false;
|
|
|
|
CGEventSetType(event,kCGEventMouseMoved);
|
|
CGEventPost(tap, event);
|
|
|
|
CGEventSetType(event,downtype);
|
|
CGEventPost(tap, event);
|
|
|
|
|
|
CGEventSetType(event, dragtype);
|
|
CGEventSetLocation(event,pos2);
|
|
CGEventPost(tap, event);
|
|
|
|
CGEventSetType(event, uptype);
|
|
CGEventPost(tap, event);
|
|
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
|
if (loop)
|
|
loop->SetShouldWaitForEvent(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
wxUIActionSimulator::DoKey(int keycode, int WXUNUSED(modifiers), bool isDown)
|
|
{
|
|
CGKeyCode cgcode = wxCharCodeWXToOSX((wxKeyCode)keycode);
|
|
|
|
wxCFRef<CGEventRef>
|
|
event(CGEventCreateKeyboardEvent(NULL, cgcode, isDown));
|
|
if ( !event )
|
|
return false;
|
|
|
|
CGEventPost(kCGHIDEventTap, event);
|
|
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
|
if (loop)
|
|
loop->SetShouldWaitForEvent(true);
|
|
|
|
return true;
|
|
}
|
|
|
|
#endif // wxUSE_UIACTIONSIMULATOR
|
|
|