Browse Source

Move bitmap menu to core

master
boisso 7 years ago
parent
commit
13cc98469a
  1. 22
      k-meleon/BrowserFrm.cpp
  2. 2
      k-meleon/BrowserFrm.h
  3. 139
      k-meleon/KmImage.cpp
  4. 21
      k-meleon/KmImage.h
  5. 434
      k-meleon/KmMenu.cpp
  6. 47
      k-meleon/KmMenu.h
  7. 15
      k-meleon/KmSkin.cpp
  8. 83
      k-meleon/MozUtils.cpp
  9. 34
      k-meleon/MozUtils.h
  10. 50
      k-meleon/Plugins.cpp
  11. 2
      k-meleon/ReBarEx.cpp
  12. 2
      k-meleon/VisualStylesXP.h
  13. 637
      k-meleon/bmp_menu/bmp_menu.cpp
  14. 15
      k-meleon/ie_favorites/ie_plugin.cpp
  15. 23
      k-meleon/ie_favorites/ie_utils.cpp
  16. 19
      k-meleon/kmeleon_plugin.h
  17. 19
      k-meleon/ns_bookmarks/ns_bookmarks.cpp
  18. 25
      k-meleon/ns_bookmarks/ns_bookmarks_utils.cpp
  19. 18
      k-meleon/op_hotlist/op_plugin.cpp
  20. 21
      k-meleon/op_hotlist/op_utils.cpp

22
k-meleon/BrowserFrm.cpp

@ -152,6 +152,8 @@ BEGIN_MESSAGE_MAP(CBrowserFrame, CFrameWnd)
// ON_WM_MOVING()
ON_WM_DESTROY()
ON_WM_GETMINMAXINFO()
ON_WM_MEASUREITEM()
ON_WM_DRAWITEM()
END_MESSAGE_MAP()
#define PREF_TOOLBAND_LOCKED "kmeleon.general.toolbars_locked"
@ -1351,6 +1353,8 @@ void CBrowserFrame::SetFavIcon(int iIcon)
cb.iSelectedImage = cb.iImage = iIcon;
cb.iItem = -1;
m_wndUrlBar.SetItem(&cb);
m_wndUrlBar.Invalidate();
m_wndUrlBar.RedrawWindow();
if (theApp.preferences.GetBool("kmeleon.favicons.titleBar", FALSE))
{
@ -1899,3 +1903,21 @@ void CBrowserFrame::AllowJS(BOOL allow)
{
GetActiveView()->GetBrowserWrapper()->AllowJS(allow);
}
void CBrowserFrame::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// TODO: Add your message handler code here and/or call default
if (lpMeasureItemStruct->CtlType == ODT_MENU) {
theApp.menus.MeasureItem(lpMeasureItemStruct);
return;
}
CFrameWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
void CBrowserFrame::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (lpDrawItemStruct->CtlType == ODT_MENU)
return theApp.menus.DrawItem(lpDrawItemStruct);
CFrameWnd::OnDrawItem(nIDCtl, lpDrawItemStruct);
}

2
k-meleon/BrowserFrm.h

@ -372,6 +372,8 @@ protected:
//}}AFX_VIRTUAL
public:
afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
};
/////////////////////////////////////////////////////////////////////////////

139
k-meleon/KmImage.cpp

@ -57,7 +57,9 @@ NS_IMETHODIMP nsImageObserver::Notify(imgIRequest *aProxy, int32_t aType, const
}
else if (aType == imgINotificationObserver::DECODE_COMPLETE)
{
mObserver->ImageLoaded(CreateDIB(aProxy));
KmImage img;
img.LoadFromBitmap(CreateDIB(aProxy));
mObserver->ImageLoaded(img);
aProxy->CancelAndForgetObserver(NS_OK);
//mRequest = nullptr;
delete mObserver;
@ -74,6 +76,17 @@ NS_IMETHODIMP nsImageObserver::Notify(imgIRequest *aProxy, int32_t aType, const
return NS_OK;
}
void nsImageObserver::OnDownload(nsIURI* aUri, nsresult ns, LPSTREAM stream, LPCTSTR aName)
{
if (NS_SUCCEEDED(ns) && stream) {
KmImage img;
img.Load(stream);
mObserver->ImageLoaded(img);
}
delete mObserver;
NS_RELEASE_THIS();
}
static void
ConvertBGRXToBGRA(uint8_t* aData, const IntSize &aSize, int32_t aStride)
{
@ -224,7 +237,9 @@ HBITMAP nsImageObserver::CreateDIB(imgIRequest *aRequest)
#ifdef _DEBUG
// There is a problem with the linking in debug
// Use a dummy image instead
return (HBITMAP)::LoadImage(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT);
CString closeBmp;
theApp.skin.FindSkinFile(closeBmp, _T("dummy.bmp"));
return (HBITMAP)::LoadImage(::AfxGetInstanceHandle(), closeBmp, IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT|LR_LOADFROMFILE);
//return NULL;
#endif
@ -357,6 +372,55 @@ bool KmImage::LoadFromSkin(LPCTSTR name, const LPRECT prect, bool single)
return true;
}
bool KmImage::LoadFromIcon(HICON hicon)
{
Clean();
BITMAP bmp;
ICONINFO ii;
GetIconInfo(hicon, &ii);
GetObject(ii.hbmColor, sizeof(bmp), &bmp);
bool hasAlpha = false;
Gdiplus::Bitmap temp(ii.hbmColor, NULL);
Gdiplus::BitmapData lockedBitmapData;
Gdiplus::Rect rc(0, 0, temp.GetWidth(), temp.GetHeight());
temp.LockBits(&rc, Gdiplus::ImageLockModeRead, temp.GetPixelFormat(), &lockedBitmapData);
mGdiBitmap = new Gdiplus::Bitmap(bmp.bmWidth, bmp.bmHeight, lockedBitmapData.Stride, PixelFormat32bppARGB, (BYTE*)lockedBitmapData.Scan0);
temp.UnlockBits(&lockedBitmapData);
DeleteObject(ii.hbmColor);
DeleteObject(ii.hbmMask);
return mGdiBitmap != nullptr;
/*
for (int y = 0; y < temp.GetHeight(); y++)
{
byte *pixelBytes = (byte*)lockedBitmapData.Scan0 + y*lockedBitmapData.Stride;
for (int x = 0; x SetPixel(x, y, Gdiplus::Color(*pixel));
hasAlpha = hasAlpha || (pixelBytes[3] > 0 && pixelBytes[3] < 255);
}
}
temp.UnlockBits(&bmpData);
if (!hasAlpha)
{
// If there's no alpha transparency information, we need to use the mask
// to turn back on visible pixels
Gdiplus::Bitmap maskBitmap(iconInfo.hbmMask,NULL);
Gdiplus::Color cMask, cBitmap;
for (int y = 0; y < maskBitmap.GetHeight(); y++)
{
for (int x = 0; x GetPixel(x, y, &cBitmap);
cBitmap.SetValue(cBitmap.GetValue() | 0xFF000000); // turn alpha to opaque (i.e. 0xFF)
mGdiBitmap->SetPixel(x, y, cBitmap);
}
}
}
}
return mGdiBitmap;*/
}
bool KmImage::LoadFromBitmap(HBITMAP hbmp, bool reverse)
{
ASSERT(hbmp);
@ -388,7 +452,7 @@ bool KmImage::LoadFromBitmap(HBITMAP hbmp, bool reverse)
mGdiBitmap = Gdiplus::Bitmap::FromHBITMAP(hbmp, NULL);
MakeTransparent(mTrColor);
}
return mGdiBitmap != nullptr;
}
@ -423,6 +487,71 @@ bool KmImage::MakeTransparent(COLORREF clr)
return true;
}
typedef struct
{
BYTE bWidth; // Width, in pixels, of the image
BYTE bHeight; // Height, in pixels, of the image
BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
BYTE bReserved; // Reserved ( must be 0)
WORD wPlanes; // Color Planes
WORD wBitCount; // Bits per pixel
DWORD dwBytesInRes; // How many bytes in this resource?
DWORD dwImageOffset; // Where in the file is this image?
} ICONDIRENTRY, *LPICONDIRENTRY;
typedef struct
{
WORD idReserved; // Reserved (must be 0)
WORD idType; // Resource Type (1 for icons)
WORD idCount; // How many images?
//ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)
} ICONDIR, *LPICONDIR;
bool KmImage::Load(LPSTREAM stream)
{
ULONG read;
ICONDIR header;
LARGE_INTEGER zero = {0,0};
ULARGE_INTEGER lread, lwrit;
stream->Seek(zero, STREAM_SEEK_SET, &lread);
stream->Read(&header , sizeof(ICONDIR), &read);
if (header.idReserved == 0 && header.idType == 1) {
// Support for .ico, get the best quality icon
ICONDIRENTRY* pIconDir = (ICONDIRENTRY*)malloc(sizeof(ICONDIRENTRY)*header.idCount);
stream->Read(pIconDir, sizeof(ICONDIRENTRY)*header.idCount, &read);
if (read == sizeof(ICONDIRENTRY)*header.idCount) {
int idx = 0, bw = 0, depth = 0;
for (int i=0;i<header.idCount;i++) {
if (pIconDir[i].bWidth>bw ||
(pIconDir[i].bWidth == bw && pIconDir[i].wBitCount > depth))
{
bw = pIconDir[i].bWidth;
depth = pIconDir[i].wBitCount;
idx = i;
}
}
LPSTREAM ss;
CreateStreamOnHGlobal(NULL, TRUE, &ss);
zero.LowPart = pIconDir[idx].dwImageOffset;
stream->Seek(zero, STREAM_SEEK_SET, &lread);
ULARGE_INTEGER gnagna = {0,0};
gnagna.LowPart = pIconDir[idx].dwBytesInRes;
stream->CopyTo(ss, gnagna, &lread, &lwrit);
mGdiBitmap = Gdiplus::Bitmap::FromStream(stream);
stream->Release();
return mGdiBitmap != nullptr;
}
free(pIconDir);
}
mGdiBitmap = Gdiplus::Bitmap::FromStream(stream);
return mGdiBitmap != nullptr;
}
bool KmImage::Load(LPCTSTR path)
{
Clean();
@ -655,7 +784,7 @@ HBITMAP KmImage::GetHBitmap()
bmi.bmiHeader.biBitCount = USHORT( 32 );
bmi.bmiHeader.biCompression = BI_RGB;
hbmp = ::CreateDIBSection( NULL, &bmi, DIB_RGB_COLORS, &bits, NULL, 0 );
Gdiplus::Bitmap bmDest( GetWidth(), GetHeight(), GetWidth()*4, IsComCtl6()?PixelFormat32bppARGB:PixelFormat32bppRGB, static_cast< BYTE* >( bits ) );
Gdiplus::Bitmap bmDest( GetWidth(), GetHeight(), GetWidth()*4, IsComCtl6()?PixelFormat32bppPARGB:PixelFormat32bppRGB, static_cast< BYTE* >( bits ) );
Gdiplus::Graphics gDest( &bmDest );
if (gDest.DrawImage( mGdiBitmap, 0, 0 ) != Gdiplus::Ok) {
DeleteObject(hbmp);
@ -666,7 +795,7 @@ HBITMAP KmImage::GetHBitmap()
if (mGdiBitmap->GetHBITMAP(0, &hbmp) != Gdiplus::Ok)
return NULL;
}
mBitmap.Attach(hbmp);
return hbmp;
}

21
k-meleon/KmImage.h

@ -21,12 +21,17 @@
#include "imgIRequest.h"
#include "imgINotificationObserver.h"
#include "imgILoader.h"
#include "MozUtils.h"
class KmImage;
interface IImageObserver {
virtual void ImageLoaded(HBITMAP) = 0;
virtual void ImageLoaded(KmImage& img) = 0;
};
class nsImageObserver : public imgINotificationObserver, public nsSupportsWeakReference
class nsImageObserver :
public imgINotificationObserver,
public nsSupportsWeakReference,
public IDownloadObserver
{
NS_DECL_ISUPPORTS
NS_DECL_IMGINOTIFICATIONOBSERVER
@ -35,6 +40,13 @@ class nsImageObserver : public imgINotificationObserver, public nsSupportsWeakRe
virtual ~nsImageObserver() { }
static bool LoadImage(IImageObserver* observer, nsIURI* imgUri)
{
nsImageObserver* obs = new nsImageObserver(observer);
NS_ADDREF(obs);
return DownloadToStream(imgUri, obs);
}
static bool LoadImageGecko(IImageObserver* observer, nsIURI* imgUri)
{
nsresult rv;
nsCOMPtr<imgILoader> loader = do_GetService("@mozilla.org/image/loader;1", &rv);
@ -46,6 +58,8 @@ class nsImageObserver : public imgINotificationObserver, public nsSupportsWeakRe
nullptr, nullptr, getter_AddRefs(obs->mRequest)));
}
void OnDownload(nsIURI*, nsresult, LPSTREAM stream, LPCTSTR);
protected:
IImageObserver* mObserver;
nsCOMPtr<imgIRequest> mRequest;
@ -86,6 +100,7 @@ public:
};
bool Load(LPCTSTR path);
bool Load(LPSTREAM stream);
bool Crop(UINT w, UINT h, UINT index);
bool Clip(const RECT& r);
bool CropLine(UINT h, UINT line, KmImage& img) const;
@ -101,6 +116,8 @@ public:
bool LoadIndexedFromSkin(LPCTSTR name, UINT w, UINT h);
bool LoadFromSkin(LPCTSTR name, LPRECT rect = nullptr, bool single = false);
bool LoadFromBitmap(HBITMAP hbmp, bool reverse = false);
bool LoadFromIcon(HICON hicon);
int AddToImageList(CImageList& list, int index = -1);
~KmImage() {
Clean();

434
k-meleon/KmMenu.cpp

@ -22,6 +22,7 @@
#include "mfcembed.h"
#include "browserfrm.h"
#include "browserfrmtab.h"
#include "VisualStylesXP.h"
extern CMfcEmbedApp theApp;
extern BOOL ParsePluginCommand(char *pszCommand, char** plugin, char **parameter);
@ -188,6 +189,90 @@ BOOL KmMenu::Build()
return TRUE;
}
HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp)
{
*phBmp = NULL;
BITMAPINFO bmi;
SecureZeroMemory(&bmi, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biWidth = psize->cx;
bmi.bmiHeader.biHeight = psize->cy;
bmi.bmiHeader.biBitCount = 32;
HDC hdcUsed = hdc ? hdc : GetDC(NULL);
if (hdcUsed)
{
*phBmp = CreateDIBSection(hdcUsed, &bmi, DIB_RGB_COLORS, ppvBits, NULL, 0);
if (hdc != hdcUsed)
{
ReleaseDC(NULL, hdcUsed);
}
}
return (NULL == *phBmp) ? E_OUTOFMEMORY : S_OK;
}
HBITMAP IconToBitmap(HIMAGELIST il, int idx) {
IWICImagingFactory *pFactory;
HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pFactory));
HICON hicon = ImageList_ExtractIcon(0,il,idx);
HBITMAP hbmp = NULL;
if (SUCCEEDED(hr))
{
IWICBitmap *pBitmap;
hr = pFactory->CreateBitmapFromHICON(hicon, &pBitmap);
if (SUCCEEDED(hr))
{
UINT cx, cy;
hr = pBitmap->GetSize(&cx, &cy);
if (SUCCEEDED(hr))
{
const SIZE sizIcon = { (int)cx, -(int)cy };
BYTE *pbBuffer;
hr = Create32BitHBITMAP(NULL, &sizIcon, reinterpret_cast<void **>(&pbBuffer), &hbmp);
if (SUCCEEDED(hr))
{
const UINT cbStride = cx * sizeof(DWORD);
const UINT cbBuffer = cy * cbStride;
hr = pBitmap->CopyPixels(NULL, cbStride, cbBuffer, pbBuffer);
}
}
pBitmap->Release();
}
pFactory->Release();
}
return hbmp;
}
BOOL KmMenu::Build(CMenu &menu, int before)
{
BOOL wasSeparator = TRUE;
@ -205,8 +290,27 @@ BOOL KmMenu::Build(CMenu &menu, int before)
case MenuPopup: // Popup Menu
label = A2CT(item.label);
popup = theApp.menus.GetMenu(label);
if (popup) {
menu.InsertMenu(before, MF_POPUP | MF_STRING, (UINT)popup->m_hMenu, theApp.lang.Translate(label));
menu.InsertMenu(before, MF_POPUP, (UINT)popup->m_hMenu, theApp.lang.Translate(label));
if (this != theApp.menus.GetKMenu(_T("Main"))) {
if (theApp.menus.IsOwnerDraw()) {
int pos;
for (pos=0;pos<menu.GetMenuItemCount();pos++)
if (menu.GetSubMenu(pos) == popup)
break;
ASSERT(pos<menu.GetMenuItemCount());
MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_DATA | MIIM_FTYPE;
mi.fType = MF_OWNERDRAW;
mi.dwItemData = (ULONG_PTR)&item;//(ULONG_PTR)_wcsdup((LPCTSTR)pTranslated);
menu.SetMenuItemInfo(pos, &mi, TRUE);
}
}
//LOG_1("Added popup %s", label);
}
else
@ -264,18 +368,25 @@ BOOL KmMenu::Build(CMenu &menu, int before)
if (inlineMenu && !inlineMenu->IsEmpty()) {
if (!wasSeparator)
menu.InsertMenu(before, MF_SEPARATOR);
inlineMenu->Build(menu, before);
wasSeparator = FALSE;
inlineMenu->Build(menu, before);
wasSeparator = FALSE;
}
break;
}
case MenuSeparator: // Separator
case MenuSeparator: {// Separator
if (wasSeparator || (i == mMenuDef.GetCount()-1)) break;
menu.InsertMenu(before, MF_SEPARATOR);
/*MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_DATA | MIIM_TYPE;
mi.dwItemData = (ULONG_PTR)&item;
mi.fType = MF_SEPARATOR | MF_OWNERDRAW;
menu.InsertMenuItem(before, &mi, TRUE); */
wasSeparator = TRUE;
//LOG_1("Added Separator", 0);
break;
}
case MenuPlugin: {
char *plugin, *parameter;
@ -303,7 +414,57 @@ BOOL KmMenu::Build(CMenu &menu, int before)
pTranslated += _T("\t") + accel;
}
// Not setting the item to ownerdraw directly allow
// the menu accelerator to work
menu.InsertMenu(before, MF_STRING, item.command, pTranslated);
//menu.ModifyMenu(item.command, MF_STRING | MF_OWNERDRAW, item.command, _wcsdup(pTranslated));
if (!theApp.menus.IsOwnerDraw())
{
int idx = theApp.skin.GetIconIndex(item.command);
if (idx >= 0) {
MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
HIMAGELIST il = theApp.skin.GetIconList();
mi.fMask = MIIM_CHECKMARKS;
HICON icon = ImageList_ExtractIcon(0, il, idx);
ICONINFO ii;
GetIconInfo(icon, &ii);
DeleteObject(ii.hbmMask);
DeleteObject(icon);
mi.hbmpChecked = mi.hbmpUnchecked = ii.hbmColor;//IconToBitmap(il, idx);
menu.SetMenuItemInfo(item.command, &mi);
}
} else {
MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_FTYPE;
mi.fType = MF_STRING | MF_OWNERDRAW;
mi.dwItemData = 0;//(ULONG_PTR)&item;//(ULONG_PTR)_wcsdup((LPCTSTR)pTranslated);
menu.SetMenuItemInfo(item.command, &mi);
}
/*
int idx = theApp.skin.GetIconIndex(item.command);
HIMAGELIST il = theApp.skin.GetIconList();
MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_CHECKMARKS;
//mi.dwItemData = (ULONG_PTR)&item;
//mi.hbmpChecked = mi.hbmpUnchecked = IconToBitmap(il, idx);
//mi.hbmpItem = IconToBitmap(il, idx);
KmImage img;
img.LoadFromIcon(ImageList_ExtractIcon(0,il,idx));
//img.LoadIndexedFromSkin(L"menu3.png[0]",16,16);
mi.hbmpChecked = mi.hbmpUnchecked = img.GetHBitmap();
//mi.fType = MF_STRING | MF_OWNERDRAW;
//mi.wID = item.command;
UINT toto = menu.SetMenuItemInfo(item.command, &mi);
UINT tata = GetLastError();*/
//LOG_2("Added menu item %s with command %d", _label, item.command);
wasSeparator = FALSE;
break;
@ -322,10 +483,17 @@ BOOL KmMenu::Build(CMenu &menu, int before)
void KmMenu::Reset()
{
if (!mMenu.m_hMenu) return;
// XXX Crappy hack until we get rid of this crappy plugin
theApp.plugins.SendMessage("bmpmenu", "* MenuParser", "UnSetOwnerDrawn", (long)mMenu.m_hMenu, 0);
while (mMenu.GetMenuItemCount())
while (mMenu.GetMenuItemCount()) {
MENUITEMINFO mii = {0};
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_FTYPE | MIIM_DATA | MIIM_CHECKMARKS;
mMenu.GetMenuItemInfo(0, &mii, TRUE);
if (mii.hbmpChecked) DeleteObject(mii.hbmpChecked);
/*if (mii.dwItemData && (mii.fMask & MF_OWNERDRAW) {
if (mii.dwItemData) LocalFree(mii.dwItemData);
}*/
mMenu.RemoveMenu(0, MF_BYPOSITION);
}
}
void KmMenu::Invalidate()
@ -340,6 +508,258 @@ void KmMenu::Invalidate()
}
}
void DrawBitmap(HDC dc, HBITMAP bmp, RECT rc)
{
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 255;
bf.AlphaFormat = AC_SRC_ALPHA;
HDC src_dc = ::CreateCompatibleDC(dc);
HGDIOBJ old = ::SelectObject(src_dc, bmp);
::AlphaBlend(dc, rc.left, rc.top, theApp.skin.GetDefWidth(), theApp.skin.GetDefHeight(), src_dc, 0, 0, theApp.skin.GetDefWidth(), theApp.skin.GetDefHeight(), bf);
::SelectObject(src_dc, old);
::DeleteDC(src_dc);
}
void KmMenuService::DrawBitmap(LPDRAWITEMSTRUCT dis)
{
MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_CHECKMARKS;
GetMenuItemInfo((HMENU)dis->hwndItem, dis->itemID, FALSE, &mi);
if (mi.hbmpChecked) {
RECT rc = dis->rcItem;
rc.top = dis->rcItem.top + ((dis->rcItem.bottom - dis->rcItem.top - theApp.skin.GetDefHeight()) / 2);
::DrawBitmap(dis->hDC,
dis->itemState & ODS_CHECKED ? mi.hbmpChecked : mi.hbmpUnchecked,
rc);
return;
}
int idx = theApp.skin.GetIconIndex(dis->itemID);
if (dis->itemState & ODS_CHECKED) {
int cxCheck = GetSystemMetrics(SM_CXMENUCHECK);
int cyCheck = GetSystemMetrics(SM_CYMENUCHECK);
HDC hdcMem = CreateCompatibleDC(dis->hDC);
if (hdcMem) {
HBITMAP hbmMono = CreateBitmap(cxCheck, cyCheck, 1, 1, NULL);
if (hbmMono) {
HBITMAP hbmPrev = (HBITMAP)SelectObject(hdcMem, (HGDIOBJ)hbmMono);
if (hbmPrev) {
RECT rc = { 0, 0, cxCheck, cyCheck };
DrawFrameControl(hdcMem, &rc, DFC_MENU, DFCS_MENUCHECK);
BitBlt(dis->hDC, dis->rcItem.left,
dis->rcItem.top + (dis->rcItem.bottom - dis->rcItem.top - cyCheck)/2, // Seems like it need some margin
cxCheck, cyCheck, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, (HGDIOBJ)hbmPrev);
}
DeleteObject(hbmMono);
}
DeleteDC(hdcMem);
}
} else if (idx >= 0) {
int top = (dis->rcItem.bottom - dis->rcItem.top - theApp.skin.GetDefHeight()) / 2;
top += dis->rcItem.top;
if (dis->itemState & ODS_GRAYED)
ImageList_DrawEx(theApp.skin.GetIconList(), idx, dis->hDC, dis->rcItem.left, top, 0, 0, CLR_NONE, GetSysColor(COLOR_MENU), ILD_BLEND | ILD_TRANSPARENT);
else if (dis->itemState & ODS_SELECTED)
ImageList_Draw(theApp.skin.GetIconList(), idx, dis->hDC, dis->rcItem.left, top, ILD_TRANSPARENT);
else
ImageList_Draw(theApp.skin.GetIconList(), idx, dis->hDC, dis->rcItem.left, top, ILD_TRANSPARENT);
}
}
int KmMenu::GetMaxAccelWidth(HDC hDC)
{
USES_CONVERSION;
int maxAccelWidth = 0;
POSITION pos = mMenuDef.GetHeadPosition();
for (int i=0;i < mMenuDef.GetCount();i++)
{
KmMenuItem& item = mMenuDef.GetNext(pos);
int accelWidth = 0;
if (item.type == MenuString) {
SIZE size;
CString accel = theApp.accel.GetStrAccel(item.command);
GetTextExtentPoint32(hDC, accel, accel.GetLength(), &size);
accelWidth = size.cx;
} else if (item.type == MenuInline) {
KmMenu* inlineMenu = theApp.menus.GetKMenu(A2CT(item.label));
accelWidth = inlineMenu->GetMaxAccelWidth(hDC);
}
if (accelWidth > maxAccelWidth) maxAccelWidth = accelWidth;
}
return maxAccelWidth;
}
void KmMenuService::DrawItem(LPDRAWITEMSTRUCT dis)
{
MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_FTYPE | MIIM_STRING;
::GetMenuItemInfo((HMENU)dis->hwndItem, dis->itemID, FALSE, &mi);
if (mi.fType & MFT_SEPARATOR) {
RECT rc;
rc.bottom = dis->rcItem.bottom;
rc.left = dis->rcItem.left;
rc.right = dis->rcItem.right;
rc.top = dis->rcItem.top + ((rc.bottom-dis->rcItem.top)>>1); // vertical center
DrawEdge(dis->hDC, &rc, EDGE_ETCHED, BF_TOP); // draw separator line
return;
}
mi.cch++;
CAutoPtr<TCHAR> text(new TCHAR[mi.cch]);
mi.dwTypeData = text;
::GetMenuItemInfo((HMENU)dis->hwndItem, dis->itemID, FALSE, &mi);
TCHAR* pAccel = wcschr(text, _T('\t'));
if (pAccel) *pAccel = 0;
/*
KmMenuItem* item = (KmMenuItem*)dis->itemData;
if (!item || item->type == MenuSeparator) {
RECT rc;
rc.bottom = dis->rcItem.bottom;
rc.left = dis->rcItem.left;
rc.right = dis->rcItem.right;
rc.top = dis->rcItem.top + ((rc.bottom-dis->rcItem.top)>>1); // vertical center
DrawEdge(dis->hDC, &rc, EDGE_ETCHED, BF_TOP); // draw separator line
return;
}
USES_CONVERSION;
TCHAR* _label = A2T(item->label);
CString pTranslated;
Translate(_label, pTranslated);
//CString pTranslated = (wchar_t*)dis->itemData;*/
// Draw the highlight rectangle
SetBkMode(dis->hDC, TRANSPARENT);
if (dis->itemState & ODS_SELECTED) {
FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHT));
}
else {
FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_MENU));
SetTextColor(dis->hDC, GetSysColor(COLOR_MENUTEXT));
SetBkColor(dis->hDC, GetSysColor(COLOR_MENU));
}
if (dis->itemState & ODS_GRAYED)
if (dis->itemState & ODS_SELECTED)
SetTextColor(dis->hDC, GetSysColor(COLOR_MENU));
else
SetTextColor(dis->hDC, GetSysColor(COLOR_GRAYTEXT));
dis->rcItem.left += ::GetSystemMetrics(SM_CXEDGE);
DRAWBITMAPPROC drawProc;
if (!mProcList.Lookup((HMENU)dis->hwndItem, drawProc) || !drawProc(dis))
DrawBitmap(dis);
dis->rcItem.left += theApp.skin.GetDefWidth() + ::GetSystemMetrics(SM_CXEDGE);
DrawText(dis->hDC, text, _tcslen(text), &dis->rcItem, DT_SINGLELINE | DT_VCENTER | DT_NOCLIP);
if (theApp.preferences.GetBool("kmeleon.display.accelInMenus", TRUE)) {
CString accel = theApp.accel.GetStrAccel(dis->itemID);
if (accel.GetLength()) {
//dis->rcItem.left = dis->rcItem.right - maxAccelWidth - 16;
SIZE size;
GetTextExtentPoint32(dis->hDC, accel, accel.GetLength(), &size);
dis->rcItem.left = dis->rcItem.right - size.cx - theApp.skin.GetDefWidth() - 2;
DrawText(dis->hDC, accel, accel.GetLength(), &dis->rcItem, DT_SINGLELINE | DT_VCENTER | DT_NOCLIP);
}
}
}
/*
CMenu* pMenu = CMenu::FromHandlePermanent(
(HMENU)lpDrawItemStruct->hwndItem);
if (pMenu != NULL)
{
KmMenu* kmenu = theApp.menus.GetKMenu(pMenu);
kmenu->DrawItem(lpDrawItemStruct);
return;
}*/
void KmMenuService::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
SIZE size;
/*
KmMenuItem* item = (KmMenuItem*)lpMeasureItemStruct->itemData;
if (!item || item->type == MenuSeparator) {
lpMeasureItemStruct->itemWidth = 0;
lpMeasureItemStruct->itemHeight = GetSystemMetrics(SM_CYMENUSIZE) >> 1;
return;
}
USES_CONVERSION;
CString text = theApp.lang.Translate(A2T(item->label));*/
if (!mLastActivated)
return;
MENUITEMINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIIM_FTYPE | MIIM_STRING;
mLastActivated->GetMenuItemInfo(lpMeasureItemStruct->itemID, &mi);
if (mi.fType & MFT_SEPARATOR) {
lpMeasureItemStruct->itemWidth = 0;
lpMeasureItemStruct->itemHeight = GetSystemMetrics(SM_CYMENUSIZE) >> 1;
return;
}
CAutoPtr<TCHAR> text(new TCHAR[mi.cch+1]);
mi.dwTypeData = text;
mLastActivated->GetMenuItemInfo(lpMeasureItemStruct->itemID, &mi);
HDC hDC = CreateCompatibleDC(NULL);
//HDC hDC = ::GetWindowDC(theApp.m_pMostRecentBrowserFrame->m_hWnd);
HFONT oldFont = (HFONT)SelectObject(hDC, mMenuFont);
GetTextExtentPoint32(hDC, _T("X"), 1, &size);
int spaceBetween = size.cx;
TCHAR* pAccel = wcschr(text, _T('\t'));
if (pAccel) *pAccel = 0;
/*GetTextExtentPoint32(hDC, text, _tcslen(text), &size);
if (size.cx > mMaxTextLength) mMaxTextLength = size.cx;
*accel = _T('\\');
accel++;
}*/
GetTextExtentPoint32(hDC, text, _tcslen(text), &size);
if (size.cx > mMaxTextLength) mMaxTextLength = size.cx;
lpMeasureItemStruct->itemWidth = mMaxTextLength;
CString accel = theApp.accel.GetStrAccel(lpMeasureItemStruct->itemID);
if (accel.GetLength()) {
GetTextExtentPoint32(hDC, accel, accel.GetLength(), &size);
lpMeasureItemStruct->itemWidth += spaceBetween + size.cx;
}
lpMeasureItemStruct->itemWidth -= (GetSystemMetrics(SM_CXMENUCHECK)-1);
lpMeasureItemStruct->itemHeight = GetSystemMetrics(SM_CYMENUSIZE);
int height = theApp.skin.GetDefHeight();
int width = theApp.skin.GetDefWidth();
lpMeasureItemStruct->itemWidth += width + ::GetSystemMetrics(SM_CXEDGE) * 2;
if (lpMeasureItemStruct->itemHeight < height+2)
lpMeasureItemStruct->itemHeight = height+2;
SelectObject(hDC, oldFont);
DeleteDC(hDC);
}
/*
void KmMenuService::SetMenu(LPCTSTR menu, KmMenuItem item, long before)

47
k-meleon/KmMenu.h

@ -19,6 +19,9 @@
#ifndef __KMMENU_H__
#define __KMMENU_H__
#include "ODMenu.h"
typedef int (__cdecl* DRAWBITMAPPROC)(DRAWITEMSTRUCT *dis);
enum KmMenuType
{
MenuString = 0,
@ -31,9 +34,9 @@ enum KmMenuType
struct KmMenuItem
{
KmMenuType type;
char id[80];
char label[80];
KmMenuType type;
char id[80];
int command;
int groupid;
@ -50,7 +53,7 @@ struct KmMenuItem
class KmMenu {
public:
KmMenu(BOOL popup) : mPopup(popup), mInvalid(TRUE) {};
KmMenu(BOOL popup) : mPopup(popup), mInvalid(TRUE), mDrawProc(nullptr) {};
~KmMenu(void) {};
void RemoveItem(KmMenuItem& item);
@ -71,18 +74,24 @@ public:
if (mInvalid || !mMenu.m_hMenu) Build();
return &mMenu;
}
void DrawItem(LPDRAWITEMSTRUCT);
void MeasureItem(LPMEASUREITEMSTRUCT);
DRAWBITMAPPROC mDrawProc;
protected:
void DrawBitmap(LPDRAWITEMSTRUCT);
int GetMaxAccelWidth(HDC hDC);
void Reset();
BOOL Build(CMenu &menu, int before);
BOOL IsEmpty() { return (mMenuDef.GetCount() == 0); }
CMenu mMenu;
CODMenu mMenu;
CList<KmMenuItem, KmMenuItem&> mMenuDef;
CList<KmMenu*, KmMenu*> mDependencies;
BOOL mInvalid;
BOOL mPopup;
};
class KmMenuService
@ -90,7 +99,14 @@ class KmMenuService
public:
KmMenuService() : mLastActivated(NULL) {
DWORD dwVersion = ::GetVersion();
dwVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
mOwnerDraw = true;//dwVersion<=5;
NONCLIENTMETRICS ncm = {0};
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS,0,(PVOID)&ncm,FALSE);
mMenuFont.CreateFontIndirect(&ncm.lfMenuFont);
}
KmMenu* CreateMenu(LPCTSTR name) {
@ -202,7 +218,8 @@ public:
KmMenu* Activate(CMenu* menu) {
KmMenu* kmenu = GetKMenu(menu);
if (kmenu) kmenu->GetMenu();
mLastActivated = kmenu;
mLastActivated = menu;
mMaxTextLength = 0;
return kmenu;
}
@ -214,13 +231,25 @@ public:
return FALSE;
}
BOOL IsOwnerDraw() {
return mOwnerDraw;
}
~KmMenuService() {
Destroy();
}
void DrawItem(LPDRAWITEMSTRUCT);
void MeasureItem(LPMEASUREITEMSTRUCT);
CMap<HMENU, HMENU, DRAWBITMAPPROC, DRAWBITMAPPROC> mProcList;
protected:
void DrawBitmap(LPDRAWITEMSTRUCT);
CMap<CString, LPCTSTR, KmMenu*, KmMenu*> mMenus;
KmMenu* mLastActivated;
CMenu* mLastActivated;
BOOL mOwnerDraw;
CFont mMenuFont;
int mMaxTextLength;
};

15
k-meleon/KmSkin.cpp

@ -54,10 +54,10 @@ int KmIconList::AddIcon(KmImage& img, KmImage& hotImg, KmImage& deadImg, UINT id
int pos = img.AddToImageList(mCold, index);
if (pos == -1) return -1;
ASSERT(idx == -1 || pos == idx);
idx = hotImg.AddToImageList(mHot, index);
ASSERT(pos == idx);
pos = hotImg.AddToImageList(mHot, index);
ASSERT(pos == idx);
pos = deadImg.AddToImageList(mDead, index);
idx = deadImg.AddToImageList(mDead, index);
ASSERT(pos == idx);
if (id) mCmdList[id] = pos;
return pos;
@ -284,7 +284,7 @@ bool KmSkin::Init(LPCTSTR skinName)
if (!file.Open(filename, CFile::modeRead, NULL))
return false;
char* buf = new char[file.GetLength()+1];
CAutoPtr<char> buf(new char[file.GetLength()+1]);
UINT size = file.Read(buf, file.GetLength());
buf[size] = 0;
@ -377,19 +377,16 @@ public:
iconSkinObserver(UINT id): mID (id), mRegion(CRect(0,0,0,0)) {}
iconSkinObserver(UINT id, RECT r): mID (id), mRegion(r) {}
~iconSkinObserver() {}
void ImageLoaded(HBITMAP hBitmap)
void ImageLoaded(KmImage &img)
{
if (!hBitmap) return;
//if (!img) return;
UINT w = theApp.skin.GetUserWidth();
UINT h = theApp.skin.GetUserHeight();
KmImage img;
img.LoadFromBitmap(hBitmap);
if (mRegion.bottom != 0 || mRegion.right != 0)
img.Clip(mRegion);
img.Resize(w, h);
theApp.skin.mImages->AddIcon(img, mID);
DeleteObject(hBitmap);
theApp.toolbars.Refresh();
}

83
k-meleon/MozUtils.cpp

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "MozUtils.h"
#include "nsIWindowWatcher.h"
#include "nsIIOService.h"
@ -741,3 +742,85 @@ bool RunJS(const wchar_t* userScript, CString& result)
NS_ENSURE_TRUE(win, false);
return InjectJS(win, userScript, result);
}
#include "nsIIOService.h"
#include "nsIChannel.h"
#include "nsIInputStream.h"
#include "KmImage.h"
NS_IMPL_ISUPPORTS(streamListener, nsIStreamListener, nsIRequestObserver, nsISupportsWeakReference);
NS_IMETHODIMP streamListener::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext, nsIInputStream *aInputStream, uint64_t aOffset, uint32_t aCount)
{
if (!mStream) return NS_ERROR_FAILURE;
char buffer[8192];
uint32_t bytesRead;
uint32_t bytesRemaining = aCount;
while (bytesRemaining) {
nsresult rv = aInputStream->Read(buffer, sizeof(buffer), &bytesRead);
NS_ENSURE_SUCCESS(rv, rv);
if (!bytesRead) break;
ULONG rr;
HRESULT hr = mStream->Write(buffer, bytesRead, &rr);
if (hr != S_OK) return NS_ERROR_FAILURE;
bytesRemaining -= bytesRead;
}
return NS_OK;
}
NS_IMETHODIMP streamListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
{
if (!mStream)
CreateStreamOnHGlobal(NULL, TRUE, &mStream);
return NS_OK;
}
NS_IMETHODIMP streamListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatusCode)
{
if (NS_SUCCEEDED(aStatusCode))
mStream->Commit(STGC_DEFAULT);
if (mObserver)
mObserver->OnDownload(nullptr, aStatusCode, mStream.p, mPath);
return NS_OK;
}
bool DownloadToStream(nsIURI* uri, IDownloadObserver* observer)
{
nsresult rv;
nsCOMPtr<nsIIOService> io = do_GetService("@mozilla.org/network/io-service;1", &rv);
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIChannel> channel;
io->NewChannelFromURI(uri, getter_AddRefs(channel));
NS_ENSURE_TRUE(channel, false);
nsCOMPtr<nsIStreamListener> l = new streamListener(observer);
rv = channel->AsyncOpen(l, nullptr);
return NS_SUCCEEDED(rv);
}
bool DownloadToFile(nsIURI* uri, LPCTSTR path, IDownloadObserver* observer)
{
nsresult rv;
nsCOMPtr<nsIIOService> io = do_GetService("@mozilla.org/network/io-service;1", &rv);
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIChannel> channel;
io->NewChannelFromURI(uri, getter_AddRefs(channel));
NS_ENSURE_TRUE(channel, false);
CComPtr<IStream> stream;
HRESULT hr = SHCreateStreamOnFile(path,
STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE,
&stream);
/*HRESULT hr = SHCreateStreamOnFileEx(path,
STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_FAILIFTHERE,
FILE_ATTRIBUTE_NORMAL, TRUE, NULL, &stream);*/
if (hr != S_OK) return false;
nsCOMPtr<nsIStreamListener> l = new streamListener(observer, path, stream.p);
rv = channel->AsyncOpen(l, nullptr);
return NS_SUCCEEDED(rv);
}

34
k-meleon/MozUtils.h

@ -2,8 +2,6 @@
#ifndef __MOZUTILS_H__
#define __MOZUTILS_H__
#include "stdafx.h"
inline nsString CStringToNSString(LPCTSTR aStr);
inline nsCString CStringToNSCString(LPCTSTR aStr);
nsCString CStringToNSUTF8String(LPCTSTR aStr);
@ -13,7 +11,7 @@ nsCString CStringToNSUTF8String(LPCTSTR aStr);
#define CStringToPRUnichar(str) CT2W(str)
inline CString PRUnicharToCString(const PRUnichar* str);
CString PRUnicharToCString(const PRUnichar* str);
inline CString NSStringToCString(const nsString& aStr);
CString NSUTF8StringToCString(const nsCString& aStr);
inline CString NSCStringToCString(const nsCString& aStr);
@ -41,4 +39,34 @@ bool RunJS(const wchar_t* userScript, CString& result);
bool InjectJS(nsIDOMWindow* dom, const wchar_t* userScript, CString& result);
BOOL LogMessage(const char* category, const char* message, const char* file, uint line, uint flags);
interface IDownloadObserver {
virtual void OnDownload(nsIURI*, nsresult, LPSTREAM, LPCTSTR) = 0;
};
bool DownloadToStream(nsIURI* uri, IDownloadObserver*);
bool DownloadToFile(nsIURI* uri, LPCTSTR path, IDownloadObserver*);
#include "nsIStreamListener.h"
class streamListener : public nsIStreamListener, public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
streamListener(IDownloadObserver* observer, LPCTSTR path = NULL, LPSTREAM stream = NULL) :
mStream(stream),
mPath(path),
mObserver(observer) {
}
virtual ~streamListener() {
}
protected:
IDownloadObserver* mObserver;
CComPtr<IStream> mStream;
CString mPath;
};
#endif

50
k-meleon/Plugins.cpp

@ -555,14 +555,14 @@ int SetMozillaSessionHistory (HWND hWnd, const char **titles, const char **urls,
view->GetBrowserGlue()->UpdateCurrentURI(uri);
view->GetBrowserGlue()->mPendingLocation = urls[index];
view->GetBrowserGlue()->mHIndex = index;
view->GetBrowserGlue()->mIcon = theApp.favicons.GetHostIcon(A2CW(urls[index]));
view->GetBrowserGlue()->mIcon = theApp.favicons.GetIcon(A2CW(urls[index]));
view->GetBrowserGlue()->SetBrowserTitle(NSUTF8StringToCString(nsDependentCString(titles[index])));
uri->SetPath(NS_LITERAL_CSTRING(""));
nsCString host;
uri->GetHost(host);
host.Insert("http://", 0, 7);
uri->SetSpec(host);
view->GetBrowserGlue()->mIconURI = uri;
//view->GetBrowserGlue()->mIconURI = uri;
((CBrowserFrmTab*) GetFrame(hWnd))->SetTabIcon((CBrowserTab*)view, view->GetBrowserGlue()->mIcon);
// Let the session plugin know about it
GetFrame(hWnd)->PostMessageW(UWM_UPDATEBUSYSTATE,0,(LPARAM)hWnd);
@ -1792,7 +1792,7 @@ int GetTabsList(HWND hWnd, HWND* list, unsigned size)
return i;
}
UINT GetIconIdx(const char* host)
int GetIconIdx(const char* host)
{
USES_CONVERSION;
return theApp.favicons.GetIcon(A2CT(host));
@ -2047,6 +2047,42 @@ bool RunCommand(HWND hWnd, const char* command)
return frame->SendMessage(WM_COMMAND, MAKELONG(id, 1), 0)>0;
}
bool SetMenuDrawProc(HMENU menu, DRAWBITMAPPROC proc)
{
theApp.menus.mProcList[menu] = proc;
CMenu* m = CMenu::FromHandle(menu);
KmMenu* km = theApp.menus.GetKMenu(m);
if (!km) return false;
km->mDrawProc = proc;
return true;
}
class pluginDwnObserver: public IDownloadObserver
{
protected:
DOWNLOADPROC mProc;
void* mData;
public:
pluginDwnObserver(DOWNLOADPROC proc, void* data) : mProc(proc),mData(data) {}
virtual ~pluginDwnObserver() {}
void OnDownload(nsIURI* uri, nsresult result, LPSTREAM, LPCTSTR wpath)
{
nsCString spec;
if (uri) uri->GetSpec(spec);
CAutoPtr<char> path(EncodeUTF8(wpath));
mProc(spec.get(), path, result, mData);
delete this;
}
};
bool Download(const char* url, const char* path, DOWNLOADPROC proc, void* data)
{
nsCOMPtr<nsIURI> uri;
NewURI(getter_AddRefs(uri), nsDependentCString(url));
CAutoPtr<wchar_t> wpath(WDecodeUTF8(path));
return DownloadToFile(uri, wpath, proc ? new pluginDwnObserver(proc, data) : NULL);
}
kmeleonFunctions kmelFuncsUTF8 = {
SendMessage,
GetCommandIDs,
@ -2124,7 +2160,9 @@ kmeleonFunctions kmelFuncsUTF8 = {
ShowMenu,
GetCurrent,
RunCommand,
GetDefSizeIconList
GetDefSizeIconList,
SetMenuDrawProc,
Download
};
kmeleonFunctions kmelFuncs = {
@ -2204,7 +2242,9 @@ kmeleonFunctions kmelFuncs = {
ShowMenu,
GetCurrent,
RunCommand,
GetDefSizeIconList
GetDefSizeIconList,
SetMenuDrawProc,
Download
};
BOOL CPlugins::TestLoad(LPCTSTR file, const char *description)

2
k-meleon/ReBarEx.cpp

@ -280,8 +280,6 @@ void CReBarEx::OnChevronPushed( NMHDR * pNotifyStruct, LRESULT* result )
}
}
// SendMessage("bmpmenu", "", "SetOwnerDrawn", (long)pop.m_hMenu, (long)DrawBitmap);
if ( bAtleastOne )
pop.TrackPopupMenu ( TPM_LEFTALIGN|TPM_TOPALIGN, ptMenu.x, ptMenu.y, GetParentFrame() );

2
k-meleon/VisualStylesXP.h

@ -4,7 +4,7 @@
#pragma once
#include <uxtheme.h>
#include <tmschema.h>
#include <vssym32.h>
class CVisualStylesXP
{

637
k-meleon/bmp_menu/bmp_menu.cpp

@ -54,12 +54,6 @@ typedef int (*DRAWBITMAPPROC)(DRAWITEMSTRUCT *dis);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
WNDPROC KMeleonWndProc;
int DrawBitmap(DRAWITEMSTRUCT *dis);
void DrawCheckMark(HDC pDC,int x,int y,COLORREF color);
void SetOwnerDrawn(HMENU menu, DRAWBITMAPPROC DrawProc, BOOL topLevel);
void UnSetOwnerDrawn(HMENU menu);
int Init();
void Create(HWND parent);
void Config(HWND parent);
@ -75,6 +69,8 @@ kmeleonPlugin kPlugin = {
DoMessage
};
bool gbIsComCtl6 = false;
/*
# sample config
@ -89,33 +85,8 @@ ID_BLARG2
}
*/
// this maps HMENU's to DrawProcs
typedef std::map<HMENU, DRAWBITMAPPROC> menuMap;
menuMap menus;
BOOL bFirstRun;