Beispiel #1
0
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;
}
    void CovHTMLCodePrinter::addNewLineHeader()
    {
        if (isNewLine)
        {
            const std::size_t indent = getIndentSize();
            out << L"<tr class=\'";
            if (current && isInsideKnownFunction())
            {
                if (current->isCommentExp())
                {
                    out << L"none";
                }
                else if (current->isFunctionDec())
                {
                    out << (getCurrentResult().getCounter() ? L"cover" : L"uncover");
                }
		else if (current->isCaseExp())
                {
		    out << (getCurrentResult().isCovered(static_cast<const ast::CaseExp *>(current)->getTest()) ? L"cover" : L"uncover");
		}
                else
                {
                    out << (getCurrentResult().isCovered(current) ? L"cover" : L"uncover");
                }
            }
            else
            {
                out << L"none";
            }
            ++lineCount;
            out <<  L"\' id=\'L" << lineCount << L"\'>\n"
                << L"<td class=\'num\'><a href=\'#L" << lineCount << L"\'>" << lineCount << L"</a></td>\n"
                << L"<td class=\'src\'><pre>" << std::wstring(indent, L' ');

            counter = indent;
            isNewLine = false;
        }
        current = nullptr;
    }