Exemplo n.º 1
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void
ListControlDesc::drawRow(size_t aRowIndex, const Core::Rectangle& aRowRectangle) const
{
    ListControl* listControl = dynamic_cast<ListControl*>(listWindow_);

    const ListControl::Row& row = listControl->rowAt(aRowIndex);

    Core::Rectangle textRectangle = aRowRectangle;
    textRectangle.translateBy(Core::Vector2(2.0f, 0.0f));

    bool isNormalText = true;
    Color backgroundColor;
    Color textColor;
    if(static_cast<int>(aRowIndex) == listControl->selectedIndex())
    {
        isNormalText = false;
        backgroundColor = selectionColor_;
        textColor = selectedTextColor_;
    }
    else if(static_cast<int>(aRowIndex) == listControl->highlightedIndex())
    {
        isNormalText = false;
        backgroundColor = highlightColor_;
        textColor = highlightedTextColor_;
    }

    if(!isNormalText)
    {
        Renderer::setCurrentColor(backgroundColor);
        Renderer::drawRectangle(aRowRectangle.topLeft(), aRowRectangle.bottomRight(), true);
        const Color unselectedTextColor = textDesc_->color();
        textDesc_->setColor(textColor);
        for(unsigned j = 0; j < listControl->numberOfColumns(); ++j)
        {
            (*textDesc_)
                .setText(row.stringAt(j))
                .draw(textRectangle)
                ;
            textRectangle.translateBy(Core::Vector2(listControl->columnWidth(j), 0.0f));
        }
        textDesc_->setColor(unselectedTextColor);
    }
    else
    {
        for(unsigned j = 0; j < listControl->numberOfColumns(); ++j)
        {
            (*textDesc_)
                .setText(row.stringAt(j))
                .draw(textRectangle)
                ;
            textRectangle.translateBy(Core::Vector2(listControl->columnWidth(j), 0.0f));
        }
    }
}
Exemplo n.º 2
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void
ListControlDesc::draw(const Core::Rectangle& anArea) const
{
    ListWindowDesc::draw(anArea);

    // ***********************************************************************
    //  draw the column separators
    // ***********************************************************************

    const Core::Vector2 topLeft     = anArea.topLeft();
    const Core::Vector2 bottomLeft  = anArea.bottomLeft();

    ListControl* listControl = dynamic_cast<ListControl*>(listWindow_);
    Renderer::setCurrentColor(separatorColor_);
    Renderer::setLineWidth(separatorWidth_);
    float curX = listControl->columnWidth(0);
    for(size_t sep = 1; sep < listControl->numberOfColumns(); ++sep)
    {
        Core::Vector2 offs(curX, 0);
        Renderer::drawLine(topLeft + offs, bottomLeft + offs);
        curX += listControl->columnWidth(sep);
    }
}