]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/NSWindow.mm
Applied patch [ 735304 ] wxDisplay::ChangeMode - does not resize full-screen windows
[wxWidgets.git] / src / cocoa / NSWindow.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/NSWindow.mm
3 // Purpose: wxCocoaNSWindow
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/03/16
7 // RCS-ID: $Id:
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/wxprec.h"
21 #ifndef WX_PRECOMP
22 #include "wx/log.h"
23 #include "wx/menuitem.h"
24 #endif // WX_PRECOMP
25
26 #include "wx/cocoa/ObjcPose.h"
27 #include "wx/cocoa/NSWindow.h"
28
29 #import <Appkit/NSWindow.h>
30
31 // ----------------------------------------------------------------------------
32 // globals
33 // ----------------------------------------------------------------------------
34 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSWindow)
35
36 void wxCocoaNSWindow::AssociateNSWindow(WX_NSWindow cocoaNSWindow)
37 {
38 [cocoaNSWindow setReleasedWhenClosed: NO];
39 sm_cocoaHash.insert(wxCocoaNSWindowHash::value_type(cocoaNSWindow,this));
40 }
41
42 // ============================================================================
43 // @class wxPoserNSWindow
44 // ============================================================================
45 @interface wxPoserNSWindow : NSWindow
46 {
47 }
48
49 - (void)close;
50 - (BOOL)windowShouldClose: (id)sender;
51
52 - (BOOL)wxMenuItemAction: (id)sender;
53 @end // wxPoserNSwindow
54
55 WX_IMPLEMENT_POSER(wxPoserNSWindow);
56 @implementation wxPoserNSWindow : NSWindow
57
58 - (void)close
59 {
60 wxLogDebug("close");
61 wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
62 if(tlw)
63 tlw->Cocoa_close();
64 [super close];
65 }
66
67 - (BOOL)windowShouldClose: (id)sender
68 {
69 wxLogDebug("windowShouldClose");
70 wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(sender);
71 if(tlw && !tlw->Cocoa_windowShouldClose())
72 return NO;
73 wxLogDebug("Window will most likely be CLOSED");
74 if([[wxPoserNSWindow superclass] instancesRespondToSelector:@selector(windowShouldClose:)])
75 return [super windowShouldClose: sender];
76 return YES;
77 }
78
79 - (BOOL)wxMenuItemAction: (id)sender
80 {
81 wxLogDebug("wxMenuItemAction");
82 wxMenuItem *item = wxMenuItem::GetFromCocoa(sender);
83 if(!item)
84 return NO;
85
86 wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
87 wxASSERT(tlw);
88 tlw->Cocoa_wxMenuItemAction(*item);
89 return YES;
90 }
91 @end // implementation wxPoserNSWindow
92