Fix menu size

import/tags/kmeleon75_1
Dorian 7 years ago
parent 10c294f3a1
commit 7d74745f5b
  1. 38
      k-meleon/KmMenu.cpp
  2. 5
      k-meleon/KmMenu.h

@ -667,18 +667,15 @@ void KmMenuService::DrawItem(LPDRAWITEMSTRUCT dis)
DRAWBITMAPPROC drawProc;
if (!mProcList.Lookup((HMENU)dis->hwndItem, drawProc) || !drawProc(dis))
DrawBitmap(dis);
dis->rcItem.left += theApp.skin.GetDefWidth() + ::GetSystemMetrics(SM_CXEDGE);
dis->rcItem.left += theApp.skin.GetDefWidth() + ::GetSystemMetrics(SM_CXEDGE) + 1;
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);
dis->rcItem.right -= GetSystemMetrics(SM_CXMENUCHECK) + 2;
DrawText(dis->hDC, accel, accel.GetLength(), &dis->rcItem, DT_RIGHT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP);
}
}
}
@ -725,39 +722,38 @@ void KmMenuService::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
mi.dwTypeData = text;
mLastActivated->GetMenuItemInfo(lpMeasureItemStruct->itemID, &mi);
HDC hDC = CreateCompatibleDC(NULL);
//HDC hDC = ::GetWindowDC(theApp.m_pMostRecentBrowserFrame->m_hWnd);
HWND hWnd = theApp.m_pMostRecentBrowserFrame ? NULL : theApp.m_pMostRecentBrowserFrame->m_hWnd;
HDC hDC = ::GetWindowDC(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;
//GetTextExtentPoint32(hDC, text, _tcslen(text), &size);
//if (size.cx > mMaxTextLength) mMaxTextLength = size.cx;
RECT rcText = {0};
DrawText(hDC, text, -1, &rcText, DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_CALCRECT);
if (rcText.right > mMaxTextLength) mMaxTextLength = rcText.right;
lpMeasureItemStruct->itemWidth = mMaxTextLength;
CString accel = theApp.accel.GetStrAccel(lpMeasureItemStruct->itemID);
if (accel.GetLength()) {
GetTextExtentPoint32(hDC, accel, accel.GetLength(), &size);
lpMeasureItemStruct->itemWidth += spaceBetween + size.cx;
if (size.cx > mMaxAccelLength) mMaxAccelLength = size.cx;
}
lpMeasureItemStruct->itemWidth -= (GetSystemMetrics(SM_CXMENUCHECK)-1);
if (mMaxAccelLength > 0)
lpMeasureItemStruct->itemWidth += spaceBetween + mMaxAccelLength;
lpMeasureItemStruct->itemHeight = GetSystemMetrics(SM_CYMENUSIZE);
int height = theApp.skin.GetDefHeight();
int width = theApp.skin.GetDefWidth();
lpMeasureItemStruct->itemWidth += width + ::GetSystemMetrics(SM_CXEDGE) * 2;
lpMeasureItemStruct->itemWidth += width + ::GetSystemMetrics(SM_CXEDGE) * 2 + 1;
if (lpMeasureItemStruct->itemHeight < height+2)
lpMeasureItemStruct->itemHeight = height+2;
SelectObject(hDC, oldFont);
DeleteDC(hDC);
ReleaseDC(hWnd, hDC);
}
/*

@ -19,7 +19,6 @@
#ifndef __KMMENU_H__
#define __KMMENU_H__
#include "ODMenu.h"
typedef int (__cdecl* DRAWBITMAPPROC)(DRAWITEMSTRUCT *dis);
enum KmMenuType
@ -86,7 +85,7 @@ protected:
BOOL Build(CMenu &menu, int before);
BOOL IsEmpty() { return (mMenuDef.GetCount() == 0); }
CODMenu mMenu;
CMenu mMenu;
CList<KmMenuItem, KmMenuItem&> mMenuDef;
CList<KmMenu*, KmMenu*> mDependencies;
BOOL mInvalid;
@ -220,6 +219,7 @@ public:
if (kmenu) kmenu->GetMenu();
mLastActivated = menu;
mMaxTextLength = 0;
mMaxAccelLength = 0;
return kmenu;
}
@ -250,6 +250,7 @@ protected:
BOOL mOwnerDraw;
CFont mMenuFont;
int mMaxTextLength;
int mMaxAccelLength;
};

Loading…
Cancel
Save