Rev 1290 | Rev 1298 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | pageitem.h - description |
||
3 | ------------------- |
||
4 | begin : Sat Apr 7 2001 |
||
5 | copyright : (C) 2001 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | |||
18 | #ifndef PAGEITEM_H |
||
19 | #define PAGEITEM_H |
||
20 | |||
21 | #include <qobject.h> |
||
22 | #include <qwidget.h> |
||
23 | #include <qpointarray.h> |
||
24 | #include <qptrlist.h> |
||
25 | #include <qimage.h> |
||
26 | #include <qpixmap.h> |
||
27 | #include <qvaluestack.h> |
||
28 | #include <qvaluelist.h> |
||
68 | Franz | 29 | #include "scpainter.h" |
1204 | tsoots | 30 | #include "undoobject.h" |
838 | cbradney | 31 | class ScribusDoc; |
1204 | tsoots | 32 | class UndoManager; |
33 | class UndoState; |
||
3 | paul | 34 | /** |
35 | *@author Franz Schmid |
||
36 | */ |
||
37 | |||
1204 | tsoots | 38 | class PageItem : public QObject, public UndoObject |
270 | Franz | 39 | { |
40 | Q_OBJECT |
||
3 | paul | 41 | |
42 | public: |
||
456 | fschmid | 43 | PageItem(ScribusDoc *pa, int art, double x, double y, double w, double h, double w2, QString fill, QString outline); |
3 | paul | 44 | ~PageItem() {}; |
168 | Franz | 45 | struct ZZ { |
46 | double xco; |
||
47 | double yco; |
||
268 | Franz | 48 | double wide; |
49 | double kern; |
||
168 | Franz | 50 | int Siz; |
51 | int Style; |
||
52 | int scale; |
||
268 | Franz | 53 | int shade; |
54 | int shade2; |
||
55 | bool Sele; |
||
56 | QString Zeich; |
||
57 | QString Farb; |
||
58 | QString Farb2; |
||
59 | QString ZFo; |
||
168 | Franz | 60 | }; |
3 | paul | 61 | /** Zeichnet das Item */ |
168 | Franz | 62 | void paintObj(QRect e=QRect(), QPixmap *ppX = 0); |
63 | void DrawObj(ScPainter *p, QRect e); |
||
1065 | cbradney | 64 | double SetZeichAttr(struct ScText *hl, int *chs, QString *chx); |
3 | paul | 65 | void SetFarbe(QColor *tmp, QString farbe, int shad); |
68 | Franz | 66 | void DrawZeichenS(ScPainter *p, struct ZZ *hl); |
3 | paul | 67 | void DrawPolyL(QPainter *p, QPointArray pts); |
68 | QString ExpandToken(uint base); |
||
69 | bool Locked; |
||
205 | Franz | 70 | bool LockRes; |
3 | paul | 71 | bool Reverse; |
72 | /** X-Position auf der Seite */ |
||
168 | Franz | 73 | double Xpos; |
1204 | tsoots | 74 | /** @brief Stores the old X-position for undo action. Is used to detect move actions.*/ |
75 | double oldXpos; |
||
3 | paul | 76 | /** Y-Position auf der Seite */ |
168 | Franz | 77 | double Ypos; |
1204 | tsoots | 78 | /** @brief Stores the old Y-position for undo action. Is used to detect move actions. */ |
79 | double oldYpos; |
||
3 | paul | 80 | /** Breite des Elements */ |
168 | Franz | 81 | double Width; |
1206 | tsoots | 82 | /** @brief Stores the old width for undo action. Is used to detect resize actions. */ |
83 | double oldWidth; |
||
3 | paul | 84 | /** Hoehe des Elements */ |
168 | Franz | 85 | double Height; |
1206 | tsoots | 86 | /** @brief Stores the old height for undo action. Is used to detect resize actions. */ |
87 | double oldHeight; |
||
3 | paul | 88 | /** Eckrundung von Rechtecken */ |
168 | Franz | 89 | double RadRect; |
3 | paul | 90 | /** Art des Items */ |
168 | Franz | 91 | int PType; |
3 | paul | 92 | /** Winkel um den das Item gedreht wird */ |
168 | Franz | 93 | double Rot; |
1211 | tsoots | 94 | /** @brief Stores the old rotation value for undo action. Is used to detect rotation actions. */ |
95 | double oldRot; |
||
3 | paul | 96 | /** Enthaelt das Dokument */ |
168 | Franz | 97 | ScribusDoc *Doc; |
3 | paul | 98 | int GrType; |
292 | Franz | 99 | double GrStartX; |
100 | double GrStartY; |
||
101 | double GrEndX; |
||
102 | double GrEndY; |
||
3 | paul | 103 | /** Fuellfarbe */ |
168 | Franz | 104 | QString Pcolor; |
105 | /** Abstufung fuer Fllfarbe */ |
||
106 | int Shade; |
||
3 | paul | 107 | /** Zeichenfarbe fuer Elemente */ |
168 | Franz | 108 | QString Pcolor2; |
3 | paul | 109 | /** Abstufung fuer Zeichenfarbe */ |
168 | Franz | 110 | int Shade2; |
68 | Franz | 111 | QString TxtStroke; |
112 | QString TxtFill; |
||
113 | int ShTxtStroke; |
||
114 | int ShTxtFill; |
||
115 | int TxtScale; |
||
116 | int TxTStyle; |
||
134 | Franz | 117 | int Cols; |
135 | Franz | 118 | double ColGap; |
3 | paul | 119 | /** Strichstaerke */ |
168 | Franz | 120 | double Pwidth; |
263 | Franz | 121 | double OldPwidth; |
3 | paul | 122 | /** Linienart */ |
168 | Franz | 123 | PenStyle PLineArt; |
124 | PenCapStyle PLineEnd; |
||
125 | PenJoinStyle PLineJoin; |
||
27 | Franz | 126 | QString NamedLStyle; |
3 | paul | 127 | /** Element selektiert Ja/Nein */ |
168 | Franz | 128 | bool Select; |
3 | paul | 129 | /** Definiert die Clipping-Region des Elements; */ |
168 | Franz | 130 | QPointArray Clip; |
3 | paul | 131 | FPointArray PoLine; |
340 | Franz | 132 | bool UseContour; |
133 | FPointArray ContourLine; |
||
3 | paul | 134 | QValueList<uint> Segments; |
135 | bool PoShow; |
||
80 | Franz | 136 | double BaseOffs; |
168 | Franz | 137 | bool ClipEdited; |
138 | int FrameType; |
||
3 | paul | 139 | /** Interne Item-Nummer */ |
168 | Franz | 140 | uint ItemNr; |
3 | paul | 141 | /** Hat Element Rahmen? */ |
168 | Franz | 142 | bool Frame; |
3 | paul | 143 | /** Seite zu der das Element gehoert */ |
456 | fschmid | 144 | int OwnPage; |
1211 | tsoots | 145 | /** @brief Old page number tracked for the move undo action */ |
146 | int oldOwnPage; |
||
3 | paul | 147 | /** Darzustellendes Bild */ |
168 | Franz | 148 | QImage pixm; |
204 | Franz | 149 | QImage pixmOrg; |
3 | paul | 150 | /** Dateiname des Bildes */ |
168 | Franz | 151 | QString Pfile; |
152 | QString Pfile2; |
||
153 | QString Pfile3; |
||
154 | QString IProfile; |
||
155 | bool UseEmbedded; |
||
156 | QString EmProfile; |
||
157 | int IRender; |
||
3 | paul | 158 | /** Darstellungsart Bild/Titel */ |
168 | Franz | 159 | bool PicArt; |
3 | paul | 160 | /** Bild verfuegbar */ |
168 | Franz | 161 | bool PicAvail; |
3 | paul | 162 | /** Lokales Scaling x*/ |
168 | Franz | 163 | double LocalScX; |
80 | Franz | 164 | double LocalViewX; |
3 | paul | 165 | /** Lokales Scaling y*/ |
168 | Franz | 166 | double LocalScY; |
80 | Franz | 167 | double LocalViewY; |
3 | paul | 168 | /** Lokales X */ |
168 | Franz | 169 | double LocalX; |
3 | paul | 170 | /** Lokales Y */ |
168 | Franz | 171 | double LocalY; |
3 | paul | 172 | int OrigW; |
173 | int OrigH; |
||
127 | Franz | 174 | double dpiX; |
175 | double dpiY; |
||
3 | paul | 176 | /** Anzahl horizontaler Spiegelungen */ |
168 | Franz | 177 | int flippedH; |
3 | paul | 178 | /** Anzahl vertikaler Spiegelungen */ |
168 | Franz | 179 | int flippedV; |
3 | paul | 180 | /** BoundigBox-X */ |
168 | Franz | 181 | double BBoxX; |
3 | paul | 182 | /** BoundingBox-H */ |
168 | Franz | 183 | double BBoxH; |
3 | paul | 184 | /** Extra Abstand vom Rand */ |
168 | Franz | 185 | double Extra; |
186 | double TExtra; |
||
187 | double BExtra; |
||
188 | double RExtra; |
||
3 | paul | 189 | /** Linespacing */ |
168 | Franz | 190 | double LineSp; |
3 | paul | 191 | /** Zeichen X-Position */ |
168 | Franz | 192 | double CurX; |
3 | paul | 193 | /** Zeichen Y-Position */ |
168 | Franz | 194 | double CurY; |
3 | paul | 195 | /** Cursorposition */ |
168 | Franz | 196 | int CPos; |
3 | paul | 197 | /** Text des Elements */ |
1065 | cbradney | 198 | QPtrList<ScText> itemText; |
3 | paul | 199 | /** Flag ob Element gedruckt wird */ |
168 | Franz | 200 | bool isPrintable; |
3 | paul | 201 | /** Flag fuer PDF-Bookmark */ |
168 | Franz | 202 | bool isBookmark; |
203 | int BMnr; |
||
3 | paul | 204 | /** Flag fuer PDF-Annotation */ |
168 | Franz | 205 | bool isAnnotation; |
206 | int AnType; |
||
3 | paul | 207 | int AnActType; |
168 | Franz | 208 | QString AnAction; |
3 | paul | 209 | QString An_E_act; |
210 | QString An_X_act; |
||
211 | QString An_D_act; |
||
212 | QString An_Fo_act; |
||
213 | QString An_Bl_act; |
||
214 | QString An_K_act; |
||
215 | QString An_F_act; |
||
216 | QString An_V_act; |
||
217 | QString An_C_act; |
||
218 | QString AnName; |
||
88 | Franz | 219 | bool AutoName; |
3 | paul | 220 | QString AnToolTip; |
221 | QString AnRollOver; |
||
222 | QString AnDown; |
||
223 | QString AnBColor; |
||
19 | Franz | 224 | QString An_Extern; |
3 | paul | 225 | int AnBsty; |
226 | int AnBwid; |
||
227 | int AnFeed; |
||
168 | Franz | 228 | int AnZiel; |
3 | paul | 229 | int AnFlag; |
230 | int AnMaxChar; |
||
231 | int AnVis; |
||
232 | int AnChkStil; |
||
233 | int AnFont; |
||
234 | bool AnIsChk; |
||
235 | bool AnAAact; |
||
236 | bool AnHTML; |
||
237 | bool AnUseIcons; |
||
238 | int AnIPlace; |
||
239 | int AnScaleW; |
||
240 | int AnFormat; |
||
241 | /** Flag fuer neuzeichnen im EditMode */ |
||
168 | Franz | 242 | bool Dirty; |
3 | paul | 243 | /** Item Font */ |
168 | Franz | 244 | QString IFont; |
3 | paul | 245 | /** Item Fontgroesse */ |
168 | Franz | 246 | int ISize; |
3 | paul | 247 | /** Flag fuer Auswahl */ |
168 | Franz | 248 | bool HasSel; |
3 | paul | 249 | /** Flag fuer Textfluss */ |
168 | Franz | 250 | bool Textflow; |
251 | bool Textflow2; |
||
252 | bool FrameOnly; |
||
253 | PageItem *BackBox; |
||
254 | PageItem *NextBox; |
||
255 | int NextIt; |
||
256 | int NextPg; |
||
257 | bool Tinput; |
||
258 | bool isAutoText; |
||
1065 | cbradney | 259 | int textAlignment; |
168 | Franz | 260 | uint MaxChars; |
261 | bool Redrawn; |
||
262 | double ExtraV; |
||
263 | bool isRaster; |
||
264 | double OldB; |
||
265 | double OldH; |
||
266 | double OldB2; |
||
267 | double OldH2; |
||
268 | bool Sizing; |
||
269 | bool toPixmap; |
||
3 | paul | 270 | int LayerNr; |
271 | bool ScaleType; |
||
272 | bool AspectRatio; |
||
80 | Franz | 273 | double Transparency; |
274 | double TranspStroke; |
||
168 | Franz | 275 | QValueStack<int> Groups; |
20 | Franz | 276 | bool InvPict; |
80 | Franz | 277 | QValueList<double> DashValues; |
139 | Franz | 278 | QValueList<double> TabValues; |
80 | Franz | 279 | double DashOffset; |
68 | Franz | 280 | VGradient fill_gradient; |
281 | QString Language; |
||
232 | Franz | 282 | /* Additions for Table Support */ |
283 | PageItem* LeftLink; |
||
284 | PageItem* RightLink; |
||
285 | PageItem* TopLink; |
||
286 | PageItem* BottomLink; |
||
234 | Franz | 287 | int LeftLinkID; |
288 | int RightLinkID; |
||
289 | int TopLinkID; |
||
290 | int BottomLinkID; |
||
232 | Franz | 291 | bool LeftLine; |
292 | bool RightLine; |
||
293 | bool TopLine; |
||
294 | bool BottomLine; |
||
295 | bool isTableItem; |
||
296 | bool isSingleSel; |
||
456 | fschmid | 297 | double BoundingX; |
298 | double BoundingY; |
||
299 | double BoundingW; |
||
300 | double BoundingH; |
||
301 | bool ChangedMasterItem; |
||
537 | fschmid | 302 | QString OnMasterPage; |
740 | fschmid | 303 | int startArrowIndex; |
304 | int endArrowIndex; |
||
1250 | tsoots | 305 | |
1211 | tsoots | 306 | /** @brief Manages undostack and is where all undo actions/states are sent. */ |
1204 | tsoots | 307 | UndoManager *undoManager; |
308 | /** |
||
309 | * @brief Set name of the item |
||
310 | * @param newName name for the item |
||
311 | * @author Riku Leino |
||
312 | */ |
||
313 | void setName(const QString& newName); |
||
1286 | tsoots | 314 | /** |
315 | * @brief Set the fill color of the object. |
||
316 | * @param newColor fill color for the object |
||
317 | */ |
||
318 | void setFillColor(const QString &newColor); |
||
319 | /** |
||
320 | * @brief Set the fill color shade. |
||
321 | * @param newShade shade for the fill color |
||
322 | */ |
||
323 | void setFillShade(int newShade); |
||
324 | /** |
||
325 | * @brief Set the line color of the object. |
||
326 | * @param newFill line color for the object |
||
327 | */ |
||
328 | void setLineColor(const QString &newColor); |
||
329 | /** |
||
330 | * @brief Set the line color shade. |
||
331 | * @param newColor shade for the line color |
||
332 | */ |
||
333 | void setLineShade(int newShade); |
||
1287 | tsoots | 334 | /** @brief Flip an image horizontally. */ |
335 | void flipImageH(); |
||
336 | /** @brief Flip an image vertically */ |
||
337 | void flipImageV(); |
||
1290 | tsoots | 338 | /** @brief Lock or unlock this pageitem. */ |
339 | void toggleLock(); |
||
1293 | tsoots | 340 | /** @brief Lock or unlock this pageitem */ |
341 | void setLocked(bool isLocked); |
||
1290 | tsoots | 342 | /** @brief Toggle lock for resizing */ |
343 | void toggleSizeLock(); |
||
1211 | tsoots | 344 | /** |
345 | * @brief Check the changes to the item and add undo actions for them. |
||
346 | * @param force Force the check. Do not care if mouse button or arrow key is down |
||
347 | * check anyway. |
||
348 | * @author Riku Leino |
||
349 | */ |
||
350 | void checkChanges(bool force = false); |
||
1204 | tsoots | 351 | /** |
1211 | tsoots | 352 | * @name Store undo actions |
1204 | tsoots | 353 | * @brief Add an undo action to the undo guis |
354 | * @author Riku Leino |
||
355 | */ |
||
1211 | tsoots | 356 | /*@{*/ |
1204 | tsoots | 357 | void moveUndoAction(); |
1211 | tsoots | 358 | void resizeUndoAction(); |
359 | void rotateUndoAction(); |
||
360 | /*@}*/ |
||
361 | /** @brief Required by the UndoObject */ |
||
362 | void restore(UndoState *state, bool isUndo); |
||
363 | private: |
||
1206 | tsoots | 364 | /** |
1211 | tsoots | 365 | * @name Restore helper methods |
366 | * Split the restore method for easier handling. |
||
1206 | tsoots | 367 | * @author Riku Leino |
368 | */ |
||
1211 | tsoots | 369 | /*@{*/ |
370 | void restoreMove(SimpleState *state, bool isUndo); |
||
371 | void restoreResize(SimpleState *state, bool isUndo); |
||
372 | void restoreRotate(SimpleState *state, bool isUndo); |
||
1286 | tsoots | 373 | void restoreFill(SimpleState *state, bool isUndo); |
374 | void restoreShade(SimpleState *state, bool isUndo); |
||
375 | void restoreLineColor(SimpleState *state, bool isUndo); |
||
376 | void restoreLineShade(SimpleState *state, bool isUndo); |
||
1211 | tsoots | 377 | /*@}*/ |
1238 | tsoots | 378 | |
379 | /** |
||
380 | * @brief Returns true if the actions should be sent to the UndoManager. |
||
381 | * |
||
382 | * Checks the state of the arrow keys and mouse buttons. If a key or a |
||
383 | * mouse button is down PageItem is under some action which should only be |
||
384 | * stored after the action has been finished (to get a single undo action). |
||
385 | * @return true if the actions should be sent to the UndoManager based on the |
||
386 | * state of arrow keys and mouse buttons else returns false. |
||
387 | */ |
||
388 | bool shouldCheck(); |
||
1290 | tsoots | 389 | /** @brief Clears the current selection and selects this PageItem. */ |
390 | void select(); |
||
3 | paul | 391 | }; |
392 | |||
393 | #endif |