kdeprint Library API Documentation

sidepixmap.cpp

00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License version 2 as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 * Boston, MA 02111-1307, USA. 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 // case where the main pixmap is enough, just center it 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 // we need to add tiled pixmap. Make sure we have a multiple 00062 // of 3 in the space above to simplifu tiling. 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 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 12 15:09:34 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003