X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4db3c8ac631546f9b695e7590eaa4cb2805a1145..a1a1ca8998d3a47ab880e9dd19202e50f6d25365:/src/cocoa/window.mm diff --git a/src/cocoa/window.mm b/src/cocoa/window.mm index de7edc583b..31fc7b3dad 100644 --- a/src/cocoa/window.mm +++ b/src/cocoa/window.mm @@ -4,9 +4,9 @@ // Author: David Elliott // Modified by: // Created: 2002/12/26 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) 2002 David Elliott -// Licence: wxWidgets licence +// Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -41,6 +41,58 @@ - (void)getRectsBeingDrawn:(const NSRect **)rects count:(int *)count; @end +NSPoint CocoaTransformNSViewBoundsToWx(NSView *nsview, NSPoint pointBounds) +{ + wxCHECK_MSG(nsview, pointBounds, wxT("Need to have a Cocoa view to do translation")); + if([nsview isFlipped]) + return pointBounds; + NSRect ourBounds = [nsview bounds]; + return NSMakePoint + ( pointBounds.x + , ourBounds.size.height - pointBounds.y + ); +} + +NSRect CocoaTransformNSViewBoundsToWx(NSView *nsview, NSRect rectBounds) +{ + wxCHECK_MSG(nsview, rectBounds, wxT("Need to have a Cocoa view to do translation")); + if([nsview isFlipped]) + return rectBounds; + NSRect ourBounds = [nsview bounds]; + return NSMakeRect + ( rectBounds.origin.x + , ourBounds.size.height - (rectBounds.origin.y + rectBounds.size.height) + , rectBounds.size.width + , rectBounds.size.height + ); +} + +NSPoint CocoaTransformNSViewWxToBounds(NSView *nsview, NSPoint pointWx) +{ + wxCHECK_MSG(nsview, pointWx, wxT("Need to have a Cocoa view to do translation")); + if([nsview isFlipped]) + return pointWx; + NSRect ourBounds = [nsview bounds]; + return NSMakePoint + ( pointWx.x + , ourBounds.size.height - pointWx.y + ); +} + +NSRect CocoaTransformNSViewWxToBounds(NSView *nsview, NSRect rectWx) +{ + wxCHECK_MSG(nsview, rectWx, wxT("Need to have a Cocoa view to do translation")); + if([nsview isFlipped]) + return rectWx; + NSRect ourBounds = [nsview bounds]; + return NSMakeRect + ( rectWx.origin.x + , ourBounds.size.height - (rectWx.origin.y + rectWx.size.height) + , rectWx.size.width + , rectWx.size.height + ); +} + // ======================================================================== // wxWindowCocoaHider // ======================================================================== @@ -256,8 +308,8 @@ void wxWindowCocoa::Init() m_cocoaNSView = NULL; m_cocoaHider = NULL; m_wxCocoaScrollView = NULL; - m_isBeingDeleted = FALSE; - m_isInPaint = FALSE; + m_isBeingDeleted = false; + m_isInPaint = false; m_shouldBeEnabled = true; } @@ -283,7 +335,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID winid, SetInitialFrameRect(pos,size); } - return TRUE; + return true; } // Destructor @@ -348,57 +400,25 @@ WX_NSView wxWindowCocoa::GetNSViewForHiding() const NSPoint wxWindowCocoa::CocoaTransformBoundsToWx(NSPoint pointBounds) { // TODO: Handle scrolling offset - wxCHECK_MSG(GetNSView(), pointBounds, wxT("Need to have a Cocoa view to do translation")); - if([GetNSView() isFlipped]) - return pointBounds; - NSRect ourBounds = [GetNSView() bounds]; - return NSMakePoint - ( pointBounds.x - , ourBounds.size.height - pointBounds.y - ); + return CocoaTransformNSViewBoundsToWx(GetNSView(), pointBounds); } NSRect wxWindowCocoa::CocoaTransformBoundsToWx(NSRect rectBounds) { // TODO: Handle scrolling offset - wxCHECK_MSG(GetNSView(), rectBounds, wxT("Need to have a Cocoa view to do translation")); - if([GetNSView() isFlipped]) - return rectBounds; - NSRect ourBounds = [GetNSView() bounds]; - return NSMakeRect - ( rectBounds.origin.x - , ourBounds.size.height - (rectBounds.origin.y + rectBounds.size.height) - , rectBounds.size.width - , rectBounds.size.height - ); + return CocoaTransformNSViewBoundsToWx(GetNSView(), rectBounds); } NSPoint wxWindowCocoa::CocoaTransformWxToBounds(NSPoint pointWx) { // TODO: Handle scrolling offset - wxCHECK_MSG(GetNSView(), pointWx, wxT("Need to have a Cocoa view to do translation")); - if([GetNSView() isFlipped]) - return pointWx; - NSRect ourBounds = [GetNSView() bounds]; - return NSMakePoint - ( pointWx.x - , ourBounds.size.height - pointWx.y - ); + return CocoaTransformNSViewWxToBounds(GetNSView(), pointWx); } NSRect wxWindowCocoa::CocoaTransformWxToBounds(NSRect rectWx) { // TODO: Handle scrolling offset - wxCHECK_MSG(GetNSView(), rectWx, wxT("Need to have a Cocoa view to do translation")); - if([GetNSView() isFlipped]) - return rectWx; - NSRect ourBounds = [GetNSView() bounds]; - return NSMakeRect - ( rectWx.origin.x - , ourBounds.size.height - (rectWx.origin.y + rectWx.size.height) - , rectWx.size.width - , rectWx.size.height - ); + return CocoaTransformNSViewWxToBounds(GetNSView(), rectWx); } WX_NSAffineTransform wxWindowCocoa::CocoaGetWxToBoundsTransform() @@ -419,7 +439,7 @@ bool wxWindowCocoa::Cocoa_drawRect(const NSRect &rect) wxLogDebug(wxT("Paint event recursion!")); return false; } - m_isInPaint = TRUE; + m_isInPaint = true; // Set m_updateRegion const NSRect *rects = ▭ // The bounding box of the region @@ -439,7 +459,7 @@ bool wxWindowCocoa::Cocoa_drawRect(const NSRect &rect) wxPaintEvent event(m_windowId); event.SetEventObject(this); bool ret = GetEventHandler()->ProcessEvent(event); - m_isInPaint = FALSE; + m_isInPaint = false; return ret; } @@ -560,9 +580,9 @@ bool wxWindowCocoa::Cocoa_resetCursorRects() { if(!m_cursor.GetNSCursor()) return false; - - [GetNSView() addCursorRect: [GetNSView() visibleRect] cursor: m_cursor.GetNSCursor()]; - + + [GetNSView() addCursorRect: [GetNSView() visibleRect] cursor: m_cursor.GetNSCursor()]; + return true; } @@ -659,7 +679,7 @@ void wxWindowCocoa::DoSetSize(int x, int y, int width, int height, int sizeFlags AdjustForParentClientOrigin(x,y,sizeFlags); - wxSize size(-1,-1); + wxSize size(wxDefaultSize); if((width==-1)&&!(sizeFlags&wxSIZE_ALLOW_MINUS_ONE)) { @@ -829,7 +849,18 @@ void wxWindow::DoSetClientSize(int width, int height) void wxWindow::CocoaSetWxWindowSize(int width, int height) { - wxWindowCocoa::DoSetSize(-1,-1,width,height,wxSIZE_USE_EXISTING); + wxWindowCocoa::DoSetSize(wxDefaultCoord,wxDefaultCoord,width,height,wxSIZE_USE_EXISTING); +} + +void wxWindow::SetLabel(const wxString& WXUNUSED(label)) +{ + // TODO +} + +wxString wxWindow::GetLabel() const +{ + // TODO + return wxEmptyString; } int wxWindow::GetCharHeight() const @@ -913,7 +944,7 @@ void wxWindow::DoSetVirtualSize( int x, int y ) bool wxWindow::SetFont(const wxFont& font) { // TODO - return TRUE; + return true; } static int CocoaRaiseWindowCompareFunction(id first, id second, void *target) @@ -959,7 +990,7 @@ void wxWindow::Lower() bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) { - return FALSE; + return false; } // Get the window with the focus @@ -977,14 +1008,14 @@ wxWindow *wxWindowBase::DoFindFocus() wxCocoaNSView *win; NSWindow *keyWindow = [[NSApplication sharedApplication] keyWindow]; - win = wxCocoaNSView::GetFromCocoa([keyWindow firstResponder]); + win = wxCocoaNSView::GetFromCocoa(static_cast([keyWindow firstResponder])); if(win) return win->GetWxWindow(); NSWindow *mainWindow = [[NSApplication sharedApplication] keyWindow]; if(mainWindow == keyWindow) return NULL; - win = wxCocoaNSView::GetFromCocoa([mainWindow firstResponder]); + win = wxCocoaNSView::GetFromCocoa(static_cast([mainWindow firstResponder])); if(win) return win->GetWxWindow(); @@ -1014,4 +1045,3 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt) pt = wxGetMousePosition(); return NULL; } -