public override void CalcPopupMenuSize (Graphics dc, Menu menu)
{
int x = 3;
int start = 0;
int i, n, y, max;
menu.Height = 0;
while (start < menu.MenuItems.Count) {
y = 3;
max = 0;
for (i = start; i < menu.MenuItems.Count; i++) {
MenuItem item = menu.MenuItems [i];
if ((i != start) && (item.Break || item.BarBreak))
break;
CalcItemSize (dc, item, y, x, false);
y += item.Height;
if (item.Width > max)
max = item.Width;
}
// Replace the -1 by the menu width (separators)
for (n = start; n < i; n++, start++)
menu.MenuItems [n].Width = max;
if (y > menu.Height)
menu.Height = y;
x+= max;
}
menu.Width = x;
//space for border
menu.Width += 2;
menu.Height += 2;
menu.Width += SM_CXBORDER;
menu.Height += SM_CYBORDER;
}