+bool wxWindowDC::CocoaLockFocusOnNSView(WX_NSView nsview)
+{
+ if([nsview lockFocusIfCanDraw])
+ {
+ sm_cocoaDCStack.Insert(this);
+ CocoaApplyTransformations();
+ m_lockedNSView = nsview;
+ return true;
+ }
+ wxLogDebug(wxT("focus lock failed!"));
+ return false;
+}
+
+bool wxWindowDC::CocoaUnlockFocusOnNSView()
+{
+ [[m_lockedNSView window] flushWindow];
+ [m_lockedNSView unlockFocus];
+ m_lockedNSView = NULL;
+ return true;
+}
+
+bool wxWindowDC::CocoaLockFocus()
+{
+ wxLogTrace(wxTRACE_COCOA,wxT("Locking focus on wxWindowDC=%p, NSView=%p"),this, m_window->GetNonClientNSView());
+ NSAffineTransform *newTransform = CocoaGetWxToBoundsTransform([m_window->GetNonClientNSView() isFlipped], [m_window->GetNonClientNSView() bounds].size.height);
+ [newTransform retain];
+ [m_cocoaWxToBoundsTransform release];
+ m_cocoaWxToBoundsTransform = newTransform;
+ return CocoaLockFocusOnNSView(m_window->GetNonClientNSView());
+}
+
+bool wxWindowDC::CocoaUnlockFocus()
+{
+ wxLogTrace(wxTRACE_COCOA,wxT("Unlocking focus on wxWindowDC=%p, NSView=%p"),this, m_window->GetNonClientNSView());
+ return CocoaUnlockFocusOnNSView();
+}
+
+bool wxWindowDC::CocoaGetBounds(void *rectData)
+{
+ if(!rectData)
+ return false;
+ if(!m_lockedNSView)
+ return false;
+ NSRect *pRect = (NSRect*)rectData;
+ *pRect = [m_lockedNSView bounds];
+ return true;
+}
+