/// <summary>Creates a new instance of ComboBox.</summary> /// <param name="toClone">The ComboBox to clone.</param> /// <param name="copyItems">Whether or not to copy the items over as well.</param> public ComboBox(ComboBox toClone, bool copyItems) : base(toClone) { Menu = new PopUpMenu(toClone.Menu, copyItems); Menu.TopParent = TopParent; Menu.Parent = this; Menu.OptionAdded += new EventHandler(Menu_OnOptionAdded); Menu.OptionRemoved += new EventHandler(Menu_OnOptionRemoved); Menu.OptionSelected += new EventHandler(Menu_OnOptionSelected); TextBoxBackColor = toClone.TextBoxBackColor; TextBoxForeColor = toClone.TextBoxForeColor; buttonWidth = toClone.buttonWidth; buttonGraphicPos = toClone.buttonGraphicPos; SelectedIndex = -1; }
/// <summary>Creates a new instance of ComboBox.</summary> public ComboBox() : base() { Menu = new PopUpMenu(); Menu.TopParent = TopParent; Menu.Parent = this; Menu.OptionAdded += new EventHandler(Menu_OnOptionAdded); Menu.OptionRemoved += new EventHandler(Menu_OnOptionRemoved); Menu.OptionSelected += new EventHandler(Menu_OnOptionSelected); TextBoxBackColor = Desktop.DefComboBoxTextBoxBackColor; TextBoxForeColor = Desktop.DefComboBoxTextBoxForeColor; buttonWidth = Desktop.DefComboBoxButtonWidth; buttonGraphicPos = new Vector2(); SelectedIndex = -1; TextAlign = Desktop.Alignment.TopLeft; SidePadding = Desktop.DefComboBoxSidePadding; }
/// <summary>Creates a new instance of PopUpMenu.</summary> /// <param name="toClone">The PopUpMenu to clone.</param> /// <param name="copyItems">Whether or not to copy the items over as well.</param> public PopUpMenu(PopUpMenu toClone, bool copyItems) : base(toClone) { if (copyItems) { items = new List<string>(toClone.items); itemSizes = new List<Vector2>(toClone.itemSizes); } else { items = new List<string>(); itemSizes = new List<Vector2>(); } BackColorHover = toClone.BackColorHover; ForeColor = toClone.ForeColor; ForeColorHover = toClone.ForeColorHover; font = toClone.font; sidePadding = toClone.sidePadding; locSizeChgd(); }
/// <summary>Shows the specified menu.</summary> /// <param name="menu">The menu to show.</param> public void showMenu(PopUpMenu menu) { hideMenu(); CurMenu = menu; if (CurMenu.inBounds(CursorPos - CurMenu.getScreenPos() + CurMenu.Location)) Hovered = CurMenu; }