Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scpattern.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           scpattern.cpp  -  description
00009                              -------------------
00010     begin                : Sat Sep 9 2006
00011     copyright            : (C) 2006 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #include <qstring.h>
00025 
00026 #include "scpattern.h"
00027 #include "pageitem.h"
00028 #include "pageitem_imageframe.h"
00029 #include "scribusdoc.h"
00030 #include "commonstrings.h"
00031 
00032 ScPattern::ScPattern()
00033 {
00034        items.clear();
00035        pattern = QImage();
00036        scaleX = 1.0;
00037        scaleY = 1.0;
00038        width = 0.0;
00039        height = 0.0;
00040 };
00041 
00042 void ScPattern::setDoc(ScribusDoc *doc)
00043 {
00044        m_doc = doc;
00045 }
00046 
00047 QImage* ScPattern::getPattern()
00048 {
00049        return &pattern;
00050 }
00051 
00052 void ScPattern::setPattern(QString name)
00053 {
00054        items.clear();
00055        PageItem* newItem = new PageItem_ImageFrame(m_doc, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None);
00056        if (newItem->loadImage(name, false, 72, false))
00057        {
00058               pattern = newItem->pixm.qImage().copy();
00059               scaleX = (72.0 / newItem->pixm.imgInfo.xres) * newItem->pixm.imgInfo.lowResScale;
00060               scaleY = (72.0 / newItem->pixm.imgInfo.xres) * newItem->pixm.imgInfo.lowResScale;
00061               newItem->setWidth(pattern.width());
00062               newItem->setHeight(pattern.height());
00063               newItem->SetRectFrame();
00064               newItem->gXpos = 0.0;
00065               newItem->gYpos = 0.0;
00066               newItem->gWidth = pattern.width();
00067               newItem->gHeight = pattern.height();
00068               width = pattern.width();
00069               height = pattern.height();
00070               items.append(newItem);
00071        }
00072        else
00073               pattern = QImage();
00074 }