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


C++ FontDescription::setBold方法代码示例

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


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

示例1: updateFromElement

void RenderListBox::updateFromElement()
{
    if (m_optionsChanged) {
        const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems();
        int size = numItems();
        
        float width = 0;
        TextStyle textStyle(0, 0, 0, false, false, false, false);
        for (int i = 0; i < size; ++i) {
            HTMLElement* element = listItems[i];
            String text;
            Font itemFont = style()->font();
            if (element->hasTagName(optionTag))
                text = static_cast<HTMLOptionElement*>(element)->optionText();
            else if (element->hasTagName(optgroupTag)) {
                text = static_cast<HTMLOptGroupElement*>(element)->groupLabelText();
                FontDescription d = itemFont.fontDescription();
                d.setBold(true);
                itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
                itemFont.update();
            }
                
            if (!text.isEmpty()) {
                float textWidth = itemFont.floatWidth(TextRun(text.impl()), textStyle);
                width = max(width, textWidth);
            }
        }
        m_optionsWidth = static_cast<int>(ceilf(width));
        m_optionsChanged = false;
        setNeedsLayoutAndMinMaxRecalc();
    }
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:32,代码来源:RenderListBox.cpp

示例2: paintItemForeground

void RenderListBox::paintItemForeground(PaintInfo& paintInfo, int tx, int ty, int listIndex)
{
    HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node());
    const Vector<HTMLElement*>& listItems = select->listItems();
    HTMLElement* element = listItems[listIndex];

    String itemText;
    if (element->hasTagName(optionTag))
        itemText = static_cast<HTMLOptionElement*>(element)->optionText();
    else if (element->hasTagName(optgroupTag))
        itemText = static_cast<HTMLOptGroupElement*>(element)->groupLabelText();
       
    // Determine where the item text should be placed
    IntRect r = itemBoundingBoxRect(tx, ty, listIndex);
    r.move(optionsSpacingHorizontal, style()->font().ascent());

    RenderStyle* itemStyle = element->renderStyle();
    if (!itemStyle)
        itemStyle = style();
    
    Color textColor = element->renderStyle() ? element->renderStyle()->color() : style()->color();
    if (element->hasTagName(optionTag) && static_cast<HTMLOptionElement*>(element)->selected()) {
        if (document()->frame()->isActive() && document()->focusedNode() == node())
            textColor = theme()->activeListBoxSelectionForegroundColor();
        // Honor the foreground color for disabled items
        else if (!element->disabled())
            textColor = theme()->inactiveListBoxSelectionForegroundColor();
    }

    paintInfo.context->setFillColor(textColor);

    Font itemFont = style()->font();
    if (element->hasTagName(optgroupTag)) {
        FontDescription d = itemFont.fontDescription();
        d.setBold(true);
        itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
        itemFont.update();
    }
    paintInfo.context->setFont(itemFont);
    
    unsigned length = itemText.length();
    const UChar* string = itemText.characters();
    TextStyle textStyle(0, 0, 0, false, true);
    RenderBlock::CharacterBuffer characterBuffer;

    if (itemStyle->direction() == RTL && itemStyle->unicodeBidi() == Override)
        textStyle.setRTL(true);
    else if ((itemStyle->direction() == RTL || itemStyle->unicodeBidi() != Override) && !itemStyle->visuallyOrdered()) {
        // If necessary, reorder characters by running the string through the bidi algorithm
        characterBuffer.append(string, length);
        RenderBlock::bidiReorderCharacters(document(), itemStyle, characterBuffer);
        string = characterBuffer.data();
    }
    TextRun textRun(string, length);

    // Draw the item text
    if (itemStyle->visibility() != HIDDEN)
        paintInfo.context->drawText(textRun, r.location(), textStyle);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:59,代码来源:RenderListBox.cpp


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