Index: mythtv/libs/libmythui/xmlparsebase.cpp =================================================================== --- mythtv/libs/libmythui/xmlparsebase.cpp (revision 13527) +++ mythtv/libs/libmythui/xmlparsebase.cpp (working copy) @@ -9,6 +9,7 @@ #include "mythscreentype.h" #include "mythuiimage.h" #include "mythuitext.h" +#include "mythuiclock.h" #include "mythlistbutton.h" QString XMLParseBase::getFirstText(QDomElement &element) @@ -215,6 +216,11 @@ uitype = new MythUIStateType(parent, name); else if (type == "window" && parent == GetGlobalObjectStore()) uitype = new MythScreenType(parent, name); + else if (type == "clock") + { + uitype = new MythUIClock(parent, name); + VERBOSE(VB_IMPORTANT, "Parsed Clock"); + } else { VERBOSE(VB_IMPORTANT, QString("Unknown widget type: %1").arg(type)); @@ -260,7 +266,8 @@ info.tagName() == "textarea" || info.tagName() == "buttonlist" || info.tagName() == "horizontalbuttonlist" || - info.tagName() == "statetype") + info.tagName() == "statetype" || + info.tagName() == "clock") { ParseUIType(info, info.tagName(), uitype, screen); } @@ -361,7 +368,8 @@ type == "buttonlist" || type == "horizontalbuttonlist" || type == "statetype" || - type == "window") + type == "window" || + type == "clock") { ParseUIType(e, type, parent); } Index: mythtv/libs/libmythui/mythuiclock.h =================================================================== --- mythtv/libs/libmythui/mythuiclock.h (revision 0) +++ mythtv/libs/libmythui/mythuiclock.h (revision 0) @@ -0,0 +1,44 @@ +#ifndef MYTHUI_CLOCK_H_ +#define MYTHUI_CLOCK_H_ + +#include +#include +#include + +#include "mythuitype.h" + +class MythFontProperties; + +class MythUIClock : public MythUIType +{ + public: + MythUIClock(MythUIType *parent, const char *name); + ~MythUIClock(); + + virtual void Pulse(void); + + QString m_Format; + + protected: + virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, + int alphaMod, QRect clipRect); + + virtual bool ParseElement(QDomElement &element); + virtual void CopyFrom(MythUIType *base); + virtual void CreateCopy(MythUIType *parent); + virtual void Finalize(void); + + int m_Justification; + QRect m_OrigDisplayRect; + QRect m_AltDisplayRect; + + QColor m_Color; + + QDateTime m_Time; + QDateTime m_nextUpdate; + + MythFontProperties* m_Font; + +}; + +#endif Property changes on: mythtv/libs/libmythui/mythuiclock.h ___________________________________________________________________ Name: svn:eol-style + native Index: mythtv/libs/libmythui/libmythui.pro =================================================================== --- mythtv/libs/libmythui/libmythui.pro (revision 13527) +++ mythtv/libs/libmythui/libmythui.pro (working copy) @@ -22,6 +22,7 @@ HEADERS += mythscreenstack.h mythscreentype.h mythuitype.h mythuiimage.h HEADERS += mythuitext.h mythuistatetype.h mythgesture.h xmlparsebase.h HEADERS += mythuibutton.h mythlistbutton.h myththemedmenu.h mythdialogbox.h +HEADERS += mythuiclock.h SOURCES = mythmainwindow.cpp mythpainter.cpp mythimage.cpp myththemebase.cpp SOURCES += mythpainter_qt.cpp xmlparsebase.cpp @@ -29,6 +30,7 @@ SOURCES += mythuitype.cpp mythuiimage.cpp mythuitext.cpp SOURCES += mythuistatetype.cpp mythlistbutton.cpp mythfontproperties.cpp SOURCES += mythuibutton.cpp myththemedmenu.cpp mythdialogbox.cpp +SOURCES += mythuiclock.cpp inc.path = $${PREFIX}/include/mythtv/libmythui/ @@ -37,6 +39,7 @@ inc.files += mythscreenstack.h mythscreentype.h mythuitype.h mythuiimage.h inc.files += mythuitext.h mythuibutton.h mythlistbutton.h xmlparsebase.h inc.files += myththemedmenu.h mythdialogbox.h mythfontproperties.h +inc.files += mythuiclock.h INSTALLS += inc Index: mythtv/libs/libmythui/mythuiclock.cpp =================================================================== --- mythtv/libs/libmythui/mythuiclock.cpp (revision 0) +++ mythtv/libs/libmythui/mythuiclock.cpp (revision 0) @@ -0,0 +1,121 @@ +#include +using namespace std; + +#include "mythuiclock.h" +#include "mythpainter.h" +#include "mythmainwindow.h" + +#include "mythcontext.h" +#include "mythfontproperties.h" + +MythUIClock::MythUIClock(MythUIType *parent, const char *name) + : MythUIType(parent, name) +{ + m_Font = new MythFontProperties(); + + m_OrigDisplayRect = m_AltDisplayRect = m_Area = QRect(); + + m_Justification = (Qt::AlignLeft | Qt::AlignTop); + + m_Time = QDateTime::currentDateTime(); + m_nextUpdate = m_Time.addSecs(1); + + m_Format = "hh:mm:ss"; + VERBOSE(VB_IMPORTANT, "Constructed"); +} + +MythUIClock::~MythUIClock() +{ + if (m_Font) + { + delete m_Font; + m_Font = NULL; + } +} + +void MythUIClock::Pulse(void) +{ + m_Time = QDateTime::currentDateTime(); + + if (m_Time > m_nextUpdate) + { + SetRedraw(); + m_nextUpdate = m_Time.addSecs(1); + VERBOSE(VB_IMPORTANT, QString("%1").arg(m_Format)); + } + + MythUIType::Pulse(); +} + +void MythUIClock::DrawSelf(MythPainter *p, int xoffset, int yoffset, + int alphaMod, QRect clipRect) +{ + QRect area = m_Area; + area.moveBy(xoffset, yoffset); + + int alpha = CalcAlpha(alphaMod); + + p->DrawText(area, m_Time.toString(m_Format), m_Justification, *m_Font, alpha); +} + +bool MythUIClock::ParseElement(QDomElement &element) +{ + if (element.tagName() == "area") + m_Area = m_OrigDisplayRect = parseRect(element); + else if (element.tagName() == "color") + { + m_Color = getFirstText(element); + m_Font->SetColor(m_Color); + } + else if (element.tagName() == "font") + { + QString fontname = getFirstText(element); + MythFontProperties *fp = GetFont(fontname); + if (!fp) + fp = GetGlobalFontMap()->GetFont(fontname); + if (fp) + *m_Font = *fp; + } + else if (element.tagName() == "format") + { + QString format = getFirstText(element); + m_Format = format; + } + else + return MythUIType::ParseElement(element); + + return true; +} + +void MythUIClock::CopyFrom(MythUIType *base) +{ + MythUIClock *clock = dynamic_cast(base); + if (!clock) + { + VERBOSE(VB_IMPORTANT, "ERROR, bad parsing"); + return; + } + + m_Justification = clock->m_Justification; + m_OrigDisplayRect = clock->m_OrigDisplayRect; + m_AltDisplayRect = clock->m_AltDisplayRect; + + m_Time = clock->m_Time; + + *m_Font = *(clock->m_Font); + + m_Color = clock->m_Color; + + MythUIType::CopyFrom(base); +} + +void MythUIClock::CreateCopy(MythUIType *parent) +{ + MythUIClock *clock = new MythUIClock(parent, name()); + clock->CopyFrom(this); +} + +void MythUIClock::Finalize(void) +{ + MythUIType::Finalize(); +} Property changes on: mythtv/libs/libmythui/mythuiclock.cpp ___________________________________________________________________ Name: svn:eol-style + native