updating implementations of wxGetMouseState for osx_cocoa and dummy impls for iphone

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62631 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-11-13 18:30:00 +00:00
parent 8ddda15ba5
commit f3769d53f7
3 changed files with 58 additions and 6 deletions

View File

@@ -1323,6 +1323,12 @@ int wxMacKeyCodeToModifier(wxKeyCode key)
} }
#endif #endif
#if wxOSX_USE_COCOA && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
// defined in utils.mm
#elif wxOSX_USE_CARBON_OR_COCOA
wxMouseState wxGetMouseState() wxMouseState wxGetMouseState()
{ {
wxMouseState ms; wxMouseState ms;
@@ -1331,7 +1337,6 @@ wxMouseState wxGetMouseState()
ms.SetX(pt.x); ms.SetX(pt.x);
ms.SetY(pt.y); ms.SetY(pt.y);
#if wxOSX_USE_CARBON
UInt32 buttons = GetCurrentButtonState(); UInt32 buttons = GetCurrentButtonState();
ms.SetLeftDown( (buttons & 0x01) != 0 ); ms.SetLeftDown( (buttons & 0x01) != 0 );
ms.SetMiddleDown( (buttons & 0x04) != 0 ); ms.SetMiddleDown( (buttons & 0x04) != 0 );
@@ -1342,12 +1347,12 @@ wxMouseState wxGetMouseState()
ms.SetShiftDown(modifiers & shiftKey); ms.SetShiftDown(modifiers & shiftKey);
ms.SetAltDown(modifiers & optionKey); ms.SetAltDown(modifiers & optionKey);
ms.SetMetaDown(modifiers & cmdKey); ms.SetMetaDown(modifiers & cmdKey);
#else
// TODO
#endif
return ms; return ms;
} }
#endif
// TODO : once the new key/char handling is tested, move all the code to wxWindow // TODO : once the new key/char handling is tested, move all the code to wxWindow
bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar )

View File

@@ -254,6 +254,34 @@ void wxGetMousePosition( int* x, int* y )
*y = pt.y; *y = pt.y;
}; };
#if wxOSX_USE_COCOA && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
wxMouseState wxGetMouseState()
{
wxMouseState ms;
wxPoint pt = wxGetMousePosition();
ms.SetX(pt.x);
ms.SetY(pt.y);
NSUInteger modifiers = [NSEvent modifierFlags];
NSUInteger buttons = [NSEvent pressedMouseButtons];
ms.SetLeftDown( (buttons & 0x01) != 0 );
ms.SetMiddleDown( (buttons & 0x04) != 0 );
ms.SetRightDown( (buttons & 0x02) != 0 );
ms.SetControlDown(modifiers & NSControlKeyMask);
ms.SetShiftDown(modifiers & NSShiftKeyMask);
ms.SetAltDown(modifiers & NSAlternateKeyMask);
ms.SetMetaDown(modifiers & NSCommandKeyMask);
return ms;
}
#endif
wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
{ {
return new wxOSXTimerImpl(timer); return new wxOSXTimerImpl(timer);

View File

@@ -100,6 +100,16 @@ void wxMacWakeUp()
#if wxUSE_GUI #if wxUSE_GUI
// ----------------------------------------------------------------------------
// Launch default browser
// ----------------------------------------------------------------------------
bool wxDoLaunchDefaultBrowser(const wxString& url, int flags)
{
return [[UIApplication sharedApplication] openURL:[NSURL URLWithString:wxCFStringRef(url).AsNSString()]]
== YES;
}
// TODO : reorganize // TODO : reorganize
extern wxFont* CreateNormalFont() extern wxFont* CreateNormalFont()
@@ -176,9 +186,18 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
void wxGetMousePosition( int* x, int* y ) void wxGetMousePosition( int* x, int* y )
{ {
// wxPoint pt = wxFromNSPoint(NULL, [NSEvent mouseLocation]); if ( x )
*x = 0;
if ( y )
*y = 0;
}; };
wxMouseState wxGetMouseState()
{
wxMouseState ms;
return ms;
}
// Returns depth of screen // Returns depth of screen
int wxDisplayDepth() int wxDisplayDepth()
{ {
@@ -191,7 +210,7 @@ void wxDisplaySize(int *width, int *height)
CGRect r = [[UIScreen mainScreen] applicationFrame]; CGRect r = [[UIScreen mainScreen] applicationFrame];
CGRect bounds = [[UIScreen mainScreen] bounds]; CGRect bounds = [[UIScreen mainScreen] bounds];
if ( bounds.size.height > r.size.height ) if ( UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]) )
{ {
// portrait // portrait
if ( width ) if ( width )