protected internal virtual void paintText(Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
        {
            FontMetrics fontMetrics = paramGraphics.FontMetrics;
            string      str         = applicationButtonText;
            sbyte       b1          = 40;
            sbyte       b2          = 30;
            int         i           = paramInt1 + paramInt3 / 2 - fontMetrics.stringWidth(str) / 2;
            int         j           = paramInt2 + paramInt4 / 2 - fontMetrics.Height / 2;

            j += 2;
            Rectangle rectangle = new Rectangle(i, j, fontMetrics.stringWidth(str), fontMetrics.Height);

            while (str.Length != 0)
            {
                int k = fontMetrics.stringWidth(str);
                if (k <= rectangle.width)
                {
                    break;
                }
                str = str.Substring(0, str.Length - 1);
            }
            paramGraphics.Color = Color.white;
            BasicGraphicsUtils.drawString(paramGraphics, str, -1, rectangle.x, rectangle.y + fontMetrics.Ascent);
        }
Пример #2
0
        public virtual void paint(Graphics paramGraphics, JComponent paramJComponent)
        {
            if (!(this.commandButton is CostOSRibbonApplicationMenuPopupPanel.JCommandAppMenuButton))
            {
                base.paint(paramGraphics, paramJComponent);
                return;
            }
            int i = 16;

            paramGraphics.Font = FlamingoUtilities.getFont(this.commandButton, new string[] { "Ribbon.font", "Button.font", "Panel.font" });
            this.layoutInfo    = this.layoutManager.getLayoutInfo(this.commandButton, paramGraphics);
            this.commandButton.putClientProperty("icon.bounds", this.layoutInfo.iconRect);
            if (PaintingBackground)
            {
                paintButtonBackground(paramGraphics, new Rectangle(0, 0, this.commandButton.Width, this.commandButton.Height));
            }
            if (this.layoutInfo.iconRect != null)
            {
                paintButtonIcon(paramGraphics, this.layoutInfo.iconRect);
            }
            if (this.layoutInfo.popupActionRect.Width > 0.0D)
            {
                paintPopupActionIcon(paramGraphics, this.layoutInfo.popupActionRect);
            }
            FontMetrics fontMetrics = paramGraphics.FontMetrics;
            bool        @bool       = this.commandButton.Enabled;

            if (this.commandButton is JCommandButton)
            {
                JCommandButton jCommandButton = (JCommandButton)this.commandButton;
                @bool = this.layoutInfo.isTextInActionArea ? jCommandButton.ActionModel.Enabled : jCommandButton.PopupModel.Enabled;
            }
            paramGraphics.Color = getForegroundColor(@bool);
            if (this.layoutInfo.textLayoutInfoList != null)
            {
                foreach (CommandButtonLayoutManager.TextLayoutInfo textLayoutInfo in this.layoutInfo.textLayoutInfoList)
                {
                    if (textLayoutInfo.text != null)
                    {
                        BasicGraphicsUtils.drawString(paramGraphics, textLayoutInfo.text, -1, textLayoutInfo.textRect.x - i, textLayoutInfo.textRect.y + fontMetrics.Ascent);
                    }
                }
            }
            if (@bool)
            {
                paramGraphics.Color = FlamingoUtilities.getColor(Color.gray, new string[] { "Label.disabledForeground" });
            }
            else
            {
                paramGraphics.Color = FlamingoUtilities.getColor(Color.gray, new string[] { "Label.disabledForeground" }).brighter();
            }
            if (this.layoutInfo.extraTextLayoutInfoList != null)
            {
                foreach (CommandButtonLayoutManager.TextLayoutInfo textLayoutInfo in this.layoutInfo.extraTextLayoutInfoList)
                {
                    if (textLayoutInfo.text != null)
                    {
                        BasicGraphicsUtils.drawString(paramGraphics, textLayoutInfo.text, -1, textLayoutInfo.textRect.x, textLayoutInfo.textRect.y + fontMetrics.Ascent);
                    }
                }
            }
            if (PaintingSeparators && this.layoutInfo.separatorArea != null)
            {
                if (this.layoutInfo.separatorOrientation == CommandButtonLayoutManager.CommandButtonSeparatorOrientation.HORIZONTAL)
                {
                    paintButtonHorizontalSeparator(paramGraphics, this.layoutInfo.separatorArea);
                }
                else
                {
                    paintButtonVerticalSeparator(paramGraphics, this.layoutInfo.separatorArea);
                }
            }
        }