Subversion Repositories Scribus

Rev

Rev 3820 | Rev 3894 | 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 <qpixmap.h>
26
#include <qvaluestack.h>
27
#include <qvaluelist.h>
2969 craig 28
 
29
#include "scribusapi.h"
68 Franz 30
#include "scpainter.h"
1204 tsoots 31
#include "undoobject.h"
2004 fschmid 32
#include "scimage.h"
1644 cbradney 33
#include "pagestructs.h"
838 cbradney 34
class ScribusDoc;
1204 tsoots 35
class UndoManager;
36
class UndoState;
1789 fschmid 37
class Foi;
3618 avox 38
 
39
class PageItem_ImageFrame;  
40
class PageItem_Line;        
41
class PageItem_Polygon;
42
class PageItem_PolyLine;
43
class PageItem_TextFrame;
44
class PageItem_PathText;    
45
 
3030 cbradney 46
struct CopyPasteBuffer;
3 paul 47
/**
48
  *@author Franz Schmid
49
  */
1489 tsoots 50
 
2969 craig 51
class SCRIBUS_API PageItem : public QObject, public UndoObject
270 Franz 52
{
53
        Q_OBJECT
1394 cbradney 54
 
1364 tsoots 55
        // Properties - see http://doc.trolltech.com/3.3/properties.html
1381 cbradney 56
        // See the getters and setters of these properties for details on their use.
1364 tsoots 57
        Q_PROPERTY(QString itemName READ itemName WRITE setItemName DESIGNABLE false)
1381 cbradney 58
        Q_PROPERTY(QString fillColor READ fillColor WRITE setFillColor DESIGNABLE false)
1394 cbradney 59
        Q_PROPERTY(QString lineColor READ lineColor WRITE setLineColor DESIGNABLE false)
1381 cbradney 60
        Q_PROPERTY(int fillShade READ fillShade WRITE setFillShade DESIGNABLE false)
1394 cbradney 61
        Q_PROPERTY(int lineShade READ lineShade WRITE setLineShade DESIGNABLE false)
1381 cbradney 62
        Q_PROPERTY(double fillTransparency READ fillTransparency WRITE setFillTransparency DESIGNABLE false)
63
        Q_PROPERTY(double lineTransparency READ lineTransparency WRITE setLineTransparency DESIGNABLE false)
64
        Q_PROPERTY(bool locked READ locked WRITE setLocked DESIGNABLE false)
65
        Q_PROPERTY(bool sizeLocked READ sizeLocked WRITE setSizeLocked DESIGNABLE false)
1392 cbradney 66
        Q_PROPERTY(bool imageFlippedV READ imageFlippedV WRITE setImageFlippedV DESIGNABLE false)
67
        Q_PROPERTY(bool imageFlippedH READ imageFlippedH WRITE setImageFlippedH DESIGNABLE false)
1394 cbradney 68
        Q_PROPERTY(double lineWidth READ lineWidth WRITE setLineWidth DESIGNABLE false)
69
        Q_PROPERTY(QString customLineStyle READ customLineStyle WRITE setCustomLineStyle DESIGNABLE false)
70
        Q_PROPERTY(int startArrowIndex READ getStartArrowIndex WRITE setStartArrowIndex DESIGNABLE false)
71
        Q_PROPERTY(int endArrowIndex READ getEndArrowIndex WRITE setEndArrowIndex DESIGNABLE false)
1422 tsoots 72
        Q_PROPERTY(QString font READ font WRITE setFont DESIGNABLE false)
73
        Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize DESIGNABLE false)
74
        Q_PROPERTY(int fontWidth READ fontWidth WRITE setFontWidth DESIGNABLE false)
75
        Q_PROPERTY(QString fontFillColor READ fontFillColor WRITE setFontFillColor DESIGNABLE false)
76
        Q_PROPERTY(int fontFillShade READ fontFillShade WRITE setFontFillShade DESIGNABLE false)
77
        Q_PROPERTY(QString fontStrokeColor READ fontStrokeColor WRITE setFontStrokeColor DESIGNABLE false)
78
        Q_PROPERTY(int fontStrokeShade READ fontStrokeShade WRITE setFontStrokeShade DESIGNABLE false)
79
        Q_PROPERTY(int fontEffects READ fontEffects WRITE setFontEffects DESIGNABLE false)
2436 craig 80
        Q_PROPERTY(int kerning READ kerning WRITE setKerning  DESIGNABLE false)
1422 tsoots 81
        Q_PROPERTY(double lineSpacing READ lineSpacing WRITE setLineSpacing DESIGNABLE false)
82
        Q_PROPERTY(QString language READ language WRITE setLanguage DESIGNABLE false)
1651 craig 83
        Q_PROPERTY(bool textFlowsAroundFrame READ textFlowsAroundFrame WRITE setTextFlowsAroundFrame DESIGNABLE false)
1653 craig 84
        Q_PROPERTY(bool textFlowUsesBoundingBox READ textFlowUsesBoundingBox WRITE setTextFlowUsesBoundingBox DESIGNABLE false)
2449 cbradney 85
        Q_PROPERTY(bool isPrintable READ printable WRITE setPrintable DESIGNABLE false)
2707 subik 86
 
1422 tsoots 87
        // FIXME: QMetaProperty can't translate these to/from enumerator names, probably because the
88
        // properties aren't moc'd in the Qt sources. They work fine in their
89
        // current state as plain integer properties.
1394 cbradney 90
        Q_ENUMS(PenStyle)
91
        Q_PROPERTY(PenStyle lineStyle READ lineStyle WRITE setLineStyle DESIGNABLE false)
92
        Q_ENUMS(PenCapStyle)
93
        Q_PROPERTY(PenCapStyle lineEnd READ lineEnd WRITE setLineEnd DESIGNABLE false)
94
        Q_ENUMS(PenJoinStyle)
95
        Q_PROPERTY(PenJoinStyle lineJoin READ lineJoin WRITE setLineJoin DESIGNABLE false)
96
 
1422 tsoots 97
        // This property may not hang around for too long, but should be useful
98
        // when testing out the pageitem refactoring work.  Setting it is unlikely
99
        // to currently have the desired effect.
100
        /**
3232 cbradney 101
         * @brief Item type.
1422 tsoots 102
         * @warning Do not set this property except for testing and debug purposes.
103
         */
1460 cbradney 104
        Q_ENUMS(ItemType)
105
        Q_PROPERTY(ItemType itemType READ itemType WRITE convertTo DESIGNABLE false)
1422 tsoots 106
 
1460 cbradney 107
public:
108
        // Enumerator definitions
1489 tsoots 109
 
3232 cbradney 110
        /** @brief Item Type
1460 cbradney 111
         *
3618 avox 112
         * Soon, item type will probably go away in favour of using
1460 cbradney 113
         * subclasses and checking types using more conventional methods
114
         * and using Qt's MetaObject introspection.
115
         */
116
        enum ItemType {
3232 cbradney 117
                ItemType1       = 1,
1460 cbradney 118
                ImageFrame      = 2,
3232 cbradney 119
                ItemType3       = 3,
1460 cbradney 120
                TextFrame       = 4,
121
                Line            = 5,
122
                Polygon         = 6,
123
                PolyLine        = 7,
124
                PathText        = 8
125
        };
3618 avox 126
 
127
        /* these do essentially the same as a dynamic cast but might be more readable */
128
        virtual PageItem_ImageFrame * asImageFrame() { return NULL; }
129
        virtual PageItem_Line * asLine() { return NULL; }
130
        virtual PageItem_PathText * asPathText() { return NULL; }
131
        virtual PageItem_Polygon * asPolygon() { return NULL; }
132
        virtual PageItem_PolyLine * asPolyLine() { return NULL; }
133
        virtual PageItem_TextFrame * asTextFrame() { return NULL; }
134
 
135
 
3232 cbradney 136
        /** @brief Frame Type
137
         *
138
         *
139
         */
3233 cbradney 140
        enum ItemFrameType {
141
                Unspecified =-1,
142
                Rectangle       = 0,
3232 cbradney 143
                Ellipse         = 1,
3233 cbradney 144
                Round           = 2,
145
                Other           = 3
3232 cbradney 146
        };
1460 cbradney 147
 
2282 fschmid 148
struct TabRecord
149
{
150
        double tabPosition;
151
        int tabType;
152
        QChar tabFillChar;
153
};
1460 cbradney 154
 
3625 avox 155
protected:
156
        PageItem(const PageItem & other);
157
 
158
public:
1460 cbradney 159
        PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double w, double h, double w2, QString fill, QString outline);
3 paul 160
        ~PageItem() {};
1489 tsoots 161
        struct ZZ {
168 Franz 162
                                double xco;
163
                                double yco;
268 Franz 164
                                double wide;
165
                                double kern;
168 Franz 166
                                int Siz;
2185 fschmid 167
                                int realSiz;
168 Franz 168
                                int Style;
169
                                int scale;
2230 fschmid 170
                                int scalev;
268 Franz 171
                                int shade;
172
                                int shade2;
2247 fschmid 173
                                int shadowX;
174
                                int shadowY;
2257 fschmid 175
                                int outline;
2234 fschmid 176
                                int base;
2262 fschmid 177
                                int underpos;
178
                                int underwidth;
2272 fschmid 179
                                int strikepos;
180
                                int strikewidth;
268 Franz 181
                                bool Sele;
182
                                QString Zeich;
183
                                QString Farb;
184
                                QString Farb2;
1789 fschmid 185
                                Foi* ZFo;
2434 fschmid 186
                                PageItem* embedded;
3627 cbradney 187
                        };
188
        /**
189
         * @brief Clear the contents of a frame.
190
         * WARNING: Currently *they* do not check if the user wants this.
191
         * The view does when these are called.
192
         */    
193
        virtual void clearContents() {};
3651 cbradney 194
 
195
        /**
196
         * @brief Adjust the picture scale, moved from the view, no view code here
197
         * FIXME: Move to PageItem_TextFrame
198
         */
199
        void AdjustPictScale();
3656 cbradney 200
 
201
        /**
202
         * @brief Set or get the redraw bounding box of the item, moved from the View
203
         */
204
        QRect getRedrawBounding(const double);
205
        void setRedrawBounding();
3627 cbradney 206
 
3657 cbradney 207
        /**
208
         * @brief Update the gradient vectors, moved from the View
209
         */            
210
        void updateGradientVectors();
3627 cbradney 211
 
1460 cbradney 212
 
1649 cbradney 213
        ObjAttrVector* getObjectAttributes();
1676 cbradney 214
        /*!
215
         * brief Returns a complete ObjectAttribute struct if 1 is found, or ObjectAttribute.name will be QString::null if 0 or >1 are found
216
         */
217
        ObjectAttribute getObjectAttribute(QString);
1649 cbradney 218
        void setObjectAttributes(ObjAttrVector*);
3 paul 219
  /** Zeichnet das Item */
168 Franz 220
        void paintObj(QRect e=QRect(), QPixmap *ppX = 0);
221
        void DrawObj(ScPainter *p, QRect e);
2434 fschmid 222
        void DrawObj_Pre(ScPainter *p, double &sc);
223
        void DrawObj_Post(ScPainter *p);
3617 cbradney 224
        virtual void DrawObj_Item(ScPainter *p);
225
        virtual void DrawObj_Item(ScPainter *p, double sc);
226
        virtual void DrawObj_Item(ScPainter *p, QRect e, double sc);
2434 fschmid 227
        void DrawObj_ImageFrame(ScPainter *p, double sc);
3617 cbradney 228
        //void DrawObj_TextFrame(ScPainter *p, QRect e, double sc);
229
        //void DrawObj_Line(ScPainter *p);
2434 fschmid 230
        void DrawObj_Polygon(ScPainter *p);
231
        void DrawObj_PolyLine(ScPainter *p);
232
        void DrawObj_PathText(ScPainter *p, double sc);
233
        void DrawObj_Embedded(ScPainter *p, QRect e, struct ZZ *hl);
3242 cbradney 234
 
235
        void SetFrameShape(int count, double *vals);
236
        void SetRectFrame();
237
        void SetOvalFrame();
238
        void SetFrameRound();
3680 cbradney 239
        void SetPolyClip(int up);
240
        void UpdatePolyClip();
3242 cbradney 241
        //QRect getRedrawBounding(const double);
242
        //void setRedrawBounding();
243
        void getBoundingRect(double *x1, double *y1, double *x2, double *y2);
3030 cbradney 244
        void copyToCopyPasteBuffer(struct CopyPasteBuffer *Buffer);
3242 cbradney 245
 
3829 cbradney 246
        virtual void handleModeEditKey(QKeyEvent *k, bool &keyRepeat);
3680 cbradney 247
 
248
 
249
 
250
 
251
 
252
 
253
 
1065 cbradney 254
        double SetZeichAttr(struct ScText *hl, int *chs, QString *chx);
3 paul 255
        void SetFarbe(QColor *tmp, QString farbe, int shad);
68 Franz 256
        void DrawZeichenS(ScPainter *p, struct ZZ *hl);
3 paul 257
        void DrawPolyL(QPainter *p, QPointArray pts);
258
        QString ExpandToken(uint base);
259
        bool Reverse;
260
  /** X-Position auf der Seite */
168 Franz 261
        double Xpos;
1204 tsoots 262
        /** @brief Stores the old X-position for undo action. Is used to detect move actions.*/
263
        double oldXpos;
3 paul 264
  /** Y-Position auf der Seite */
168 Franz 265
        double Ypos;
1204 tsoots 266
        /** @brief Stores the old Y-position for undo action. Is used to detect move actions. */
267
        double oldYpos;
3 paul 268
  /** Breite des Elements */
168 Franz 269
        double Width;
1206 tsoots 270
        /** @brief Stores the old width for undo action. Is used to detect resize actions. */
271
        double oldWidth;
3 paul 272
  /** Hoehe des Elements */
168 Franz 273
        double Height;
1206 tsoots 274
        /** @brief Stores the old height for undo action. Is used to detect resize actions. */
275
        double oldHeight;
2955 fschmid 276
        double gXpos;
277
        double gYpos;
278
        double gWidth;
279
        double gHeight;
3 paul 280
  /** Eckrundung von Rechtecken */
168 Franz 281
        double RadRect;
3 paul 282
  /** Winkel um den das Item gedreht wird */
168 Franz 283
        double Rot;
1211 tsoots 284
        /** @brief Stores the old rotation value for undo action. Is used to detect rotation actions. */
285
        double oldRot;
3 paul 286
  /** Enthaelt das Dokument */
168 Franz 287
        ScribusDoc *Doc;
3 paul 288
        int GrType;
292 Franz 289
        double GrStartX;
290
        double GrStartY;
291
        double GrEndX;
292
        double GrEndY;
68 Franz 293
        QString TxtStroke;
294
        QString TxtFill;
295
        int ShTxtStroke;
296
        int ShTxtFill;
297
        int TxtScale;
2230 fschmid 298
        int TxtScaleV;
68 Franz 299
        int TxTStyle;
2234 fschmid 300
        int TxtBase;
2247 fschmid 301
        int TxtShadowX;
302
        int TxtShadowY;
2257 fschmid 303
        int TxtOutline;
2262 fschmid 304
        int TxtUnderPos;
305
        int TxtUnderWidth;
2272 fschmid 306
        int TxtStrikePos;
307
        int TxtStrikeWidth;
134 Franz 308
        int Cols;
135 Franz 309
        double ColGap;
3 paul 310
  /** Strichstaerke */
168 Franz 311
        double Pwidth;
263 Franz 312
        double OldPwidth;
3 paul 313
  /** Linienart */
168 Franz 314
        PenStyle PLineArt;
315
        PenCapStyle PLineEnd;
316
        PenJoinStyle PLineJoin;
27 Franz 317
        QString NamedLStyle;
3 paul 318
  /** Element selektiert Ja/Nein */
168 Franz 319
        bool Select;
3 paul 320
  /** Definiert die Clipping-Region des Elements; */
168 Franz 321
        QPointArray Clip;
3 paul 322
        FPointArray PoLine;
340 Franz 323
        FPointArray ContourLine;
2040 fschmid 324
        FPointArray imageClip;
3 paul 325
        QValueList<uint> Segments;
2074 fschmid 326
        QValueList<ScImage::imageEffect> effectsInUse;
3 paul 327
        bool PoShow;
80 Franz 328
        double BaseOffs;
168 Franz 329
        bool ClipEdited;
1460 cbradney 330
        // Don't know exactly what this is, but it's not the same as itemType
168 Franz 331
        int FrameType;
3 paul 332
  /** Interne Item-Nummer */
168 Franz 333
        uint ItemNr;
3 paul 334
  /** Hat Element Rahmen? */
168 Franz 335
        bool Frame;
3 paul 336
  /** Seite zu der das Element gehoert */
456 fschmid 337
        int OwnPage;
1211 tsoots 338
        /** @brief Old page number tracked for the move undo action */
339
        int oldOwnPage;
3 paul 340
  /** Darzustellendes Bild */
2004 fschmid 341
        ScImage pixm;
3 paul 342
  /** Dateiname des Bildes */
168 Franz 343
        QString Pfile;
344
        QString Pfile2;
345
        QString Pfile3;
346
        QString IProfile;
347
        bool UseEmbedded;
348
        QString EmProfile;
349
        int IRender;
3 paul 350
  /** Darstellungsart Bild/Titel */
168 Franz 351
        bool PicArt;
3 paul 352
  /** Bild verfuegbar */
168 Franz 353
        bool PicAvail;
3 paul 354
  /** Lokales Scaling x*/
168 Franz 355
        double LocalScX;
3 paul 356
  /** Lokales Scaling y*/
168 Franz 357
        double LocalScY;
3 paul 358
  /** Lokales X */
168 Franz 359
        double LocalX;
3 paul 360
  /** Lokales Y */
168 Franz 361
        double LocalY;
3 paul 362
        int OrigW;
363
        int OrigH;
364
  /** BoundigBox-X */
168 Franz 365
        double BBoxX;
3 paul 366
  /** BoundingBox-H */
168 Franz 367
        double BBoxH;
3 paul 368
  /** Extra Abstand vom Rand */
168 Franz 369
        double Extra;
370
        double TExtra;
371
        double BExtra;
372
        double RExtra;
3 paul 373
  /** Linespacing */
168 Franz 374
        double LineSp;
2309 fschmid 375
        int LineSpMode;
3 paul 376
  /** Zeichen X-Position */
168 Franz 377
        double CurX;
3 paul 378
  /** Zeichen Y-Position */
168 Franz 379
        double CurY;
3 paul 380
  /** Cursorposition */
168 Franz 381
        int CPos;
3 paul 382
  /** Text des Elements */
1065 cbradney 383
        QPtrList<ScText> itemText;
3 paul 384
  /** Flag fuer PDF-Bookmark */
168 Franz 385
        bool isBookmark;
386
        int BMnr;
3 paul 387
  /** Flag fuer PDF-Annotation */
168 Franz 388
        bool isAnnotation;
389
        int AnType;
3 paul 390
        int AnActType;
168 Franz 391
        QString AnAction;
3 paul 392
        QString An_E_act;
393
        QString An_X_act;
394
        QString An_D_act;
395
        QString An_Fo_act;
396
        QString An_Bl_act;
397
        QString An_K_act;
398
        QString An_F_act;
399
        QString An_V_act;
400
        QString An_C_act;
88 Franz 401
        bool AutoName;
3 paul 402
        QString AnToolTip;
403
        QString AnRollOver;
404
        QString AnDown;
405
        QString AnBColor;
19 Franz 406
        QString An_Extern;
3 paul 407
        int AnBsty;
408
        int AnBwid;
409
        int AnFeed;
168 Franz 410
        int AnZiel;
3 paul 411
        int AnFlag;
412
        int AnMaxChar;
413
        int AnVis;
414
        int AnChkStil;
415
        int AnFont;
416
        bool AnIsChk;
417
        bool AnAAact;
418
        bool AnHTML;
419
        bool AnUseIcons;
420
        int AnIPlace;
421
        int AnScaleW;
422
        int AnFormat;
423
  /** Flag fuer neuzeichnen im EditMode */
168 Franz 424
        bool Dirty;
3 paul 425
  /** Item Font */
168 Franz 426
        QString IFont;
3 paul 427
  /** Item Fontgroesse */
168 Franz 428
        int ISize;
3 paul 429
  /** Flag fuer Auswahl */
168 Franz 430
        bool HasSel;
3 paul 431
  /** Flag fuer Textfluss */
168 Franz 432
        bool FrameOnly;
433
        PageItem *BackBox;
434
        PageItem *NextBox;
435
        int NextIt;
436
        int NextPg;
437
        bool Tinput;
438
        bool isAutoText;
1065 cbradney 439
        int textAlignment;
168 Franz 440
        uint MaxChars;
441
        bool Redrawn;
2382 fschmid 442
        int ExtraV;
168 Franz 443
        bool isRaster;
444
        double OldB;
445
        double OldH;
446
        double OldB2;
447
        double OldH2;
448
        bool Sizing;
449
        bool toPixmap;
3 paul 450
        int LayerNr;
451
        bool ScaleType;
452
        bool AspectRatio;
168 Franz 453
        QValueStack<int> Groups;
80 Franz 454
        QValueList<double> DashValues;
2282 fschmid 455
        QValueList<TabRecord> TabValues;
80 Franz 456
        double DashOffset;
68 Franz 457
        VGradient fill_gradient;
1905 fschmid 458
        bool fillRule;
68 Franz 459
        QString Language;
232 Franz 460
/* Additions for Table Support */
461
        PageItem* LeftLink;
462
        PageItem* RightLink;
463
        PageItem* TopLink;
464
        PageItem* BottomLink;
234 Franz 465
        int LeftLinkID;
466
        int RightLinkID;
467
        int TopLinkID;
468
        int BottomLinkID;
232 Franz 469
        bool LeftLine;
470
        bool RightLine;
471
        bool TopLine;
472
        bool BottomLine;
473
        bool isTableItem;
474
        bool isSingleSel;
456 fschmid 475
        double BoundingX;
476
        double BoundingY;
477
        double BoundingW;
478
        double BoundingH;
479
        bool ChangedMasterItem;
537 fschmid 480
        QString OnMasterPage;
740 fschmid 481
        int startArrowIndex;
482
        int endArrowIndex;
2434 fschmid 483
        bool isEmbedded;
2984 fschmid 484
        QColor fillQColor;
485
        QColor strokeQColor;
1250 tsoots 486
 
1211 tsoots 487
        /** @brief Manages undostack and is where all undo actions/states are sent. */
1204 tsoots 488
        UndoManager *undoManager;
1361 tsoots 489
        /**  @brief Get name of the item
490
         *
491
         * This is unrelated to QObject::name(); the pageItem's name is independent
492
         * of its Qt name.
493
         * See also PageItem::setItemName()
494
         */
1371 tsoots 495
        QString itemName() const;
1361 tsoots 496
        /**
1204 tsoots 497
         * @brief Set name of the item
498
         * @param newName name for the item
499
         * @author Riku Leino
1361 tsoots 500
         *
501
         * Note that this is unrelated to QObject::setName()
502
         * See also PageItem::itemName()
1204 tsoots 503
         */
1361 tsoots 504
        void setItemName(const QString& newName);
1381 cbradney 505
 
506
        /** @brief Get the (name of the) fill color of the object */
507
        QString fillColor() const;
1286 tsoots 508
        /**
509
         * @brief Set the fill color of the object.
510
         * @param newColor fill color for the object
511
         */
512
        void setFillColor(const QString &newColor);
1381 cbradney 513
 
514
        /** @brief Get the shade of the fill color */
515
        int fillShade() const;
1286 tsoots 516
        /**
517
         * @brief Set the fill color shade.
518
         * @param newShade shade for the fill color
519
         */
520
        void setFillShade(int newShade);
1381 cbradney 521
 
522
        /** @brief Get the transparency of the fill color */
523
        double fillTransparency() const;
1286 tsoots 524
        /**
1371 tsoots 525
         * @brief Set the transparency of the fill color.
526
         * @param newTransparency transparency of the fill color
527
         */
528
        void setFillTransparency(double newTransparency);
1381 cbradney 529
 
530
        /** @brief Get the line color of the object */
531
        QString lineColor() const;
1371 tsoots 532
        /**
1286 tsoots 533
         * @brief Set the line color of the object.
534
         * @param newFill line color for the object
535
         */
536
        void setLineColor(const QString &newColor);
1381 cbradney 537
 
538
        /** @brief Get the line color shade */
539
        int lineShade() const;
1286 tsoots 540
        /**
541
         * @brief Set the line color shade.
542
         * @param newColor shade for the line color
543
         */
544
        void setLineShade(int newShade);
1381 cbradney 545
 
546
        /** @brief Get the line transparency */
547
        double lineTransparency() const;
1371 tsoots 548
        /**
549
         * @brief Set the transparency of the line color.
550
         * @param newTransparency transparency of the line color
551
         */
552
        void setLineTransparency(double newTransparency);
1394 cbradney 553
 
554
        /** @brief Get the style of line */
555
        PenStyle lineStyle() const;
1383 tsoots 556
        /**
557
         * @brief Set the style of line.
558
         * @param newStyle style of line
559
         * @sa Qt::PenStyle
560
         */
561
        void setLineStyle(PenStyle newStyle);
1394 cbradney 562
 
563
        /** @brief Get the width of the line */
564
        double lineWidth() const;
1385 tsoots 565
        /**
566
         * @brief Set the width of line
567
         * @param newWidth width of line
568
         */
569
        void setLineWidth(double newWidth);
1394 cbradney 570
 
571
        /** @brief Get the end cap style of the line */
572
        PenCapStyle lineEnd() const;
1385 tsoots 573
        /**
574
         * @brief Set the end style of line
575
         * @param newStyle end style of line
576
         * @sa Qt::PenCapStyle
577
         */
578
        void setLineEnd(PenCapStyle newStyle);
1394 cbradney 579
 
580
        /** @brief Get the join style of multi-segment lines */
581
        PenJoinStyle lineJoin() const;
1385 tsoots 582
        /**
583
         * @brief Set the join style of line
584
         * @param newStyle join style of line
585
         * @sa Qt::PenJoinStyle
586
         */
587
        void setLineJoin(PenJoinStyle newStyle);
1392 cbradney 588
 
1394 cbradney 589
        /** @brief Get name of active custom line style */
590
        QString customLineStyle() const;
1489 tsoots 591
        /**
1386 tsoots 592
         * @brief Set custom line style
593
         * @param newStyle name of the custom style
594
         */
595
        void setCustomLineStyle(const QString& newStyle);
1392 cbradney 596
 
1394 cbradney 597
        /** @brief Get start arrow index
598
         * @sa PageItem::getEndArrowIndex(), PageItem::setStartArrowIndex()
599
         */
600
        int getStartArrowIndex() const;
1391 tsoots 601
        /**
602
         * @brief Set start arrow index
603
         * @param newIndex index for start arrow
604
         */
605
        void setStartArrowIndex(int newIndex);
1394 cbradney 606
 
607
        /** @brief Get end arrow index
608
         * @sa PageItem::getStartArrowIndex(), PageItem::setEndArrowIndex()
609
         */
610
        int getEndArrowIndex() const;
1391 tsoots 611
        /**
612
         * @brief Set end arrow index
613
         * @param newIndex index for end arrow
614
         */
615
        void setEndArrowIndex(int newIndex);
1392 cbradney 616
 
1394 cbradney 617
        /** @brief Is the image flipped horizontally? */
618
        bool imageFlippedH() const;
619
        /** @brief Horizontally flip / unflip the image */
620
        void setImageFlippedH(bool flipped);
1287 tsoots 621
        /** @brief Flip an image horizontally. */
622
        void flipImageH();
1392 cbradney 623
 
624
        /** @brief Is the image flipped vertically? */
625
        bool imageFlippedV() const;
626
        /** @brief Vertically flip / unflip the image */
627
        void setImageFlippedV(bool flipped);
1287 tsoots 628
        /** @brief Flip an image vertically */
629
        void flipImageV();
1381 cbradney 630
 
1495 tsoots 631
        /**
632
         * @brief Set the image scaling mode.
633
         * @param freeScale is the scaling free (not forced to frame size)
634
         * @param keepRatio should the image's aspect ratio be respected
635
         */
636
        void setImageScalingMode(bool freeScale, bool keepRatio);
637
 
1290 tsoots 638
        /** @brief Lock or unlock this pageitem. */
639
        void toggleLock();
1381 cbradney 640
        /** @brief is the item locked ? */
641
        bool locked() const;
1293 tsoots 642
        /** @brief Lock or unlock this pageitem */
643
        void setLocked(bool isLocked);
1381 cbradney 644
 
1290 tsoots 645
        /** @brief Toggle lock for resizing */
646
        void toggleSizeLock();
1381 cbradney 647
        /** @brief Is the item's size locked? */
648
        bool sizeLocked() const;
649
        /** @brief set lock for resizing */
1298 fschmid 650
        void setSizeLocked(bool isLocked);
1381 cbradney 651
 
1422 tsoots 652
        /** @brief Get the PageItem-wide font name */
653
        QString font() const;
1399 tsoots 654
        /**
655
         * @brief Set font for the PageItem.
656
         * @param newFont name of the font
657
         */
658
        void setFont(const QString& newFont);
1422 tsoots 659
 
660
        /** @brief Get the PageItem-wide font size */
661
        int fontSize() const;
1400 tsoots 662
        /**
663
         * @brief Set the font size of the frame
664
         * @param newSize font size
665
         */
666
        void setFontSize(int newSize);
1422 tsoots 667
 
2230 fschmid 668
        /** @brief Get the PageItem-wide character height scaling percentage */
669
        int fontHeight() const;
670
        /**
671
         * @brief Set scaling height of character
672
         * @param newWidth width of character
673
         */
674
        void setFontHeight(int newHeight);
675
 
1422 tsoots 676
        /** @brief Get the PageItem-wide character width scaling percentage */
677
        int fontWidth() const;
1400 tsoots 678
        /**
679
         * @brief Set scaling width of character
680
         * @param newWidth width of character
681
         */
682
        void setFontWidth(int newWidth);
1422 tsoots 683
 
684
        /** @brief Get the name of the PageItem-wide font fill color */
685
        QString fontFillColor() const;
1489 tsoots 686
        /**
1401 tsoots 687
         * @brief Set font fill color
688
         * @param newColor font fill color
689
         */
690
        void setFontFillColor(const QString& newColor);
1422 tsoots 691
 
692
        /** @brief Get the PageItem-wide font fill shade */
693
        int fontFillShade() const;
1402 tsoots 694
        /**
695
         * @brief Set the shade of font fill color
696
         * @param newShade shade of font fill color
697
         */
698
        void setFontFillShade(int newShade);
1422 tsoots 699
 
700
        /** @brief Get the PageItem-wide font stroke color */
701
        QString fontStrokeColor() const;
1489 tsoots 702
        /**
1401 tsoots 703
         * @brief Set the color of font stroke
704
         * @param newColor color of font stroke
705
         */
706
        void setFontStrokeColor(const QString& newColor);
1422 tsoots 707
 
708
        /** @brief Get the PageItem-wide font stroke shade */
709
        int fontStrokeShade() const;
1402 tsoots 710
        /**
711
         * @brief Set the shade of font stroke color
712
         * @param newShade shade of font stroke color
713
         */
714
        void setFontStrokeShade(int newShade);
1422 tsoots 715
 
716
        /** @brief Get the PageItem-wide font effects flags
717
         *
718
         * TODO This should probably be an enum set
719
         */
720
        int fontEffects() const;
1403 tsoots 721
        /**
1415 tsoots 722
         * @brief Set font effects
723
         * @param newEffects font effects
724
         */
725
        void setFontEffects(int newEffects);
1422 tsoots 726
 
727
        /** @brief Get PageItem-wide text kerning */
2382 fschmid 728
        int kerning() const;
1415 tsoots 729
        /**
1403 tsoots 730
         * @brief Set kerning for the text
731
         * @param newKerning kerning for the text
732
         */
2382 fschmid 733
        void setKerning(int newKerning);
1422 tsoots 734
 
735
        /** @brief Get the PageItem-wide line spacing */
736
        double lineSpacing() const;
1403 tsoots 737
        /**
738
         * @brief Set a line spacing for the frame
739
         * @param newSpacing line spacing for the frame
740
         */
741
        void setLineSpacing(double newSpacing);
1422 tsoots 742
 
743
        /** @brief Get the hyphenation language for the frame */
744
        QString language() const;
1403 tsoots 745
        /**
746
         * @brief Set the hyphenation language for the frame
747
         * @param newLanguage hyphenation language for the frame
748
         */
749
        void setLanguage(const QString& newLanguage);
1399 tsoots 750
 
1489 tsoots 751
        /**
1651 craig 752
         * @brief Does text flow around this object
1656 craig 753
         * @sa setTextFlowsAroundFrame()
1651 craig 754
         */
755
        bool textFlowsAroundFrame() const;
756
        /**
757
         * @brief Enable/disable text flowing around this item
1489 tsoots 758
         * @param isFlowing true if text is wanted to flow around this object or false if not
1656 craig 759
         * @sa textFlowsAroundFrame()
1489 tsoots 760
         */
1651 craig 761
        void setTextFlowsAroundFrame(bool isFlowing);
1489 tsoots 762
 
763
        /**
1653 craig 764
         * @brief Should text flow around the object's bounding box if text flow is enabled?
765
         * @sa PageItem::setTextFlowUsesBoundingBox()
766
         */
767
        bool textFlowUsesBoundingBox() const;
768
        /**
1489 tsoots 769
         * @brief Tells if the text flow should follow the square frame border if <code>useBounding</code>
770
         * @brief is true, if it is set false text fill flow around the object border rather than frame.
771
         *
772
         * Setting this to true will unset contour line to false. Bounding box and contour line cannot
773
         * be used at the same time.
774
         * @param useBounding true if text should flow around the frame border false if it should follow
775
         * the actual shape of the object.
1656 craig 776
         * @sa setTextFlowsAroundFrame()
777
         * @sa setTextFlowUsesContourLine()
778
         * @sa textFlowUsesBoundingBox()
1489 tsoots 779
         */
1653 craig 780
        void setTextFlowUsesBoundingBox(bool useBounding);
1489 tsoots 781
 
782
        /**
1656 craig 783
         * @brief Should text flow around the contour line of the frame?
784
         * @sa setTextFlowUsesContourLine()
785
         */
786
        bool textFlowUsesContourLine() const;
787
        /**
1489 tsoots 788
         * @brief Tells if the text flow should follow the contour line of the frame.
789
         *
790
         * Setting this to true will unset bounding box to false. Contour line and bounding box cannot
791
         * be used at the same time.
792
         * @param useContour true if text should flow around the contour line of the frame false if
793
         * it should flow around the actual shap of the object.
1656 craig 794
         * @sa setTextFlowsAroundFrame()
795
         * @sa setTextFlowUsesBoundingBox()
796
         * @sa textFlowUsesContourLine()
1489 tsoots 797
         */
1656 craig 798
        void setTextFlowUsesContourLine(bool useContour);
1489 tsoots 799
 
1422 tsoots 800
        /** @brief Get the frame type
801
         *
802
         * @attention The whole concept of frame types is due for some radical
803
         *            re-working, so don't rely on this interface staying stable.
804
         *            It's here as an interim step to eliminate direct member access
805
         *            on PageItems.
806
         */
1460 cbradney 807
        ItemType itemType() const;
1416 tsoots 808
        /**
809
         * @brief Convert this PageItem to PageItem type <code>newType</code>
810
         * @param newType PageItem type for conversion
811
         */
1460 cbradney 812
        void convertTo(ItemType newType);
1416 tsoots 813
 
1489 tsoots 814
        /**
1688 tsoots 815
        * Set the layer for the item
816
        * @param layerId layer where this item is moved
817
        */
818
        void setLayer(int layerId);
819
 
820
        /**
1211 tsoots 821
         * @brief Check the changes to the item and add undo actions for them.
822
         * @param force Force the check. Do not care if mouse button or arrow key is down
823
         * check anyway.
824
         * @author Riku Leino
825
         */
826
        void checkChanges(bool force = false);
1204 tsoots 827
        /**
1211 tsoots 828
         * @name Store undo actions
1204 tsoots 829
         * @brief Add an undo action to the undo guis
830
         * @author Riku Leino
831
         */
1211 tsoots 832
        /*@{*/
1204 tsoots 833
        void moveUndoAction();
1211 tsoots 834
        void resizeUndoAction();
835
        void rotateUndoAction();
836
        /*@}*/
837
        /** @brief Required by the UndoObject */
838
        void restore(UndoState *state, bool isUndo);
1361 tsoots 839
 
2058 craig 840
        /**
841
         * @brief Return a variant of `originalName' that is guaranteed to be unique
842
         *        in the same document as this PageItem.  If the passed name is not
843
         *        in use it is returned unchanged.
844
         * @author Craig Ringer
845
         *
846
         * Usually of the form 'Copy of <name>' or 'Copy of <name> (n)'
847
         */
848
        QString generateUniqueCopyName(const QString originalName) const;
2449 cbradney 849
        /**
850
         * @brief Is this item printed?
851
         * @sa setPrintable()
852
         */
853
        bool printable() const;
854
        /**
855
         * @brief Tells if the frame is set to be printed or not
856
         * @sa printable()
857
         */
858
        void setPrintable(bool toPrint);
2937 cbradney 859
 
860
        /**
861
         * @brief Set the tagged member for use when deleting items, instead of reselecting them.
862
         * @sa setTagged()
863
         */
864
        bool isTagged() const;
865
        /**
866
         * @brief Tells if the frame is tagged or not
867
         * @sa isTagged()
868
         */
869
        void setTagged(bool);
3302 cbradney 870
        /**
871
         * @brief Load an image into an image frame, moved from ScribusView
872
         * @return True if load succeeded
873
         */
874
        bool loadImage(const QString& filename, const bool reload, const int gsResolution=-1);
2937 cbradney 875
 
1361 tsoots 876
protected:
1206 tsoots 877
        /**
1211 tsoots 878
         * @name Restore helper methods
879
         * Split the restore method for easier handling.
1206 tsoots 880
         * @author Riku Leino
881
         */
1211 tsoots 882
        /*@{*/
883
        void restoreMove(SimpleState *state, bool isUndo);
884
        void restoreResize(SimpleState *state, bool isUndo);
885
        void restoreRotate(SimpleState *state, bool isUndo);
1286 tsoots 886
        void restoreFill(SimpleState *state, bool isUndo);
887
        void restoreShade(SimpleState *state, bool isUndo);
888
        void restoreLineColor(SimpleState *state, bool isUndo);
889
        void restoreLineShade(SimpleState *state, bool isUndo);
1357 tsoots 890
        void restoreName(SimpleState *state, bool isUndo);
1371 tsoots 891
        void restoreFillTP(SimpleState *state, bool isUndo);
892
        void restoreLineTP(SimpleState *state, bool isUndo);
1383 tsoots 893
        void restoreLineStyle(SimpleState *state, bool isUndo);
1385 tsoots 894
        void restoreLineEnd(SimpleState *state, bool isUndo);
895
        void restoreLineJoin(SimpleState *state, bool isUndo);
896
        void restoreLineWidth(SimpleState *state, bool isUndo);
1386 tsoots 897
        void restoreCustomLineStyle(SimpleState *state, bool isUndo);
1391 tsoots 898
        void restoreArrow(SimpleState *state, bool isUndo, bool isStart);
1399 tsoots 899
        void restoreFont(SimpleState *state, bool isUndo);
1400 tsoots 900
        void restoreFontSize(SimpleState *state, bool isUndo);
901
        void restoreFontWidth(SimpleState *state, bool isUndo);
1401 tsoots 902
        void restoreFontFill(SimpleState *state, bool isUndo);
903
        void restoreFontStroke(SimpleState *state, bool isUndo);
1402 tsoots 904
        void restoreFontFillShade(SimpleState *state, bool isUndo);
905
        void restoreFontStrokeShade(SimpleState *state, bool isUndo);
1403 tsoots 906
        void restoreKerning(SimpleState *state, bool isUndo);
907
        void restoreLineSpacing(SimpleState *state, bool isUndo);
908
        void restoreLanguage(SimpleState *state, bool isUndo);
1404 tsoots 909
        void restorePStyle(SimpleState *state, bool isUndo);
1415 tsoots 910
        void restoreFontEffect(SimpleState *state, bool isUndo);
1416 tsoots 911
        void restoreType(SimpleState *state, bool isUndo);
1489 tsoots 912
        void restoreTextFlowing(SimpleState *state, bool isUndo);
1495 tsoots 913
        void restoreImageScaling(SimpleState *state, bool isUndo);
1509 tsoots 914
        void restorePoly(SimpleState *state, bool isUndo, bool isContour);
1518 tsoots 915
        void restoreContourLine(SimpleState *state, bool isUndo);
1688 tsoots 916
        void restoreLayer(SimpleState *state, bool isUndo);
1832 tsoots 917
        void restoreGetImage(SimpleState *state, bool isUndo);
1211 tsoots 918
        /*@}*/
1238 tsoots 919
 
920
        /**
921
         * @brief Returns true if the actions should be sent to the UndoManager.
922
         *
923
         * Checks the state of the arrow keys and mouse buttons. If a key or a
924
         * mouse button is down PageItem is under some action which should only be
925
         * stored after the action has been finished (to get a single undo action).
926
         * @return true if the actions should be sent to the UndoManager based on the
927
         * state of arrow keys and mouse buttons else returns false.
928
         */
929
        bool shouldCheck();
1290 tsoots 930
        /** @brief Clears the current selection and selects this PageItem. */
931
        void select();
1361 tsoots 932
 
933
        // Protected members
934
 
935
        /**
1460 cbradney 936
         * @brief Frame Type, eg line, text frame, etc.
937
         *
938
         * This will probably go away when pageitem is split into
939
         * subclasses.
940
         */
941
        ItemType itemTypeVal;
942
 
943
        /**
1361 tsoots 944
         * @brief Item name. Unicode. User visible (outline, property palette, etc).
1392 cbradney 945
         * @sa PageItem::itemName(), PageItem::setItemName()
946
         */
1361 tsoots 947
        QString AnName;
1392 cbradney 948
 
949
        /**
1394 cbradney 950
         * @brief Fill color name
951
         * @sa PageItem::fillColor(), PageItem::setFillColor()
952
         */
953
        QString fillColorVal;
954
 
955
        /**
956
         * @brief Line color name
957
         * @sa PageItem::lineColor(), PageItem::setLineColor()
958
         */
959
        QString lineColorVal;
960
 
961
        /**
962
         * @brief Line shade
963
         * @sa PageItem::lineShade, PageItem::setLineShade()
964
         */
965
        int lineShadeVal;
966
 
967
        /**
968
         * @brief Fill shade
969
         * @sa PageItem::fillShade, PageItem::setFillShade()
970
         */
971
        int fillShadeVal;
972
 
973
        /**
974
         * @brief Fill transparency
975
         * @sa PageItem::fillTransparency(), PageItem::setFillTransparency()
976
         */
977
        double fillTransparencyVal;
978
 
979
        /**
980
         * @brief Line stroke transparency.
981
         * @sa PageItem::lineTransparency(), PageItem::setLineTransparency()
982
         */
983
        double lineTransparencyVal;
984
 
985
        /**
1392 cbradney 986
         * @brief Is the image in this image item flipped horizontally?
987
         * @sa PageItem::isImageFlippedH(), PageItem::setImageFlippedH(),
988
         *     PageItem::flipImageH(), PageItem::flippedV
989
         */
990
        bool imageIsFlippedH;
991
 
992
        /**
993
         * @brief Is the image in this image item flipped vertically?
994
         * @sa PageItem::isImageFlippedV(), PageItem::setImageFlippedV(),
995
         *     PageItem::flipImageV(), PageItem::flippedH
996
         */
997
        bool imageIsFlippedV;
998
 
999
        /**
1000
         * @brief Is the item locked (cannot be moved, resized, etc)?
1001
         * @sa PageItem::locked(), PageItem::setLocked(), PageItem::toggleLock()
1002
         */
1003
        bool Locked;
1004
 
1005
        /**
1006
         * @brief Is the item's size locked?
1007
         * @sa PageItem::sizeLocked(), PageItem::setSizeLocked(), PageItem::toggleSizeLock()
1008
         */
1009
        bool LockRes;
1653 craig 1010
 
1644 cbradney 1011
        /**
1653 craig 1012
         * @brief Should text flow around the item
1013
         * @sa PageItem::textFlowsAroundFrame(), PateItem::setTextFlowsAroundFrame()
1014
         */
1015
        bool textFlowsAroundFrameVal;
1016
 
1017
        /**
1018
         * @brief Should text flow around the item's bounding box?
1656 craig 1019
         * @sa PageItem::textFlowUsesBoundingBox(), PageItem::setTextFlowUsesBoundingBox()
1653 craig 1020
         */
1021
        bool textFlowUsesBoundingBoxVal;
1022
 
1023
        /**
1656 craig 1024
         * @brief Should text flow around the item's contour line?
2449 cbradney 1025
         * @sa PageItem::textFlowUsesContourLine(), PageItem::setTextFlowUsesContourLine()
1656 craig 1026
         */
1027
        bool textFlowUsesContourLineVal;
1028
 
1029
        /**
1644 cbradney 1030
         * @brief Stores the attributes of the pageitem (NOT properties, the user defined ATTRIBUTES)
2707 subik 1031
         * @sa
1032
         */
1649 cbradney 1033
        ObjAttrVector pageItemAttributes;
2707 subik 1034
 
2449 cbradney 1035
        /**
1036
         * @brief Is this item set to be printed/exported
1037
         * @sa PageItem::printable(), PageItem::setPrintable()
2707 subik 1038
         */
2449 cbradney 1039
        bool isPrintable;
2937 cbradney 1040
 
1041
        /**
1042
         * @brief Is this item set to have an action done to it, eg deleted
1043
         * @sa PageItem::isTagged(), PageItem::setTagged()
1044
         */
1045
        bool tagged;
2449 cbradney 1046
 
3 paul 1047
};
1048
 
1049
#endif