当前位置: 首页>>代码示例>>C++>>正文


C++ Style::fontColor方法代码示例

本文整理汇总了C++中Style::fontColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Style::fontColor方法的具体用法?C++ Style::fontColor怎么用?C++ Style::fontColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Style的用法示例。


在下文中一共展示了Style::fontColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createEditor

bool FoCellTool::createEditor(bool clear, bool /*focus*/)
{
    bool status=false;
    const Cell cell(selection()->activeSheet(), selection()->marker());

    if (selection()->activeSheet()->isProtected() && !cell.style().notProtected())
        return false;

    if(!editor()) {
        m_editor=new FoCellEditor(this,canvas()->canvasWidget());
        m_editor->setEditorFont(cell.style().font(), true, canvas()->viewConverter());
        if(m_editor) {
            status=true;
        }
    }

    if(status) {

        double w = cell.width();
        double h = cell.height();
        double min_w = cell.width();
        double min_h = cell.height();


        double xpos = selection()->activeSheet()->columnPosition(selection()->marker().x());
        xpos += canvas()->viewConverter()->viewToDocumentX(canvas()->canvasController()->canvasOffsetX());

        Qt::LayoutDirection sheetDir = selection()->activeSheet()->layoutDirection();
        bool rtlText = cell.displayText().isRightToLeft();

        // if sheet and cell direction don't match, then the editor's location
        // needs to be shifted backwards so that it's right above the cell's text
        if (w > 0 && ((sheetDir == Qt::RightToLeft && !rtlText) ||
                      (sheetDir == Qt::LeftToRight && rtlText)))
            xpos -= w - min_w;

        // paint editor above correct cell if sheet direction is RTL
        if (sheetDir == Qt::RightToLeft) {
            double dwidth = canvas()->viewConverter()->viewToDocumentX(canvas()->canvasWidget()->width());
            double w2 = qMax(w, min_w);
            xpos = dwidth - w2 - xpos;
        }

        double ypos = selection()->activeSheet()->rowPosition(selection()->marker().y());
        ypos += canvas()->viewConverter()->viewToDocumentY(canvas()->canvasController()->canvasOffsetY());

        // Setup the editor's palette.
        const Style style = cell.effectiveStyle();
        QPalette editorPalette(m_editor->palette());
        QColor color = style.fontColor();
        if (!color.isValid())
            color = canvas()->canvasWidget()->palette().text().color();
        editorPalette.setColor(QPalette::Text, color);
        color = style.backgroundColor();
        if (!color.isValid())
            color = editorPalette.base().color();
        editorPalette.setColor(QPalette::Background, color);
        m_editor->setPalette(editorPalette);

        // apply (table shape) offset
        xpos += offset().x();
        ypos += offset().y();

        const QRectF rect(xpos + 0.5, ypos + 0.5, w - 0.5, h - 0.5); //needed to circumvent rounding issue with height/width
        const QRectF zoomedRect = canvas()->viewConverter()->documentToView(rect);
        m_editor->setGeometry(zoomedRect.toRect().adjusted(1, 1, -1, -1));
        m_editor->setMinimumSize(QSize((int)canvas()->viewConverter()->documentToViewX(min_w) - 1,
                                       (int)canvas()->viewConverter()->documentToViewY(min_h) - 1));
        m_editor->show();

        // Laurent 2001-12-05
        // Don't add focus when we create a new editor and
        // we select text in edit widget otherwise we don't delete
        // selected text.
        /*if (focus)
        m_editor->setFocus();*/
        selection()->update();
        if (!clear && !cell.isNull()) {
            m_editor->setText(cell.userInput());

        }
        if(clear) {
            m_externalEditor->clear();
        } else {
            m_externalEditor->setPlainText(editor()->toPlainText());
            m_externalEditor->setCursorPosition(m_externalEditor->toPlainText().length());
            connect(((FoCellEditor*)m_editor), SIGNAL(textChanged(const QString &)),
                    m_externalEditor, SLOT(setText(const QString &)));
            connect(m_externalEditor, SIGNAL(textChanged(const QString &)),
                    ((FoCellEditor*)m_editor), SLOT(setText(const QString &)));
        }
        m_editor->setFocus();
        m_editor->setCursorPosition(m_editor->toPlainText().length());
    }
    return status;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:96,代码来源:FoCellTool.cpp


注:本文中的Style::fontColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。