Rev 5569 | Rev 5584 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 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 | */ |
||
3614 | cbradney | 7 | /*************************************************************************** |
8 | pageitem.cpp - description |
||
9 | ------------------- |
||
10 | begin : Sat Apr 7 2001 |
||
11 | copyright : (C) 2001 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 "pageitem_imageframe.h" |
||
25 | #include "pageitem_imageframe.moc" |
||
26 | #include <qpainter.h> |
||
27 | #include <qpen.h> |
||
28 | #include <qfont.h> |
||
29 | #include <qregion.h> |
||
30 | #include <qpoint.h> |
||
31 | #include <qfileinfo.h> |
||
32 | #include <qdrawutil.h> |
||
33 | #include <qbitmap.h> |
||
34 | #include <qregexp.h> |
||
35 | #include <qmessagebox.h> |
||
36 | #include <cmath> |
||
37 | #include <cassert> |
||
38 | |||
39 | #include "mpalette.h" |
||
40 | #include "page.h" |
||
41 | #include "pageitem.h" |
||
42 | #include "prefsmanager.h" |
||
43 | #include "scpaths.h" |
||
44 | #include "scribus.h" |
||
45 | #include "scribusstructs.h" |
||
46 | #include "scribusdoc.h" |
||
4546 | subik | 47 | #include "commonstrings.h" |
3614 | cbradney | 48 | #include "undomanager.h" |
49 | #include "undostate.h" |
||
50 | #include "scconfig.h" |
||
51 | |||
52 | #include <ft2build.h> |
||
53 | #include FT_GLYPH_H |
||
54 | |||
55 | #include "scfontmetrics.h" |
||
56 | #include "util.h" |
||
57 | |||
58 | using namespace std; |
||
59 | |||
60 | PageItem_ImageFrame::PageItem_ImageFrame(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline) |
||
61 | : PageItem(pa, PageItem::ImageFrame, x, y, w, h, w2, fill, outline) |
||
62 | { |
||
63 | } |
||
64 | |||
5350 | avox | 65 | void PageItem_ImageFrame::DrawObj_Item(ScPainter *p, QRect /*e*/, double sc) |
3614 | cbradney | 66 | { |
4084 | cbradney | 67 | if(!m_Doc->RePos) |
3614 | cbradney | 68 | { |
5572 | fschmid | 69 | if (!m_Doc->layerOutline(m_Doc->layerLevelFromNumber(LayerNr))) |
3614 | cbradney | 70 | { |
5572 | fschmid | 71 | if ((fillColor() != CommonStrings::None) || (GrType != 0)) |
72 | { |
||
73 | p->setupPolygon(&PoLine); |
||
74 | p->fillPath(); |
||
75 | } |
||
3614 | cbradney | 76 | } |
5471 | fschmid | 77 | p->save(); |
78 | #ifdef HAVE_CAIRO |
||
79 | if (imageClip.size() != 0) |
||
80 | { |
||
81 | p->setupPolygon(&imageClip); |
||
82 | p->setClipPath(); |
||
83 | } |
||
84 | p->setupPolygon(&PoLine); |
||
85 | p->setClipPath(); |
||
86 | #else |
||
87 | if (imageClip.size() != 0) |
||
88 | { |
||
89 | p->setupPolygon(&imageClip); |
||
90 | p->setClipPath2(&PoLine, true); |
||
91 | } |
||
92 | else |
||
93 | { |
||
94 | p->setupPolygon(&PoLine); |
||
95 | p->setClipPath(); |
||
96 | } |
||
97 | #endif |
||
3614 | cbradney | 98 | if (Pfile.isEmpty()) |
99 | { |
||
4084 | cbradney | 100 | if ((Frame) && (m_Doc->guidesSettings.framesShown)) |
3614 | cbradney | 101 | { |
102 | p->setPen(black, 1, SolidLine, FlatCap, MiterJoin); |
||
103 | p->drawLine(FPoint(0, 0), FPoint(Width, Height)); |
||
104 | p->drawLine(FPoint(0, Height), FPoint(Width, 0)); |
||
105 | } |
||
106 | } |
||
107 | else |
||
108 | { |
||
109 | if ((!PicArt) || (!PicAvail)) |
||
110 | { |
||
4084 | cbradney | 111 | if ((Frame) && (m_Doc->guidesSettings.framesShown)) |
3614 | cbradney | 112 | { |
113 | p->setPen(red, 1, SolidLine, FlatCap, MiterJoin); |
||
114 | p->drawLine(FPoint(0, 0), FPoint(Width, Height)); |
||
115 | p->drawLine(FPoint(0, Height), FPoint(Width, 0)); |
||
116 | } |
||
117 | } |
||
118 | else |
||
119 | { |
||
120 | if (imageFlippedH()) |
||
121 | { |
||
122 | p->translate(Width * sc, 0); |
||
123 | p->scale(-1, 1); |
||
124 | } |
||
125 | if (imageFlippedV()) |
||
126 | { |
||
127 | p->translate(0, Height * sc); |
||
128 | p->scale(1, -1); |
||
129 | } |
||
130 | p->translate(LocalX*LocalScX*sc, LocalY*LocalScY*sc); |
||
131 | p->scale(LocalScX, LocalScY); |
||
132 | if (pixm.imgInfo.lowResType != 0) |
||
133 | p->scale(pixm.imgInfo.lowResScale, pixm.imgInfo.lowResScale); |
||
134 | p->drawImage(&pixm); |
||
135 | } |
||
136 | } |
||
5471 | fschmid | 137 | p->restore(); |
3614 | cbradney | 138 | } |
139 | } |
||
3627 | cbradney | 140 | |
141 | void PageItem_ImageFrame::clearContents() |
||
142 | { |
||
3955 | fschmid | 143 | effectsInUse.clear(); |
144 | PicAvail = false; |
||
3627 | cbradney | 145 | Pfile = ""; |
146 | pixm = ScImage(); |
||
4546 | subik | 147 | |
3627 | cbradney | 148 | LocalScX = 1; |
149 | LocalScY = 1; |
||
150 | OrigW = 0; |
||
151 | OrigH = 0; |
||
152 | LocalX = 0; |
||
153 | LocalY = 0; |
||
154 | setImageFlippedH(false); |
||
155 | setImageFlippedV(false); |
||
156 | EmProfile = ""; |
||
157 | ScaleType = true; |
||
158 | AspectRatio = true; |
||
159 | setFillTransparency(0.0); |
||
160 | setLineTransparency(0.0); |
||
161 | imageClip.resize(0); |
||
4546 | subik | 162 | // emit UpdtObj(Doc->currentPage->pageNr(), ItemNr); |
3627 | cbradney | 163 | } |
164 | |||
5226 | cbradney | 165 | void PageItem_ImageFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat) |
166 | { |
||
167 | double moveBy=1.0; |
||
168 | ButtonState buttonState = k->state(); |
||
169 | if ((buttonState & ShiftButton) && !(buttonState & ControlButton)) |
||
170 | moveBy=10.0; |
||
171 | else if ((buttonState & ShiftButton) && (buttonState & ControlButton) && !(buttonState & AltButton)) |
||
172 | moveBy=0.1; |
||
173 | else if ((buttonState & ShiftButton) && (buttonState & ControlButton) && (buttonState & AltButton)) |
||
174 | moveBy=0.01; |
||
175 | moveBy/=m_Doc->unitRatio();//Lets allow movement by the current doc ratio, not only points |
||
176 | double dX=0.0,dY=0.0; |
||
177 | int kk = k->key(); |
||
178 | switch (kk) |
||
179 | { |
||
180 | case Key_Left: |
||
181 | dX=-moveBy; |
||
182 | break; |
||
183 | case Key_Right: |
||
184 | dX=moveBy; |
||
185 | break; |
||
186 | case Key_Up: |
||
187 | dY=-moveBy; |
||
188 | break; |
||
189 | case Key_Down: |
||
190 | dY=moveBy; |
||
191 | break; |
||
192 | } |
||
193 | if (dX!=0.0 || dY!=0.0) |
||
194 | { |
||
195 | moveImageInFrame(dX, dY); |
||
196 | ScribusView* view = m_Doc->view(); |
||
197 | view->updateContents(getRedrawBounding(view->scale())); |
||
198 | } |
||
5243 | cbradney | 199 | } |