Snoop incoming mouse messages for an element and inform tooltip manager about them.
Inheritance: GlobalId, IMouseController
Exemple #1
0
        /// <summary>
        /// Create a button controller for the view.
        /// </summary>
        /// <param name="viewButton">View to be controlled.</param>
        /// <param name="needPaint">Paint delegate.</param>
        /// <param name="clickHandler">Reference to click handler.</param>
        /// <returns>Controller instance.</returns>
        public override ButtonSpecViewControllers CreateController(ViewDrawButton viewButton,
            NeedPaintHandler needPaint,
            MouseEventHandler clickHandler)
        {
            // Create a ribbon specific button controller
            _controller = new ButtonSpecRibbonController(viewButton, needPaint);
            _controller.BecomesFixed = true;
            _controller.Click += clickHandler;

            // If associated with a tooltip manager then pass mouse messages onto tooltip manager
            IMouseController mouseController = (IMouseController)_controller;
            if (Manager.ToolTipManager != null)
                mouseController = new ToolTipController(Manager.ToolTipManager, viewButton, _controller);

            // Return a collection of controllers
            return new ButtonSpecViewControllers(mouseController, _controller, _controller);
        }
Exemple #2
0
        /// <summary>
        /// Create a button controller for the view.
        /// </summary>
        /// <param name="viewButton">View to be controlled.</param>
        /// <param name="needPaint">Paint delegate.</param>
        /// <param name="clickHandler">Reference to click handler.</param>
        /// <returns>Controller instance.</returns>
        public virtual ButtonSpecViewControllers CreateController(ViewDrawButton viewButton,
                                                                  NeedPaintHandler needPaint,
                                                                  MouseEventHandler clickHandler)
        {
            // Create a standard button controller
            _controller = new ButtonController(viewButton, needPaint);
            _controller.BecomesFixed = true;
            _controller.Click       += clickHandler;

            // If associated with a tooltip manager then pass mouse messages onto tooltip manager
            IMouseController mouseController = (IMouseController)_controller;

            if (Manager.ToolTipManager != null)
            {
                mouseController = new ToolTipController(Manager.ToolTipManager, viewButton, _controller);
            }

            // Return a collection of controllers
            return(new ButtonSpecViewControllers(mouseController, _controller, _controller));
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonQATButton class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="qatButton">Reference to button definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonQATButton(KryptonRibbon ribbon,
                                       IQuickAccessToolbarButton qatButton,
                                       NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(qatButton != null);

            // Remember incoming references
            _ribbon = ribbon;
            _qatButton = qatButton;

            // If the source interface comes from a component then allow it to
            // be selected at design time by clicking on the view instance
            Component = qatButton as System.ComponentModel.Component;

            // Attach a controller to this element for the pressing of the button
            QATButtonController controller = new QATButtonController(ribbon, this, needPaint);
            controller.Click += new MouseEventHandler(OnClick);
            SourceController = controller;
            KeyController = controller;

            // Create controller for intercepting events to determine tool tip handling
            MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager,
                                                    this, controller);

            // Use a class to convert from ribbon tab to content interface
            _contentProvider = new QATButtonToContent(qatButton);

            // Create and add the draw content for display inside the button
            _drawContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top);
            Add(_drawContent);

            // Need to notice when the ribbon enable state changes
            _ribbon.EnabledChanged += new EventHandler(OnRibbonEnableChanged);

            // Set the initial enabled state
            UpdateEnabled();
        }
        /// <summary>
        /// Create a mouse controller appropriate for operating this button.
        /// </summary>
        /// <returns>Reference to IMouseController interface.</returns>
        protected virtual IMouseController CreateMouseController()
        {
            // Create the button controller
            _buttonController = new PageButtonController(this, new NeedPaintHandler(OnNeedPaint));
            _buttonController.ClickOnDown = true;
            _buttonController.Click += new MouseEventHandler(OnClick);
            _buttonController.RightClick += new MouseEventHandler(OnRightClick);

            // Allow the page to be dragged and hook into drag events
            _buttonController.AllowDragging = true;
            _buttonController.DragStart += new EventHandler<DragStartEventCancelArgs>(OnDragStart);
            _buttonController.DragMove += new EventHandler<PointEventArgs>(OnDragMove);
            _buttonController.DragEnd += new EventHandler<PointEventArgs>(OnDragEnd);
            _buttonController.DragQuit += new EventHandler(OnDragQuit);
            _buttonController.ButtonDragRectangle += new EventHandler<ButtonDragRectangleEventArgs>(OnButtonDragRectangle);
            _buttonController.ButtonDragOffset += new EventHandler<ButtonDragOffsetEventArgs>(OnButtonDragOffset);

            // Should the item be selected on the mouse down or the mouse up?
            _buttonController.ClickOnDown = ButtonClickOnDown;

            // We need to be notified of got/lost focus and keyboard events
            SourceController = _buttonController;
            KeyController = _buttonController;

            // Create two decorators in order to support tooltips and hover events
            ToolTipController toolTipController = new ToolTipController(_navigator.ToolTipManager, this, _buttonController);
            ToolTipController hoverController = new ToolTipController(_navigator.HoverManager, this, toolTipController);
            return hoverController;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawNavRibbonTab class.
        /// </summary>
        /// <param name="navigator">Owning navigator instance.</param>
        /// <param name="page">Page this ribbon tab represents.</param>
        public ViewDrawNavRibbonTab(KryptonNavigator navigator,
                                    KryptonPage page)
        {
            Debug.Assert(navigator != null);
            Debug.Assert(page != null);

            _navigator = navigator;
            _page = page;
            _lastClick = DateTime.Now.AddDays(-1);

            // Associate the page component with this view element
            Component = page;

            // Create a controller for managing button behavior
            _buttonController = new PageButtonController(this, new NeedPaintHandler(OnNeedPaint));
            _buttonController.ClickOnDown = true;
            _buttonController.Click += new MouseEventHandler(OnClick);
            _buttonController.RightClick += new MouseEventHandler(OnRightClick);

            // Allow the page to be dragged and hook into drag events
            _buttonController.AllowDragging = true;
            _buttonController.DragStart += new EventHandler<DragStartEventCancelArgs>(OnDragStart);
            _buttonController.DragMove += new EventHandler<PointEventArgs>(OnDragMove);
            _buttonController.DragEnd += new EventHandler<PointEventArgs>(OnDragEnd);
            _buttonController.DragQuit += new EventHandler(OnDragQuit);
            _buttonController.ButtonDragRectangle += new EventHandler<ButtonDragRectangleEventArgs>(OnButtonDragRectangle);
            _buttonController.ButtonDragOffset += new EventHandler<ButtonDragOffsetEventArgs>(OnButtonDragOffset);

            // A tab is selected on being pressed and not on the mouse up
            _buttonController.ClickOnDown = true;

            // We need to be notified of got/lost focus and keyboard events
            SourceController = _buttonController;
            KeyController = _buttonController;

            // Create a decorator to interface with the tooltip manager
            ToolTipController toolTipController = new ToolTipController(_navigator.ToolTipManager, this, _buttonController);
            ToolTipController hoverController = new ToolTipController(_navigator.HoverManager, this, toolTipController);

            // Assign controller for handing mouse input
            MouseController = hoverController;

            // Create overrides for handling a focus state
            _paletteGeneral = _navigator.StateCommon.RibbonGeneral;
            _overrideStateNormal = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StateNormal.RibbonTab.TabDraw, _page.StateNormal.RibbonTab.TabDraw, _page.StateNormal.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateTracking = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StateTracking.RibbonTab.TabDraw, _page.StateTracking.RibbonTab.TabDraw, _page.StateTracking.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStatePressed = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StatePressed.RibbonTab.TabDraw, _page.StatePressed.RibbonTab.TabDraw, _page.StatePressed.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateSelected = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StateSelected.RibbonTab.TabDraw, _page.StateSelected.RibbonTab.TabDraw, _page.StateSelected.RibbonTab.Content, PaletteState.FocusOverride);

            // Use a class to convert from ribbon tab to content interface
            _contentProvider = new RibbonTabToContent(_paletteGeneral, _overrideStateNormal, _overrideStateNormal);

            // Create the content view element and use the content provider as a way to
            // convert from the ribbon palette entries to the content palette entries
            _viewContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top);

            // Add content to the view
            _layoutDocker = new ViewLayoutDocker();
            _layoutDocker.Add(_viewContent, ViewDockStyle.Fill);
            Add(_layoutDocker);

            // Create button specification collection manager
            _buttonManager = new ButtonSpecNavManagerLayoutBar(Navigator, Navigator.InternalRedirector, Page.ButtonSpecs, null,
                                                               new ViewLayoutDocker[] { _layoutDocker },
                                                               new IPaletteMetric[] { Navigator.StateCommon },
                                                               new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                               new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                               new PaletteMetricPadding[] { PaletteMetricPadding.PageButtonPadding },
                                                               new GetToolStripRenderer(Navigator.CreateToolStripRenderer),
                                                               new NeedPaintHandler(OnNeedPaint));

            // Hook up the tooltip manager so that tooltips can be generated
            _buttonManager.ToolTipManager = Navigator.ToolTipManager;
            _buttonManager.RemapTarget = ButtonSpecNavRemap.ButtonSpecRemapTarget.ButtonStandalone;

            // Ensure current button specs are created
            _buttonManager.RecreateButtons();

            // Create the state specific memento array
            _mementos = new IDisposable[Enum.GetValues(typeof(PaletteState)).Length];

            // Cache the last shape encountered
            _lastRibbonShape = PaletteRibbonShape.Office2010;
        }