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


C++ TreeViewItem::isLastOfSiblings方法代码示例

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


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

示例1: getInsertPosition

TreeViewItem* TreeView::getInsertPosition (int& x, int& y, int& insertIndex,
                                           const StringArray& files, const String& sourceDescription,
                                           Component* sourceComponent) const throw()
{
    insertIndex = 0;
    TreeViewItem* item = getItemAt (y);

    if (item == 0)
        return 0;

    Rectangle<int> itemPos (item->getItemPosition (true));
    insertIndex = item->getIndexInParent();
    const int oldY = y;
    y = itemPos.getY();

    if (item->getNumSubItems() == 0 || ! item->isOpen())
    {
        if (files.size() > 0 ? item->isInterestedInFileDrag (files)
                             : item->isInterestedInDragSource (sourceDescription, sourceComponent))
        {
            // Check if we're trying to drag into an empty group item..
            if (oldY > itemPos.getY() + itemPos.getHeight() / 4
                 && oldY < itemPos.getBottom() - itemPos.getHeight() / 4)
            {
                insertIndex = 0;
                x = itemPos.getX() + getIndentSize();
                y = itemPos.getBottom();
                return item;
            }
        }
    }

    if (oldY > itemPos.getCentreY())
    {
        y += item->getItemHeight();

        while (item->isLastOfSiblings() && item->parentItem != 0
                && item->parentItem->parentItem != 0)
        {
            if (x > itemPos.getX())
                break;

            item = item->parentItem;
            itemPos = item->getItemPosition (true);
            insertIndex = item->getIndexInParent();
        }

        ++insertIndex;
    }

    x = itemPos.getX();
    return item->parentItem;
}
开发者ID:Labmind,项目名称:GUI,代码行数:53,代码来源:juce_TreeView.cpp

示例2: paintRecursively

void TreeViewItem::paintRecursively (Graphics& g, int width)
{
    jassert (ownerView != 0);
    if (ownerView == 0)
        return;

    const int indent = getIndentX();
    const int itemW = itemWidth < 0 ? width - indent : itemWidth;

    {
        Graphics::ScopedSaveState ss (g);
        g.setOrigin (indent, 0);

        if (g.reduceClipRegion (drawsInLeftMargin ? -indent : 0, 0,
                                drawsInLeftMargin ? itemW + indent : itemW, itemHeight))
            paintItem (g, itemW, itemHeight);
    }

    g.setColour (ownerView->findColour (TreeView::linesColourId));

    const float halfH = itemHeight * 0.5f;
    int depth = 0;
    TreeViewItem* p = parentItem;

    while (p != 0)
    {
        ++depth;
        p = p->parentItem;
    }

    if (! ownerView->rootItemVisible)
        --depth;

    const int indentWidth = ownerView->getIndentSize();

    if (depth >= 0 && ownerView->openCloseButtonsVisible)
    {
        float x = (depth + 0.5f) * indentWidth;

        if (depth >= 0)
        {
            if (parentItem != 0 && parentItem->drawLinesInside)
                g.drawLine (x, 0, x, isLastOfSiblings() ? halfH : (float) itemHeight);


            if ((parentItem != 0 && parentItem->drawLinesInside)
                 || (parentItem == 0 && drawLinesInside))
                g.drawLine (x, halfH, x + indentWidth / 2, halfH);
        }

        p = parentItem;
        int d = depth;

        while (p != 0 && --d >= 0)
        {
            x -= (float) indentWidth;

            if ((p->parentItem == 0 || p->parentItem->drawLinesInside)
                 && ! p->isLastOfSiblings())
            {
                g.drawLine (x, 0, x, (float) itemHeight);
            }

            p = p->parentItem;
        }

        if (mightContainSubItems())
        {
            Graphics::ScopedSaveState ss (g);

            g.setOrigin (depth * indentWidth, 0);
            g.reduceClipRegion (0, 0, indentWidth, itemHeight);

            paintOpenCloseButton (g, indentWidth, itemHeight,
                static_cast <TreeViewContentComponent*> (ownerView->viewport->getViewedComponent())
                    ->isMouseOverButton (this));
        }
    }

    if (isOpen())
    {
        const Rectangle<int> clip (g.getClipBounds());

        for (int i = 0; i < subItems.size(); ++i)
        {
            TreeViewItem* const ti = subItems.getUnchecked(i);

            const int relY = ti->y - y;

            if (relY >= clip.getBottom())
                break;

            if (relY + ti->totalHeight >= clip.getY())
            {
                Graphics::ScopedSaveState ss (g);

                g.setOrigin (0, relY);

                if (g.reduceClipRegion (0, 0, width, ti->totalHeight))
                    ti->paintRecursively (g, width);
//.........这里部分代码省略.........
开发者ID:Labmind,项目名称:GUI,代码行数:101,代码来源:juce_TreeView.cpp


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