|
|
|
@ -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) |
|
|
|
|