]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/NSView.mm
added CopyFromDIB()
[wxWidgets.git] / src / cocoa / NSView.mm
CommitLineData
fb896a32
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: cocoa/NSView.mm
3// Purpose: wxCocoaNSView
4// Author: David Elliott
5// Modified by:
6// Created: 2003/02/15
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/window.h"
23#endif // WX_PRECOMP
24
25#include "wx/cocoa/NSView.h"
26
27#import <Appkit/NSView.h>
28#import <Foundation/NSNotification.h>
29#import <Foundation/NSString.h>
30
31// ----------------------------------------------------------------------------
32// globals
33// ----------------------------------------------------------------------------
34WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSView)
35
36void wxCocoaNSView::AssociateNSView(WX_NSView cocoaNSView)
37{
38 sm_cocoaHash.insert(wxCocoaNSViewHash::value_type(cocoaNSView,this));
39 [[NSNotificationCenter defaultCenter] addObserver:(id)sm_cocoaObserver selector:@selector(notificationFrameChanged:) name:@"NSViewFrameDidChangeNotification" object:cocoaNSView];
40 [cocoaNSView setPostsFrameChangedNotifications: YES];
41}
42
43void wxCocoaNSView::DisassociateNSView(WX_NSView cocoaNSView)
44{
45 sm_cocoaHash.erase(cocoaNSView);
46 [[NSNotificationCenter defaultCenter] removeObserver:(id)sm_cocoaObserver name:@"NSViewFrameDidChangeNotification" object:cocoaNSView];
47}
48
49// ============================================================================
50// @class wxPoserNSView
51// ============================================================================
52@interface wxPoserNSView : NSView
53{
54}
55
56@end // wxPoserNSView
57
58WX_IMPLEMENT_POSER(wxPoserNSView);
59@implementation wxPoserNSView : NSView
60
61@end // implementation wxPoserNSView
62
63@interface wxNSViewNotificationObserver : NSObject
64{
65}
66
67// FIXME: Initializing like this is a really bad idea. If for some reason
68// we ever require posing as an NSObject we won't be able to since an instance
69// will have already been created here. Of course, catching messages for
70// NSObject seems like a LOT of overkill, so I doubt we ever will anyway!
71void *wxCocoaNSView::sm_cocoaObserver = [[wxNSViewNotificationObserver alloc] init];
72
73- (void)notificationFrameChanged: (NSNotification *)notification;
74@end // interface wxNSViewNotificationObserver
75
76@implementation wxNSViewNotificationObserver : NSObject
77
78- (void)notificationFrameChanged: (NSNotification *)notification;
79{
80 wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa([notification object]);
81 wxCHECK_RET(win,"notificationFrameChanged received but no wxWindow exists");
82 win->Cocoa_FrameChanged();
83}
84
85@end // implementation wxNSViewNotificationObserver
86