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 (class 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 QPtrList<LCDMenuItem> menuItems; menuItems.setAutoDelete(true); QPtrListIterator<UIListBtnTypeItem> it = (*m_selIterator); uint count = 0; // move back up the list a little while (it.current() && count < lcddev->getLCDHeight()) { --it; ++count; } if (!it.current()) it.toFirst(); count = 0; while (it.current() && count < lcddev->getLCDHeight() * 2) { UIListBtnTypeItem *curItem = it.current(); 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(new LCDMenuItem(selected, checkState, msg)); ++it; ++count; } 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(); QPtrListIterator<UIListBtnTypeItem> it = (*m_topIterator); while (it.current() && (y - m_rect.y()) <= (m_contentsRect.height() - m_itemHeight)) { if (active_on && it.current()->getOverrideInactive()) { font = m_fontInactive; p->setFont(font->face); p->setPen(font->color); it.current()->setJustification(m_justify); it.current()->paint(p, font, x, y, active_on); font = m_active ? m_fontActive : m_fontInactive;; p->setFont(font->face); p->setPen(font->color); } else { it.current()->setJustification(m_justify); it.current()->paint(p, font, x, y, active_on); } y += m_itemHeight + m_itemSpacing; ++it; } 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); } }
bool UIListBtnType::incSearchNext(void) { if (!m_selItem) { return false; } // // Move the active node to the node whose string value // starts or contains the search text // QPtrListIterator<UIListBtnTypeItem> it = (*m_selIterator); ++it; while (it.current()) { if (m_bIncSearchContains) { if (it.current()->text().find(m_incSearch, 0, false) != -1) break; } else { if (it.current()->text().startsWith(m_incSearch, false)) break; } ++it; } // if it is NULL, we reached the end of the list. wrap to the // beginning and try again if (!it.current()) { it.toFirst(); while (it.current()) { // we're back at the current_node, which means there are no // matching nodes if (it.current() == m_selItem) { break; } if (m_bIncSearchContains) { if (it.current()->text().find(m_incSearch, 0, false) != -1) break; } else { if (it.current()->text().startsWith(m_incSearch, false)) break; } ++it; } } if (it.current()) { SetItemCurrent(it.current()); return true; } return false; }