System.Windows.Forms.ThemeWin32Classic.CalcMenuBarSize C# (CSharp) Method

CalcMenuBarSize() public method

public CalcMenuBarSize ( Graphics dc, Menu menu, int width ) : int
dc System.Drawing.Graphics
menu Menu
width int
return int
		public override int CalcMenuBarSize (Graphics dc, Menu menu, int width)
		{
			int x = 0;
			int y = 0;
			menu.Height = 0;

			foreach (MenuItem item in menu.MenuItems) {

				CalcItemSize (dc, item, y, x, true);

				if (x + item.Width > width) {
					item.X = 0;
					y += item.Height;
					item.Y = y;
					x = 0;
				}

				x += item.Width;
				item.MenuBar = true;				

				if (y + item.Height > menu.Height)
					menu.Height = item.Height + y;
			}

			menu.Width = width;						
			return menu.Height;
		}
ThemeWin32Classic