src/gui/dialogs/qnspanelproxy_mac.mm
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    50 static QWidget *currentWindow = 0;
    50 static QWidget *currentWindow = 0;
    51 QT_END_NAMESPACE
    51 QT_END_NAMESPACE
    52 
    52 
    53 QT_USE_NAMESPACE
    53 QT_USE_NAMESPACE
    54 
    54 
    55 @class QNSPanelProxy;
    55 @class QT_MANGLE_NAMESPACE(QNSPanelProxy);
    56 
    56 
    57 @interface QNSPanelProxy : NSWindow {
    57 @interface QT_MANGLE_NAMESPACE(QNSPanelProxy) : NSWindow {
    58 }
    58 }
    59 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    59 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    60     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation;
    60     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation;
    61 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    61 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    62     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation screen:(NSScreen *)screen;
    62     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation screen:(NSScreen *)screen;
    64     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation;
    64     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation;
    65 - (id)qt_fakeInitWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    65 - (id)qt_fakeInitWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    66     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation screen:(NSScreen *)screen;
    66     backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation screen:(NSScreen *)screen;
    67 @end
    67 @end
    68 
    68 
    69 @implementation QNSPanelProxy
    69 @implementation QT_MANGLE_NAMESPACE(QNSPanelProxy)
    70 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    70 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    71       backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
    71       backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
    72 {
    72 {
    73     // remove evil flag
    73     // remove evil flag
    74     windowStyle &= ~NSUtilityWindowMask;
    74     windowStyle &= ~NSUtilityWindowMask;
   106     Q_UNUSED(screen);
   106     Q_UNUSED(screen);
   107     return nil;
   107     return nil;
   108 }
   108 }
   109 @end
   109 @end
   110 
   110 
   111 @class QNSWindowProxy;
   111 @class QT_MANGLE_NAMESPACE(QNSWindowProxy);
   112 
   112 
   113 @interface QNSWindowProxy : NSWindow {
   113 @interface QT_MANGLE_NAMESPACE(QNSWindowProxy) : NSWindow {
   114 }
   114 }
   115 - (void)setTitle:(NSString *)title;
   115 - (void)setTitle:(NSString *)title;
   116 - (void)qt_fakeSetTitle:(NSString *)title;
   116 - (void)qt_fakeSetTitle:(NSString *)title;
   117 @end
   117 @end
   118 
   118 
   119 @implementation QNSWindowProxy
   119 @implementation QT_MANGLE_NAMESPACE(QNSWindowProxy)
   120 - (void)setTitle:(NSString *)title
   120 - (void)setTitle:(NSString *)title
   121 {
   121 {
   122     QCFString cftitle(currentWindow->windowTitle());
   122     QCFString cftitle(currentWindow->windowTitle());
   123 
   123 
   124     // evil reverse engineering
   124     // evil reverse engineering
   188 */
   188 */
   189 void macStartInterceptNSPanelCtor()
   189 void macStartInterceptNSPanelCtor()
   190 {
   190 {
   191     macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
   191     macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
   192                       @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
   192                       @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
   193                       [NSPanel class], [QNSPanelProxy class]);
   193                       [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
   194     macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
   194     macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
   195                       @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
   195                       @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
   196                       [NSPanel class], [QNSPanelProxy class]);
   196                       [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
   197 }
   197 }
   198 
   198 
   199 /*
   199 /*
   200     Restore things as they were.
   200     Restore things as they were.
   201 */
   201 */
   202 void macStopInterceptNSPanelCtor()
   202 void macStopInterceptNSPanelCtor()
   203 {
   203 {
   204     macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
   204     macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
   205                      @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
   205                      @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
   206                      [NSPanel class], [QNSPanelProxy class]);
   206                      [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
   207     macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
   207     macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
   208                      @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
   208                      @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
   209                      [NSPanel class], [QNSPanelProxy class]);
   209                      [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
   210 }
   210 }
   211 
   211 
   212 /*
   212 /*
   213     Intercept the NSPrintPanel and NSPageLayout setTitle: calls. The
   213     Intercept the NSPrintPanel and NSPageLayout setTitle: calls. The
   214     hack is similar as for NSColorPanel above.
   214     hack is similar as for NSColorPanel above.
   215 */
   215 */
   216 void macStartInterceptWindowTitle(QWidget *window)
   216 void macStartInterceptWindowTitle(QWidget *window)
   217 {
   217 {
   218     currentWindow = window;
   218     currentWindow = window;
   219     macStartIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
   219     macStartIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
   220                       [NSWindow class], [QNSWindowProxy class]);
   220                       [NSWindow class], [QT_MANGLE_NAMESPACE(QNSWindowProxy) class]);
   221 }
   221 }
   222 
   222 
   223 /*
   223 /*
   224     Restore things as they were.
   224     Restore things as they were.
   225 */
   225 */
   226 void macStopInterceptWindowTitle()
   226 void macStopInterceptWindowTitle()
   227 {
   227 {
   228     currentWindow = 0;
   228     currentWindow = 0;
   229     macStopIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
   229     macStopIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
   230                      [NSWindow class], [QNSWindowProxy class]);
   230                      [NSWindow class], [QT_MANGLE_NAMESPACE(QNSWindowProxy) class]);
   231 }
   231 }
   232 
   232 
   233 /*
   233 /*
   234     Doesn't really belong in here.
   234     Doesn't really belong in here.
   235 */
   235 */