X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0fe0275981e662b56d9df1e5847932326f04cf0b..3454ecd508f3d5a2a31f1c1d9048de80763135d1:/src/cocoa/window.mm?ds=sidebyside diff --git a/src/cocoa/window.mm b/src/cocoa/window.mm index a1e06db23e..1e4fd289db 100644 --- a/src/cocoa/window.mm +++ b/src/cocoa/window.mm @@ -14,8 +14,10 @@ #include "wx/log.h" #include "wx/window.h" #endif //WX_PRECOMP +#include "wx/tooltip.h" #include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" #import #import @@ -24,8 +26,6 @@ #import #import -#include - // Turn this on to paint green over the dummy views for debugging #undef WXCOCOA_FILL_DUMMY_VIEW @@ -33,6 +33,11 @@ #import #endif //def WXCOCOA_FILL_DUMMY_VIEW +// A category for methods that are only present in Panther's SDK +@interface NSView(wxNSViewPrePantherCompatibility) +- (void)getRectsBeingDrawn:(const NSRect **)rects count:(int *)count; +@end + // ======================================================================== // wxWindowCocoaHider // ======================================================================== @@ -118,6 +123,7 @@ void wxWindowCocoaHider::Cocoa_FrameChanged(void) [m_owner->GetNSViewForHiding() setFrame:[m_dummyNSView frame]]; } + #ifdef WXCOCOA_FILL_DUMMY_VIEW bool wxWindowCocoaHider::Cocoa_drawRect(const NSRect& rect) { @@ -353,13 +359,8 @@ bool wxWindowCocoa::Cocoa_drawRect(const NSRect &rect) const NSRect *rects = ▭ // The bounding box of the region int countRects = 1; // Try replacing the larger rectangle with a list of smaller ones: -NS_DURING - // This only works on Panther -// [GetNSView() getRectsBeingDrawn:&rects count:&countRects]; - // This compiles everywhere (and still only works on Panther) - objc_msgSend(GetNSView(),@selector(getRectsBeingDrawn:count:),&rects,&countRects); -NS_HANDLER -NS_ENDHANDLER + if ([GetNSView() respondsToSelector:@selector(getRectsBeingDrawn:count:)]) + [GetNSView() getRectsBeingDrawn:&rects count:&countRects]; m_updateRegion = wxRegion(rects,countRects); wxPaintEvent event(m_windowId); @@ -479,6 +480,16 @@ void wxWindowCocoa::Cocoa_FrameChanged(void) GetEventHandler()->ProcessEvent(event); } +bool wxWindowCocoa::Cocoa_resetCursorRects() +{ + if(!m_cursor.GetNSCursor()) + return false; + + [GetNSView() addCursorRect: [GetNSView() visibleRect] cursor: m_cursor.GetNSCursor()]; + + return true; +} + bool wxWindow::Close(bool force) { // The only reason this function exists is that it is virtual and @@ -598,6 +609,20 @@ void wxWindowCocoa::DoSetSize(int x, int y, int width, int height, int sizeFlags DoMoveWindow(x,y,width,height); } +#if wxUSE_TOOLTIPS + +void wxWindowCocoa::DoSetToolTip( wxToolTip *tip ) +{ + wxWindowBase::DoSetToolTip(tip); + + if ( m_tooltip ) + { + m_tooltip->SetWindow((wxWindow *)this); + } +} + +#endif + void wxWindowCocoa::DoMoveWindow(int x, int y, int width, int height) { wxAutoNSAutoreleasePool pool; @@ -669,6 +694,11 @@ WXWidget wxWindow::GetHandle() const return m_cocoaNSView; } +wxWindow* wxWindow::GetWxWindow() const +{ + return (wxWindow*) this; +} + void wxWindow::Refresh(bool eraseBack, const wxRect *rect) { [m_cocoaNSView setNeedsDisplay:YES]; @@ -676,7 +706,14 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect) void wxWindow::SetFocus() { - // TODO +#ifdef __WXDEBUG__ + bool bOK = +#endif + [GetNSView() lockFocusIfCanDraw]; + + //Note that the normal lockFocus works on hidden and minimized windows + //and has no return value - which probably isn't what we want + wxASSERT(bOK); } void wxWindow::DoCaptureMouse() @@ -857,8 +894,12 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) // Get the window with the focus wxWindow *wxWindowBase::DoFindFocus() { - // TODO - return NULL; + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa([NSView focusView]); + + if (!win) + return NULL; + + return win->GetWxWindow(); } /* static */ wxWindow *wxWindowBase::GetCapture()