Esempio n. 1
0
void UIListTreeType::FillLevelFromTree(UIListGenericTree *item,
                                       UIListBtnType *list)
{
    if (!item || !list)
        return;

    ClearLevel(list);

    vector<GenericTree*> itemlist = item->getAllChildren();

    vector<GenericTree*>::const_iterator it = itemlist.begin();

    for ( ; it != itemlist.end(); ++it)
    {
        UIListGenericTree *uichild =
            dynamic_cast<UIListGenericTree*>(*it);

        if (!uichild)
            continue;

        UIListBtnTypeItem *newitem;

        int check = uichild->getCheck();
        newitem = new UIListBtnTypeItem(list, uichild->getString(),
                                        uichild->getImage(), (check >= 0),
                                        (UIListBtnTypeItem::CheckState)check,
                                        (uichild->childCount() > 0));
        newitem->setData(uichild);

        uichild->setItem(newitem);

        if (!uichild->getActive())
            newitem->setOverrideInactive(true);
    }
}
Esempio n. 2
0
void UIListTreeType::FillLevelFromTree(UIListGenericTree *item,
                                       UIListBtnType *list)
{
    if (!item || !list)
        return;

    ClearLevel(list);

    QPtrList<GenericTree> *itemlist = item->getAllChildren();

    QPtrListIterator<GenericTree> it(*itemlist);
    GenericTree *child;

    while ((child = it.current()) != 0)
    {
        UIListGenericTree *uichild = (UIListGenericTree *)child;

        UIListBtnTypeItem *newitem;

        int check = uichild->getCheck();
        newitem = new UIListBtnTypeItem(list, child->getString(),
                                        uichild->getImage(), (check >= 0),
                                        (UIListBtnTypeItem::CheckState)check,
                                        (child->childCount() > 0));
        newitem->setData(uichild);

        uichild->setItem(newitem);

        if (!uichild->getActive())
            newitem->setOverrideInactive(true);

        ++it;
    }
}
Esempio n. 3
0
void UIListTreeType::ClearLevel(UIListBtnType *list)
{
    UIListBtnTypeItem *clear = list->GetItemFirst();
    while (clear)
    {
        UIListGenericTree *gt = (UIListGenericTree *)clear->getData();
        gt->setItem(NULL);
        clear = list->GetItemNext(clear);
    }

    list->Reset();
}
Esempio n. 4
0
void UIListTreeType::SetCurrentPosition(void)
{
    if (!currentlevel)
        return;

    UIListBtnTypeItem *lbt = currentlevel->GetItemCurrent();

    if (!lbt)
        return;

    currentpos = (UIListGenericTree *)(lbt->getData());
    emit itemEntered(this, currentpos);
}
Esempio n. 5
0
void UIListTreeType::RefreshCurrentLevel(void)
{
    if (currentlevel)
    {
        QPtrListIterator<UIListBtnTypeItem> it = currentlevel->GetIterator();

        UIListBtnTypeItem *item;
        while ((item = it.current()))
        {
            UIListGenericTree *ui = (UIListGenericTree *)item->getData();
            ui->setActive(ui->getActive());
            ++it;
        }
    }
}
Esempio n. 6
0
void UIListBtnType::Draw(QPainter *p, int order, int context, bool active_on)
{
    if (!m_visible || hidden)
        return;

    if (!m_initialized)
        Init();

    if (m_order != order)
        return;

    if (m_context != -1 && m_context != context)
        return;

    //  Put something on the LCD device (if one exists)
    if (LCD *lcddev = LCD::Get())
    {
        if (m_active)
        {
            // add max of lcd height menu items either side of the selected item
            // let the lcdserver figure out which ones to display


            // move back up the list a little
            uint count = 0;
            int i;
            for (i = m_selPosition;
                 (i >= 0) && (count < lcddev->getLCDHeight()); --i, ++count);

            i = (i < 0) ? 0 : i;
            count = 0;

            QList<LCDMenuItem> menuItems;
            for (; ((uint)i < (uint)m_itemList.size()) &&
                     (count < lcddev->getLCDHeight() * 2); ++i, ++count)
            {
                UIListBtnTypeItem *curItem = m_itemList[i];
                QString msg = curItem->text();
                bool selected;
                CHECKED_STATE checkState = NOTCHECKABLE;
                if (curItem->checkable())
                {
                    if (curItem->state() == UIListBtnTypeItem::HalfChecked ||
                        curItem->state() == UIListBtnTypeItem::FullChecked)
                        checkState = CHECKED;
                    else
                        checkState = UNCHECKED;
                }

                if (curItem == m_selItem)
                    selected = true;
                else
                    selected = false;

                menuItems.append(LCDMenuItem(selected, checkState, msg));
            }

            QString title = "";

            if (m_parentListTree && m_parentListTree->getDepth() > 0)
                title = "<< ";
            else
                title = "   ";

            if ((m_selItem && m_selItem->getDrawArrow()) || m_showArrow)
                title += " >>";
            else
                title += "   ";

            if (!menuItems.isEmpty())
            {
                lcddev->switchToMenu(menuItems, title);
            }
        }
    }

    fontProp* font = m_active ? m_fontActive : m_fontInactive;

    if (!active_on)
    {
        font = m_fontInactive;
    }

    p->setFont(font->face);
    p->setPen(font->color);

    int x = m_rect.x() + m_xdrawoffset;

    int y = m_rect.y();

    for (int i = m_topPosition;
         (i < (int)m_itemList.size()) &&
             ((y - m_rect.y()) <= (m_contentsRect.height() - m_itemHeight));
         i++)
    {
        if (active_on && m_itemList[i]->getOverrideInactive())
        {
            font = m_fontInactive;
            p->setFont(font->face);
            p->setPen(font->color);
            m_itemList[i]->setJustification(m_justify);
            m_itemList[i]->paint(p, font, x, y, active_on);
            font = m_active ? m_fontActive : m_fontInactive;;
            p->setFont(font->face);
            p->setPen(font->color);
        }
        else
        {
            m_itemList[i]->setJustification(m_justify);
            m_itemList[i]->paint(p, font, x, y, active_on);
        }

        y += m_itemHeight + m_itemSpacing;
    }

    if (m_showScrollArrows)
    {
        if (m_showUpArrow)
            p->drawPixmap(x + m_arrowsRect.x(),
                          m_rect.y() + m_arrowsRect.y(),
                          m_upArrowActPix);
        else
            p->drawPixmap(x + m_arrowsRect.x(),
                          m_rect.y() + m_arrowsRect.y(),
                          m_upArrowRegPix);
        if (m_showDnArrow)
            p->drawPixmap(x + m_arrowsRect.x() +
                          m_upArrowRegPix.width() + m_itemMargin,
                          m_rect.y() + m_arrowsRect.y(),
                          m_dnArrowActPix);
        else
            p->drawPixmap(x + m_arrowsRect.x() +
                          m_upArrowRegPix.width() + m_itemMargin,
                          m_rect.y() + m_arrowsRect.y(),
                          m_dnArrowRegPix);
    }

}