Exemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonScrollPort class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="orientation">Viewport orientation.</param>
        /// <param name="viewFiller">View to size and position.</param>
        /// <param name="insetForTabs">Should scoller be inset for use in tabs area.</param>
        /// <param name="scrollSpeed">Scrolling speed.</param>
        /// <param name="needPaintDelegate">Delegate for notifying paint/layout requests.</param>
        public ViewLayoutRibbonScrollPort(KryptonRibbon ribbon,
                                          Orientation orientation,
                                          ViewBase viewFiller,
                                          bool insetForTabs,
                                          int scrollSpeed,
                                          NeedPaintHandler needPaintDelegate)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(viewFiller != null);
            Debug.Assert(needPaintDelegate != null);

            // Remember initial settings
            _ribbon            = ribbon;
            _orientation       = orientation;
            _viewFiller        = viewFiller;
            _needPaintDelegate = needPaintDelegate;
            _scrollSpeed       = scrollSpeed;
            _ribbonTabs        = viewFiller as ViewLayoutRibbonTabs;

            // Default to left hand scroll position
            _scrollOffset = 0;

            // Place the child view inside a actual control, so that the contents of the
            // filler are clipped to the control size. This is needed if the child view
            // contains controls and need clipping inside this area and so prevent them
            // from drawing over the end scrollers.
            _viewControlContent = new RibbonViewControl(ribbon);
            _viewControlContent.PaintBackground += OnViewControlPaintBackground;
            ViewLayoutControl = new ViewLayoutControl(_viewControlContent, ribbon, _viewFiller);

            // For ribbon tabs we want to monitor and intercept the WM_NCHITTEST so that the remainder of the
            // tabs area acts like the application title bar and can be used to manipulate the application
            if (_ribbonTabs != null)
            {
                ViewLayoutControl.ChildControl.WndProcHitTest += OnChildWndProcHitTest;
            }

            // Create the two scrollers used when not enough space for filler
            _nearScroller = new ViewLayoutRibbonScroller(ribbon, NearOrientation, insetForTabs, needPaintDelegate);
            _farScroller  = new ViewLayoutRibbonScroller(ribbon, FarOrientation, insetForTabs, needPaintDelegate);

            // Hook into scroller events
            _nearScroller.Click += OnNearClick;
            _farScroller.Click  += OnFarClick;

            // Add elements in correct order
            Add(ViewLayoutControl);
            Add(_nearScroller);
            Add(_farScroller);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonTab class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="layoutTabs">Reference to view used for layout out tabs.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonTab(KryptonRibbon ribbon,
                                 ViewLayoutRibbonTabs layoutTabs,
                                 NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(layoutTabs != null);
            Debug.Assert(needPaint != null);

            // Cache incoming values
            Ribbon = ribbon;
            ViewLayoutRibbonTabs = layoutTabs;
            _needPaint           = needPaint;

            // Create overrides for handling a focus state
            _paletteGeneral                      = ribbon.StateCommon.RibbonGeneral;
            _overrideStateNormal                 = new PaletteRibbonDoubleInheritOverride(Ribbon.OverrideFocus.RibbonTab, Ribbon.OverrideFocus.RibbonTab, Ribbon.StateNormal.RibbonTab, Ribbon.StateNormal.RibbonTab, PaletteState.FocusOverride);
            _overrideStateTracking               = new PaletteRibbonDoubleInheritOverride(Ribbon.OverrideFocus.RibbonTab, Ribbon.OverrideFocus.RibbonTab, Ribbon.StateTracking.RibbonTab, Ribbon.StateTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideStateCheckedNormal          = new PaletteRibbonDoubleInheritOverride(Ribbon.OverrideFocus.RibbonTab, Ribbon.OverrideFocus.RibbonTab, Ribbon.StateCheckedNormal.RibbonTab, Ribbon.StateCheckedNormal.RibbonTab, PaletteState.FocusOverride);
            _overrideStateCheckedTracking        = new PaletteRibbonDoubleInheritOverride(Ribbon.OverrideFocus.RibbonTab, Ribbon.OverrideFocus.RibbonTab, Ribbon.StateCheckedTracking.RibbonTab, Ribbon.StateCheckedTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideStateContextTracking        = new PaletteRibbonDoubleInheritOverride(Ribbon.OverrideFocus.RibbonTab, Ribbon.OverrideFocus.RibbonTab, Ribbon.StateContextTracking.RibbonTab, Ribbon.StateContextTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideStateContextCheckedNormal   = new PaletteRibbonDoubleInheritOverride(Ribbon.OverrideFocus.RibbonTab, Ribbon.OverrideFocus.RibbonTab, Ribbon.StateContextCheckedNormal.RibbonTab, Ribbon.StateContextCheckedNormal.RibbonTab, PaletteState.FocusOverride);
            _overrideStateContextCheckedTracking = new PaletteRibbonDoubleInheritOverride(Ribbon.OverrideFocus.RibbonTab, Ribbon.OverrideFocus.RibbonTab, Ribbon.StateContextCheckedTracking.RibbonTab, Ribbon.StateContextCheckedTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideCurrent                     = _overrideStateNormal;

            // Create and default the setup of the context colors provider
            _paletteContextCurrent = new PaletteRibbonContextDouble(Ribbon);
            _paletteContextCurrent.SetInherit(_overrideCurrent);

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

            // Use a controller to change state because of mouse movement
            RibbonTabController controller = new RibbonTabController(Ribbon, this, _needPaint);

            controller.Click        += OnTabClicked;
            controller.ContextClick += OnTabContextClicked;
            MouseController          = controller;
            SourceController         = controller;
            KeyController            = controller;

            // Associate this view with the source component (required for design time selection)
            Component = _ribbonTab;

            // Create and add the draw content for display inside the tab
            Add(new ViewDrawContent(_contentProvider, this, VisualOrientation.Top, true, false));

            // Create the state specific memento array
            _mementos = new IDisposable[Enum.GetValues(typeof(PaletteState)).Length];
        }
Exemplo n.º 3
0
        private void CreateViewElements(PaletteRedirect redirect)
        {
            // Layout for individual tabs inside the header
            LayoutTabs = new ViewLayoutRibbonTabs(_ribbon, NeedPaintDelegate);

            // Put inside a viewport so scrollers are used when tabs cannot be shrunk to fill space
            _tabsViewport = new ViewLayoutRibbonScrollPort(_ribbon, System.Windows.Forms.Orientation.Horizontal, LayoutTabs, true, SCROLL_SPEED, NeedPaintDelegate)
            {
                TransparentBackground = true
            };
            _tabsViewport.PaintBackground += OnTabsPaintBackground;
            LayoutTabs.ParentControl       = _tabsViewport.ViewLayoutControl.ChildControl;
            LayoutTabs.NeedPaintDelegate   = _tabsViewport.ViewControlPaintDelegate;

            // We use a layout docker as a child to prevent buttons going to the left of the app button
            ViewLayoutDocker tabsDocker = new ViewLayoutDocker
            {
                // Place the tabs viewport as the fill inside ourself, the button specs will be placed
                // to the left and right of this fill element automatically by the button manager below
                { _tabsViewport, ViewDockStyle.Fill }
            };

            // We need to draw the bottom half of the application button or a full app tab
            LayoutAppButton = new ViewLayoutRibbonAppButton(_ribbon, true);
            LayoutAppTab    = new ViewLayoutRibbonAppTab(_ribbon);

            // Connect up the application button controller to the app button element
            _appButtonController.Target3        = LayoutAppButton.AppButton;
            _appButtonController.Click         += OnAppButtonClicked;
            _appButtonController.MouseReleased += OnAppButtonReleased;
            LayoutAppButton.MouseController     = _appButtonController;
            LayoutAppButton.SourceController    = _appButtonController;
            LayoutAppButton.KeyController       = _appButtonController;

            _appTabController.Target1        = LayoutAppTab.AppTab;
            _appTabController.Click         += OnAppButtonClicked;
            _appTabController.MouseReleased += OnAppButtonReleased;
            LayoutAppTab.MouseController     = _appTabController;
            LayoutAppTab.SourceController    = _appTabController;
            LayoutAppTab.KeyController       = _appTabController;

            // When the app button is not visible we need separator instead before start of first tab
            _layoutAppButtonSep = new ViewLayoutSeparator(5, 0)
            {
                Visible = false
            };

            // Used separators around the tabs and the edge elements
            _rightSeparator = new ViewLayoutRibbonSeparator(FAR_TAB_GAP, true);
            _leftSeparator  = new ViewLayoutRibbonSeparator(BUTTON_TAB_GAP_2007, true);

            // Place application button on left  and tabs as the filler (with some separators for neatness)
            Add(_rightSeparator, ViewDockStyle.Left);
            Add(_leftSeparator, ViewDockStyle.Left);
            Add(LayoutAppButton, ViewDockStyle.Left);
            Add(_layoutAppButtonSep, ViewDockStyle.Left);
            Add(LayoutAppTab, ViewDockStyle.Left);
            Add(tabsDocker, ViewDockStyle.Fill);

            // Create button specification collection manager
            PaletteRedirect aeroOverrideText = new PaletteRedirectRibbonAeroOverride(_ribbon, redirect);

            ButtonSpecManager = new ButtonSpecManagerLayoutRibbon(_ribbon, aeroOverrideText, _ribbon.ButtonSpecs, _buttonSpecsFixed,
                                                                  new ViewLayoutDocker[] { tabsDocker },
                                                                  new IPaletteMetric[] { _ribbon.StateCommon },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary },
                                                                  new PaletteMetricPadding[] { PaletteMetricPadding.RibbonButtonPadding },
                                                                  _ribbon.CreateToolStripRenderer,
                                                                  NeedPaintDelegate);

            // Create the manager for handling tooltips
            ToolTipManager                   = new ToolTipManager();
            ToolTipManager.ShowToolTip      += OnShowToolTip;
            ToolTipManager.CancelToolTip    += OnCancelToolTip;
            ButtonSpecManager.ToolTipManager = ToolTipManager;
        }