/// <summary> /// Initialize a new instance of the VisualPopupGroup class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonGroup">Reference to ribbon group for display.</param> /// <param name="renderer">Drawing renderer.</param> public VisualPopupGroup(KryptonRibbon ribbon, KryptonRibbonGroup ribbonGroup, IRenderer renderer) : base(renderer, true) { Debug.Assert(ribbon != null); Debug.Assert(ribbonGroup != null); // Remember references needed later _ribbon = ribbon; _ribbonGroup = ribbonGroup; // Create a view element for drawing the group ViewGroup = new ViewDrawRibbonGroup(ribbon, ribbonGroup, NeedPaintDelegate) { Collapsed = false }; // Create the background that will contain the actual group instance _viewBackground = new ViewDrawRibbonGroupsBorder(ribbon, true, NeedPaintDelegate) { ViewGroup }; // Attach the root to the view manager instance ViewManager = new ViewRibbonPopupGroupManager(this, ribbon, _viewBackground, ViewGroup, NeedPaintDelegate); // Create and add a hidden button to act as the focus target _hiddenFocusTarget = new Button { TabStop = false }; _hiddenFocusTarget.Location = new Point(-_hiddenFocusTarget.Width, -_hiddenFocusTarget.Height); CommonHelper.AddControlToParent(this, _hiddenFocusTarget); }
/// <summary> /// Perform mouse leave processing. /// </summary> /// <param name="e">An EventArgs that contains the event data.</param> public override void MouseLeave(EventArgs e) { Debug.Assert(e != null); // Validate incoming reference if (e == null) { throw new ArgumentNullException(nameof(e)); } if (!_ribbon.InDesignMode) { // Only interested if the application window we are inside is active or a docking floating window is active if (_active || (CommonHelper.ActiveFloatingWindow != null)) { // If there is an active element if (_activeGroup != null) { _activeGroup.PerformNeedPaint(false, _activeGroup.ClientRectangle); _activeGroup.Tracking = false; _activeGroup = null; } } } // Remember to call base class for standard mouse processing base.MouseLeave(e); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupImage class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonGroup">Reference to ribbon group definition.</param> /// <param name="viewGroup">Reference to top level group element.</param> public ViewDrawRibbonGroupImage(KryptonRibbon ribbon, KryptonRibbonGroup ribbonGroup, ViewDrawRibbonGroup viewGroup) { Debug.Assert(ribbon != null); Debug.Assert(ribbonGroup != null); Debug.Assert(viewGroup != null); _ribbon = ribbon; _ribbonGroup = ribbonGroup; _viewGroup = viewGroup; }
/// <summary> /// Initialize a new instance of the ViewRibbonPopupGroupManager class. /// </summary> /// <param name="control">Owning control.</param> /// <param name="ribbon">Owning ribbon control instance.</param> /// <param name="root">View for group we are tracking.</param> /// <param name="viewGroup">Group to track.</param> /// <param name="needPaintDelegate">Delegate for performing painting.</param> public ViewRibbonPopupGroupManager(Control control, KryptonRibbon ribbon, ViewBase root, ViewDrawRibbonGroup viewGroup, NeedPaintHandler needPaintDelegate) : base(control, root) { Debug.Assert(ribbon != null); Debug.Assert(viewGroup != null); Debug.Assert(needPaintDelegate != null); _ribbon = ribbon; _viewGroup = viewGroup; _needPaintDelegate = needPaintDelegate; }
/// <summary> /// Perform mouse movement handling. /// </summary> /// <param name="e">A MouseEventArgs that contains the event data.</param> /// <param name="rawPt">The actual point provided from the windows message.</param> public override void MouseMove(MouseEventArgs e, Point rawPt) { Debug.Assert(e != null); // Validate incoming reference if (e == null) { throw new ArgumentNullException(nameof(e)); } if (!_ribbon.InDesignMode) { // Only interested if the application window we are inside is active or a docking floating window is active if (_active || (CommonHelper.ActiveFloatingWindow != null)) { // Only hot track groups if in the correct mode if (_minimizedMode == _ribbon.RealMinimizedMode) { // Get the view group instance that matches this point ViewDrawRibbonGroup viewGroup = _viewGroups.ViewGroupFromPoint(new Point(e.X, e.Y)); // Is there a change in active group? if (viewGroup != _activeGroup) { if (_activeGroup != null) { _activeGroup.Tracking = false; _activeGroup.PerformNeedPaint(false, _activeGroup.ClientRectangle); } _activeGroup = viewGroup; if (_activeGroup != null) { _activeGroup.Tracking = true; _activeGroup.PerformNeedPaint(false, _activeGroup.ClientRectangle); } } } } } // Remember to call base class for standard mouse processing base.MouseMove(e, rawPt); }
/// <summary> /// Show the group popup relative to the parent group instance. /// </summary> /// <param name="parentGroup">Parent group instance.</param> /// <param name="parentScreenRect">Screen rectangle of the parent.</param> public void ShowCalculatingSize(ViewDrawRibbonGroup parentGroup, Rectangle parentScreenRect) { // Prevent ribbon from laying out the same group as we are // about to get the preferred size from. This reentrancy can // happen if the group has a custom control that is then moved // to be reparented to the popup group and so therefore cause // a layout of the main ribbon. _ribbon.SuspendLayout(); SuspendLayout(); try { // Find the size the group requests to be Size popupSize; using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer)) { popupSize = ViewGroup.GetPreferredSize(context); } // Override the height to enforce the correct group height popupSize.Height = _ribbon.CalculatedValues.GroupHeight; // Mark the group as showing as a popup _ribbonGroup.ShowingAsPopup = true; // Request we be shown below the parent screen rect Show(CalculateBelowPopupRect(parentScreenRect, popupSize)); } finally { // Reverse the suspend call _ribbon.ResumeLayout(); ResumeLayout(); } }