#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
+#include "wx/cocoa/ObjcRef.h"
#include "wx/cocoa/objc/NSView.h"
#include "wx/cocoa/objc/NSWindow.h"
bool need_debug = cocoaNSWindow || m_cocoaNSWindow;
if(need_debug) wxLogTrace(wxTRACE_COCOA_RetainRelease,wxT("wxTopLevelWindowCocoa=%p::SetNSWindow [m_cocoaNSWindow=%p retainCount]=%d"),this,m_cocoaNSWindow,[m_cocoaNSWindow retainCount]);
DisassociateNSWindow(m_cocoaNSWindow);
- [cocoaNSWindow retain];
- [m_cocoaNSWindow release];
+ wxGCSafeRetain(cocoaNSWindow);
+ wxGCSafeRelease(m_cocoaNSWindow);
m_cocoaNSWindow = cocoaNSWindow;
// NOTE: We are no longer using posing so we won't get events on the
// window's view unless it was explicitly created as the wx view class.
wxLogTrace(wxTRACE_COCOA,wxT("wxTopLevelWindowCocoa=%p::CocoaDelegate_windowDidBecomeKey"),this);
wxActivateEvent event(wxEVT_ACTIVATE, true, GetId());
event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
+ HandleWindowEvent(event);
}
void wxTopLevelWindowCocoa::CocoaDelegate_windowDidResignKey(void)
wxLogTrace(wxTRACE_COCOA,wxT("wxTopLevelWindowCocoa=%p::CocoaDelegate_windowDidResignKey"),this);
wxActivateEvent event(wxEVT_ACTIVATE, false, GetId());
event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
+ HandleWindowEvent(event);
}
void wxTopLevelWindowCocoa::CocoaDelegate_windowDidBecomeMain(void)
// is shown. I doubt this will cause any problems though.
wxSizeEvent event(GetSize(), GetId());
event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
+ HandleWindowEvent(event);
[m_cocoaNSWindow makeKeyAndOrderFront:m_cocoaNSWindow];
}
wxWindow* wxTopLevelWindowCocoa::SetDefaultItem(wxWindow *win)
{
wxWindow *old = wxTopLevelWindowBase::SetDefaultItem(win);
- NSView *newView = win->GetNSView();
NSCell *newCell;
- // newView does not have to be an NSControl, we only cast to NSControl*
- // to silence the warning about cell not being implemented.
- if(newView != nil && [newView respondsToSelector:@selector(cell)])
- newCell = [(NSControl*)newView cell];
+ if(win != NULL)
+ {
+ NSView *newView = win->GetNSView();
+ // newView does not have to be an NSControl, we only cast to NSControl*
+ // to silence the warning about cell not being implemented.
+ if(newView != nil && [newView respondsToSelector:@selector(cell)])
+ newCell = [(NSControl*)newView cell];
+ else
+ newCell = nil;
+
+ if(newCell != nil && ![newCell isKindOfClass:[NSButtonCell class]])
+ { // It's not an NSButtonCell, set the default to nil.
+ newCell = nil;
+ }
+ }
else
newCell = nil;
- if(newCell != nil && ![newCell isKindOfClass:[NSButtonCell class]])
- { // It's not an NSButtonCell, set the default to nil.
- newCell = nil;
- }
-
[GetNSWindow() setDefaultButtonCell:(NSButtonCell*)newCell];
return old;
}