Changeset 6721 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 1, 2008 3:14:02 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h
r6715 r6721 255 255 CGImageRef DarwinQPixmapFromMimeSourceToCGImage (const char *aSource); 256 256 CGImageRef DarwinCreateDockBadge (const char *aSource); 257 CGImageRef DarwinCreateDockPreview (CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage = NULL);258 CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage);257 void DarwinUpdateDockPreview (CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage = NULL); 258 void DarwinUpdateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage); 259 259 OSStatus DarwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData); 260 260 #endif /* Q_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r6715 r6721 2939 2939 CGImageRef ir = 2940 2940 static_cast <VBoxQuartz2DFrameBuffer *> (mFrameBuf)->imageRef(); 2941 SetApplicationDockTileImage ( 2942 ::DarwinCreateDockPreview (ir, mVirtualBoxLogo)); 2941 ::DarwinUpdateDockPreview (ir, mVirtualBoxLogo); 2943 2942 } 2944 2943 else 2945 2944 # endif 2946 SetApplicationDockTileImage ( 2947 ::DarwinCreateDockPreview (mFrameBuf, mVirtualBoxLogo)); 2945 ::DarwinUpdateDockPreview (mFrameBuf, mVirtualBoxLogo); 2948 2946 } 2949 2947 #endif … … 2959 2957 2960 2958 #ifdef Q_WS_MAC 2961 SetApplicationDockTileImage ( 2962 ::DarwinCreateDockPreview (DarwinQPixmapToCGImage (&mPausedShot), 2963 mVirtualBoxLogo, 2964 mMainWnd->dockImageState())); 2959 ::DarwinUpdateDockPreview (DarwinQPixmapToCGImage (&mPausedShot), 2960 mVirtualBoxLogo, 2961 mMainWnd->dockImageState()); 2965 2962 #endif 2966 2963 } -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp
r6720 r6721 128 128 129 129 /** 130 * Creates a dock preview image. 131 * 132 * This method is a callback that creates a 128x128 preview image of the VM window. 133 * 134 * @returns CGImageRef for the new image. (Remember to release it when finished with it.) 130 * Updates the dock preview image. 131 * 132 * This method is a callback that updates the 128x128 preview image of the VM window in the dock. 133 * 135 134 * @param aVMImage the vm screen as a CGImageRef 136 135 * @param aOverlayImage an optional icon overlay image to add at the bottom right of the icon 137 136 * @param aStateImage an optional state overlay image to add at the center of the icon 138 137 */ 139 CGImageRef DarwinCreateDockPreview (CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage)138 void DarwinUpdateDockPreview (CGImageRef aVMImage, CGImageRef aOverlayImage, CGImageRef aStateImage) 140 139 { 141 140 Assert (aVMImage); … … 163 162 (targetHeight - scaledHeight) / 2.0, 164 163 scaledWidth, scaledHeight); 165 /* Create a bitmap context to draw on */ 166 CGImageRef dockImage = NULL; 167 int bitmapBytesPerRow = targetWidth * 4; 168 int bitmapByteCount = bitmapBytesPerRow * targetHeight; 169 void *bitmapData = RTMemAlloc (bitmapByteCount); 170 if (bitmapData) 171 { 172 CGContextRef context = CGBitmapContextCreate (bitmapData, targetWidth, targetHeight, 8, bitmapBytesPerRow, cs, kCGImageAlphaPremultipliedLast); 173 /* rounded corners */ 164 /* Create the context to draw on */ 165 CGContextRef context = BeginCGContextForApplicationDockTile(); 166 Assert (context); 167 /* Clear the background */ 168 CGContextClearRect (context, CGRectMake (0, 0, 128, 128)); 169 /* rounded corners */ 174 170 // CGContextSetLineJoin (context, kCGLineJoinRound); 175 171 // CGContextSetShadow (context, CGSizeMake (10, 5), 1); 176 172 // CGContextSetAllowsAntialiasing (context, true); 177 /* some little boarder */ 178 iconRect = CGRectInset (iconRect, 1, 1); 179 /* gray stroke */ 180 CGContextSetRGBStrokeColor (context, 225.0/255.0, 218.0/255.0, 211.0/255.0, 1); 181 iconRect = CGRectInset (iconRect, 6, 6); 182 CGContextStrokeRectWithWidth (context, iconRect, 12); 183 iconRect = CGRectInset (iconRect, 5, 5); 184 /* black stroke */ 185 CGContextSetRGBStrokeColor (context, 0.0, 0.0, 0.0, 1.0); 186 CGContextStrokeRectWithWidth (context, iconRect, 2); 187 /* vm content */ 188 iconRect = CGRectInset (iconRect, 1, 1); 189 CGContextDrawImage (context, iconRect, aVMImage); 190 /* the state image at center */ 191 if (aStateImage) 192 { 193 CGRect stateRect = CGRectMake ((targetWidth - CGImageGetWidth (aStateImage)) / 2.0, (targetHeight - CGImageGetHeight (aStateImage)) / 2.0, CGImageGetWidth (aStateImage), CGImageGetHeight (aStateImage)); 194 CGContextDrawImage (context, stateRect, aStateImage); 195 } 196 /* the overlay image at bottom/right */ 197 if (aOverlayImage) 198 { 199 CGRect overlayRect = CGRectMake (targetWidth - CGImageGetWidth (aOverlayImage), 0, CGImageGetWidth (aOverlayImage), CGImageGetHeight (aOverlayImage)); 200 CGContextDrawImage (context, overlayRect, aOverlayImage); 201 } 202 /* Create the preview image ref from the bitmap */ 203 dockImage = CGBitmapContextCreateImage (context); 204 CGContextRelease (context); 205 RTMemFree (bitmapData); 206 } 173 /* some little boarder */ 174 iconRect = CGRectInset (iconRect, 1, 1); 175 /* gray stroke */ 176 CGContextSetRGBStrokeColor (context, 225.0/255.0, 218.0/255.0, 211.0/255.0, 1); 177 iconRect = CGRectInset (iconRect, 6, 6); 178 CGContextStrokeRectWithWidth (context, iconRect, 12); 179 iconRect = CGRectInset (iconRect, 5, 5); 180 /* black stroke */ 181 CGContextSetRGBStrokeColor (context, 0.0, 0.0, 0.0, 1.0); 182 CGContextStrokeRectWithWidth (context, iconRect, 2); 183 /* vm content */ 184 iconRect = CGRectInset (iconRect, 1, 1); 185 CGContextDrawImage (context, iconRect, aVMImage); 186 /* the state image at center */ 187 if (aStateImage) 188 { 189 CGRect stateRect = CGRectMake ((targetWidth - CGImageGetWidth (aStateImage)) / 2.0, 190 (targetHeight - CGImageGetHeight (aStateImage)) / 2.0, 191 CGImageGetWidth (aStateImage), 192 CGImageGetHeight (aStateImage)); 193 CGContextDrawImage (context, stateRect, aStateImage); 194 } 195 /* the overlay image at bottom/right */ 196 if (aOverlayImage) 197 { 198 CGRect overlayRect = CGRectMake (targetWidth - CGImageGetWidth (aOverlayImage), 199 0, 200 CGImageGetWidth (aOverlayImage), 201 CGImageGetHeight (aOverlayImage)); 202 CGContextDrawImage (context, overlayRect, aOverlayImage); 203 } 204 /* This flush updates the dock icon */ 205 CGContextFlush (context); 206 EndCGContextForApplicationDockTile (context); 207 207 208 208 CGColorSpaceRelease (cs); 209 210 Assert (dockImage); 211 return dockImage; 212 } 213 214 /** 215 * Creates a dock preview image. 216 * 217 * This method is a callback that creates a 128x128 preview image of the VM window. 218 * 219 * @returns CGImageRef for the new image. (Remember to release it when finished with it.) 209 } 210 211 /** 212 * Updates the dock preview image. 213 * 214 * This method is a callback that updates the 128x128 preview image of the VM window in the dock. 215 * 220 216 * @param aFrameBuffer The guest frame buffer. 221 217 * @param aOverlayImage an optional icon overlay image to add at the bottom right of the icon 222 218 */ 223 CGImageRef DarwinCreateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage)219 void DarwinUpdateDockPreview (VBoxFrameBuffer *aFrameBuffer, CGImageRef aOverlayImage) 224 220 { 225 221 CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); … … 231 227 kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false, 232 228 kCGRenderingIntentDefault); 233 /* Create thepreview icon */234 CGImageRef dockImage = DarwinCreateDockPreview (ir, aOverlayImage);229 /* Update the dock preview icon */ 230 ::DarwinUpdateDockPreview (ir, aOverlayImage); 235 231 /* Release the temp data and image */ 236 232 CGDataProviderRelease (dp); 237 233 CGImageRelease (ir); 238 234 CGColorSpaceRelease (cs); 239 240 return dockImage;241 235 } 242 236
Note:
See TracChangeset
for help on using the changeset viewer.