]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/dcmemory.mm
multilib mode compilation fix
[wxWidgets.git] / src / cocoa / dcmemory.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/dcmemory.mm
3 // Purpose: wxMemoryDC class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/03/16
7 // RCS-ID: $Id$
8 // Copyright: (c) 2002 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/dcmemory.h"
13
14 #import <AppKit/NSImage.h>
15
16 //-----------------------------------------------------------------------------
17 // wxMemoryDC
18 //-----------------------------------------------------------------------------
19
20 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxDC)
21
22 wxMemoryDC::wxMemoryDC(void)
23 {
24 m_cocoaNSImage = NULL;
25 m_ok = false;
26 }
27
28 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
29 {
30 m_cocoaNSImage = NULL;
31 m_ok = false;
32 }
33
34 wxMemoryDC::~wxMemoryDC(void)
35 {
36 CocoaUnwindStackAndLoseFocus();
37 [m_cocoaNSImage release];
38 }
39
40 bool wxMemoryDC::CocoaLockFocus()
41 {
42 if(m_cocoaNSImage)
43 {
44 [m_cocoaNSImage lockFocusOnRepresentation: m_selectedBitmap.GetNSBitmapImageRep()];
45 sm_cocoaDCStack.Insert(this);
46 return true;
47 }
48 return false;
49 }
50
51 bool wxMemoryDC::CocoaUnlockFocus()
52 {
53 [m_cocoaNSImage unlockFocus];
54 return true;
55 }
56
57 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
58 {
59 CocoaUnwindStackAndLoseFocus();
60 [m_cocoaNSImage release];
61 m_cocoaNSImage = nil;
62 m_selectedBitmap = bitmap;
63 if(m_selectedBitmap.Ok())
64 {
65 m_cocoaNSImage = [[NSImage alloc]
66 initWithSize:NSMakeSize(m_selectedBitmap.GetWidth(),
67 m_selectedBitmap.GetHeight())];
68 [m_cocoaNSImage addRepresentation: m_selectedBitmap.GetNSBitmapImageRep()];
69 }
70 }
71
72 void wxMemoryDC::DoGetSize( int *width, int *height ) const
73 {
74 if(width)
75 *width = m_selectedBitmap.GetWidth();
76 if(height)
77 *height = m_selectedBitmap.GetHeight();
78 }
79