Rev 1364 | Rev 1381 | 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 |
||
1364 | tsoots | 41 | // Properties - see http://doc.trolltech.com/3.3/properties.html |
42 | Q_PROPERTY(QString itemName READ itemName WRITE setItemName DESIGNABLE false) |
||
3 | paul | 43 | public: |
456 | fschmid | 44 | PageItem(ScribusDoc *pa, int art, double x, double y, double w, double h, double w2, QString fill, QString outline); |
3 | paul | 45 | ~PageItem() {}; |
168 | Franz | 46 | struct ZZ { |
47 | double xco; |
||
48 | double yco; |
||
268 | Franz | 49 | double wide; |
50 | double kern; |
||
168 | Franz | 51 | int Siz; |
52 | int Style; |
||
53 | int scale; |
||
268 | Franz | 54 | int shade; |
55 | int shade2; |
||
56 | bool Sele; |
||
57 | QString Zeich; |
||
58 | QString Farb; |
||
59 | QString Farb2; |
||
60 | QString ZFo; |
||
168 | Franz | 61 | }; |
3 | paul | 62 | /** Zeichnet das Item */ |
168 | Franz | 63 | void paintObj(QRect e=QRect(), QPixmap *ppX = 0); |
64 | void DrawObj(ScPainter *p, QRect e); |
||
1065 | cbradney | 65 | double SetZeichAttr(struct ScText *hl, int *chs, QString *chx); |
3 | paul | 66 | void SetFarbe(QColor *tmp, QString farbe, int shad); |
68 | Franz | 67 | void DrawZeichenS(ScPainter *p, struct ZZ *hl); |
3 | paul | 68 | void DrawPolyL(QPainter *p, QPointArray pts); |
69 | QString ExpandToken(uint base); |
||
70 | bool Locked; |
||
205 | Franz | 71 | bool LockRes; |
3 | paul | 72 | bool Reverse; |
73 | /** X-Position auf der Seite */ |
||
168 | Franz | 74 | double Xpos; |
1204 | tsoots | 75 | /** @brief Stores the old X-position for undo action. Is used to detect move actions.*/ |
76 | double oldXpos; |
||
3 | paul | 77 | /** Y-Position auf der Seite */ |
168 | Franz | 78 | double Ypos; |
1204 | tsoots | 79 | /** @brief Stores the old Y-position for undo action. Is used to detect move actions. */ |
80 | double oldYpos; |
||
3 | paul | 81 | /** Breite des Elements */ |
168 | Franz | 82 | double Width; |
1206 | tsoots | 83 | /** @brief Stores the old width for undo action. Is used to detect resize actions. */ |
84 | double oldWidth; |
||
3 | paul | 85 | /** Hoehe des Elements */ |
168 | Franz | 86 | double Height; |
1206 | tsoots | 87 | /** @brief Stores the old height for undo action. Is used to detect resize actions. */ |
88 | double oldHeight; |
||
3 | paul | 89 | /** Eckrundung von Rechtecken */ |
168 | Franz | 90 | double RadRect; |
3 | paul | 91 | /** Art des Items */ |
168 | Franz | 92 | int PType; |
3 | paul | 93 | /** Winkel um den das Item gedreht wird */ |
168 | Franz | 94 | double Rot; |
1211 | tsoots | 95 | /** @brief Stores the old rotation value for undo action. Is used to detect rotation actions. */ |
96 | double oldRot; |
||
3 | paul | 97 | /** Enthaelt das Dokument */ |
168 | Franz | 98 | ScribusDoc *Doc; |
3 | paul | 99 | int GrType; |
292 | Franz | 100 | double GrStartX; |
101 | double GrStartY; |
||
102 | double GrEndX; |
||
103 | double GrEndY; |
||
3 | paul | 104 | /** Fuellfarbe */ |
168 | Franz | 105 | QString Pcolor; |
106 | /** Abstufung fuer Fllfarbe */ |
||
107 | int Shade; |
||
3 | paul | 108 | /** Zeichenfarbe fuer Elemente */ |
168 | Franz | 109 | QString Pcolor2; |
3 | paul | 110 | /** Abstufung fuer Zeichenfarbe */ |
168 | Franz | 111 | int Shade2; |
68 | Franz | 112 | QString TxtStroke; |
113 | QString TxtFill; |
||
114 | int ShTxtStroke; |
||
115 | int ShTxtFill; |
||
116 | int TxtScale; |
||
117 | int TxTStyle; |
||
134 | Franz | 118 | int Cols; |
135 | Franz | 119 | double ColGap; |
3 | paul | 120 | /** Strichstaerke */ |
168 | Franz | 121 | double Pwidth; |
263 | Franz | 122 | double OldPwidth; |
3 | paul | 123 | /** Linienart */ |
168 | Franz | 124 | PenStyle PLineArt; |
125 | PenCapStyle PLineEnd; |
||
126 | PenJoinStyle PLineJoin; |
||
27 | Franz | 127 | QString NamedLStyle; |
3 | paul | 128 | /** Element selektiert Ja/Nein */ |
168 | Franz | 129 | bool Select; |
3 | paul | 130 | /** Definiert die Clipping-Region des Elements; */ |
168 | Franz | 131 | QPointArray Clip; |
3 | paul | 132 | FPointArray PoLine; |
340 | Franz | 133 | bool UseContour; |
134 | FPointArray ContourLine; |
||
3 | paul | 135 | QValueList<uint> Segments; |
136 | bool PoShow; |
||
80 | Franz | 137 | double BaseOffs; |
168 | Franz | 138 | bool ClipEdited; |
139 | int FrameType; |
||
3 | paul | 140 | /** Interne Item-Nummer */ |
168 | Franz | 141 | uint ItemNr; |
3 | paul | 142 | /** Hat Element Rahmen? */ |
168 | Franz | 143 | bool Frame; |
3 | paul | 144 | /** Seite zu der das Element gehoert */ |
456 | fschmid | 145 | int OwnPage; |
1211 | tsoots | 146 | /** @brief Old page number tracked for the move undo action */ |
147 | int oldOwnPage; |
||
3 | paul | 148 | /** Darzustellendes Bild */ |
168 | Franz | 149 | QImage pixm; |
204 | Franz | 150 | QImage pixmOrg; |
3 | paul | 151 | /** Dateiname des Bildes */ |
168 | Franz | 152 | QString Pfile; |
153 | QString Pfile2; |
||
154 | QString Pfile3; |
||
155 | QString IProfile; |
||
156 | bool UseEmbedded; |
||
157 | QString EmProfile; |
||
158 | int IRender; |
||
3 | paul | 159 | /** Darstellungsart Bild/Titel */ |
168 | Franz | 160 | bool PicArt; |
3 | paul | 161 | /** Bild verfuegbar */ |
168 | Franz | 162 | bool PicAvail; |
3 | paul | 163 | /** Lokales Scaling x*/ |
168 | Franz | 164 | double LocalScX; |
80 | Franz | 165 | double LocalViewX; |
3 | paul | 166 | /** Lokales Scaling y*/ |
168 | Franz | 167 | double LocalScY; |
80 | Franz | 168 | double LocalViewY; |
3 | paul | 169 | /** Lokales X */ |
168 | Franz | 170 | double LocalX; |
3 | paul | 171 | /** Lokales Y */ |
168 | Franz | 172 | double LocalY; |
3 | paul | 173 | int OrigW; |
174 | int OrigH; |
||
127 | Franz | 175 | double dpiX; |
176 | double dpiY; |
||
3 | paul | 177 | /** Anzahl horizontaler Spiegelungen */ |
168 | Franz | 178 | int flippedH; |
3 | paul | 179 | /** Anzahl vertikaler Spiegelungen */ |
168 | Franz | 180 | int flippedV; |
3 | paul | 181 | /** BoundigBox-X */ |
168 | Franz | 182 | double BBoxX; |
3 | paul | 183 | /** BoundingBox-H */ |
168 | Franz | 184 | double BBoxH; |
3 | paul | 185 | /** Extra Abstand vom Rand */ |
168 | Franz | 186 | double Extra; |
187 | double TExtra; |
||
188 | double BExtra; |
||
189 | double RExtra; |
||
3 | paul | 190 | /** Linespacing */ |
168 | Franz | 191 | double LineSp; |
3 | paul | 192 | /** Zeichen X-Position */ |
168 | Franz | 193 | double CurX; |
3 | paul | 194 | /** Zeichen Y-Position */ |
168 | Franz | 195 | double CurY; |
3 | paul | 196 | /** Cursorposition */ |
168 | Franz | 197 | int CPos; |
3 | paul | 198 | /** Text des Elements */ |
1065 | cbradney | 199 | QPtrList<ScText> itemText; |
3 | paul | 200 | /** Flag ob Element gedruckt wird */ |
168 | Franz | 201 | bool isPrintable; |
3 | paul | 202 | /** Flag fuer PDF-Bookmark */ |
168 | Franz | 203 | bool isBookmark; |
204 | int BMnr; |
||
3 | paul | 205 | /** Flag fuer PDF-Annotation */ |
168 | Franz | 206 | bool isAnnotation; |
207 | int AnType; |
||
3 | paul | 208 | int AnActType; |
168 | Franz | 209 | QString AnAction; |
3 | paul | 210 | QString An_E_act; |
211 | QString An_X_act; |
||
212 | QString An_D_act; |
||
213 | QString An_Fo_act; |
||
214 | QString An_Bl_act; |
||
215 | QString An_K_act; |
||
216 | QString An_F_act; |
||
217 | QString An_V_act; |
||
218 | QString An_C_act; |
||
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; |
1361 | tsoots | 308 | /** @brief Get name of the item |
309 | * |
||
310 | * This is unrelated to QObject::name(); the pageItem's name is independent |
||
311 | * of its Qt name. |
||
312 | * See also PageItem::setItemName() |
||
313 | */ |
||
1371 | tsoots | 314 | QString itemName() const; |
1361 | tsoots | 315 | /** |
1204 | tsoots | 316 | * @brief Set name of the item |
317 | * @param newName name for the item |
||
318 | * @author Riku Leino |
||
1361 | tsoots | 319 | * |
320 | * Note that this is unrelated to QObject::setName() |
||
321 | * See also PageItem::itemName() |
||
1204 | tsoots | 322 | */ |
1361 | tsoots | 323 | void setItemName(const QString& newName); |
1286 | tsoots | 324 | /** |
325 | * @brief Set the fill color of the object. |
||
326 | * @param newColor fill color for the object |
||
327 | */ |
||
328 | void setFillColor(const QString &newColor); |
||
329 | /** |
||
330 | * @brief Set the fill color shade. |
||
331 | * @param newShade shade for the fill color |
||
332 | */ |
||
333 | void setFillShade(int newShade); |
||
334 | /** |
||
1371 | tsoots | 335 | * @brief Set the transparency of the fill color. |
336 | * @param newTransparency transparency of the fill color |
||
337 | */ |
||
338 | void setFillTransparency(double newTransparency); |
||
339 | /** |
||
1286 | tsoots | 340 | * @brief Set the line color of the object. |
341 | * @param newFill line color for the object |
||
342 | */ |
||
343 | void setLineColor(const QString &newColor); |
||
344 | /** |
||
345 | * @brief Set the line color shade. |
||
346 | * @param newColor shade for the line color |
||
347 | */ |
||
348 | void setLineShade(int newShade); |
||
1371 | tsoots | 349 | /** |
350 | * @brief Set the transparency of the line color. |
||
351 | * @param newTransparency transparency of the line color |
||
352 | */ |
||
353 | void setLineTransparency(double newTransparency); |
||
1287 | tsoots | 354 | /** @brief Flip an image horizontally. */ |
355 | void flipImageH(); |
||
356 | /** @brief Flip an image vertically */ |
||
357 | void flipImageV(); |
||
1290 | tsoots | 358 | /** @brief Lock or unlock this pageitem. */ |
359 | void toggleLock(); |
||
1293 | tsoots | 360 | /** @brief Lock or unlock this pageitem */ |
361 | void setLocked(bool isLocked); |
||
1290 | tsoots | 362 | /** @brief Toggle lock for resizing */ |
363 | void toggleSizeLock(); |
||
1298 | fschmid | 364 | /** @brief Toggle lock for resizing */ |
365 | void setSizeLocked(bool isLocked); |
||
1211 | tsoots | 366 | /** |
367 | * @brief Check the changes to the item and add undo actions for them. |
||
368 | * @param force Force the check. Do not care if mouse button or arrow key is down |
||
369 | * check anyway. |
||
370 | * @author Riku Leino |
||
371 | */ |
||
372 | void checkChanges(bool force = false); |
||
1204 | tsoots | 373 | /** |
1211 | tsoots | 374 | * @name Store undo actions |
1204 | tsoots | 375 | * @brief Add an undo action to the undo guis |
376 | * @author Riku Leino |
||
377 | */ |
||
1211 | tsoots | 378 | /*@{*/ |
1204 | tsoots | 379 | void moveUndoAction(); |
1211 | tsoots | 380 | void resizeUndoAction(); |
381 | void rotateUndoAction(); |
||
382 | /*@}*/ |
||
383 | /** @brief Required by the UndoObject */ |
||
384 | void restore(UndoState *state, bool isUndo); |
||
1361 | tsoots | 385 | |
386 | protected: |
||
1206 | tsoots | 387 | /** |
1211 | tsoots | 388 | * @name Restore helper methods |
389 | * Split the restore method for easier handling. |
||
1206 | tsoots | 390 | * @author Riku Leino |
391 | */ |
||
1211 | tsoots | 392 | /*@{*/ |
393 | void restoreMove(SimpleState *state, bool isUndo); |
||
394 | void restoreResize(SimpleState *state, bool isUndo); |
||
395 | void restoreRotate(SimpleState *state, bool isUndo); |
||
1286 | tsoots | 396 | void restoreFill(SimpleState *state, bool isUndo); |
397 | void restoreShade(SimpleState *state, bool isUndo); |
||
398 | void restoreLineColor(SimpleState *state, bool isUndo); |
||
399 | void restoreLineShade(SimpleState *state, bool isUndo); |
||
1357 | tsoots | 400 | void restoreName(SimpleState *state, bool isUndo); |
1371 | tsoots | 401 | void restoreFillTP(SimpleState *state, bool isUndo); |
402 | void restoreLineTP(SimpleState *state, bool isUndo); |
||
1211 | tsoots | 403 | /*@}*/ |
1238 | tsoots | 404 | |
405 | /** |
||
406 | * @brief Returns true if the actions should be sent to the UndoManager. |
||
407 | * |
||
408 | * Checks the state of the arrow keys and mouse buttons. If a key or a |
||
409 | * mouse button is down PageItem is under some action which should only be |
||
410 | * stored after the action has been finished (to get a single undo action). |
||
411 | * @return true if the actions should be sent to the UndoManager based on the |
||
412 | * state of arrow keys and mouse buttons else returns false. |
||
413 | */ |
||
414 | bool shouldCheck(); |
||
1290 | tsoots | 415 | /** @brief Clears the current selection and selects this PageItem. */ |
416 | void select(); |
||
1361 | tsoots | 417 | |
418 | // Protected members |
||
419 | |||
420 | /** |
||
421 | * @brief Item name. Unicode. User visible (outline, property palette, etc). |
||
422 | * |
||
423 | * See PageItem::itemName(), PageItem::setItemName() |
||
424 | * */ |
||
425 | QString AnName; |
||
3 | paul | 426 | }; |
427 | |||
428 | #endif |