+//
+// wx native implementation classes
+//
+
+@interface wxNSWindow : NSWindow
+
+{
+ wxNonOwnedWindowCocoaImpl* impl;
+}
+
+- (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation;
+- (wxNonOwnedWindowCocoaImpl*) implementation;
+
+@end
+
+@implementation wxNSWindow
+
+- (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation
+{
+ impl = theImplementation;
+}
+
+- (wxNonOwnedWindowCocoaImpl*) implementation
+{
+ return impl;
+}
+
+
+@end
+
+@interface wxNSPanel : wxNSWindow
+
+{
+}
+
+@end
+
+@implementation wxNSPanel
+
+@end
+
+
+//
+// controller
+//
+
+@interface wxNonOwnedWindowController : NSObject
+{
+}
+
+- (void)windowDidResize:(NSNotification *)notification;
+- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
+- (void)windowDidResignMain:(NSNotification *)notification;
+- (void)windowDidBecomeMain:(NSNotification *)notification;
+- (void)windowDidMove:(NSNotification *)notification;
+- (BOOL)windowShouldClose:(id)window;
+
+@end
+
+@implementation wxNonOwnedWindowController
+
+- (id) init
+{
+ [super init];
+ return self;
+}
+
+- (BOOL)windowShouldClose:(id)nwindow
+{
+ wxNSWindow* window = (wxNSWindow*) nwindow;
+ wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
+ if ( windowimpl )
+ {
+ wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->Close();
+ }
+ return NO;
+}
+
+- (NSSize)windowWillResize:(NSWindow *)win
+ toSize:(NSSize)proposedFrameSize
+{
+ NSRect frame = [win frame];
+ wxRect wxframe = wxFromNSRect( NULL, frame );
+ wxframe.SetWidth( proposedFrameSize.width );
+ wxframe.SetHeight( proposedFrameSize.height );
+ wxNSWindow* window = (wxNSWindow*) win;
+ wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
+ if ( windowimpl )
+ {
+ wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
+ if ( wxpeer )
+ {
+ wxpeer->HandleResizing( 0, &wxframe );
+ NSSize newSize = NSMakeSize(wxframe.GetWidth(), wxframe.GetHeight());
+ return newSize;
+ }
+ }
+
+ return proposedFrameSize;
+}
+
+- (void)windowDidResize:(NSNotification *)notification
+{
+ wxNSWindow* window = (wxNSWindow*) [notification object];
+ wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
+ if ( windowimpl )
+ {
+ wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->HandleResized(0);
+ }
+}
+
+- (void)windowDidMove:(NSNotification *)notification
+{
+ wxNSWindow* window = (wxNSWindow*) [notification object];
+ wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
+ if ( windowimpl )
+ {
+ wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->HandleMoved(0);
+ }
+}
+
+- (void)windowDidBecomeMain:(NSNotification *)notification
+{
+ wxNSWindow* window = (wxNSWindow*) [notification object];
+ wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
+ if ( windowimpl )
+ {
+ wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->HandleActivated(0, true);
+ }
+}
+
+- (void)windowDidResignMain:(NSNotification *)notification
+{
+ wxNSWindow* window = (wxNSWindow*) [notification object];
+ wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
+ if ( windowimpl )
+ {
+ wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
+ if ( wxpeer )
+ wxpeer->HandleActivated(0, false);
+ }
+}
+
+@end
+