src/gui/kernel/qcocoawindowdelegate_mac.mm
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   305 -(QWidget *)qt_qwidgetForWindow:(NSWindow *)window
   305 -(QWidget *)qt_qwidgetForWindow:(NSWindow *)window
   306 {
   306 {
   307     return m_windowHash->value(window);
   307     return m_windowHash->value(window);
   308 }
   308 }
   309 
   309 
       
   310 - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
       
   311 {
       
   312     Q_UNUSED(newFrame);
       
   313     // saving the current window geometry before the window is maximized
       
   314     QWidget *qwidget = m_windowHash->value(window);
       
   315     if (qwidget->isWindow() && !(qwidget->windowState() & Qt::WindowMaximized)) {
       
   316         QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget);
       
   317         widgetPrivate->topData()->normalGeometry = qwidget->geometry();
       
   318     }
       
   319     return YES;
       
   320 }
       
   321 
   310 - (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame
   322 - (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame
   311 {
   323 {
   312     NSRect frameToReturn = defaultFrame;
   324     NSRect frameToReturn = defaultFrame;
   313     QWidget *qwidget = m_windowHash->value(window);
   325     QWidget *qwidget = m_windowHash->value(window);
   314     QSizeF size = qwidget->maximumSize();
   326     QSizeF size = qwidget->maximumSize();
   315     frameToReturn.size.width = qMin<CGFloat>(frameToReturn.size.width, size.width());
   327     NSRect windowFrameRect = [window frame];
   316     frameToReturn.size.height = qMin<CGFloat>(frameToReturn.size.height, size.height());
   328     NSRect viewFrameRect = [[window contentView] frame];
       
   329     // consider additional size required for titlebar & frame
       
   330     frameToReturn.size.width = qMin<CGFloat>(frameToReturn.size.width,
       
   331             size.width()+(windowFrameRect.size.width - viewFrameRect.size.width));
       
   332     frameToReturn.size.height = qMin<CGFloat>(frameToReturn.size.height,
       
   333             size.height()+(windowFrameRect.size.height - viewFrameRect.size.height));
   317     return frameToReturn;
   334     return frameToReturn;
   318 }
   335 }
   319 
   336 
   320 - (void)becomeDelegteForWindow:(NSWindow *)window  widget:(QWidget *)widget
   337 - (void)becomeDelegteForWindow:(NSWindow *)window  widget:(QWidget *)widget
   321 {
   338 {
   344     if (widget)
   361     if (widget)
   345         [self resignDelegateForWindow:[[drawer contentView] window]];
   362         [self resignDelegateForWindow:[[drawer contentView] window]];
   346     m_drawerHash->remove(drawer);
   363     m_drawerHash->remove(drawer);
   347 }
   364 }
   348 
   365 
       
   366 - (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
       
   367 {
       
   368     Q_UNUSED(menu);
       
   369     QWidget *qwidget = m_windowHash->value(window);
       
   370     if (qwidget && !qwidget->windowFilePath().isEmpty()) {
       
   371         return YES;
       
   372     }
       
   373     return NO;
       
   374 }
       
   375 
       
   376 - (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event
       
   377                                                           from:(NSPoint)dragImageLocation
       
   378                                                 withPasteboard:(NSPasteboard *)pasteboard
       
   379 {
       
   380     Q_UNUSED(event);
       
   381     Q_UNUSED(dragImageLocation);
       
   382     Q_UNUSED(pasteboard);
       
   383     QWidget *qwidget = m_windowHash->value(window);
       
   384     if (qwidget && !qwidget->windowFilePath().isEmpty()) {
       
   385         return YES;
       
   386     }
       
   387     return NO;
       
   388 }
   349 @end
   389 @end
   350 #endif// QT_MAC_USE_COCOA
   390 #endif// QT_MAC_USE_COCOA