Subversion Repositories Scribus

Rev

Rev 6369 | Rev 6380 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6368 fschmid 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
7
/***************************************************************************
8
                          scpattern.cpp  -  description
9
                             -------------------
10
    begin                : Sat Sep 9 2006
11
    copyright            : (C) 2006 by Franz Schmid
12
    email                : Franz.Schmid@altmuehlnet.de
13
 ***************************************************************************/
14
 
15
/***************************************************************************
16
 *                                                                         *
17
 *   This program is free software; you can redistribute it and/or modify  *
18
 *   it under the terms of the GNU General Public License as published by  *
19
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 *   (at your option) any later version.                                   *
21
 *                                                                         *
22
 ***************************************************************************/
23
 
24
#include <qstring.h>
25
 
26
#include "scpattern.h"
27
#include "pageitem.h"
6369 fschmid 28
#include "pageitem_imageframe.h"
29
#include "scribusdoc.h"
30
#include "commonstrings.h"
6368 fschmid 31
 
32
ScPattern::ScPattern()
33
{
34
        file = "";
6369 fschmid 35
//      items.setAutoDelete(true);
6368 fschmid 36
        items.clear();
37
        pattern = QImage();
6369 fschmid 38
        offsetX = 0.0;
39
        offsetY = 0.0;
40
        scaleX = 1.0;
41
        scaleY = 1.0;
42
        rotation = 0.0;
6368 fschmid 43
};
44
 
6369 fschmid 45
void ScPattern::setDoc(ScribusDoc *doc)
46
{
47
        m_doc = doc;
48
}
49
 
6368 fschmid 50
QImage* ScPattern::getPattern()
51
{
52
        return &pattern;
53
}
54
 
55
void ScPattern::setPattern(QString name)
56
{
6369 fschmid 57
        items.clear();
58
        PageItem* newItem = new PageItem_ImageFrame(m_doc, 0, 0, 1, 1, 0, CommonStrings::None, CommonStrings::None);
59
        if (newItem->loadImage(name, false, 72, false))
6368 fschmid 60
        {
6369 fschmid 61
                pattern = newItem->pixm.qImage().copy();
62
                scaleX = (72.0 / newItem->pixm.imgInfo.xres) * newItem->pixm.imgInfo.lowResScale;
63
                scaleY = (72.0 / newItem->pixm.imgInfo.xres) * newItem->pixm.imgInfo.lowResScale;
64
                newItem->setWidth(pattern.width());
65
                newItem->setHeight(pattern.height());
6378 fschmid 66
                newItem->SetRectFrame();
67
                newItem->gXpos = 0.0;
68
                newItem->gYpos = 0.0;
69
                newItem->gWidth = pattern.width();
70
                newItem->gHeight = pattern.height();
6369 fschmid 71
                items.append(newItem);
6368 fschmid 72
                file = name;
73
        }
74
        else
75
                pattern = QImage();
76
}