]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/NSWindow.mm
fix makefile (changed filelist)
[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 if(cocoaNSWindow)
39 {
40 [cocoaNSWindow setReleasedWhenClosed: NO];
41 sm_cocoaHash.insert(wxCocoaNSWindowHash::value_type(cocoaNSWindow,this));
42 }
43 }
44
45 // ============================================================================
46 // @class wxPoserNSWindow
47 // ============================================================================
48 @interface wxPoserNSWindow : NSWindow
49 {
50 }
51
52 - (void)close;
53 - (BOOL)windowShouldClose: (id)sender;
54
55 - (BOOL)wxMenuItemAction: (id)sender;
56 @end // wxPoserNSwindow
57
58 WX_IMPLEMENT_POSER(wxPoserNSWindow);
59 @implementation wxPoserNSWindow : NSWindow
60
61 - (void)close
62 {
63 wxLogDebug("close");
64 wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
65 if(tlw)
66 tlw->Cocoa_close();
67 [super close];
68 }
69
70 - (BOOL)windowShouldClose: (id)sender
71 {
72 wxLogDebug("windowShouldClose");
73 wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(sender);
74 if(tlw && !tlw->Cocoa_windowShouldClose())
75 return NO;
76 wxLogDebug("Window will most likely be CLOSED");
77 if([[wxPoserNSWindow superclass] instancesRespondToSelector:@selector(windowShouldClose:)])
78 return [super windowShouldClose: sender];
79 return YES;
80 }
81
82 - (BOOL)wxMenuItemAction: (id)sender
83 {
84 wxLogDebug("wxMenuItemAction");
85 wxMenuItem *item = wxMenuItem::GetFromCocoa(sender);
86 if(!item)
87 return NO;
88
89 wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
90 wxASSERT(tlw);
91 tlw->Cocoa_wxMenuItemAction(*item);
92 return YES;
93 }
94 @end // implementation wxPoserNSWindow
95