8 #include <QDomDocument>
105 static QObject *
qChildHelper(
const char *objName,
const char *inheritsClass,
106 bool recursiveSearch,
const QObjectList &children)
108 if (children.isEmpty())
111 bool onlyWidgets = (inheritsClass
112 && qstrcmp(inheritsClass,
"QWidget") == 0);
113 const QLatin1String oName(objName);
115 for (
int i = 0; i < children.size(); ++i)
117 QObject *obj = children.at(i);
121 if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
124 else if ((!inheritsClass || obj->inherits(inheritsClass))
125 && (!objName || obj->objectName() == oName))
128 if (recursiveSearch && (dynamic_cast<MythUIGroup *>(obj) != NULL)
146 QObject *ret =
qChildHelper(name.toLatin1().constData(), NULL,
true, children());
168 if (type->objectName() ==
name)
215 QList<MythUIType *>::iterator it;
233 bool focusable)
const
244 QList<MythUIType *>::const_iterator it;
254 if (!(*it)->GetArea().contains(p -
GetArea().topLeft()))
298 QList<MythUIType *>::Iterator it;
301 (*it)->ResetNeedsRedraw();
324 if (childRegion.isEmpty())
459 QList<MythUIAnimation*>::Iterator i;
461 (*i)->IncrementCurrentTime();
463 QList<MythUIType *>::Iterator it;
490 realArea.translate(xoffset, yoffset);
492 if (!realArea.intersects(clipRect))
497 DrawSelf(p, xoffset, yoffset, alphaMod, clipRect);
499 QList<MythUIType *>::Iterator it;
503 (*it)->Draw(p, xoffset +
m_Area.x(), yoffset +
m_Area.y(),
509 static const QBrush nullbrush(Qt::NoBrush);
515 font.
SetFace(QFont(
"Droid Sans"));
518 p->
DrawText(realArea, objectName(), 0, font, 255, realArea);
558 if (size ==
m_Area.size())
617 int delta_w,
int delta_h)
624 QRect bounded(
m_Area.x() - delta_x,
627 m_Area.height() + delta_h);
632 QPoint center = bounded.center();
634 if (bounded.isNull())
637 bounded.setSize(bounded.size().expandedTo(
GetMinSize()));
639 bounded.moveCenter(center);
642 if (bounded.x() + bounded.width() >
m_Area.x() +
m_Area.width())
644 if (bounded.y() + bounded.height() >
m_Area.y() +
m_Area.height())
646 if (bounded.x() <
m_Area.x())
648 bounded.moveLeft(
m_Area.x());
649 if (bounded.width() >
m_Area.width())
650 bounded.setWidth(
m_Area.width());
652 if (bounded.y() <
m_Area.y())
654 bounded.moveTop(
m_Area.y());
655 if (bounded.height() >
m_Area.height())
656 bounded.setHeight(
m_Area.height());
662 QList<MythUIType *>::iterator it;
666 if (!(*it)->m_Initiator)
667 (*it)->AdjustMinArea(delta_x, delta_y, delta_w, delta_h);
682 QList<MythUIType *>::iterator it;
686 if (!(*it)->m_Initiator)
687 (*it)->VanishSibling();
697 int delta_x = 0, delta_y = 0, delta_w = 0, delta_h = 0;
715 QList<MythUIType *>::iterator it;
722 if (!(*it)->m_Vanished)
725 area = (*it)->GetArea();
727 actual_area = actual_area.united(area);
729 area = (*it)->m_Area;
731 allowed_area = allowed_area.united(area);
736 actual_area = actual_area.intersected(
m_Area);
737 allowed_area = allowed_area.intersected(
m_Area);
739 if (
m_Vanish && actual_area.size().isNull())
747 delta_x =
m_Area.x() - actual_area.x();
748 delta_y =
m_Area.y() - actual_area.y();
749 delta_w = actual_area.width() -
m_Area.width();
750 delta_h = actual_area.height() -
m_Area.height();
754 delta_x = allowed_area.x() - actual_area.x();
755 delta_y = allowed_area.y() - actual_area.y();
756 delta_w = actual_area.width() - allowed_area.width();
757 delta_h = actual_area.height() - allowed_area.height();
765 if (*it == calling_child)
768 if (!(*it)->m_Initiator)
771 (*it)->VanishSibling();
773 (*it)->AdjustMinArea(delta_x, delta_y, delta_w, delta_h);
776 area = (*it)->GetArea();
778 actual_area = actual_area.united(area);
784 actual_area.
setRect(0, 0, 0, 0);
788 QSize bound(actual_area.width(), actual_area.height());
793 actual_area.x() + bound.width(),
794 actual_area.y() + bound.height());
811 bool vanish = (
m_Vanish && rect.isNull());
820 QPoint center = bounded.center();
822 if (bounded.isNull())
825 bounded.setSize(bounded.size().expandedTo(
GetMinSize()));
827 bounded.moveCenter(center);
828 if (bounded.x() + bounded.width() >
m_Area.x() +
m_Area.width())
830 if (bounded.y() + bounded.height() >
m_Area.y() +
m_Area.height())
832 if (bounded.x() <
m_Area.x())
834 bounded.moveLeft(
m_Area.x());
835 if (bounded.width() >
m_Area.width())
836 bounded.setWidth(
m_Area.width());
838 if (bounded.y() <
m_Area.y())
840 bounded.moveTop(
m_Area.y());
841 if (bounded.height() >
m_Area.height())
842 bounded.setHeight(
m_Area.height());
855 QSize childSize = rect.size();
858 if (childSize == size)
861 SetSize(size.expandedTo(childSize));
903 if (destXY.x() ==
m_Area.x() && destXY.y() ==
m_Area.y())
1092 QList<MythUIType *>::Iterator it;
1095 (*it)->AddFocusableChildrenToList(focusList);
1137 QList<MythUIAnimation*>::Iterator i;
1145 QList<MythUIType *>::Iterator it;
1155 (*it)->CreateCopy(
this);
1178 const QString &filename, QDomElement &element,
bool showWarnings)
1182 if (element.tagName() ==
"position")
1184 else if (element.tagName() ==
"area")
1188 else if (element.tagName() ==
"minsize")
1191 if (element.hasAttribute(
"initiator"))
1194 if (element.hasAttribute(
"vanish"))
1199 else if (element.tagName() ==
"alpha")
1204 else if (element.tagName() ==
"alphapulse")
1207 m_AlphaMin = element.attribute(
"min",
"0").toInt();
1218 else if (element.tagName() ==
"focusorder")
1223 else if (element.tagName() ==
"loadondemand")
1227 else if (element.tagName() ==
"helptext")
1231 else if (element.tagName() ==
"animation")
1276 QList<MythUIType *>::iterator it;
1280 (*it)->RecalculateArea(recurse);
1337 QList<MythUIType *>::Iterator it;
1350 if (
m_Area.contains(point))
1384 QString dependeeName = i.value();
1385 bool reverse =
false;
1386 if (dependeeName.startsWith(
'!'))
1389 dependeeName.remove(0,1);
1394 if (dependee && dependant)
1405 QList<MythUIType *>::iterator it;
1409 (*it)->ConnectDependants(recurse);