Changeset 34192 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Nov 19, 2010 12:27:13 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/darwin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm
r30155 r34192 84 84 CGImageRelease(pCGImage); 85 85 return pNSImage; 86 } 87 88 NativeNSStringRef darwinToNativeString(const char* pcszString) 89 { 90 return [NSString stringWithUTF8String: pcszString]; 86 91 } 87 92 … … 138 143 } 139 144 145 void darwinMinaturizeWindow(NativeNSWindowRef pWindow) 146 { 147 // [[NSApplication sharedApplication] miniaturizeAll]; 148 // printf("bla\n"); 149 // [pWindow miniaturize:pWindow]; 150 // [[NSApplication sharedApplication] deactivate]; 151 // [pWindow performMiniaturize:nil]; 152 } 153 140 154 void darwinSetDockIconMenu(QMenu* pMenu) 141 155 { … … 169 183 windowFrame.origin.y -= h1; 170 184 171 [pWindow setFrame:windowFrame display:YES animate:YES]; 185 [pWindow setFrame:windowFrame display:YES animate: YES]; 186 } 187 188 void darwinWindowAnimateResizeNewImpl(NativeNSWindowRef pWindow, int height, bool fAnimate) 189 { 190 /* It seems that Qt doesn't return the height of the window with the 191 * toolbar height included. So add this size manually. Could easily be that 192 * the Trolls fix this in the final release. */ 193 NSToolbar *toolbar = [pWindow toolbar]; 194 NSRect windowFrame = [pWindow frame]; 195 int toolbarHeight = 0; 196 if(toolbar && [toolbar isVisible]) 197 toolbarHeight = NSHeight(windowFrame) - NSHeight([[pWindow contentView] frame]); 198 int h = height + toolbarHeight; 199 int h1 = h - NSHeight(windowFrame); 200 windowFrame.size.height = h; 201 windowFrame.origin.y -= h1; 202 203 [pWindow setFrame:windowFrame display:YES animate: fAnimate ? YES : NO]; 204 } 205 206 void darwinTest(NativeNSViewRef pViewOld, NativeNSViewRef pViewNew, int h) 207 { 208 NSMutableDictionary *pDicts[3] = { nil, nil, nil }; 209 int c = 0; 210 211 /* Scaling necessary? */ 212 if (h != -1) 213 { 214 NSWindow *pWindow = [(pViewOld ? pViewOld : pViewNew) window]; 215 NSToolbar *toolbar = [pWindow toolbar]; 216 NSRect windowFrame = [pWindow frame]; 217 /* Dictionary containing all animation parameters. */ 218 pDicts[c] = [NSMutableDictionary dictionaryWithCapacity:2]; 219 /* Specify the animation target. */ 220 [pDicts[c] setObject:pWindow forKey:NSViewAnimationTargetKey]; 221 /* Scaling effect. */ 222 [pDicts[c] setObject:[NSValue valueWithRect:windowFrame] forKey:NSViewAnimationStartFrameKey]; 223 int toolbarHeight = 0; 224 if(toolbar && [toolbar isVisible]) 225 toolbarHeight = NSHeight(windowFrame) - NSHeight([[pWindow contentView] frame]); 226 int h1 = h + toolbarHeight; 227 int h2 = h1 - NSHeight(windowFrame); 228 windowFrame.size.height = h1; 229 windowFrame.origin.y -= h2; 230 [pDicts[c] setObject:[NSValue valueWithRect:windowFrame] forKey:NSViewAnimationEndFrameKey]; 231 ++c; 232 } 233 /* Fade out effect. */ 234 if (pViewOld) 235 { 236 /* Dictionary containing all animation parameters. */ 237 pDicts[c] = [NSMutableDictionary dictionaryWithCapacity:2]; 238 /* Specify the animation target. */ 239 [pDicts[c] setObject:pViewOld forKey:NSViewAnimationTargetKey]; 240 /* Fade out effect. */ 241 [pDicts[c] setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey]; 242 ++c; 243 } 244 /* Fade in effect. */ 245 if (pViewNew) 246 { 247 /* Dictionary containing all animation parameters. */ 248 pDicts[c] = [NSMutableDictionary dictionaryWithCapacity:2]; 249 /* Specify the animation target. */ 250 [pDicts[c] setObject:pViewNew forKey:NSViewAnimationTargetKey]; 251 /* Fade in effect. */ 252 [pDicts[c] setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey]; 253 ++c; 254 } 255 /* Create our animation object. */ 256 NSViewAnimation *pAni = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:pDicts count:c]]; 257 [pAni setDuration:.15]; 258 [pAni setAnimationCurve:NSAnimationEaseIn]; 259 [pAni setAnimationBlockingMode:NSAnimationBlocking]; 260 // [pAni setAnimationBlockingMode:NSAnimationNonblockingThreaded]; 261 262 /* Run the animation. */ 263 [pAni startAnimation]; 264 /* Cleanup */ 265 [pAni release]; 172 266 } 173 267 … … 203 297 204 298 return fResult; 299 } 300 301 bool darwinShowFileInFinder(NativeNSStringRef pstrFile) 302 { 303 return [[NSWorkspace sharedWorkspace] selectFile:pstrFile inFileViewerRootedAtPath:@""]; 304 } 305 306 bool darwinOpenFile(NativeNSStringRef pstrFile) 307 { 308 return [[NSWorkspace sharedWorkspace] openFile:pstrFile]; 205 309 } 206 310 … … 252 356 NSEventType eEvtType = [pEvent type]; 253 357 bool fGlobalHotkey = false; 358 // 359 // if ( (eEvtType == NSKeyDown || eEvtType == NSKeyUp) 360 // && [[NSApp mainMenu] performKeyEquivalent:pEvent]) 361 // return true; 362 // return false; 363 // && [[[NSApp mainMenu] delegate] menuHasKeyEquivalent:[NSApp mainMenu] forEvent:pEvent target:b action:a]) 254 364 255 365 switch (eEvtType) … … 266 376 || KeyCode == 0x04) /* CMD+H (Hide) */ 267 377 fGlobalHotkey = true; 268 } 378 } 269 379 else if ( ((fEvtMask & (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICELALTKEYMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK)) == (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICELALTKEYMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK)) /* L+ALT+CMD */ 270 380 || ((fEvtMask & (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICERCMDKEYMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK)) == (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICERCMDKEYMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK))) /* R+ALT+CMD */ … … 280 390 } 281 391 392 void darwinRetranslateAppMenu() 393 { 394 /* This is purely Qt internal. If the Trolls change something here, it will 395 not work anymore, but at least it will not be a burning man. */ 396 if ([NSApp respondsToSelector:@selector(qt_qcocoamenuLoader)]) 397 { 398 id loader = [NSApp performSelector:@selector(qt_qcocoamenuLoader)]; 399 if ([loader respondsToSelector:@selector(qtTranslateApplicationMenu)]) 400 [loader performSelector:@selector(qtTranslateApplicationMenu)]; 401 } 402 } 403 -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp
r30151 r34192 38 38 NativeNSViewRef darwinToNativeView(QWidget *pWidget) 39 39 { 40 return reinterpret_cast<NativeNSViewRef>(pWidget->winId()); 40 if (pWidget) 41 return reinterpret_cast<NativeNSViewRef>(pWidget->winId()); 42 return nil; 41 43 } 42 44 43 45 NativeNSWindowRef darwinToNativeWindow(QWidget *pWidget) 44 46 { 45 return ::darwinToNativeWindowImpl(::darwinToNativeView(pWidget)); 47 if (pWidget) 48 return ::darwinToNativeWindowImpl(::darwinToNativeView(pWidget)); 49 return nil; 46 50 } 47 51 … … 81 85 { 82 86 ::darwinWindowAnimateResizeImpl(::darwinToNativeWindow(pWidget), aTarget.x(), aTarget.y(), aTarget.width(), aTarget.height()); 87 } 88 89 void darwinWindowAnimateResizeNew(QWidget *pWidget, int h, bool fAnimate) 90 { 91 ::darwinWindowAnimateResizeNewImpl(::darwinToNativeWindow(pWidget), h, fAnimate); 92 } 93 94 void darwinTest(QWidget *pWidget1, QWidget *pWidget2, int h) 95 { 96 ::darwinTest(::darwinToNativeView(pWidget1), ::darwinToNativeView(pWidget2), h); 83 97 } 84 98 … … 116 130 return false; 117 131 #endif /* !QT_MAC_USE_COCOA */ 132 } 133 134 void darwinMinaturizeWindow(QWidget *pWidget) 135 { 136 return ::darwinMinaturizeWindow(::darwinToNativeWindow(pWidget)); 137 } 138 139 bool darwinShowFileInFinder(const QString& strFile) 140 { 141 return ::darwinShowFileInFinder(darwinToNativeString(strFile.toUtf8().constData())); 142 } 143 144 bool darwinOpenFile(const QString& strFile) 145 { 146 return ::darwinOpenFile(darwinToNativeString(strFile.toUtf8().constData())); 118 147 } 119 148 -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h
r31235 r34192 31 31 ADD_COCOA_NATIVE_REF(NSView); 32 32 ADD_COCOA_NATIVE_REF(NSWindow); 33 ADD_COCOA_NATIVE_REF(NSString); 33 34 34 35 class QImage; … … 48 49 NativeNSWindowRef darwinToNativeWindowImpl(NativeNSViewRef pView); 49 50 NativeNSViewRef darwinToNativeViewImpl(NativeNSWindowRef pWindow); 51 NativeNSStringRef darwinToNativeString(const char* pcszString); 50 52 51 53 /******************************************************************************** … … 60 62 void darwinSetMouseCoalescingEnabled(bool fEnabled); 61 63 64 void darwintest(NativeNSWindowRef pWindow); 62 65 /******************************************************************************** 63 66 * … … 66 69 ********************************************************************************/ 67 70 void darwinWindowAnimateResizeImpl(NativeNSWindowRef pWindow, int x, int y, int width, int height); 71 void darwinWindowAnimateResizeNewImpl(NativeNSWindowRef pWindow, int height, bool fAnimate); 72 void darwinTest(NativeNSViewRef pView, NativeNSViewRef pView1, int h); 68 73 void darwinWindowInvalidateShapeImpl(NativeNSWindowRef pWindow); 69 74 void darwinWindowInvalidateShadowImpl(NativeNSWindowRef pWindow); … … 71 76 bool darwinIsToolbarVisible(NativeNSWindowRef pWindow); 72 77 bool darwinIsWindowMaximized(NativeNSWindowRef pWindow); 78 void darwinMinaturizeWindow(NativeNSWindowRef pWindow); 79 80 bool darwinShowFileInFinder(NativeNSStringRef pstrFile); 81 bool darwinOpenFile(NativeNSStringRef pstrFile); 73 82 74 83 float darwinSmallFontSize(); … … 80 89 81 90 bool darwinIsApplicationCommand(ConstNativeNSEventRef pEvent); 91 92 void darwinRetranslateAppMenu(); 82 93 83 94 RT_C_DECLS_END … … 168 179 void darwinDisableIconsInMenus(void); 169 180 181 void darwinTest(QWidget *pWidget1, QWidget *pWidget2, int h); 182 170 183 /******************************************************************************** 171 184 * … … 174 187 ********************************************************************************/ 175 188 void darwinWindowAnimateResize(QWidget *pWidget, const QRect &aTarget); 189 void darwinWindowAnimateResizeNew(QWidget *pWidget, int h, bool fAnimate); 176 190 void darwinWindowInvalidateShape(QWidget *pWidget); 177 191 void darwinWindowInvalidateShadow(QWidget *pWidget); … … 179 193 bool darwinIsToolbarVisible(QToolBar *pToolBar); 180 194 bool darwinIsWindowMaximized(QWidget *pWidget); 195 void darwinMinaturizeWindow(QWidget *pWidget); 196 197 bool darwinShowFileInFinder(const QString &strFile); 198 bool darwinOpenFile(const QString &strFile); 199 181 200 QString darwinSystemLanguage(void); 182 201 QPixmap darwinCreateDragPixmap(const QPixmap& aPixmap, const QString &aText);
Note:
See TracChangeset
for help on using the changeset viewer.