00001
00002 #include <cstdlib>
00003
00004
00005 #include <QRect>
00006 #include <QDomDocument>
00007
00008
00009 #include "mythlogging.h"
00010
00011
00012 #include "mythpainter.h"
00013 #include "mythmainwindow.h"
00014 #include "mythuihelper.h"
00015 #include "mythscreentype.h"
00016 #include "mythuivideo.h"
00017 #include "mythimage.h"
00018
00019 #define LOC QString("MythUIVideo(0x%1): ").arg((uint64_t)this, 0, 16)
00020
00021 MythUIVideo::MythUIVideo(MythUIType *parent, const QString &name)
00022 : MythUIType(parent, name)
00023 {
00024 m_image = GetMythPainter()->GetFormatImage();
00025 m_backgroundColor = QColor(Qt::black);
00026 }
00027
00028 MythUIVideo::~MythUIVideo()
00029 {
00030 if (m_image)
00031 {
00032 m_image->DownRef();
00033 m_image = NULL;
00034 }
00035 }
00036
00040 void MythUIVideo::Reset(void)
00041 {
00042 if (m_image)
00043 {
00044 m_image->DownRef();
00045 m_image = NULL;
00046 }
00047
00048 m_image = GetMythPainter()->GetFormatImage();
00049
00050 MythUIType::Reset();
00051 }
00052
00053 void MythUIVideo::UpdateFrame(MythImage *image)
00054 {
00055 m_image->Assign(*image);
00056
00057 SetRedraw();
00058 }
00059
00060 void MythUIVideo::UpdateFrame(QPixmap *pixmap)
00061 {
00062 m_image->Assign(*pixmap);
00063
00064 SetRedraw();
00065 }
00066
00070 void MythUIVideo::Pulse(void)
00071 {
00072
00073 MythUIType::Pulse();
00074 }
00075
00079 void MythUIVideo::DrawSelf(MythPainter *p, int xoffset, int yoffset,
00080 int alphaMod, QRect clipRect)
00081 {
00082 QRect area = GetArea();
00083 area.translate(xoffset, yoffset);
00084
00085 if (!m_image || m_image->isNull())
00086 return;
00087
00088 if (m_image)
00089 p->DrawImage(area.x(), area.y(), m_image, alphaMod);
00090 }
00091
00095 bool MythUIVideo::ParseElement(
00096 const QString &filename, QDomElement &element, bool showWarnings)
00097 {
00098 if (element.tagName() == "backgroundcolor")
00099 {
00100 m_backgroundColor = QColor(getFirstText(element));
00101 }
00102 else
00103 return MythUIType::ParseElement(filename, element, showWarnings);
00104
00105 return true;
00106 }
00107
00111 void MythUIVideo::CopyFrom(MythUIType *base)
00112 {
00113 MythUIType::CopyFrom(base);
00114 }
00115
00119 void MythUIVideo::CreateCopy(MythUIType *parent)
00120 {
00121 MythUIVideo *im = new MythUIVideo(parent, objectName());
00122 im->CopyFrom(this);
00123 }