Exemplo n.º 1
0
 private void OnShowToolTip(object sender, ToolTipEventArgs e)
 {
     if (!base.IsDisposed)
     {
         Form form = base.FindForm();
         if (((form == null) || form.ContainsFocus) && !base.DesignMode)
         {
             IContentValues contentValues = null;
             LabelStyle     toolTip       = LabelStyle.ToolTip;
             ButtonSpec     buttonSpec    = this._buttonManager.ButtonSpecFromView(e.Target);
             if ((buttonSpec != null) && this.AllowButtonSpecToolTips)
             {
                 ButtonSpecToContent content = new ButtonSpecToContent(base.Redirector, buttonSpec);
                 if (content.HasContent)
                 {
                     contentValues = content;
                     toolTip       = buttonSpec.ToolTipStyle;
                 }
             }
             if (contentValues != null)
             {
                 if (this._visualPopupToolTip != null)
                 {
                     this._visualPopupToolTip.Dispose();
                 }
                 this._visualPopupToolTip           = new VisualPopupToolTip(base.Redirector, contentValues, base.Renderer, PaletteBackStyle.ControlToolTip, PaletteBorderStyle.ControlToolTip, CommonHelper.ContentStyleFromLabelStyle(toolTip));
                 this._visualPopupToolTip.Disposed += new EventHandler(this.OnVisualPopupToolTipDisposed);
                 this._visualPopupToolTip.ShowCalculatingSize(base.RectangleToScreen(e.Target.ClientRectangle));
             }
         }
     }
 }
        private void OnShowToolTip(object sender, ToolTipEventArgs e)
        {
            if (!IsDisposed)
            {
                // Do not show tooltips when the form we are in does not have focus
                Form topForm = _calendar.CalendarControl.FindForm();
                if ((topForm != null) && !topForm.ContainsFocus)
                {
                    return;
                }

                // Never show tooltips are design time
                if (!_calendar.InDesignMode)
                {
                    IContentValues sourceContent = null;
                    LabelStyle     toolTipStyle  = LabelStyle.ToolTip;

                    // Find the button spec associated with the tooltip request
                    ButtonSpec buttonSpec = _buttonManager.ButtonSpecFromView(e.Target);

                    // If the tooltip is for a button spec
                    if (buttonSpec != null)
                    {
                        // Are we allowed to show page related tooltips
                        if (AllowButtonSpecToolTips)
                        {
                            // Create a helper object to provide tooltip values
                            ButtonSpecToContent buttonSpecMapping = new ButtonSpecToContent(_redirector, buttonSpec);

                            // Is there actually anything to show for the tooltip
                            if (buttonSpecMapping.HasContent)
                            {
                                sourceContent = buttonSpecMapping;
                                toolTipStyle  = buttonSpec.ToolTipStyle;
                            }
                        }
                    }

                    if (sourceContent != null)
                    {
                        // Remove any currently showing tooltip
                        _visualPopupToolTip?.Dispose();

                        // Create the actual tooltip popup object
                        _visualPopupToolTip = new VisualPopupToolTip(_redirector,
                                                                     sourceContent,
                                                                     _calendar.GetRenderer(),
                                                                     PaletteBackStyle.ControlToolTip,
                                                                     PaletteBorderStyle.ControlToolTip,
                                                                     CommonHelper.ContentStyleFromLabelStyle(toolTipStyle));

                        _visualPopupToolTip.Disposed += new EventHandler(OnVisualPopupToolTipDisposed);

                        // Show relative to the provided screen rectangle
                        _visualPopupToolTip.ShowCalculatingSize(_calendar.CalendarControl.RectangleToScreen(e.Target.ClientRectangle));
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawMenuItemContent class.
 /// </summary>
 /// <param name="palette">Source of palette display values.</param>
 /// <param name="values">Source of content values.</param>
 /// <param name="columnIndex">Menu item column index.</param>
 public ViewDrawMenuItemContent(IPaletteContent palette,
                                IContentValues values,
                                int columnIndex)
     : base(palette, values, VisualOrientation.Top)
 {
     _columnIndex = columnIndex;
     _overridePreferredWidth = 0;
 }
 /// <summary>
 /// Initialize a new instance of the ViewDrawMenuItemContent class.
 /// </summary>
 /// <param name="palette">Source of palette display values.</param>
 /// <param name="values">Source of content values.</param>
 /// <param name="columnIndex">Menu item column index.</param>
 public ViewDrawMenuItemContent(IPaletteContent palette,
                                IContentValues values,
                                int columnIndex)
     : base(palette, values, VisualOrientation.Top)
 {
     ColumnIndex             = columnIndex;
     _overridePreferredWidth = 0;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initialize a new instance of the VisualPopupTooltip class.
 /// </summary>
 /// <param name="redirector">Redirector for recovering palette values.</param>
 /// <param name="contentValues">Source of content values.</param>
 /// <param name="renderer">Drawing renderer.</param>
 public VisualPopupToolTip(PaletteRedirect redirector,
                           IContentValues contentValues,
                           IRenderer renderer)
     : this(redirector, contentValues, renderer,
            PaletteBackStyle.ControlToolTip,
            PaletteBorderStyle.ControlToolTip,
            PaletteContentStyle.LabelToolTip)
 {
 }
 /// <summary>
 /// Initialize a new instance of the VisualPopupTooltip class.
 /// </summary>
 /// <param name="redirector">Redirector for recovering palette values.</param>
 /// <param name="contentValues">Source of content values.</param>
 /// <param name="renderer">Drawing renderer.</param>
 public VisualPopupToolTip(PaletteRedirect redirector,
                           IContentValues contentValues,
                           IRenderer renderer)
     : this(redirector, contentValues, renderer,
            PaletteBackStyle.ControlToolTip,
            PaletteBorderStyle.ControlToolTip,
            PaletteContentStyle.LabelToolTip)
 {
 }
 /// <summary>
 /// Initialize a new instance of the ViewDrawButton class.
 /// </summary>
 /// <param name="paletteDisabled">Palette source for the disabled state.</param>
 /// <param name="paletteNormal">Palette source for the normal state.</param>
 /// <param name="paletteTracking">Palette source for the tracking state.</param>
 /// <param name="palettePressed">Palette source for the pressed state.</param>
 /// <param name="paletteMetric">Palette source for metric values.</param>
 /// <param name="buttonValues">Source for content values.</param>
 /// <param name="orientation">Visual orientation of the content.</param>
 /// <param name="useMnemonic">Use mnemonics.</param>
 public ViewDrawButton(IPaletteTriple paletteDisabled,
                       IPaletteTriple paletteNormal,
                       IPaletteTriple paletteTracking,
                       IPaletteTriple palettePressed,
                       IPaletteMetric paletteMetric,
                       IContentValues buttonValues,
                       VisualOrientation orientation,
                       bool useMnemonic)
     : this(paletteDisabled, paletteNormal, paletteTracking, palettePressed,
            paletteNormal, paletteTracking, palettePressed, paletteMetric,
            buttonValues, orientation, useMnemonic)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawButton class.
 /// </summary>
 /// <param name="paletteDisabled">Palette source for the disabled state.</param>
 /// <param name="paletteNormal">Palette source for the normal state.</param>
 /// <param name="paletteTracking">Palette source for the tracking state.</param>
 /// <param name="palettePressed">Palette source for the pressed state.</param>
 /// <param name="paletteMetric">Palette source for metric values.</param>
 /// <param name="buttonValues">Source for content values.</param>
 /// <param name="orientation">Visual orientation of the content.</param>
 /// <param name="useMnemonic">Use mnemonics.</param>
 public ViewDrawButton(IPaletteTriple paletteDisabled,
                       IPaletteTriple paletteNormal,
                       IPaletteTriple paletteTracking,
                       IPaletteTriple palettePressed,
                       IPaletteMetric paletteMetric,
                       IContentValues buttonValues,
                       VisualOrientation orientation,
                       bool useMnemonic)
     : this(paletteDisabled, paletteNormal, paletteTracking, palettePressed,
            paletteNormal, paletteTracking, palettePressed, paletteMetric,
            buttonValues, orientation, useMnemonic)
 {
 }
Exemplo n.º 9
0
		/// <summary>
		/// Initialize a new instance of the ViewDrawContent class.
		/// </summary>
		/// <param name="paletteContent">Palette source for the content.</param>
		/// <param name="values">Reference to actual content values.</param>
		/// <param name="orientation">Visual orientation of the content.</param>
		public ViewDrawContent(IPaletteContent paletteContent, 
							   IContentValues values,
							   VisualOrientation orientation)
		{
			// Cache the starting values
			_paletteContent = paletteContent;
			_values = values;
			_orientation = orientation;

            // Default other state
            _drawOnComposition = false;
            _testForFocusCues = false;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawContent class.
        /// </summary>
        /// <param name="paletteContent">Palette source for the content.</param>
        /// <param name="values">Reference to actual content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        public ViewDrawContent(IPaletteContent paletteContent, 
							   IContentValues values,
							   VisualOrientation orientation)
        {
            // Cache the starting values
            _paletteContent = paletteContent;
            _values = values;
            _orientation = orientation;

            // Default other state
            _drawOnComposition = false;
            _testForFocusCues = false;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawContent class.
        /// </summary>
        /// <param name="paletteContent">Palette source for the content.</param>
        /// <param name="values">Reference to actual content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="composition">Draw on composition.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        public ViewDrawContent(IPaletteContent paletteContent,
                               IContentValues values,
                               VisualOrientation orientation,
                               bool composition,
                               bool glowing)
        {
            // Cache the starting values
            _paletteContent = paletteContent;
            Values          = values;
            Orientation     = orientation;

            // Default other state
            DrawContentOnComposition = composition;
            Glowing          = glowing;
            TestForFocusCues = false;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMonthUpDown class.
        /// </summary>
        /// <param name="paletteState">Palette source for states.</param>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="buttonValues">Source for content values.</param>
        /// <param name="glyph">Glyph to be drawn.</param>
        /// <param name="needPaintHandler">Delegate for requests repainting.</param>
        public ViewDrawMonthUpDown(IPaletteTriple paletteState,
                                   IPaletteMetric paletteMetric,
                                   IContentValues buttonValues,
                                   DrawMonthCalendarGlyph glyph,
                                   NeedPaintHandler needPaintHandler)
            : base(paletteState, paletteState, paletteState, paletteState,
                   paletteMetric, buttonValues, VisualOrientation.Top, false)
        {
            _glyph = glyph;

            // Assign a controller to handle visual interaction
            _controller              = new ButtonController(this, needPaintHandler);
            _controller.Click       += OnButtonClick;
            _controller.MouseSelect += OnButtonMouseSelect;
            _controller.Repeat       = true;
            _controller.ClickOnDown  = true;
            MouseController          = _controller;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMonthUpDown class.
        /// </summary>
        /// <param name="paletteState">Palette source for states.</param>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="buttonValues">Source for content values.</param>
        /// <param name="glyph">Glyph to be drawn.</param>
        /// <param name="needPaintHandler">Delegate for requests repainting.</param>
        public ViewDrawMonthUpDown(IPaletteTriple paletteState,
                                   IPaletteMetric paletteMetric,
                                   IContentValues buttonValues,
                                   DrawMonthCalendarGlyph glyph,
                                   NeedPaintHandler needPaintHandler)
            : base(paletteState, paletteState, paletteState, paletteState, 
                   paletteMetric, buttonValues, VisualOrientation.Top, false)
        {
            _glyph = glyph;

            // Assign a controller to handle visual interaction
            _controller = new ButtonController(this, needPaintHandler);
            _controller.Click += new MouseEventHandler(OnButtonClick);
            _controller.MouseSelect += new MouseEventHandler(OnButtonMouseSelect);
            _controller.Repeat = true;
            _controller.ClickOnDown = true;
            MouseController = _controller;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawButton class.
        /// </summary>
        /// <param name="dateTimePicker">Owning control.</param>
        /// <param name="paletteState">Palette source for states.</param>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="buttonValues">Source for content values.</param>
        /// <param name="glyph">Glyph to be drawn.</param>
        /// <param name="needPaintHandler">Delegate for requests repainting.</param>
        /// <param name="repeat">Should button repeat.</param>
        public ViewDrawDateTimeButton(KryptonDateTimePicker dateTimePicker,
                                      IPaletteTriple paletteState,
                                      IPaletteMetric paletteMetric,
                                      IContentValues buttonValues,
                                      DrawDateTimeGlyph glyph,
                                      NeedPaintHandler needPaintHandler,
                                      bool repeat)
            : base(paletteState, paletteState, paletteState, paletteState,
                   paletteMetric, buttonValues, VisualOrientation.Top, false)
        {
            _dateTimePicker = dateTimePicker;
            _glyph          = glyph;

            // Assign a controller to handle visual interaction
            _controller = new ButtonController(this, needPaintHandler);
            _controller.BecomesFixed = !repeat;
            _controller.Click       += new MouseEventHandler(OnButtonClick);
            _controller.MouseSelect += new MouseEventHandler(OnButtonMouseSelect);
            _controller.Repeat       = repeat;
            _controller.ClickOnDown  = true;
            MouseController          = _controller;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawButton class.
        /// </summary>
        /// <param name="dateTimePicker">Owning control.</param>
        /// <param name="paletteState">Palette source for states.</param>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="buttonValues">Source for content values.</param>
        /// <param name="glyph">Glyph to be drawn.</param>
        /// <param name="needPaintHandler">Delegate for requests repainting.</param>
        /// <param name="repeat">Should button repeat.</param>
        public ViewDrawDateTimeButton(KryptonDateTimePicker dateTimePicker,
                                      IPaletteTriple paletteState,
                                      IPaletteMetric paletteMetric,
                                      IContentValues buttonValues,
                                      DrawDateTimeGlyph glyph,
                                      NeedPaintHandler needPaintHandler,
                                      bool repeat)
            : base(paletteState, paletteState, paletteState, paletteState, 
                   paletteMetric, buttonValues, VisualOrientation.Top, false)
        {
            _dateTimePicker = dateTimePicker;
            _glyph = glyph;

            // Assign a controller to handle visual interaction
            _controller = new ButtonController(this, needPaintHandler);
            _controller.BecomesFixed = !repeat;
            _controller.Click += new MouseEventHandler(OnButtonClick);
            _controller.MouseSelect += new MouseEventHandler(OnButtonMouseSelect);
            _controller.Repeat = repeat;
            _controller.ClickOnDown = true;
            MouseController = _controller;
        }
Exemplo n.º 16
0
        private void UpdateContentFromItemIndex(int index)
        {
            IContentValues itemValues = Items[index] as IContentValues;

            // If the object exposes the rich interface then use is...
            if (itemValues != null)
            {
                _contentValues.ShortText = itemValues.GetShortText();
                _contentValues.LongText  = itemValues.GetLongText();

                // _contentValues.Image = itemValues.GetImage(PaletteState.Normal);
                // _contentValues.ImageTransparentColor = itemValues.GetImageTransparentColor(PaletteState.Normal);
            }
            else
            {
                // Get the text string for the item
                _contentValues.ShortText = _listBox.GetItemText(Items[index]);
                _contentValues.LongText  = null;

                // _contentValues.Image = null;
                // _contentValues.ImageTransparentColor = Color.Empty;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initialize a new instance of the VisualPopupTooltip class.
        /// </summary>
        /// <param name="redirector">Redirector for recovering palette values.</param>
        /// <param name="contentValues">Source of content values.</param>
        /// <param name="renderer">Drawing renderer.</param>
        /// <param name="backStyle">Style for the tooltip background.</param>
        /// <param name="borderStyle">Style for the tooltip border.</param>
        /// <param name="contentStyle">Style for the tooltip content.</param>
        public VisualPopupToolTip(PaletteRedirect redirector,
                                  IContentValues contentValues,
                                  IRenderer renderer,
                                  PaletteBackStyle backStyle,
                                  PaletteBorderStyle borderStyle,
                                  PaletteContentStyle contentStyle)
            : base(renderer, true)
        {
            Debug.Assert(contentValues != null);

            // Remember references needed later
            _contentValues = contentValues;

            // Create the triple redirector needed by view elements
            _palette = new PaletteTripleMetricRedirect(redirector, backStyle, borderStyle, contentStyle, NeedPaintDelegate);

            // Our view contains background and border with content inside
            _drawDocker  = new ViewDrawDocker(_palette.Back, _palette.Border, null);
            _drawContent = new ViewDrawContent(_palette.Content, _contentValues, VisualOrientation.Top);
            _drawDocker.Add(_drawContent, ViewDockStyle.Fill);

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawDocker);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initialize a new instance of the VisualPopupTooltip class.
        /// </summary>
        /// <param name="redirector">Redirector for recovering palette values.</param>
        /// <param name="contentValues">Source of content values.</param>
        /// <param name="renderer">Drawing renderer.</param>
        /// <param name="backStyle">Style for the tooltip background.</param>
        /// <param name="borderStyle">Style for the tooltip border.</param>
        /// <param name="contentStyle">Style for the tooltip content.</param>
        public VisualPopupToolTip(PaletteRedirect redirector,
                                  IContentValues contentValues,
                                  IRenderer renderer,
                                  PaletteBackStyle backStyle,
                                  PaletteBorderStyle borderStyle,
                                  PaletteContentStyle contentStyle)
            : base(renderer, true)
        {
            Debug.Assert(contentValues != null);

            // Remember references needed later
            _contentValues = contentValues;

            // Create the triple redirector needed by view elements
            _palette = new PaletteTripleMetricRedirect(redirector, backStyle, borderStyle, contentStyle, NeedPaintDelegate);

            // Our view contains background and border with content inside
            _drawDocker = new ViewDrawDocker(_palette.Back, _palette.Border, null);
            _drawContent = new ViewDrawContent(_palette.Content, _contentValues, VisualOrientation.Top);
            _drawDocker.Add(_drawContent, ViewDockStyle.Fill);

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawDocker);
        }
Exemplo n.º 19
0
        private void OnShowToolTip(object sender, ToolTipEventArgs e)
        {
            if (!_ribbon.IsDisposed)
            {
                // Do not show tooltips when the form we are in does not have focus
                Form topForm = _ribbon.FindForm();
                if ((topForm != null) && !topForm.ContainsFocus)
                {
                    return;
                }

                // Never show tooltips are design time
                if (!_ribbon.InDesignMode)
                {
                    IContentValues sourceContent = null;
                    LabelStyle     toolTipStyle  = LabelStyle.SuperTip;
                    Rectangle      screenRect    = new Rectangle(e.ScreenPt, new Size(1, 1));

                    // If the target is the application button
                    if ((e.Target is ViewLayoutRibbonAppButton) || (e.Target is ViewLayoutRibbonAppTab))
                    {
                        // Create a content that recovers values from a the ribbon for the app button/tab
                        AppButtonToolTipToContent appButtonContent = new AppButtonToolTipToContent(_ribbon);

                        // Is there actually anything to show for the tooltip
                        if (appButtonContent.HasContent)
                        {
                            sourceContent = appButtonContent;

                            // Grab the style from the app button settings
                            toolTipStyle = _ribbon.RibbonAppButton.AppButtonToolTipStyle;

                            // Display below the mouse cursor
                            screenRect.Height += SystemInformation.CursorSize.Height / 3 * 2;
                        }
                    }
                    else
                    {
                        // If the target is a QAT button
                        if (e.Target is ViewDrawRibbonQATButton)
                        {
                            // Cast to correct type
                            ViewDrawRibbonQATButton viewElement = (ViewDrawRibbonQATButton)e.Target;

                            // Create a content that recovers values from a IQuickAccessToolbarButton
                            QATButtonToolTipToContent qatButtonContent = new QATButtonToolTipToContent(viewElement.QATButton);

                            // Is there actually anything to show for the tooltip
                            if (qatButtonContent.HasContent)
                            {
                                sourceContent = qatButtonContent;

                                // Grab the style from the QAT button settings
                                toolTipStyle = viewElement.QATButton.GetToolTipStyle();

                                // Display below the mouse cursor
                                screenRect.Height += SystemInformation.CursorSize.Height / 3 * 2;
                            }
                        }
                        else
                        {
                            // If the target is a label
                            if ((e.Target.Parent != null) && (e.Target.Parent is ViewDrawRibbonGroupLabel))
                            {
                                // Cast to correct type
                                ViewDrawRibbonGroupLabel viewElement = (ViewDrawRibbonGroupLabel)e.Target.Parent;

                                // Create a content that recovers values from a KryptonRibbonGroupItem
                                GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement.GroupLabel);

                                // Is there actually anything to show for the tooltip
                                if (groupItemContent.HasContent)
                                {
                                    sourceContent = groupItemContent;

                                    // Grab the style from the group label settings
                                    toolTipStyle = viewElement.GroupLabel.ToolTipStyle;

                                    // Display below the bottom of the ribbon control
                                    Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle;
                                    screenRect.Y      = ribbonScreenRect.Y;
                                    screenRect.Height = ribbonScreenRect.Height;
                                    screenRect.X      = ribbonScreenRect.X + viewElement.ClientLocation.X;
                                    screenRect.Width  = viewElement.ClientWidth;
                                }
                            }
                            else
                            {
                                // Is the target is a button or cluster button
                                if (e.Target is ViewDrawRibbonGroupButtonBackBorder)
                                {
                                    // Cast to correct type
                                    ViewDrawRibbonGroupButtonBackBorder viewElement = (ViewDrawRibbonGroupButtonBackBorder)e.Target;

                                    // Create a content that recovers values from a KryptonRibbonGroupItem
                                    GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement.GroupItem);

                                    // Is there actually anything to show for the tooltip
                                    if (groupItemContent.HasContent)
                                    {
                                        sourceContent = groupItemContent;

                                        // Grab the style from the group button/group cluster button settings
                                        toolTipStyle = viewElement.GroupItem.InternalToolTipStyle;

                                        // Display below the bottom of the ribbon control
                                        Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle;
                                        screenRect.Y      = ribbonScreenRect.Y;
                                        screenRect.Height = ribbonScreenRect.Height;
                                        screenRect.X      = ribbonScreenRect.X + viewElement.ClientLocation.X;
                                        screenRect.Width  = viewElement.ClientWidth;
                                    }
                                }
                                else
                                {
                                    if (e.Target is ViewLayoutRibbonCheckBox)
                                    {
                                        // Cast to correct type
                                        ViewDrawRibbonGroupCheckBox viewElement = (ViewDrawRibbonGroupCheckBox)e.Target.Parent;

                                        // Create a content that recovers values from a KryptonRibbonGroupItem
                                        GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement.GroupCheckBox);

                                        // Is there actually anything to show for the tooltip
                                        if (groupItemContent.HasContent)
                                        {
                                            sourceContent = groupItemContent;

                                            // Grab the style from the group check box cluster button settings
                                            toolTipStyle = viewElement.GroupCheckBox.InternalToolTipStyle;

                                            // Display below the bottom of the ribbon control
                                            Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle;
                                            screenRect.Y      = ribbonScreenRect.Y;
                                            screenRect.Height = ribbonScreenRect.Height;
                                            screenRect.X      = ribbonScreenRect.X + viewElement.ClientLocation.X;
                                            screenRect.Width  = viewElement.ClientWidth;
                                        }
                                    }
                                    else
                                    {
                                        if (e.Target is ViewLayoutRibbonRadioButton)
                                        {
                                            // Cast to correct type
                                            ViewDrawRibbonGroupRadioButton viewElement = (ViewDrawRibbonGroupRadioButton)e.Target.Parent;

                                            // Create a content that recovers values from a KryptonRibbonGroupItem
                                            GroupItemToolTipToContent groupItemContent = new GroupItemToolTipToContent(viewElement.GroupRadioButton);

                                            // Is there actually anything to show for the tooltip
                                            if (groupItemContent.HasContent)
                                            {
                                                sourceContent = groupItemContent;

                                                // Grab the style from the group radio button button settings
                                                toolTipStyle = viewElement.GroupRadioButton.InternalToolTipStyle;

                                                // Display below the bottom of the ribbon control
                                                Rectangle ribbonScreenRect = _ribbon.ToolTipScreenRectangle;
                                                screenRect.Y      = ribbonScreenRect.Y;
                                                screenRect.Height = ribbonScreenRect.Height;
                                                screenRect.X      = ribbonScreenRect.X + viewElement.ClientLocation.X;
                                                screenRect.Width  = viewElement.ClientWidth;
                                            }
                                        }
                                        else
                                        {
                                            // Find the button spec associated with the tooltip request
                                            ButtonSpec buttonSpec = _buttonManager.ButtonSpecFromView(e.Target);

                                            // If the tooltip is for a button spec
                                            if (buttonSpec != null)
                                            {
                                                // Are we allowed to show page related tooltips
                                                if (_ribbon.AllowButtonSpecToolTips)
                                                {
                                                    // Create a helper object to provide tooltip values
                                                    ButtonSpecToContent buttonSpecMapping = new ButtonSpecToContent(_ribbon.GetRedirector(), buttonSpec);

                                                    // Is there actually anything to show for the tooltip
                                                    if (buttonSpecMapping.HasContent)
                                                    {
                                                        sourceContent = buttonSpecMapping;

                                                        // Grab the style from the button spec settings
                                                        toolTipStyle = buttonSpec.ToolTipStyle;

                                                        // Display below the mouse cursor
                                                        screenRect.Height += SystemInformation.CursorSize.Height / 3 * 2;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (sourceContent != null)
                    {
                        // Remove any currently showing tooltip
                        _visualPopupToolTip?.Dispose();

                        // Create the actual tooltip popup object
                        _visualPopupToolTip = new VisualPopupToolTip(_ribbon.GetRedirector(),
                                                                     sourceContent,
                                                                     _ribbon.Renderer,
                                                                     PaletteBackStyle.ControlToolTip,
                                                                     PaletteBorderStyle.ControlToolTip,
                                                                     CommonHelper.ContentStyleFromLabelStyle(toolTipStyle));

                        _visualPopupToolTip.Disposed += new EventHandler(OnVisualPopupToolTipDisposed);

                        // The popup tooltip control always adds on a border above/below so we negate that here.
                        screenRect.Height -= 20;

                        // Show relative to the provided screen rectangle
                        _visualPopupToolTip.ShowCalculatingSize(screenRect);
                    }
                }
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawRibbonRecentShortcut class.
 /// </summary>
 /// <param name="paletteContent">Palette source for the content.</param>
 /// <param name="values">Reference to actual content values.</param>
 public ViewDrawRibbonRecentShortcut(IPaletteContent paletteContent,
                                     IContentValues values)
     : base(paletteContent, values, VisualOrientation.Top)
 {
 }
Exemplo n.º 21
0
        private static void AllocateShortTextSpace(ViewLayoutContext context,
                                                   Graphics g,
                                                   StandardContentMemento memento,
                                                   IPaletteContent paletteContent,
                                                   IContentValues contentValues,
                                                   PaletteState state,
                                                   Rectangle displayRect,
                                                   RightToLeft rtl,
                                                   int spacingGap,
                                                   ref Size[,] allocation,
                                                   bool composition,
                                                   bool glowing)
        {
            // By default, we cannot draw the text
            memento.DrawShortText = false;

            // Get the defined text for display
            string shortText = contentValues.GetShortText();

            // Is there any text to be drawn?
            if ((shortText != null) && (shortText.Length > 0))
            {
                // If the text is not allowed to span multiple lines
                if (paletteContent.GetContentShortTextMultiLine(state) == InheritBool.False)
                {
                    // Replace any carriage returns and newlines with just spaces
                    shortText = shortText.Replace("\r\n", " ");
                    shortText = shortText.Replace("\n", " ");
                    shortText = shortText.Replace("\r", " ");
                }

                // Convert from alignment enums to integers
                int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentShortTextH(state));
                int alignVIndex = (int)paletteContent.GetContentShortTextV(state);

                // Cache the rendering hint used
                memento.ShortTextHint = CommonHelper.PaletteTextHintToRenderingHint(paletteContent.GetContentShortTextHint(state));
                memento.ShortTextTrimming = paletteContent.GetContentShortTextTrim(state);

                bool fontChanged = false;
                Font textFont = paletteContent.GetContentShortTextFont(state);

                // Get the appropriate font to use in the caption area
                if (paletteContent.GetContentStyle() == PaletteContentStyle.HeaderForm)
                {
                    Font captionFont = ContentFontForButtonForm(context, textFont);
                    fontChanged = (captionFont != textFont);
                    textFont = captionFont;
                }

                // Get a pixel accurate measure of text drawing space needed
                memento.ShortTextMemento = AccurateText.MeasureString(g,
                                                                      rtl,
                                                                      shortText,
                                                                      textFont,
                                                                      memento.ShortTextTrimming,
                                                                      paletteContent.GetContentShortTextMultiLineH(state),
                                                                      paletteContent.GetContentShortTextPrefix(state),
                                                                      memento.ShortTextHint,
                                                                      composition,
                                                                      glowing,
                                                                      fontChanged);

                // Space required for short text starts with the text width itself
                Size requiredSpace = memento.ShortTextMemento.Size;

                // Find the space available given our required alignment
                if (AllocateAlignmentSpace(alignHIndex, alignVIndex,
                                           allocation, displayRect,
                                           spacingGap, memento.ShortTextTrimming,
                                           ref requiredSpace))
                {
                    // Allocate the actual space used up
                    // Cache the actual draw size of the text
                    memento.ShortTextRect.Size = requiredSpace;

                    // Mark the memento to draw the short text
                    memento.DrawShortText = true;
                }
            }
        }
Exemplo n.º 22
0
        private static void AllocateImageSpace(StandardContentMemento memento,
                                               IPaletteContent paletteContent,
                                               IContentValues contentValues,
                                               PaletteState state,
                                               Rectangle displayRect,
                                               RightToLeft rtl,
                                               ref Size[,] allocation)
        {
            // By default, we cannot draw the image
            memento.DrawImage = false;

            // Get the image details
            memento.Image = contentValues.GetImage(state);
            memento.ImageTransparentColor = contentValues.GetImageTransparentColor(state);

            // Is there any image to be drawn?
            if (memento.Image != null)
            {
                try
                {
                    // Cache the size of the image
                    memento.ImageRect.Size = memento.Image.Size;

                    // Check for enough space to show all of the image
                    if ((displayRect.Width >= memento.ImageRect.Width) &&
                        (displayRect.Height >= memento.ImageRect.Height))
                    {
                        // Convert from alignment enums to integers
                        int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentImageH(state));
                        int alignVIndex = (int)paletteContent.GetContentImageV(state);

                        // Bump the allocated space in the destination grid cell
                        allocation[alignHIndex, alignVIndex].Width += memento.ImageRect.Width;
                        allocation[alignHIndex, alignVIndex].Height += memento.ImageRect.Height;

                        // Yes, we do want to draw the image/icon
                        memento.DrawImage = true;
                    }
                }
                catch
                {
                    // Image is not valid, so do not use it!
                    memento.Image = null;
                    memento.DrawImage = false;
                }
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonRecentShortcut class.
        /// </summary>
        /// <param name="paletteContent">Palette source for the content.</param>
        /// <param name="values">Reference to actual content values.</param>
        public ViewDrawRibbonRecentShortcut(IPaletteContent paletteContent, 
							                IContentValues values)
            : base(paletteContent, values, VisualOrientation.Top)
        {
        }
Exemplo n.º 24
0
        /// <summary>
        /// Get the preferred size for drawing the content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Drawing onto a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Preferred size.</returns>
        public abstract Size GetContentPreferredSize(ViewLayoutContext context,
													 IPaletteContent palette,
													 IContentValues values,
													 VisualOrientation orientation,
													 PaletteState state,
                                                     bool composition,
                                                     bool glowing);
Exemplo n.º 25
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawButton class.
        /// </summary>
        /// <param name="paletteDisabled">Palette source for the disabled state.</param>
        /// <param name="paletteNormal">Palette source for the normal state.</param>
        /// <param name="paletteTracking">Palette source for the tracking state.</param>
        /// <param name="palettePressed">Palette source for the pressed state.</param>
        /// <param name="paletteCheckedNormal">Palette source for the normal checked state.</param>
        /// <param name="paletteCheckedTracking">Palette source for the tracking checked state.</param>
        /// <param name="paletteCheckedPressed">Palette source for the pressed checked state.</param>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="buttonValues">Source for content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="useMnemonic">Use mnemonics.</param>
        public ViewDrawButton(IPaletteTriple paletteDisabled,
							  IPaletteTriple paletteNormal,
							  IPaletteTriple paletteTracking,
							  IPaletteTriple palettePressed,
                              IPaletteTriple paletteCheckedNormal,
                              IPaletteTriple paletteCheckedTracking,
                              IPaletteTriple paletteCheckedPressed,
                              IPaletteMetric paletteMetric,
                              IContentValues buttonValues,
							  VisualOrientation orientation,
							  bool useMnemonic)
        {
            // Remember the source information
            _paletteDisabled = paletteDisabled;
            _paletteNormal = paletteNormal;
            _paletteTracking = paletteTracking;
            _palettePressed = palettePressed;
            _paletteCheckedNormal = paletteCheckedNormal;
            _paletteCheckedTracking = paletteCheckedTracking;
            _paletteCheckedPressed = paletteCheckedPressed;
            _paletteCurrent = _paletteNormal;

            // Default to not being checked
            _checked = false;
            _allowUncheck = true;
            _dropDown = false;
            _splitter = false;
            _dropDownPosition = VisualOrientation.Right;

            // Create the drop down view
            _drawDropDown = new ViewLayoutCenter(1);
            _drawDropDownButton = new ViewDrawDropDownButton();
            _drawDropDown.Add(_drawDropDownButton);
            _drawOuterSeparator = new ViewLayoutSeparator(1);

            // Create the view used to draw the split edge
            _edgeRedirect = new PaletteBorderEdgeRedirect(_paletteNormal.PaletteBorder, null);
            _drawSplitBorder = new ViewDrawBorderEdge(new PaletteBorderEdge(_edgeRedirect, null), CommonHelper.VisualToOrientation(orientation));

            // Our view contains background and border with content inside
            _drawContent = new ViewDrawContent(_paletteNormal.PaletteContent, buttonValues, orientation);
            _drawCanvas = new ViewDrawSplitCanvas(_paletteNormal.PaletteBack, _paletteNormal.PaletteBorder, paletteMetric, PaletteMetricPadding.None, orientation);

            // Use a docker layout to organize the contents of the canvas
            _layoutDocker = new ViewLayoutDocker();
            _layoutDocker.Add(_drawContent, ViewDockStyle.Fill);
            _layoutDocker.Add(_drawSplitBorder, ViewDockStyle.Right);
            _layoutDocker.Add(_drawDropDown, ViewDockStyle.Right);
            _layoutDocker.Add(_drawOuterSeparator, ViewDockStyle.Right);
            _layoutDocker.Tag = this;

            // Pass the mnemonic default to the content view
            _drawContent.UseMnemonic = useMnemonic;

            // Place the content inside the canvas
            _drawCanvas.Add(_layoutDocker);

            // Set initial view element visible states
            UpdateDropDown();

            // Place the canvas inside ourself
            Add(_drawCanvas);
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawButton class.
        /// </summary>
        /// <param name="paletteDisabled">Palette source for the disabled state.</param>
        /// <param name="paletteNormal">Palette source for the normal state.</param>
        /// <param name="paletteTracking">Palette source for the tracking state.</param>
        /// <param name="palettePressed">Palette source for the pressed state.</param>
        /// <param name="paletteCheckedNormal">Palette source for the normal checked state.</param>
        /// <param name="paletteCheckedTracking">Palette source for the tracking checked state.</param>
        /// <param name="paletteCheckedPressed">Palette source for the pressed checked state.</param>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="buttonValues">Source for content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="useMnemonic">Use mnemonics.</param>
        public ViewDrawButton(IPaletteTriple paletteDisabled,
                              IPaletteTriple paletteNormal,
                              IPaletteTriple paletteTracking,
                              IPaletteTriple palettePressed,
                              IPaletteTriple paletteCheckedNormal,
                              IPaletteTriple paletteCheckedTracking,
                              IPaletteTriple paletteCheckedPressed,
                              IPaletteMetric paletteMetric,
                              IContentValues buttonValues,
                              VisualOrientation orientation,
                              bool useMnemonic)
        {
            // Remember the source information
            _paletteDisabled        = paletteDisabled;
            _paletteNormal          = paletteNormal;
            _paletteTracking        = paletteTracking;
            _palettePressed         = palettePressed;
            _paletteCheckedNormal   = paletteCheckedNormal;
            _paletteCheckedTracking = paletteCheckedTracking;
            _paletteCheckedPressed  = paletteCheckedPressed;
            CurrentPalette          = _paletteNormal;

            // Default to not being checked
            Checked           = false;
            AllowUncheck      = true;
            _dropDown         = false;
            _splitter         = false;
            _dropDownPosition = VisualOrientation.Right;

            // Create the drop down view
            _drawDropDown       = new ViewLayoutCenter(1);
            _drawDropDownButton = new ViewDrawDropDownButton();
            _drawDropDown.Add(_drawDropDownButton);
            _drawOuterSeparator = new ViewLayoutSeparator(1);

            // Create the view used to draw the split edge
            _edgeRedirect    = new PaletteBorderEdgeRedirect(_paletteNormal.PaletteBorder, null);
            _drawSplitBorder = new ViewDrawBorderEdge(new PaletteBorderEdge(_edgeRedirect, null), CommonHelper.VisualToOrientation(orientation));

            // Our view contains background and border with content inside
            _drawContent = new ViewDrawContent(_paletteNormal.PaletteContent, buttonValues, orientation);
            _drawCanvas  = new ViewDrawSplitCanvas(_paletteNormal.PaletteBack, _paletteNormal.PaletteBorder, paletteMetric, PaletteMetricPadding.None, orientation);

            // Use a docker layout to organize the contents of the canvas
            LayoutDocker = new ViewLayoutDocker
            {
                { _drawContent, ViewDockStyle.Fill },
                { _drawSplitBorder, ViewDockStyle.Right },
                { _drawDropDown, ViewDockStyle.Right },
                { _drawOuterSeparator, ViewDockStyle.Right }
            };
            LayoutDocker.Tag = this;

            // Pass the mnemonic default to the content view
            _drawContent.UseMnemonic = useMnemonic;

            // Place the content inside the canvas
            _drawCanvas.Add(LayoutDocker);

            // Set initial view element visible states
            UpdateDropDown();

            // Place the canvas inside ourself
            Add(_drawCanvas);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Get the preferred size for drawing the content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Should draw on a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Preferred size.</returns>
        public override Size GetContentPreferredSize(ViewLayoutContext context,
													 IPaletteContent palette,
													 IContentValues values,
													 VisualOrientation orientation,
                                                     PaletteState state,
                                                     bool composition,
                                                     bool glowing)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);
            Debug.Assert(values != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Provide a maximum sized rectangle for placing content into, in
            // order to work out how much of the space is actually allocated
            Rectangle displayRect = new Rectangle(Point.Empty, new Size(int.MaxValue, int.MaxValue));

            // Track the allocated space in each grid position
            Size[,] allocation = new Size[3, 3] { { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty } };

            // Create a memento for storing calculations
            using (StandardContentMemento memento = new StandardContentMemento())
            {
                // Cache the size of a spacing gap
                int spacingGap = palette.GetContentAdjacentGap(state);

                // Is the content intended for a vertical drawing orientation?
                bool vertical = (orientation == VisualOrientation.Left) ||
                                (orientation == VisualOrientation.Right);

                // Drawing vertical means we can ignore right to left, otherwise get value from control
                RightToLeft rtl = (vertical ? RightToLeft.No : context.Control.RightToLeft);

                // Allocate space for each required content in turn
                AllocateImageSpace(memento, palette, values, state, displayRect, rtl, ref allocation);
                AllocateShortTextSpace(context, context.Graphics, memento, palette, values, state, displayRect, rtl, spacingGap, ref allocation, composition, glowing);
                AllocateLongTextSpace(context, context.Graphics, memento, palette, values, state, displayRect, rtl, spacingGap, ref allocation, composition, glowing);

                // Add up total allocated for rows and columns
                int allocatedWidth = AllocatedTotalWidth(allocation, -1, -1, spacingGap);
                int allocatedHeight = AllocatedTotalHeight(allocation);

                // Grab the padding for the content
                Padding borderPadding = palette.GetContentPadding(state);

                // For the form level buttons we have to calculate the correct padding based on caption area
                PaletteContentStyle contentStyle = palette.GetContentStyle();
                if ((contentStyle == PaletteContentStyle.ButtonForm) ||
                    (contentStyle == PaletteContentStyle.ButtonFormClose))
                    borderPadding = ContentPaddingForButtonForm(borderPadding, context, allocatedHeight);

                // The preferred size needed depends on the orientation.
                switch (orientation)
                {
                    case VisualOrientation.Top:
                    case VisualOrientation.Bottom:
                        // Preferred size is the allocated space for the content plus the border padding
                        return new Size(allocatedWidth + borderPadding.Horizontal,
                                        allocatedHeight + borderPadding.Vertical);
                    case VisualOrientation.Left:
                    case VisualOrientation.Right:
                        // Preferred size is the allocated space for the content plus the border padding
                        return new Size(allocatedHeight + borderPadding.Vertical,
                                        allocatedWidth + borderPadding.Horizontal);
                    default:
                        // Should never happen!
                        Debug.Assert(false);
                        return Size.Empty;
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Perform layout calculations on the provided content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="availableRect">Space available for laying out.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Drawing onto a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Memento with cached information.</returns>
        public abstract IDisposable LayoutContent(ViewLayoutContext context,
											      Rectangle availableRect,
											      IPaletteContent palette,
											      IContentValues values,
											      VisualOrientation orientation,
											      PaletteState state,
                                                  bool composition, 
                                                  bool glowing);
Exemplo n.º 29
0
        /// <summary>
        /// Perform layout calculations on the provided content.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <param name="availableRect">Display area available for laying out.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="values">Content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Should draw on a composition element.</param>
        /// <param name="glowing">If composition, should glowing be drawn.</param>
        /// <returns>Memento with cached information.</returns>
        public override IDisposable LayoutContent(ViewLayoutContext context,
											      Rectangle availableRect,
											      IPaletteContent palette,
											      IContentValues values,
											      VisualOrientation orientation,
											      PaletteState state,
                                                  bool composition,
                                                  bool glowing)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);
            Debug.Assert(values != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Remember the original value, for use later
            Rectangle cacheDisplayRect = availableRect;

            // Grab the padding for the content
            Padding borderPadding = palette.GetContentPadding(state);

            // Is the content intended for a vertical drawing orientation?
            bool vertical = (orientation == VisualOrientation.Left) ||
                            (orientation == VisualOrientation.Right);

            // If we need to apply in a vertical orientation
            if (vertical)
            {
                // Our algorithm only works by assuming a left to right horizontal
                // orientation, so we adjust the display rect to that orientation
                // and then at the end adjust the memento produced back to the
                // required orientation again. 'AdjustForOrientation'
                int temp = availableRect.Width;
                availableRect.Width = availableRect.Height;
                availableRect.Height = temp;
            }

            // Apply padding to the rectangle
            availableRect.X += borderPadding.Left;
            availableRect.Y += borderPadding.Top;
            availableRect.Width -= borderPadding.Horizontal;
            availableRect.Height -= borderPadding.Vertical;

            // If we need to apply in a vertical orientation
            if (vertical)
            {
                // This is the display rect we need to use in 'AdjustForOrientation'
                // and cache it for later. The displayRect itself is modified during
                // the below process and so cannot be used directly.
                int temp = cacheDisplayRect.Width;
                cacheDisplayRect.Width = cacheDisplayRect.Height;
                cacheDisplayRect.Height = temp;
            }

            // Track the allocated space in each grid position
            Size[,] allocation = new Size[3, 3] { { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty },
                                                  { Size.Empty, Size.Empty, Size.Empty } };

            // Create a memento to return to caller
            StandardContentMemento memento = new StandardContentMemento();

            // Cache the size of a spacing gap
            int spacingGap = palette.GetContentAdjacentGap(state);

            // Drawing vertical means we can ignore right to left, otherwise get value from control
            RightToLeft rtl = (vertical ? RightToLeft.No : context.Control.RightToLeft);

            // Allocate space for each required content in turn
            AllocateImageSpace(memento, palette, values, state, availableRect, rtl, ref allocation);
            AllocateShortTextSpace(context, context.Graphics, memento, palette, values, state, availableRect, rtl, spacingGap, ref allocation, composition, glowing);
            AllocateLongTextSpace(context, context.Graphics, memento, palette, values, state, availableRect, rtl, spacingGap, ref allocation, composition, glowing);

            // Find the width of the columns and heights of the rows
            int[] colWidths = AllocatedColumnWidths(allocation, -1);
            int[] rowHeights = AllocatedRowHeights(allocation);

            // Add up total allocated for rows and columns
            int allocatedWidth = AllocatedTotalWidth(allocation, -1, -1, spacingGap);
            int allocatedHeight = AllocatedTotalHeight(allocation);

            // Excess width to allocate?
            if (allocatedWidth < availableRect.Width)
                ApplyExcessSpace(availableRect.Width - allocatedWidth, ref colWidths);

            // Excess height to allocate?
            if (allocatedHeight < availableRect.Height)
                rowHeights[1] += (availableRect.Height - allocatedHeight);

            // Find x positions and y positions
            int col0 = availableRect.Left;
            int col1 = col0 + colWidths[0];

            // Do we need to add a spacing gap after the first column?
            if (((colWidths[0] > 0) && (colWidths[1] > 0)) ||
                ((colWidths[0] > 0) && (colWidths[1] == 0) && (colWidths[2] > 0)))
                col1 += spacingGap;

            int col2 = col1 + colWidths[1];

            // Do we need to add a spacing gap after the second column?
            if ((colWidths[1] > 0) && (colWidths[2] > 0))
                col2 += spacingGap;

            int row0 = availableRect.Top;
            int row1 = row0 + rowHeights[0];
            int row2 = row1 + rowHeights[1];

            // Decide on the ordering of the alignment to position
            PaletteRelativeAlign aAlign = (rtl == RightToLeft.Yes ? PaletteRelativeAlign.Far : PaletteRelativeAlign.Near);
            PaletteRelativeAlign bAlign = PaletteRelativeAlign.Center;
            PaletteRelativeAlign cAlign = (rtl == RightToLeft.Yes ? PaletteRelativeAlign.Near : PaletteRelativeAlign.Far);

            // Size and position the contents of each aligned cell
            PositionAlignContent(memento, palette, state, rtl, aAlign, PaletteRelativeAlign.Near, col0, row0, colWidths[0], rowHeights[0], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, aAlign, PaletteRelativeAlign.Center, col0, row1, colWidths[0], rowHeights[1], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, aAlign, PaletteRelativeAlign.Far, col0, row2, colWidths[0], rowHeights[2], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, bAlign, PaletteRelativeAlign.Near, col1, row0, colWidths[1], rowHeights[0], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, bAlign, PaletteRelativeAlign.Center, col1, row1, colWidths[1], rowHeights[1], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, bAlign, PaletteRelativeAlign.Far, col1, row2, colWidths[1], rowHeights[2], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, cAlign, PaletteRelativeAlign.Near, col2, row0, colWidths[2], rowHeights[0], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, cAlign, PaletteRelativeAlign.Center, col2, row1, colWidths[2], rowHeights[1], spacingGap);
            PositionAlignContent(memento, palette, state, rtl, cAlign, PaletteRelativeAlign.Far, col2, row2, colWidths[2], rowHeights[2], spacingGap);

            // Ask the memento to adjust itself for the required orientation
            memento.AdjustForOrientation(orientation, cacheDisplayRect);

            return memento;
        }