mirror of https://github.com/BOINC/boinc.git
Mac MGR: Fix code drawing menubar icon with newer versions of wxwidgets
svn path=/trunk/boinc/; revision=14410
This commit is contained in:
parent
a17d211ff8
commit
d2b5c1ca08
|
@ -12338,3 +12338,12 @@ Charlie 18 Dec 07
|
|||
|
||||
clientgui/
|
||||
sg_ViewTabPage.cpp
|
||||
|
||||
Charlie 19 Dec 07
|
||||
- Mac MGR: Fix code which draws menubar icon to properly use alpha
|
||||
channel with newer versions of wxwidgets.
|
||||
|
||||
clientgui/
|
||||
mac/
|
||||
SystemMenu.m
|
||||
MacSysMenu.cpp,h
|
||||
|
|
|
@ -165,8 +165,6 @@ CMacSystemMenu::~CMacSystemMenu() {
|
|||
|
||||
// Set the System Menu Icon from XPM data
|
||||
bool CMacSystemMenu::SetIcon(const wxIcon& icon, const wxString&) {
|
||||
wxBitmapRefData * theBitsRefData;
|
||||
PicHandle thePICT;
|
||||
wxBitmap theBits;
|
||||
|
||||
if (&icon == currentIcon)
|
||||
|
@ -175,19 +173,20 @@ bool CMacSystemMenu::SetIcon(const wxIcon& icon, const wxString&) {
|
|||
currentIcon = &icon;
|
||||
|
||||
theBits.CopyFromIcon(icon);
|
||||
theBitsRefData = theBits.GetBitmapData();
|
||||
thePICT = theBitsRefData->GetPictHandle();
|
||||
if ( (SetSystemMenuIcon != NULL ) && (thePICT != NULL) ) {
|
||||
SetSystemMenuIcon(thePICT);
|
||||
CGImageRef imageRef = (CGImageRef)theBits.CGImageCreate();
|
||||
if ( (SetSystemMenuIcon != NULL ) && (imageRef != NULL) ) {
|
||||
SetSystemMenuIcon(imageRef);
|
||||
CGImageRelease( imageRef );
|
||||
return true;
|
||||
}
|
||||
|
||||
if(imageRef != NULL) CGImageRelease( imageRef );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CMacSystemMenu::BuildMenu() {
|
||||
wxBitmapRefData * theBitsRefData;
|
||||
PicHandle thePICT;
|
||||
wxBitmap theBits;
|
||||
wxMenu *themenu;
|
||||
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
||||
|
@ -200,10 +199,8 @@ void CMacSystemMenu::BuildMenu() {
|
|||
m_iconTaskBarSnooze = *pSkinAdvanced->GetApplicationSnoozeIcon();
|
||||
|
||||
theBits.CopyFromIcon(m_iconTaskBarNormal);
|
||||
theBitsRefData = theBits.GetBitmapData();
|
||||
thePICT = theBitsRefData->GetPictHandle();
|
||||
|
||||
if ( (SetUpSystemMenu != NULL ) && (thePICT != NULL) ) {
|
||||
CGImageRef imageRef = (CGImageRef)theBits.CGImageCreate();
|
||||
if ( (SetUpSystemMenu != NULL ) && (imageRef != NULL) ) {
|
||||
// Currently, the system menu is the same as the Dock menu with the addition of
|
||||
// the Quit menu item. If in the future you wish to make the system menu different
|
||||
// from the Dock menu, override CTaskBarIcon::BuildContextMenu() and
|
||||
|
@ -224,10 +221,11 @@ void CMacSystemMenu::BuildMenu() {
|
|||
|
||||
themenu->SetEventHandler(this);
|
||||
|
||||
SetUpSystemMenu((MenuRef)(themenu->GetHMenu()), thePICT);
|
||||
SetUpSystemMenu((MenuRef)(themenu->GetHMenu()), imageRef);
|
||||
|
||||
currentIcon = NULL;
|
||||
}
|
||||
if(imageRef != NULL) CGImageRelease( imageRef );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
|
||||
void LoadPrivateFrameworkBundle( CFStringRef framework, CFBundleRef *bundlePtr );
|
||||
// Function pointer prototypes to the Mach-O Cocoa wrappers
|
||||
typedef void (*SetUpSystemMenuProc)(MenuRef menuToCopy, PicHandle theIcon);
|
||||
typedef void (*SetSystemMenuIconProc)(PicHandle theIcon);
|
||||
typedef void (*SetUpSystemMenuProc)(MenuRef menuToCopy, CGImageRef theIcon);
|
||||
typedef void (*SetSystemMenuIconProc)(CGImageRef theIcon);
|
||||
|
||||
SetUpSystemMenuProc SetUpSystemMenu;
|
||||
SetSystemMenuIconProc SetSystemMenuIcon;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
SystemMenu *gSystemMenu = NULL;
|
||||
NSStatusItem *gStatusItem = NULL;
|
||||
|
||||
void SetSystemMenuIcon(PicHandle theIcon);
|
||||
void SetSystemMenuIcon(CGImageRef theIcon);
|
||||
static OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr);
|
||||
|
||||
/*
|
||||
|
@ -83,7 +83,7 @@ FallbackMethod:
|
|||
|
||||
/*
|
||||
*/
|
||||
void SetUpSystemMenu(MenuRef menuToCopy, PicHandle theIcon) {
|
||||
void SetUpSystemMenu(MenuRef menuToCopy, CGImageRef theIcon) {
|
||||
NSAutoreleasePool* pool;
|
||||
|
||||
if (gSystemMenu == NULL)
|
||||
|
@ -199,7 +199,7 @@ void SetUpSystemMenu(MenuRef menuToCopy, PicHandle theIcon) {
|
|||
}
|
||||
|
||||
|
||||
void SetSystemMenuIcon(PicHandle theIcon)
|
||||
void SetSystemMenuIcon(CGImageRef theIcon)
|
||||
{
|
||||
if (theIcon == NULL)
|
||||
{
|
||||
|
@ -213,14 +213,26 @@ void SetSystemMenuIcon(PicHandle theIcon)
|
|||
return;
|
||||
}
|
||||
|
||||
unsigned theLength = GetHandleSize((Handle)theIcon);
|
||||
NSData* theData = [[NSData alloc] initWithBytes:*theIcon length:theLength];
|
||||
NSImage* theImage = [[NSImage alloc] initWithData:theData];
|
||||
NSRect imageRect = NSMakeRect(0.0, 0.0, 0.0, 0.0);
|
||||
CGContextRef imageContext = nil;
|
||||
NSImage* theImage = nil;
|
||||
|
||||
// Get the image dimensions.
|
||||
imageRect.size.height = CGImageGetHeight(theIcon);
|
||||
imageRect.size.width = CGImageGetWidth(theIcon);
|
||||
|
||||
// Create a new image to receive the Quartz image data.
|
||||
theImage = [[NSImage alloc] initWithSize:imageRect.size];
|
||||
[theImage lockFocus];
|
||||
|
||||
// Get the Quartz context and draw.
|
||||
imageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
||||
CGContextDrawImage(imageContext, *(CGRect*)&imageRect, theIcon);
|
||||
[theImage unlockFocus];
|
||||
|
||||
[gStatusItem setImage:theImage];
|
||||
|
||||
[theImage release];
|
||||
[theData release];
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue