예제 #1
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void onPaintForeground(FCPaint paint, FCRect clipRect)
        {
            String text = Text;
            int    width = Width, height = Height;

            if (width > 0 && height > 0)
            {
                FCRect  buttonRect = new FCRect(5, (height - m_buttonSize.cy) / 2, 5 + m_buttonSize.cx, (height + m_buttonSize.cy) / 2);
                FCPoint tLocation  = new FCPoint();
                FCSize  tSize      = new FCSize();
                FCFont  font       = Font;
                if (text != null && text.Length > 0)
                {
                    tSize       = paint.textSize(text, font);
                    tLocation.x = buttonRect.right + 5;
                    tLocation.y = (height - tSize.cy) / 2;
                }
                //居中
                if (m_buttonAlign == FCHorizontalAlign.Center)
                {
                    buttonRect.left  = (width - m_buttonSize.cx) / 2;
                    buttonRect.right = (width + m_buttonSize.cx) / 2;
                    tLocation.x      = buttonRect.right + 5;
                }
                //远离
                else if (m_buttonAlign == FCHorizontalAlign.Right)
                {
                    buttonRect.left  = width - m_buttonSize.cx - 5;
                    buttonRect.right = width - 5;
                    tLocation.x      = buttonRect.left - tSize.cx - 5;
                }
                //绘制背景图
                onPaintCheckButton(paint, buttonRect);
                //绘制文字
                if (text != null && text.Length > 0)
                {
                    FCRect tRect     = new FCRect(tLocation.x, tLocation.y, tLocation.x + tSize.cx + 1, tLocation.y + tSize.cy);
                    long   textColor = getPaintingTextColor();
                    if (AutoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom))
                    {
                        if (tRect.right > clipRect.right)
                        {
                            tRect.right = clipRect.right;
                        }
                        if (tRect.bottom > clipRect.bottom)
                        {
                            tRect.bottom = clipRect.bottom;
                        }
                        paint.drawTextAutoEllipsis(text, textColor, font, tRect);
                    }
                    else
                    {
                        paint.drawText(text, textColor, font, tRect);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void onPaint(FCPaint paint, FCRect rect, FCRect clipRect, bool isAlternate)
        {
            int       clipW = clipRect.right - clipRect.left;
            int       clipH = clipRect.bottom - clipRect.top;
            FCGrid    grid  = Grid;
            FCGridRow row   = Row;

            if (clipW > 0 && clipH > 0 && grid != null && Column != null && row != null && TargetColumn != null)
            {
                int          width      = rect.right - rect.left;
                int          height     = rect.bottom - rect.top;
                int          scrollH    = 0;
                FCHScrollBar hscrollBar = grid.HScrollBar;
                if (hscrollBar != null && hscrollBar.Visible)
                {
                    scrollH = hscrollBar.Pos;
                }
                FCFont          font         = null;
                long            backColor    = FCColor.None;
                long            textColor    = FCColor.None;
                bool            autoEllipsis = m_tree.AutoEllipsis;
                FCGridCellStyle style        = Style;
                if (style != null)
                {
                    if (style.AutoEllipsis)
                    {
                        autoEllipsis = style.AutoEllipsis;
                    }
                    backColor = style.BackColor;
                    if (style.Font != null)
                    {
                        font = style.Font;
                    }
                    textColor = style.TextColor;
                }
                FCGridRowStyle rowStyle = grid.RowStyle;
                if (isAlternate)
                {
                    FCGridRowStyle alternateRowStyle = grid.AlternateRowStyle;
                    if (alternateRowStyle != null)
                    {
                        rowStyle = alternateRowStyle;
                    }
                }
                if (rowStyle != null)
                {
                    bool selected = false;
                    ArrayList <FCGridRow> selectedRows = grid.SelectedRows;
                    int selectedRowsSize = selectedRows.size();
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    if (backColor == FCColor.None)
                    {
                        //选中
                        if (selected)
                        {
                            backColor = rowStyle.SelectedBackColor;
                        }
                        //悬停
                        else if (Row == Grid.HoveredRow)
                        {
                            backColor = rowStyle.HoveredBackColor;
                        }
                        //普通
                        else
                        {
                            backColor = rowStyle.BackColor;
                        }
                    }
                    if (font == null)
                    {
                        font = rowStyle.Font;
                    }
                    if (textColor == FCColor.None)
                    {
                        //选中
                        if (selected)
                        {
                            textColor = rowStyle.SelectedTextColor;
                        }
                        //悬停
                        else if (Row == Grid.HoveredRow)
                        {
                            textColor = rowStyle.HoveredTextColor;
                        }
                        //普通
                        else
                        {
                            textColor = rowStyle.TextColor;
                        }
                    }
                }
                //绘制背景
                paint.fillRect(backColor, rect);
                FCRect headerRect = TargetColumn.Bounds;
                headerRect.left += Grid.HorizontalOffset - scrollH;
                headerRect.top  += Grid.VerticalOffset - scrollH;
                int left = headerRect.left;
                //绘制复选框
                if (m_tree.CheckBoxes)
                {
                    int    cw           = m_tree.CheckBoxSize.cx;
                    int    ch           = m_tree.CheckBoxSize.cy;
                    FCRect checkBoxRect = new FCRect();
                    checkBoxRect.left   = left;
                    checkBoxRect.top    = rect.top + (height - ch) / 2;
                    checkBoxRect.right  = checkBoxRect.left + cw;
                    checkBoxRect.bottom = checkBoxRect.top + ch;
                    onPaintCheckBox(paint, checkBoxRect);
                    left += cw + 10;
                }
                //绘制折叠展开的标志
                int nw = m_tree.NodeSize.cx;
                int nh = m_tree.NodeSize.cy;
                if (m_nodes.size() > 0)
                {
                    FCRect nodeRect = new FCRect();
                    nodeRect.left   = left;
                    nodeRect.top    = rect.top + (height - nh) / 2;
                    nodeRect.right  = nodeRect.left + nw;
                    nodeRect.bottom = nodeRect.top + nh;
                    onPaintNode(paint, nodeRect);
                }
                left    += nw + 10;
                m_indent = left;
                String text = getPaintText();
                //绘制文字
                if (text != null)
                {
                    FCSize tSize = paint.textSize(text, font);
                    FCRect tRect = new FCRect();
                    tRect.left   = left;
                    tRect.top    = rect.top + (row.Height - tSize.cy) / 2;
                    tRect.right  = tRect.left + tSize.cx;
                    tRect.bottom = tRect.top + tSize.cy;
                    if (autoEllipsis && (tRect.right < clipRect.right || tRect.bottom < clipRect.bottom))
                    {
                        if (tRect.right < clipRect.right)
                        {
                            tRect.right = clipRect.right;
                        }
                        if (tRect.bottom < clipRect.bottom)
                        {
                            tRect.bottom = clipRect.bottom;
                        }
                        paint.drawTextAutoEllipsis(text, textColor, font, tRect);
                    }
                    else
                    {
                        paint.drawText(text, textColor, font, tRect);
                    }
                }
            }
            onPaintControl(paint, rect, clipRect);
        }
예제 #3
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void onPaintForeground(FCPaint paint, FCRect clipRect)
        {
            String text = Text;

            //绘制文字
            if (text != null && text.Length > 0)
            {
                int width = Width, height = Height;
                if (width > 0 && height > 0)
                {
                    FCFont    font      = Font;
                    FCSize    tSize     = paint.textSize(text, font);
                    long      linkColor = getPaintingLinkColor();
                    FCPoint   tPoint    = new FCPoint((width - tSize.cx) / 2, (height - tSize.cy) / 2);
                    FCPadding padding   = Padding;
                    switch (m_textAlign)
                    {
                    case FCContentAlignment.BottomCenter:
                        tPoint.y = height - tSize.cy;
                        break;

                    case FCContentAlignment.BottomLeft:
                        tPoint.x = padding.left;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.BottomRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.MiddleLeft:
                        tPoint.x = padding.left;
                        break;

                    case FCContentAlignment.MiddleRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        break;

                    case FCContentAlignment.TopCenter:
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopLeft:
                        tPoint.x = padding.left;
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = padding.top;
                        break;
                    }
                    FCRect tRect = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    if (AutoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom))
                    {
                        if (tRect.right > clipRect.right)
                        {
                            tRect.right = clipRect.right;
                        }
                        if (tRect.bottom > clipRect.bottom)
                        {
                            tRect.bottom = clipRect.bottom;
                        }
                        paint.drawTextAutoEllipsis(text, linkColor, font, tRect);
                    }
                    else
                    {
                        paint.drawText(text, linkColor, font, tRect);
                    }
                    //画下划线
                    FCNative native = Native;
                    if (m_linkBehavior == FCLinkBehavior.AlwaysUnderLine || (m_linkBehavior == FCLinkBehavior.HoverUnderLine && (this == native.PushedControl || this == native.HoveredControl)))
                    {
                        paint.drawLine(linkColor, 1, 0, tPoint.x, tPoint.y + tSize.cy, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public virtual void onPaint(FCPaint paint, FCRect rect, FCRect clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                if (m_grid != null && m_row != null && m_column != null)
                {
                    //判断选中
                    String text     = getPaintText();
                    bool   selected = false;
                    if (m_grid.SelectionMode == FCGridSelectionMode.SelectCell)
                    {
                        ArrayList <FCGridCell> selectedCells = m_grid.SelectedCells;
                        int selectedCellSize = selectedCells.size();
                        for (int i = 0; i < selectedCellSize; i++)
                        {
                            if (selectedCells.get(i) == this)
                            {
                                selected = true;
                                break;
                            }
                        }
                    }
                    else if (m_grid.SelectionMode == FCGridSelectionMode.SelectFullColumn)
                    {
                        ArrayList <FCGridColumn> selectedColumns = m_grid.SelectedColumns;
                        int selectedColumnsSize = selectedColumns.size();
                        for (int i = 0; i < selectedColumnsSize; i++)
                        {
                            if (selectedColumns.get(i) == m_column)
                            {
                                selected = true;
                                break;
                            }
                        }
                    }
                    else if (m_grid.SelectionMode == FCGridSelectionMode.SelectFullRow)
                    {
                        ArrayList <FCGridRow> selectedRows = m_grid.SelectedRows;
                        int selectedRowsSize = selectedRows.size();
                        for (int i = 0; i < selectedRowsSize; i++)
                        {
                            if (selectedRows.get(i) == m_row)
                            {
                                selected = true;
                                break;
                            }
                        }
                    }
                    //获取颜色
                    FCFont            font            = null;
                    long              backColor       = FCColor.None;
                    long              textColor       = FCColor.None;
                    bool              autoEllipsis    = m_grid.AutoEllipsis;
                    FCHorizontalAlign horizontalAlign = m_column.CellAlign;
                    if (m_style != null)
                    {
                        if (m_style.AutoEllipsis)
                        {
                            autoEllipsis = m_style.AutoEllipsis;
                        }
                        backColor = m_style.BackColor;
                        if (m_style.Font != null)
                        {
                            font = m_style.Font;
                        }
                        textColor = m_style.TextColor;
                        if (m_style.Align != FCHorizontalAlign.Inherit)
                        {
                            horizontalAlign = m_style.Align;
                        }
                    }
                    FCGridRowStyle rowStyle = m_grid.RowStyle;
                    if (isAlternate)
                    {
                        FCGridRowStyle alternateRowStyle = m_grid.AlternateRowStyle;
                        if (alternateRowStyle != null)
                        {
                            rowStyle = alternateRowStyle;
                        }
                    }
                    if (rowStyle != null)
                    {
                        if (backColor == FCColor.None)
                        {
                            if (selected)
                            {
                                backColor = rowStyle.SelectedBackColor;
                            }
                            else if (m_row == m_grid.HoveredRow)
                            {
                                backColor = rowStyle.HoveredBackColor;
                            }
                            else
                            {
                                backColor = rowStyle.BackColor;
                            }
                        }
                        if (font == null)
                        {
                            font = rowStyle.Font;
                        }
                        if (textColor == FCColor.None)
                        {
                            if (selected)
                            {
                                textColor = rowStyle.SelectedTextColor;
                            }
                            else if (m_row == m_grid.HoveredRow)
                            {
                                textColor = rowStyle.HoveredTextColor;
                            }
                            else
                            {
                                textColor = rowStyle.TextColor;
                            }
                        }
                    }
                    paint.fillRect(backColor, rect);
                    FCSize  tSize  = paint.textSize(text, font);
                    FCPoint tPoint = new FCPoint(rect.left + 1, rect.top + clipH / 2 - tSize.cy / 2);
                    int     width  = rect.right - rect.left;
                    if (tSize.cx < width)
                    {
                        if (horizontalAlign == FCHorizontalAlign.Center)
                        {
                            tPoint.x = rect.left + (rect.right - rect.left - tSize.cx) / 2;
                        }
                        else if (horizontalAlign == FCHorizontalAlign.Right)
                        {
                            tPoint.x = rect.right - tSize.cx - 2;
                        }
                    }
                    FCRect tRect = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    if (autoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom))
                    {
                        if (tRect.right > clipRect.right)
                        {
                            tRect.right = clipRect.right;
                        }
                        if (tRect.bottom > clipRect.bottom)
                        {
                            tRect.bottom = clipRect.bottom;
                        }
                        paint.drawTextAutoEllipsis(text, textColor, font, tRect);
                    }
                    else
                    {
                        paint.drawText(text, textColor, font, tRect);
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void onPaintForeground(FCPaint paint, FCRect clipRect)
        {
            String text = Text;

            //绘制文字
            if (text != null && text.Length > 0)
            {
                int width = Width, height = Height;
                if (width > 0 && height > 0)
                {
                    FCFont    font    = Font;
                    FCSize    tSize   = paint.textSize(text, font);
                    FCPoint   tPoint  = new FCPoint((width - tSize.cx) / 2, (height - tSize.cy) / 2);
                    FCPadding padding = Padding;
                    switch (m_textAlign)
                    {
                    case FCContentAlignment.BottomCenter:
                        tPoint.y = height - tSize.cy;
                        break;

                    case FCContentAlignment.BottomLeft:
                        tPoint.x = padding.left;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.BottomRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.MiddleLeft:
                        tPoint.x = padding.left;
                        break;

                    case FCContentAlignment.MiddleRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        break;

                    case FCContentAlignment.TopCenter:
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopLeft:
                        tPoint.x = padding.left;
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = padding.top;
                        break;
                    }
                    FCRect tRect     = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    long   textColor = getPaintingTextColor();
                    if (AutoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom))
                    {
                        if (tRect.right > clipRect.right)
                        {
                            tRect.right = clipRect.right;
                        }
                        if (tRect.bottom > clipRect.bottom)
                        {
                            tRect.bottom = clipRect.bottom;
                        }
                        paint.drawTextAutoEllipsis(text, textColor, font, tRect);
                    }
                    else
                    {
                        paint.drawText(text, textColor, font, tRect);
                    }
                }
            }
        }