Fixes needed to get transient popup windows working, also implement SetFont for OS X Cocoa for classes that support it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59424 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -141,6 +141,7 @@ public :
|
|||||||
virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
||||||
virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
|
virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
|
||||||
virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
||||||
|
virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
|
||||||
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
|
||||||
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
|
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
|
||||||
virtual void resetCursorRects(WXWidget slf, void* _cmd);
|
virtual void resetCursorRects(WXWidget slf, void* _cmd);
|
||||||
|
@@ -291,7 +291,7 @@ void wxPopupTransientWindow::Popup(wxWindow *winFocus)
|
|||||||
m_focus->SetFocus();
|
m_focus->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined( __WXMSW__ ) || defined( __WXMAC__)
|
#if defined( __WXMSW__ ) || (defined( __WXMAC__) && wxOSX_USE_CARBON)
|
||||||
// MSW doesn't allow to set focus to the popup window, but we need to
|
// MSW doesn't allow to set focus to the popup window, but we need to
|
||||||
// subclass the window which has the focus, and not winFocus passed in or
|
// subclass the window which has the focus, and not winFocus passed in or
|
||||||
// otherwise everything else breaks down
|
// otherwise everything else breaks down
|
||||||
|
@@ -116,6 +116,11 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector
|
|||||||
impl = theImplementation;
|
impl = theImplementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)canBecomeKeyWindow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (wxNonOwnedWindowCocoaImpl*) implementation
|
- (wxNonOwnedWindowCocoaImpl*) implementation
|
||||||
{
|
{
|
||||||
return impl;
|
return impl;
|
||||||
@@ -144,8 +149,8 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector
|
|||||||
|
|
||||||
- (void)windowDidResize:(NSNotification *)notification;
|
- (void)windowDidResize:(NSNotification *)notification;
|
||||||
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
|
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
|
||||||
- (void)windowDidResignMain:(NSNotification *)notification;
|
- (void)windowDidResignKey:(NSNotification *)notification;
|
||||||
- (void)windowDidBecomeMain:(NSNotification *)notification;
|
- (void)windowDidBecomeKey:(NSNotification *)notification;
|
||||||
- (void)windowDidMove:(NSNotification *)notification;
|
- (void)windowDidMove:(NSNotification *)notification;
|
||||||
- (BOOL)windowShouldClose:(id)window;
|
- (BOOL)windowShouldClose:(id)window;
|
||||||
|
|
||||||
@@ -219,7 +224,7 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidBecomeMain:(NSNotification *)notification
|
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
wxNSWindow* window = (wxNSWindow*) [notification object];
|
wxNSWindow* window = (wxNSWindow*) [notification object];
|
||||||
wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
|
wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
|
||||||
@@ -231,7 +236,7 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidResignMain:(NSNotification *)notification
|
- (void)windowDidResignKey:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
wxNSWindow* window = (wxNSWindow*) [notification object];
|
wxNSWindow* window = (wxNSWindow*) [notification object];
|
||||||
wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
|
wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
|
||||||
@@ -239,7 +244,15 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector
|
|||||||
{
|
{
|
||||||
wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
|
wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
|
||||||
if ( wxpeer )
|
if ( wxpeer )
|
||||||
|
{
|
||||||
wxpeer->HandleActivated(0, false);
|
wxpeer->HandleActivated(0, false);
|
||||||
|
// Needed for popup window since the firstResponder
|
||||||
|
// (focus in wx) doesn't change when this
|
||||||
|
// TLW becomes inactive.
|
||||||
|
wxFocusEvent event( wxEVT_KILL_FOCUS, wxpeer->GetId());
|
||||||
|
event.SetEventObject(wxpeer);
|
||||||
|
wxpeer->HandleWindowEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +296,11 @@ long style, long extraStyle, const wxString& name )
|
|||||||
|
|
||||||
int windowstyle = NSBorderlessWindowMask;
|
int windowstyle = NSBorderlessWindowMask;
|
||||||
|
|
||||||
if ( style & wxFRAME_TOOL_WINDOW )
|
if ( style & wxFRAME_TOOL_WINDOW || ( style & wxPOPUP_WINDOW ) ||
|
||||||
|
GetWXPeer()->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
|
||||||
|
{
|
||||||
m_macWindow = [wxNSPanel alloc];
|
m_macWindow = [wxNSPanel alloc];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
m_macWindow = [wxNSWindow alloc];
|
m_macWindow = [wxNSWindow alloc];
|
||||||
|
|
||||||
@@ -383,7 +399,8 @@ long style, long extraStyle, const wxString& name )
|
|||||||
|
|
||||||
[m_macWindow setAcceptsMouseMovedEvents: YES];
|
[m_macWindow setAcceptsMouseMovedEvents: YES];
|
||||||
|
|
||||||
// [m_macWindow makeKeyAndOrderFront:nil];
|
if ( ( style & wxPOPUP_WINDOW ) )
|
||||||
|
[m_macWindow makeKeyAndOrderFront:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -535,6 +535,15 @@ BOOL wxOSX_performKeyEquivalent(NSView* self, SEL _cmd, NSEvent *event)
|
|||||||
return impl->performKeyEquivalent(event, self, _cmd);
|
return impl->performKeyEquivalent(event, self, _cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL wxOSX_acceptsFirstResponder(NSView* self, SEL _cmd)
|
||||||
|
{
|
||||||
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
|
if (impl == NULL)
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
return impl->acceptsFirstResponder(self, _cmd);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL wxOSX_becomeFirstResponder(NSView* self, SEL _cmd)
|
BOOL wxOSX_becomeFirstResponder(NSView* self, SEL _cmd)
|
||||||
{
|
{
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
@@ -780,6 +789,17 @@ bool wxWidgetCocoaImpl::performKeyEquivalent(WX_NSEvent event, WXWidget slf, voi
|
|||||||
return superimpl(slf, (SEL)_cmd, event);
|
return superimpl(slf, (SEL)_cmd, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxWidgetCocoaImpl::acceptsFirstResponder(WXWidget slf, void *_cmd)
|
||||||
|
{
|
||||||
|
// Make sure wxWindows can receive focus by default like they do for other ports.
|
||||||
|
|
||||||
|
// FIXME: It'd be nice to have some way to tie this in with AcceptsFocus
|
||||||
|
// but that currently causes loops because the call to m_peer->CanFocus()
|
||||||
|
// ends up calling this method again. Don't know how to avoid it without
|
||||||
|
// making a setter method for focus.
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxWidgetCocoaImpl::becomeFirstResponder(WXWidget slf, void *_cmd)
|
bool wxWidgetCocoaImpl::becomeFirstResponder(WXWidget slf, void *_cmd)
|
||||||
{
|
{
|
||||||
wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
|
||||||
@@ -943,6 +963,7 @@ void wxOSXCocoaClassAddWXMethods(Class c)
|
|||||||
|
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(performKeyEquivalent:), (IMP) wxOSX_performKeyEquivalent, "v@:@" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(performKeyEquivalent:), (IMP) wxOSX_performKeyEquivalent, "v@:@" )
|
||||||
|
|
||||||
|
wxOSX_CLASS_ADD_METHOD(c, @selector(acceptsFirstResponder), (IMP) wxOSX_acceptsFirstResponder, "c@:" )
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(becomeFirstResponder), (IMP) wxOSX_becomeFirstResponder, "c@:" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(becomeFirstResponder), (IMP) wxOSX_becomeFirstResponder, "c@:" )
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(resignFirstResponder), (IMP) wxOSX_resignFirstResponder, "c@:" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(resignFirstResponder), (IMP) wxOSX_resignFirstResponder, "c@:" )
|
||||||
wxOSX_CLASS_ADD_METHOD(c, @selector(resetCursorRects), (IMP) wxOSX_resetCursorRects, "v@:" )
|
wxOSX_CLASS_ADD_METHOD(c, @selector(resetCursorRects), (IMP) wxOSX_resetCursorRects, "v@:" )
|
||||||
@@ -1256,7 +1277,7 @@ void wxWidgetCocoaImpl::SetupTabs( const wxNotebook& notebook)
|
|||||||
void wxWidgetCocoaImpl::GetBestRect( wxRect *r ) const
|
void wxWidgetCocoaImpl::GetBestRect( wxRect *r ) const
|
||||||
{
|
{
|
||||||
r->x = r->y = r->width = r->height = 0;
|
r->x = r->y = r->width = r->height = 0;
|
||||||
// if ( [m_osxView isKindOfClass:[NSControl class]] )
|
|
||||||
if ( [m_osxView respondsToSelector:@selector(sizeToFit)] )
|
if ( [m_osxView respondsToSelector:@selector(sizeToFit)] )
|
||||||
{
|
{
|
||||||
NSRect former = [m_osxView frame];
|
NSRect former = [m_osxView frame];
|
||||||
@@ -1319,9 +1340,14 @@ void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant )
|
|||||||
[m_osxView setControlSize:size];
|
[m_osxView setControlSize:size];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::SetFont(wxFont const&, wxColour const&, long, bool)
|
void wxWidgetCocoaImpl::SetFont(wxFont const& font, wxColour const&, long, bool)
|
||||||
{
|
{
|
||||||
// TODO
|
if ([m_osxView respondsToSelector:@selector(setFont:)])
|
||||||
|
#if wxOSX_USE_CORE_TEXT
|
||||||
|
[m_osxView setFont: (CTFontRef)font.MacGetCTFont()];
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
|
void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
|
||||||
|
Reference in New Issue
Block a user