* Make menu icons "transparent" during initialization.
* Replace winnt menu icons with smaller ones.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.6 KiB |
@ -43,6 +43,7 @@ function gdi32_defines(lib) {
|
||||
this.NOMIRRORBITMAP = win32.DWORD(0x80000000); /* Do not Mirror the bitmap in this call */
|
||||
this.CAPTUREBLT = win32.DWORD(0x40000000); /* Include layered windows */
|
||||
lib.lazy_bind("CreateCompatibleBitmap", win32.HBITMAP, win32.HDC, ctypes.int, ctypes.int);
|
||||
lib.lazy_bind("CreateBitmap", win32.HBITMAP, ctypes.int, ctypes.int, win32.UINT, win32.UINT, ctypes.voidptr_t);
|
||||
lib.lazy_bind("CreateBitmapIndirect", win32.HBITMAP, win32.BITMAP.ptr);
|
||||
lib.lazy_bind("GetObjectW", ctypes.int, win32.HGDIOBJ, ctypes.int, win32.LPVOID);
|
||||
lib.lazy_bind("GetCurrentObject", win32.HGDIOBJ, win32.HDC, win32.UINT);
|
||||
@ -177,6 +178,9 @@ function gdi32_defines(lib) {
|
||||
this.PBITMAPINFO = this.BITMAPINFO.ptr;
|
||||
lib.lazy_bind("SetDIBits", ctypes.int, win32.HDC, win32.HBITMAP, win32.UINT, win32.UINT, ctypes.voidptr_t, this.BITMAPINFO.ptr, win32.UINT);
|
||||
|
||||
lib.lazy_bind("GetPixel", win32.COLORREF, win32.HDC, ctypes.int, ctypes.int);
|
||||
lib.lazy_bind("SetPixel", win32.COLORREF, win32.HDC, ctypes.int, ctypes.int, win32.COLORREF);
|
||||
|
||||
}
|
||||
|
||||
new ctypes_library(GDI32_LIBNAME, GDI32_ABIS, gdi32_defines, this);
|
||||
|
@ -412,6 +412,9 @@ function user32_defines(lib) {
|
||||
this.SWP_DEFERERASE = 0x2000;
|
||||
this.SWP_ASYNCWINDOWPOS = 0x4000;
|
||||
|
||||
lib.lazy_bind("GetSysColor", win32.DWORD, ctypes.int);
|
||||
this.COLOR_MENU = 4;
|
||||
|
||||
}
|
||||
|
||||
new ctypes_library(USER32_LIBNAME, USER32_ABIS, user32_defines, this);
|
||||
|
@ -29,14 +29,13 @@ if ("undefined" == typeof(firetray.Handler))
|
||||
|
||||
const ICON_CHROME_PATH = "chrome://firetray/skin/icons/winnt";
|
||||
const ICON_CHROME_FILES = {
|
||||
'blank-icon': ICON_CHROME_PATH+"/blank-icon.bmp",
|
||||
'mail-unread': ICON_CHROME_PATH+"/mail-unread.ico",
|
||||
// these are for the popup menu:
|
||||
'prefs': ICON_CHROME_PATH+"/gtk-preferences.bmp",
|
||||
'quit': ICON_CHROME_PATH+"/application-exit.bmp",
|
||||
'new-wnd': ICON_CHROME_PATH+"/document-new.bmp",
|
||||
'new-msg': ICON_CHROME_PATH+"/gtk-edit.bmp",
|
||||
'reset': ICON_CHROME_PATH+"/gtk-apply.bmp"
|
||||
'blank-icon': { use:'tray', path:ICON_CHROME_PATH+"/blank-icon.bmp" },
|
||||
'mail-unread': { use:'tray', path:ICON_CHROME_PATH+"/mail-unread.ico" },
|
||||
'prefs': { use:'menu', path:ICON_CHROME_PATH+"/gtk-preferences.bmp" },
|
||||
'quit': { use:'menu', path:ICON_CHROME_PATH+"/application-exit.bmp" },
|
||||
'new-wnd': { use:'menu', path:ICON_CHROME_PATH+"/document-new.bmp" },
|
||||
'new-msg': { use:'menu', path:ICON_CHROME_PATH+"/gtk-edit.bmp" },
|
||||
'reset': { use:'menu', path:ICON_CHROME_PATH+"/gtk-apply.bmp" },
|
||||
};
|
||||
|
||||
|
||||
@ -97,8 +96,13 @@ firetray.StatusIcon = {
|
||||
/* we'll take the first icon in the .ico file. To get the icon count in the
|
||||
file, pass ctypes.cast(ctypes.int(-1), win32.UINT); */
|
||||
for (let imgName in ICON_CHROME_FILES) {
|
||||
let path = firetray.Utils.chromeToPath(ICON_CHROME_FILES[imgName]);
|
||||
let path = firetray.Utils.chromeToPath(ICON_CHROME_FILES[imgName].path);
|
||||
let img = this.loadImageFromFile(path);
|
||||
if (img && ICON_CHROME_FILES[imgName].use == 'menu')
|
||||
/* Ideally we should rebuild the menu each time it is shown as the menu
|
||||
color may change. But, let's just consider it's not worth it for
|
||||
now. */
|
||||
img.himg = this.makeBitMapTransparent(img.himg);
|
||||
if (img)
|
||||
this[this.IMG_TYPES[img['type']]['map']].insert(imgName, img['himg']);
|
||||
}
|
||||
@ -418,6 +422,36 @@ firetray.StatusIcon = {
|
||||
log.error("icon '"+name+"' not defined.");
|
||||
}
|
||||
return hicon;
|
||||
},
|
||||
|
||||
// http://www.dreamincode.net/forums/topic/281612-how-to-make-bitmaps-on-menus-transparent-in-c-win32/
|
||||
makeBitMapTransparent: function(hbmSrc) {
|
||||
log.debug("hbmSrc="+hbmSrc);
|
||||
let hdcSrc = gdi32.CreateCompatibleDC(null);
|
||||
let hdcDst = gdi32.CreateCompatibleDC(null);
|
||||
if (!hdcSrc || !hdcSrc) return null;
|
||||
|
||||
let bm = new win32.BITMAP();
|
||||
let err = gdi32.GetObjectW(hbmSrc, win32.BITMAP.size, bm.address());
|
||||
let hbmOld = ctypes.cast(gdi32.SelectObject(hdcSrc, hbmSrc), win32.HBITMAP);
|
||||
let width = bm.bmWidth, height = bm.bmHeight;
|
||||
let hbmNew = gdi32.CreateBitmap(width, height, bm.bmPlanes, bm.bmBitsPixel, null);
|
||||
gdi32.SelectObject(hdcDst, hbmNew);
|
||||
|
||||
gdi32.BitBlt(hdcDst,0,0,width, height,hdcSrc,0,0,gdi32.SRCCOPY);
|
||||
|
||||
let clrTP = gdi32.GetPixel(hdcDst, 0, 0); // color of first pixel
|
||||
let clrBK = user32.GetSysColor(user32.COLOR_MENU); // current background color
|
||||
|
||||
for (let nRow=0, len=height; nRow<len; ++nRow)
|
||||
for (let nCol=0, len=width; nCol<len; ++nCol)
|
||||
if (firetray.js.strEquals(gdi32.GetPixel(hdcDst, nCol, nRow), clrTP))
|
||||
gdi32.SetPixel(hdcDst, nCol, nRow, clrBK);
|
||||
|
||||
gdi32.DeleteDC(hdcDst);
|
||||
gdi32.DeleteDC(hdcSrc);
|
||||
|
||||
return hbmNew;
|
||||
}
|
||||
|
||||
}; // firetray.StatusIcon
|
||||
|