public void paint(Surface surface, Rectangle area) { displaySize = new Size(area.Width, Height); MenuItem sel; if (selected >= 0 && selected < menuEntries.Count) { sel = menuEntries[selected]; } else { sel = null; } Rectangle rect = new Rectangle(area.Location, displaySize); rect.Height += Compound.BorderPadding.Height; surface.Fill(rect, DisplaySettings.menuForeground); rect.Height -= Compound.BorderPadding.Height; surface.Fill(rect, DisplaySettings.menuBackground); Point p = new Point(Compound.Padding + Compound.IconSize.Width + area.X, Compound.Padding + area.Y); foreach (MenuItem mi in menuEntries) { if (!(mi is MenuSeperator)) { DisplayCaption caption = mi.Caption; caption.SizeWithIcon = false; if (sel == mi) { Rectangle selrect = new Rectangle(p.X - Compound.Padding * 2, p.Y - Compound.Padding, Compound.Padding * 3, displaySize.Height); selrect.Width += Compound.Padding + caption.Width; surface.Fill(selrect, DisplaySettings.selectedColor); } caption.Blit(surface, p); p.X += caption.Width + Compound.Padding; p.X += Compound.Padding * 3; } } if (SubMenu != null) { SubMenu.Paint(surface); } }
override public void Paint(Surface display) { if (visible == false) { return; } dimensions = new Size(Compound.Padding * 2, Compound.Padding * 2); MenuItem sel; if (selected >= 0 && selected < menuEntries.Count) { sel = menuEntries[selected]; } else { sel = null; } foreach (MenuItem mi in menuEntries) { if (mi is MenuSeperator) { dimensions.Height += Compound.Padding + 2; } else { DisplayCaption caption = mi.Caption; caption.SizeWithIcon = true; dimensions.Height += caption.Height; dimensions.Width = Math.Max(dimensions.Width, Compound.Padding * 3 + Compound.IconSize.Width + caption.Width); } } Rectangle rect = new Rectangle(position, dimensions); display.Fill(rect, DisplaySettings.menuBackground); display.Draw(new SdlDotNet.Graphics.Primitives.Box(position, dimensions), DisplaySettings.menuForeground); Point p = new Point(0, Compound.Padding + position.Y); foreach (MenuItem mi in menuEntries) { p.X = Compound.Padding + position.X; if (mi is MenuSeperator) { dimensions.Height = dimensions.Height + SeperatorThickness; Rectangle line = new Rectangle(Compound.Padding + position.X, p.Y + Compound.Padding / 2, dimensions.Width - Compound.Padding * 2, Compound.Seperator); display.Fill(line, DisplaySettings.menuForeground); p.Y += Compound.Padding + 2; } else { DisplayCaption caption = mi.Caption; caption.SizeWithIcon = true; if (sel == mi) { Rectangle selrect = new Rectangle(Compound.Padding + position.X, p.Y, dimensions.Width - Compound.Padding * 2, DisplaySettings.lableFont.Height); display.Fill(selrect, DisplaySettings.selectedColor); } p.X = Compound.Padding + position.X; caption.Blit(display, p); if (mi.IsPopup()) { Point p2 = new Point(); p2.X = dimensions.Width - Compound.IconSize.Width - Compound.Padding + position.X; p2.Y += p.Y + (DisplaySettings.lableFont.Height - Compound.IconSize.Height) / 2; DisplaySettings.popupIcon.Blit(display, p2); } p.Y += DisplaySettings.lableFont.Height; } } if (SubMenu != null) { SubMenu.Paint(display); } }