sidepixmap.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "sidepixmap.h"
00021
00022 #include <qpainter.h>
00023 #include <kstandarddirs.h>
00024
00025 SidePixmap::SidePixmap(QWidget *parent, const char *name)
00026 : QFrame(parent, name)
00027 {
00028 setLineWidth(1);
00029 setFrameStyle(QFrame::WinPanel|QFrame::Sunken);
00030
00031 m_side.load(locate("data", "kdeprint/side.png"));
00032 m_tileup.load(locate("data", "kdeprint/tileup.png"));
00033 m_tiledown.load(locate("data", "kdeprint/tiledown.png"));
00034
00035 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum));
00036 }
00037
00038 bool SidePixmap::isValid()
00039 {
00040 return (!m_side.isNull() && !m_tileup.isNull() && !m_tiledown.isNull()
00041 && (m_side.width() == m_tileup.width())
00042 && (m_side.width() == m_tiledown.width()));
00043 }
00044
00045 QSize SidePixmap::sizeHint() const
00046 {
00047 return (QSize(m_side.width()+lineWidth(), 300+lineWidth()));
00048 }
00049
00050 void SidePixmap::drawContents(QPainter *p)
00051 {
00052 QRect r = contentsRect();
00053 if (r.height() <= m_side.height())
00054 {
00055
00056 int yoffset = (m_side.height()-r.height())/2;
00057 p->drawPixmap(r.left(), r.top(), m_side, 0, yoffset, r.width(), r.height());
00058 }
00059 else
00060 {
00061
00062
00063 int hh = (((r.height()-m_side.height())/2)/3)*3;
00064 if (hh > 0)
00065 p->drawTiledPixmap(r.left(), r.top(), r.width(), hh, m_tileup);
00066 p->drawPixmap(r.left(), r.top()+hh, m_side);
00067 p->drawTiledPixmap(r.left(), r.top()+m_side.height()+hh, r.width(), r.height()-m_side.height()-hh, m_tiledown);
00068 }
00069 }
|