Subversion Repositories Scribus

Rev

Rev 9431 | 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
*/
3 paul 7
/***************************************************************************
8
                          scribusview.h  -  description
9
                             -------------------
10
    begin                : Fre Apr  6 21:47:55 CEST 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
#ifndef SCRIBUSVIEW_H
25
#define SCRIBUSVIEW_H
26
 
3054 avox 27
#include "styleoptions.h"
28
 
330 Franz 29
#include <vector>
3 paul 30
// include files for QT
8501 cbradney 31
#include <q3scrollview.h>
32
#include <q3ptrlist.h>
3 paul 33
#include <qlineedit.h>
34
#include <qscrollbar.h>
3054 avox 35
#if OPTION_USE_QTOOLBUTTON
36
    #include <qtoolbutton.h>
37
#else
38
    #include <qpushbutton.h>
39
#endif
8501 cbradney 40
#include <q3popupmenu.h>
3 paul 41
#include <qlabel.h>
2966 fschmid 42
#include <qcombobox.h>
8501 cbradney 43
#include <q3progressdialog.h>
160 Franz 44
#include <qspinbox.h>
6583 fschmid 45
#include <qcursor.h>
8501 cbradney 46
//Added by qt3to4:
47
#include <QDragLeaveEvent>
48
#include <Q3ValueList>
49
#include <QDragEnterEvent>
50
#include <QDragMoveEvent>
51
#include <QDropEvent>
52
#include <QMouseEvent>
53
#include <QEvent>
54
#include <QPaintEvent>
55
#include <QWheelEvent>
8720 fschmid 56
 #include <QRubberBand>
3 paul 57
// application specific includes
2969 craig 58
#include "scribusapi.h"
3 paul 59
#include "scribusdoc.h"
2355 cbradney 60
#include "scribusstructs.h"
456 fschmid 61
#include "scpainter.h"
3670 cbradney 62
class Page;
8602 cbradney 63
#include "scrspinbox.h"
3809 cbradney 64
//#include "util.h"
838 cbradney 65
class Hruler;
66
class Vruler;
1226 tsoots 67
class UndoManager;
2868 fschmid 68
class RulerMover;
3054 avox 69
class PageSelector;
5781 cbradney 70
class ScribusWin;
71
class ScribusMainWindow;
199 Franz 72
 
3 paul 73
/**
1510 tsoots 74
 * This class provides an incomplete base for your application view.
3 paul 75
 */
76
 
8501 cbradney 77
class SCRIBUS_API ScribusView : public Q3ScrollView
3 paul 78
{
168 Franz 79
        Q_OBJECT
80
 
81
public:
5781 cbradney 82
    ScribusView(QWidget* win=0, ScribusMainWindow* mw=0, ScribusDoc* doc=0);
3 paul 83
    ~ScribusView() {};
84
  /** Vergroesserungseingabefeld */
8602 cbradney 85
        ScrSpinBox* zoomSpinBox; //zoom spinbox at bottom of view
3309 cbradney 86
        PageSelector* pageSelector; //Page selector at bottom of view
87
        RulerMover *rulerMover; //Widget between the two rulers for dragging the ruler origin
1612 cbradney 88
        Hruler *horizRuler;
89
        Vruler *vertRuler;
3054 avox 90
#if OPTION_USE_QTOOLBUTTON
3274 fschmid 91
        QToolButton *zoomDefaultToolbarButton;
3054 avox 92
        QToolButton *zoomOutToolbarButton;
93
        QToolButton *zoomInToolbarButton;
6726 fschmid 94
        QToolButton *cmsToolbarButton;
6549 fschmid 95
        QToolButton *previewToolbarButton;
3054 avox 96
#else
3274 fschmid 97
        QPushButton *zoomDefaultToolbarButton;
2887 fschmid 98
        QPushButton *zoomOutToolbarButton;
99
        QPushButton *zoomInToolbarButton;
6726 fschmid 100
        QToolButton *cmsToolbarButton;
6549 fschmid 101
        QPushButton *previewToolbarButton;
3054 avox 102
#endif
3309 cbradney 103
        QComboBox *layerMenu; //Menu for layers at bottom of view
104
        QComboBox *unitSwitcher; //Menu for units at bottom of view
6549 fschmid 105
        QComboBox *visualMenu;
456 fschmid 106
  /** Dokument zu dem die Seite gehoert */
3981 craig 107
        ScribusDoc * const Doc;
108
        ApplicationPrefs * const Prefs;
109
        UndoManager * const undoManager;
456 fschmid 110
        double OldScale;
7575 cbradney 111
        double dragX,dragY,dragW,dragH;
456 fschmid 112
        double oldW;
113
        int oldCp;
114
        int Mxp;
115
        int Myp;
4747 cbradney 116
        int dragConstrainInitPtX;
117
        int dragConstrainInitPtY;
456 fschmid 118
        int Dxp;
119
        int Dyp;
6477 fschmid 120
        int m_SnapCounter;
4663 cbradney 121
        /*!
122
         * Frame handle used for resize
123
         * 283
124
         * 7 6
125
         * 451
126
         */
127
        int frameResizeHandle;
456 fschmid 128
        int SeRx;
129
        int SeRy;
130
        int GyM;
131
        int GxM;
132
        int ClRe;
133
        int ClRe2;
134
        int SegP1;
135
        int SegP2;
136
        int RotMode;
137
        int DrHY;
138
        int DrVX;
139
        bool EdPoints;
4704 cbradney 140
        bool m_MouseButtonPressed;
4663 cbradney 141
        bool operItemMoving;
6349 fschmid 142
        bool shiftSelItems;
456 fschmid 143
        bool MoveGY;
144
        bool MoveGX;
145
        bool HaveSelRect;
4663 cbradney 146
        bool operItemResizing;
456 fschmid 147
        bool EditContour;
4049 cbradney 148
        //bool GroupSel;
456 fschmid 149
        bool DraggedGroup;
150
        bool DraggedGroupFirst;
4663 cbradney 151
        bool operItemResizeInEditMode;
7284 fschmid 152
        bool inItemCreation;
456 fschmid 153
        bool MidButt;
154
        bool updateOn;
155
        bool FirstPoly;
156
        bool Magnify;
157
        bool MoveSym;
1874 fschmid 158
        bool previewMode;
5235 fschmid 159
        bool viewAsPreview;
5237 fschmid 160
        bool storedFramesShown;
7624 fschmid 161
        bool storedShowControls;
6549 fschmid 162
        int previewVisual;
8720 fschmid 163
        int redrawMode;
164
        int redrawCount;
165
        PageItem *redrawItem;
166
        QRubberBand *redrawMarker;
9041 fschmid 167
        QPolygon redrawPolygon;
9431 fschmid 168
        bool specialRendering;
169
        bool firstSpecial;
170
        QPixmap m_buffer;
456 fschmid 171
        FPoint RCenter;
172
        FPointArray RecordP;
173
        void DrawMasterItems(ScPainter *painter, Page *page, QRect clip);
174
        void DrawPageItems(ScPainter *painter, QRect clip);
175
        void DrawPageMarks(ScPainter *p, Page* page, QRect clip);
7452 fschmid 176
        void updatesOn(bool on);
3791 cbradney 177
        //CB This MUST now be called AFTER a call to doc->addPage or doc->addMasterPage as it
178
        //does NOT create a page anymore.
2880 fschmid 179
        Page* addPage(int nr, bool mov = true);
8501 cbradney 180
        Q3PtrList<PageItem> linkedFramesToShow;
181
        Q3ValueList<int> SelNode;
2355 cbradney 182
 
3942 cbradney 183
 
971 fschmid 184
        struct oldPageVar
185
        {
186
                uint newPg;
187
                double oldXO;
188
                double oldYO;
189
        };
3934 cbradney 190
        static const uint moveWithFullOutlinesThreshold = 21;
191
        static const uint moveWithBoxesOnlyThreshold = 41;
2880 fschmid 192
        void reformPages(bool moveObjects = true);
2937 cbradney 193
        void updateLayerMenu();
2093 cbradney 194
        void showMasterPage(int nr);
195
        void hideMasterPage();
5523 fschmid 196
        QImage PageToPixmap(int Nr, int maxGr, bool drawFrame = true);
197
        QImage MPageToPixmap(QString name, int maxGr, bool drawFrame = true);
2012 fschmid 198
        void RecalcPicturesRes();
2868 fschmid 199
        void rulerMove(QMouseEvent *m);
3942 cbradney 200
        /**
201
         * Called when the ruler origin is dragged
202
         * @param m mouse event
203
         */
204
        void setNewRulerOrigin(QMouseEvent *m);
456 fschmid 205
        void FromHRuler(QMouseEvent *m);
206
        void FromVRuler(QMouseEvent *m);
1115 tsoots 207
        void SetYGuide(QMouseEvent *m, int oldIndex);
208
        void SetXGuide(QMouseEvent *m, int oldIndex);
7736 cbradney 209
//      void getClosestGuides(double xin, double yin, double *xout, double *yout);
210
//      bool ApplyGuides(double *x, double *y);
211
//      void SnapToGuides(PageItem *currItem);
7575 cbradney 212
        void getDragRectScreen(double *x, double *y, double *w, double *h);
456 fschmid 213
        void getGroupRectScreen(double *x, double *y, double *w, double *h);
214
        void paintGroupRect(bool norm = true);
9380 fschmid 215
        void PaintSizeRect(QRect neu);
9041 fschmid 216
        void PaintSizeRect(QPolygon neu);
456 fschmid 217
        void ToView(QPainter *p);
8501 cbradney 218
        void ToView(QMatrix& m);
7736 cbradney 219
//      bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
9041 fschmid 220
        void MarkClip(QPainter *p, PageItem *currItem, FPointArray cli, bool once = false);
456 fschmid 221
        bool PointOnLine(QPoint Start, QPoint Ende, QRect MArea);
1510 tsoots 222
        void TransformPoly(int mode, int rot = 1, double scaling = 1.0);
456 fschmid 223
        void Reset1Control();
224
        void ResetControl();
1957 cbradney 225
        void MoveClipPoint(PageItem *currItem, FPoint np);
7736 cbradney 226
//      bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
227
//      bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
7578 cbradney 228
        void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
7736 cbradney 229
//      void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
230
//      bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
456 fschmid 231
        void RotateGroup(double win);
7578 cbradney 232
        void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
7736 cbradney 233
//      void RotateItem(double win, int ite);
234
//      void RotateItem(double win, PageItem *currItem);
235
//      void AdjustItemSize(PageItem *currItem);
456 fschmid 236
        bool slotSetCurs(int x, int y);
237
        void slotDoCurs(bool draw);
9380 fschmid 238
        void HandleCurs(PageItem *currItem, QRect mpo);
239
        void HandleSizer(PageItem *currItem, QRect mpo, QMouseEvent *m);
456 fschmid 240
        bool GetItem(PageItem **b, int nr = -1);
241
        void Deselect(bool prop = true);
6802 subik 242
        void SelectItemNr(uint nr, bool draw = true, bool single = false);
1427 fschmid 243
        void SelectItem(PageItem *pi, bool draw = true, bool single = false);
795 fschmid 244
        void selectPage(QMouseEvent *m);
456 fschmid 245
        bool SeleItem(QMouseEvent *m);
246
        void SetupDraw(int Nr);
5164 tsoots 247
        void SetupDrawNoResize(int nr);
1957 cbradney 248
        void Transform(PageItem *currItem, QPainter *p);
8501 cbradney 249
        void Transform(PageItem *currItem, QMatrix& m);
1957 cbradney 250
        void TransformM(PageItem *currItem, QPainter *p);
456 fschmid 251
        void SetFrameRect();
252
        void SetFrameRounded();
253
        void SetFrameOval();
6431 fschmid 254
        void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false, bool noResize = true);
7900 fschmid 255
//      void QueryFarben();
7571 cbradney 256
        void rememberOldZoomLocation(int mx=0, int my=0);
1211 tsoots 257
        bool mousePressed();
1254 tsoots 258
        bool groupTransactionStarted();
1263 tsoots 259
        void setGroupTransactionStarted(bool isOn);
2380 cbradney 260
        void setScale(const double newScale);
4593 cbradney 261
        double scale() const { return Scale; }
7618 fschmid 262
        void normalizeSelectionRect();
7614 fschmid 263
        FPoint translateToView(double x, double y);
264
        FPoint translateToView(FPoint in);
265
        FPoint translateToDoc(double x, double y);
266
        FPoint translateToDoc(FPoint in);
267
        FPoint translateFromViewport(double x, double y);
268
        FPoint translateFromViewport(FPoint in);
269
        FPoint translateToViewport(double x, double y);
270
        FPoint translateToViewport(FPoint in);
4072 cbradney 271
 
3 paul 272
public slots: // Public slots
2199 cbradney 273
        void languageChange();
6726 fschmid 274
        void toggleCMS();
6549 fschmid 275
        void switchPreviewVisual(int vis);
5235 fschmid 276
        void togglePreview();
2380 cbradney 277
        void unitChange();
4651 cbradney 278
        void setRulersShown(bool isShown);
4654 cbradney 279
        void slotUpdateContents();
280
        void slotUpdateContents(const QRect &r);
3274 fschmid 281
  /** Zooms in or out */
168 Franz 282
        void slotDoZoom();
3274 fschmid 283
        void slotZoom100();
284
  /** Zooms in */
238 Franz 285
        void slotZoomIn(int mx=0,int my=0);
286
        void slotZoomOut(int mx=0,int my=0);
456 fschmid 287
  /** Redraws everything */
168 Franz 288
        void DrawNew();
289
        void setMenTxt(int Seite);
2937 cbradney 290
        void setLayerMenuText(const QString &);
168 Franz 291
        void GotoPa(int Seite);
3 paul 292
        void GotoLa(int l);
168 Franz 293
        void GotoPage(int Seite);
294
        void ChgUnit(int art);
7618 fschmid 295
        void SetCPo(double x, double y);
296
        void SetCCPo(double x, double y);
2260 cbradney 297
        void editExtendedImageProperties();
4585 cbradney 298
        void RefreshItem(PageItem *currItem);
6344 jghali 299
        void RefreshGradient(PageItem *currItem, double dx = 8, double dy = 8);
3942 cbradney 300
        /**
301
         * Adjust an image frame's size to fit the size of the image in it
302
         */
7739 cbradney 303
//      void adjustFrametoImageSize();
456 fschmid 304
        void ToggleBookmark();
305
        void ToggleAnnotation();
7755 cbradney 306
//      void sentToScrap();
456 fschmid 307
        void ToBack();
308
        void ToFront();
309
        void LowerItem();
310
        void RaiseItem();
311
        void ToPicFrame();
312
        void ToPolyFrame();
313
        void ToTextFrame();
314
        void ToBezierFrame();
2026 cbradney 315
        void ToPathText();
316
        void FromPathText();
7739 cbradney 317
//      void UniteObj();
318
//      void SplitObj();
456 fschmid 319
        void Bezier2Poly();
320
        void PasteToPage();
5827 fschmid 321
        void PasteRecentToPage(int id);
456 fschmid 322
        void TextToPath();
4704 cbradney 323
        void blinkCursor();
4672 cbradney 324
        void adjustCanvas(double width, double height, double dX=0.0, double dY=0.0);
168 Franz 325
 
3 paul 326
private: // Private attributes
8501 cbradney 327
        Q3PopupMenu *pmen3;
328
        Q3PopupMenu *pmenResolution;
4799 fschmid 329
        QTime moveTimer;
9668 fschmid 330
        QTimer *dragTimer;
331
        bool dragTimerFired;
168 Franz 332
        bool Ready;
3982 craig 333
        int  oldX;
334
        int  oldY;
1254 tsoots 335
        bool _groupTransactionStarted;
1461 tsoots 336
        bool _isGlobalMode;
2171 fschmid 337
        bool evSpon;
2951 fschmid 338
        bool forceRedraw;
2380 cbradney 339
        double Scale;
1226 tsoots 340
 
6139 tsoots 341
        // for shape/countour line editing undo actions
342
        // store oldClip in mousePressed if in edit shape
343
        // and in mouseRelease send the undo action with the 
344
        // new clip
345
        bool isContourLine;
346
        FPointArray *oldClip;
6145 tsoots 347
        double oldItemX;
348
        double oldItemY;
6139 tsoots 349
 
3 paul 350
private slots:
4704 cbradney 351
        void setZoom();
3942 cbradney 352
        /**
353
         * Called to update the GUI when the canvas(view) scrollbars are moved
354
         * @param x
355
         * @param y
356
         */
168 Franz 357
        void setRulerPos(int x, int y);
1443 tsoots 358
        void selectionChanged();
1461 tsoots 359
        void setObjectUndoMode();
360
        void setGlobalUndoMode();
9668 fschmid 361
        void dragTimerTimeOut();
168 Franz 362
 
3 paul 363
protected: // Protected methods
2171 fschmid 364
        virtual void viewportPaintEvent ( QPaintEvent * p );
456 fschmid 365
        virtual void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
6583 fschmid 366
        virtual void enterEvent(QEvent *);
456 fschmid 367
        virtual void leaveEvent(QEvent *);
368
        virtual void contentsDragEnterEvent(QDragEnterEvent *e);
369
        virtual void contentsDragMoveEvent(QDragMoveEvent *e);
370
        virtual void contentsDragLeaveEvent(QDragLeaveEvent *e);
371
        virtual void contentsDropEvent(QDropEvent *e);
372
        virtual void contentsMouseDoubleClickEvent(QMouseEvent *m);
373
        virtual void contentsMouseReleaseEvent(QMouseEvent *m);
374
        virtual void contentsMouseMoveEvent(QMouseEvent *m);
375
        virtual void contentsMousePressEvent(QMouseEvent *m);
3 paul 376
        virtual void contentsWheelEvent ( QWheelEvent *ev );
377
        virtual void setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
378
        virtual void setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
4019 cbradney 379
 
3954 cbradney 380
        void drawLinkFrameLine(ScPainter* painter, FPoint &start, FPoint &end);
4804 cbradney 381
        inline bool moveTimerElapsed();
4654 cbradney 382
 
383
        //The width of vertical ruler/height of horizontal ruler, set to 17 in scribusview.cpp
384
        int m_vhRulerHW;
4704 cbradney 385
        bool m_cursorVisible;
5781 cbradney 386
        ScribusMainWindow* m_ScMW;
168 Franz 387
 
3 paul 388
signals:
389
        void changeUN(int);
390
        void changeLA(int);
456 fschmid 391
        void ItemPos(double, double);
392
        void HaveSel(int);
393
        void ItemGeom(double, double);
394
        void DocChanged();
395
        void PolyOpen();
396
        void PStatus(int, uint);
397
        void SetAngle(double);
398
        void SetSizeValue(double);
3934 cbradney 399
        void SetLineArt(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle);
456 fschmid 400
        void SetLocalValues(double, double, double, double);
7900 fschmid 401
//      void ItemFarben(QString, QString, int, int);
402
//      void ItemGradient(int);
403
//      void ItemTrans(double, double);
404
//      void ItemBlend(int, int);
456 fschmid 405
        void ItemTextAttr(double);
2382 fschmid 406
        void ItemTextUSval(int);
456 fschmid 407
        void ItemTextCols(int, double);
408
        void SetDistValues(double, double, double, double);
409
        void ItemTextAbs(int);
8998 cbradney 410
        void ItemTextFont(const QString&);
456 fschmid 411
        void ItemTextSize(int);
412
        void ItemTextSca(int);
2230 fschmid 413
        void ItemTextScaV(int);
2234 fschmid 414
        void ItemTextBase(int);
2257 fschmid 415
        void ItemTextOutline(int);
2247 fschmid 416
        void ItemTextShadow(int, int);
2262 fschmid 417
        void ItemTextUnderline(int, int);
2272 fschmid 418
        void ItemTextStrike(int, int);
456 fschmid 419
        void ItemTextFarben(QString, QString, int, int);
420
        void ItemTextStil(int);
3990 cbradney 421
        //void ItemRadius(double);
456 fschmid 422
        void HasTextSel();
423
        void HasNoTextSel();
424
        void MVals(double, double, double, double, double, double, int);
425
        void PaintingDone();
426
        void LoadPic();
427
        void AppendText();
428
        void DoGroup();
1858 cbradney 429
        //void DoUnGroup();
456 fschmid 430
        void CutItem();
431
        void CopyItem();
432
        void Amode(int);
433
        void AddBM(PageItem *);
434
        void DelBM(PageItem *);
435
        void ChBMText(PageItem *);
436
        void ToScrap(QString);
3743 fschmid 437
        void LoadElem(QString, double, double, bool, bool, ScribusDoc *, ScribusView *);
456 fschmid 438
        void LevelChanged(uint);
439
        void RasterPic(bool);
440
        void HavePoint(bool, bool);
441
        void ClipPo(double, double);
442
        void AnnotProps();
443
        void EndNodeEdit();
444
        void Hrule(int);
445
        void Vrule(int);
5087 subik 446
        //void EditGuides();
456 fschmid 447
        void MousePos(double, double);
1155 fschmid 448
        void callGimp();
2626 cbradney 449
        void signalGuideInformation(int, double);
3 paul 450
};
451
#endif