2011-06-24 15 views
9

Çapraz platform SWT Java uygulamasında, dock ve durum çubuğu simgesini ayarlamak için TrayItem'in setImages() işlevini kullanıyorum. Simge 128x128 şeffaf bir PNG'dir. durumu ve tepsi simgeleri uygun şekilde hem Windows hem Linux dağıtımlarında kırpılmış, ancak Mac ben durum çubuğu simgesi şu şekilde her iki tarafta garip dolgu ile görünmesi problem:SWT TrayItem.setImage, Mac durum çubuğunda düzgün ölçeklenmiyor

Bu garip geliyor Bu benim diğer tüm platformlarda ama Mac üzerinde çalışıyor. Örneğin, burada aynı durum çubuğu simgesi Linux makinemde sorunsuz geçerli:

herkes nasıl Mac'te bu ekstra dolgu engellemek için bir fikri var mı?

+0

Herhangi bir kod olmadan, hata ayıklaması zor olacaktır. Bazı Googling’lere dayanarak, bunu sorunsuz bir şekilde yapabilmeniz gerektiği anlamına geliyor. – jtbandes

+0

Muhtemel bir hata için eclipse.platform.swt sorusunu sormayı ve https://bugs.eclipse.org/bugs/ adresinde arama yapmayı denediniz mi? –

+0

SWT Snippet 143 - http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet143.java?view=co - görünüm senin için? –

cevap

5

Sorunu SWT Cocoa kaynaklarında buldum.

public void setImage (Image image) { 
    checkWidget(); 
    if (image != null && image.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); 
    super.setImage (image); 
    double /*float*/ width = 0; 
    if (image == null) { 
     view.setImage (null); 
    } else { 
     /* 
     * Feature in Cocoa. If the NSImage object being set into the view is 
     * the same NSImage object that is already there then the new image is 
     * not taken. This results in the view's image not changing even if the 
     * NSImage object's content has changed since it was last set into the 
     * view. The workaround is to temporarily set the view's image to null 
     * so that the new image will then be taken. 
     */ 
     NSImage current = view.image(); 
     if (current != null && current.id == image.handle.id) { 
      view.setImage (null); 
     } 
     view.setImage (image.handle); 
     if (visible) { 
      width = image.handle.size().width + BORDER; 
     } 
    } 
    item.setLength (width); 
} 

sorun sadece (senin durumunda 128 px var içinde) görüntünün saf boyutunu alır hat width = image.handle.size().width + BORDER; üzerindedir. Uygun bir çözüm bulamadım (SWT bugzilla ile ilgili hata raporu aldığını gördüm).

Bu hatayı önlemenin bir yolu (şimdilik), tepsi resminizin daha küçük olmasını sağlamaktır.

+0

Haklısınız. SWT ekibine birkaç gün önce bir hata raporu gönderdim ve bunu yansıtan bu yazıyı güncellemeyi unuttum. Bu sorunun var olmasından talihsiz çünkü kodun büyük bir kısmının yoğun bir yeniden yazılmasını gerektiriyordu. Hata raporumu gör (burada) (https://bugs.eclipse.org/bugs/show_bug.cgi?id=350751) – blimmer

+2

Sadece bir takip - [hata raporu] 'nda bir yama gönderdiler (https://bugs.eclipse.org/bugs/show_bug.cgi?id=350751) Aynı sorunu yaşıyorsanız. – blimmer

İlgili konular