Subversion Repositories Scribus

Rev

Rev 4672 | Rev 4688 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
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
31
#include <qscrollview.h>
32
#include <qptrlist.h>
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
3 paul 40
#include <qpopupmenu.h>
41
#include <qlabel.h>
2966 fschmid 42
#include <qcombobox.h>
3 paul 43
#include <qprogressdialog.h>
160 Franz 44
#include <qspinbox.h>
3 paul 45
// application specific includes
2969 craig 46
#include "scribusapi.h"
3 paul 47
#include "scribusdoc.h"
2355 cbradney 48
#include "scribusstructs.h"
456 fschmid 49
#include "scpainter.h"
3670 cbradney 50
class Page;
3054 avox 51
#include "mspinbox.h"
3809 cbradney 52
//#include "util.h"
838 cbradney 53
class Hruler;
54
class Vruler;
1226 tsoots 55
class UndoManager;
2868 fschmid 56
class RulerMover;
3054 avox 57
//#include "pageselector.h"
58
class PageSelector;
199 Franz 59
 
3054 avox 60
 
3 paul 61
/**
1510 tsoots 62
 * This class provides an incomplete base for your application view.
3 paul 63
 */
64
 
2969 craig 65
class SCRIBUS_API ScribusView : public QScrollView
3 paul 66
{
168 Franz 67
        Q_OBJECT
68
 
69
public:
2834 cbradney 70
    ScribusView(QWidget *parent=0, ScribusDoc *doc=0);
3 paul 71
    ~ScribusView() {};
72
  /** Vergroesserungseingabefeld */
3309 cbradney 73
        MSpinBox* zoomSpinBox; //zoom spinbox at bottom of view
74
        PageSelector* pageSelector; //Page selector at bottom of view
75
        RulerMover *rulerMover; //Widget between the two rulers for dragging the ruler origin
1612 cbradney 76
        Hruler *horizRuler;
77
        Vruler *vertRuler;
3054 avox 78
#if OPTION_USE_QTOOLBUTTON
3274 fschmid 79
        QToolButton *zoomDefaultToolbarButton;
3054 avox 80
        QToolButton *zoomOutToolbarButton;
81
        QToolButton *zoomInToolbarButton;
82
#else
3274 fschmid 83
        QPushButton *zoomDefaultToolbarButton;
2887 fschmid 84
        QPushButton *zoomOutToolbarButton;
85
        QPushButton *zoomInToolbarButton;
3054 avox 86
#endif
3309 cbradney 87
        QComboBox *layerMenu; //Menu for layers at bottom of view
88
        QComboBox *unitSwitcher; //Menu for units at bottom of view
456 fschmid 89
  /** Dokument zu dem die Seite gehoert */
3981 craig 90
        ScribusDoc * const Doc;
91
        ApplicationPrefs * const Prefs;
92
        UndoManager * const undoManager;
456 fschmid 93
        double OldScale;
94
        double GroupX;
95
        double GroupY;
96
        double GroupW;
97
        double GroupH;
98
        double oldW;
99
        int oldCp;
100
        int Mxp;
101
        int Myp;
102
        int Dxp;
103
        int Dyp;
4663 cbradney 104
        /*!
105
         * Frame handle used for resize
106
         * 283
107
         * 7 6
108
         * 451
109
         */
110
        int frameResizeHandle;
456 fschmid 111
        int SeRx;
112
        int SeRy;
113
        int GyM;
114
        int GxM;
115
        int ClRe;
116
        int ClRe2;
117
        int SegP1;
118
        int SegP2;
119
        int RotMode;
120
        int DrHY;
121
        int DrVX;
122
        bool EdPoints;
123
        bool Mpressed;
4663 cbradney 124
        bool operItemMoving;
456 fschmid 125
        bool MoveGY;
126
        bool MoveGX;
127
        bool HaveSelRect;
4663 cbradney 128
        bool operItemResizing;
456 fschmid 129
        bool EditContour;
4049 cbradney 130
        //bool GroupSel;
456 fschmid 131
        bool DraggedGroup;
132
        bool DraggedGroupFirst;
4663 cbradney 133
        bool operItemResizeInEditMode;
456 fschmid 134
        bool MidButt;
135
        bool updateOn;
136
        bool FirstPoly;
137
        bool Magnify;
138
        bool MoveSym;
139
        bool CursVis;
1874 fschmid 140
        bool previewMode;
456 fschmid 141
        FPoint RCenter;
142
        FPointArray RecordP;
143
        void DrawMasterItems(ScPainter *painter, Page *page, QRect clip);
144
        void DrawPageItems(ScPainter *painter, QRect clip);
145
        void DrawPageMarks(ScPainter *p, Page* page, QRect clip);
3791 cbradney 146
        //CB This MUST now be called AFTER a call to doc->addPage or doc->addMasterPage as it
147
        //does NOT create a page anymore.
2880 fschmid 148
        Page* addPage(int nr, bool mov = true);
3934 cbradney 149
        //CB replaced with selection class, per ScribusDoc 
150
        //QPtrList<PageItem> SelItem;
705 fschmid 151
        QPtrList<PageItem> linkedFramesToShow;
456 fschmid 152
        QValueList<int> SelNode;
2355 cbradney 153
 
3942 cbradney 154
 
971 fschmid 155
        struct oldPageVar
156
        {
157
                uint newPg;
158
                double oldXO;
159
                double oldYO;
160
        };
3934 cbradney 161
        static const uint moveWithFullOutlinesThreshold = 21;
162
        static const uint moveWithBoxesOnlyThreshold = 41;
2880 fschmid 163
        void reformPages(bool moveObjects = true);
2937 cbradney 164
        void updateLayerMenu();
2093 cbradney 165
        void showMasterPage(int nr);
166
        void hideMasterPage();
1815 fschmid 167
        QImage PageToPixmap(int Nr, int maxGr);
168
        QImage MPageToPixmap(QString name, int maxGr);
3942 cbradney 169
        //void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
2012 fschmid 170
        void RecalcPicturesRes();
2868 fschmid 171
        void rulerMove(QMouseEvent *m);
3942 cbradney 172
        /**
173
         * Called when the ruler origin is dragged
174
         * @param m mouse event
175
         */
176
        void setNewRulerOrigin(QMouseEvent *m);
456 fschmid 177
        void FromHRuler(QMouseEvent *m);
178
        void FromVRuler(QMouseEvent *m);
1115 tsoots 179
        void SetYGuide(QMouseEvent *m, int oldIndex);
180
        void SetXGuide(QMouseEvent *m, int oldIndex);
456 fschmid 181
        bool ApplyGuides(double *x, double *y);
1957 cbradney 182
        void SnapToGuides(PageItem *currItem);
3708 cbradney 183
        QPoint ApplyGrid(const QPoint& in);
184
        FPoint ApplyGridF(const FPoint& in);
4672 cbradney 185
        //->doc void setRedrawBounding(PageItem *currItem);
456 fschmid 186
        void setGroupRect();
187
        void getGroupRect(double *x, double *y, double *w, double *h);
188
        void getGroupRectScreen(double *x, double *y, double *w, double *h);
189
        void paintGroupRect(bool norm = true);
190
        void PaintSizeRect(QPainter *p, QRect neu);
191
        void ToView(QPainter *p);
4585 cbradney 192
        //void RefreshItem(PageItem *currItem);
456 fschmid 193
        bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
4593 cbradney 194
        //void MoveItemI(PageItem* currItem, double newX, double newY, bool redraw = true);
1957 cbradney 195
        void UpdateClip(PageItem *currItem);
196
        void ConvertClip(PageItem *currItem);
2934 fschmid 197
        void MarkClip(PageItem *currItem, FPointArray cli, bool once = false);
456 fschmid 198
        bool PointOnLine(QPoint Start, QPoint Ende, QRect MArea);
1510 tsoots 199
        void TransformPoly(int mode, int rot = 1, double scaling = 1.0);
456 fschmid 200
        void Reset1Control();
201
        void ResetControl();
1957 cbradney 202
        void MoveClipPoint(PageItem *currItem, FPoint np);
456 fschmid 203
        bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
3673 cbradney 204
        bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
456 fschmid 205
        void moveGroup(double x, double y, bool fromMP = false);
1957 cbradney 206
        void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
456 fschmid 207
        bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false);
208
        void RotateGroup(double win);
4325 cbradney 209
        void scaleGroup(double scx, double scy, bool scaleText=true);
456 fschmid 210
        void RotateItem(double win, int ite);
3680 cbradney 211
        void RotateItem(double win, PageItem *currItem);
1957 cbradney 212
        void AdjustItemSize(PageItem *currItem);
213
        void AdvanceSel(PageItem *currItem, int oldPos, int len, int dir, int expandSel, int state);
456 fschmid 214
        bool slotSetCurs(int x, int y);
215
        void slotDoCurs(bool draw);
1957 cbradney 216
        void HandleCurs(QPainter *p, PageItem *currItem, QRect mpo);
217
        void HandleSizer(QPainter *p, PageItem *currItem, QRect mpo, QMouseEvent *m);
456 fschmid 218
        bool GetItem(PageItem **b, int nr = -1);
219
        void Deselect(bool prop = true);
1427 fschmid 220
        void SelectItemNr(int nr, bool draw = true, bool single = false);
221
        void SelectItem(PageItem *pi, bool draw = true, bool single = false);
795 fschmid 222
        void selectPage(QMouseEvent *m);
456 fschmid 223
        bool SeleItem(QMouseEvent *m);
224
        void SetupDraw(int Nr);
3941 cbradney 225
        //void updateGradientVectors(PageItem *currItem);
226
        //void EmitValues(PageItem *currItem);
1957 cbradney 227
        void Transform(PageItem *currItem, QPainter *p);
228
        void TransformM(PageItem *currItem, QPainter *p);
456 fschmid 229
        void SetFrameRect();
230
        void SetFrameRounded();
231
        void SetFrameOval();
4010 cbradney 232
        //void insertColor(QString nam, double c, double m, double y, double k);
4584 cbradney 233
 
3650 cbradney 234
        //void AdjustPictScale(PageItem *currItem, bool reload = true);
1065 cbradney 235
        void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
456 fschmid 236
        void QueryFarben();
238 Franz 237
        void rememberPreviousSettings(int mx=0, int my=0);
1211 tsoots 238
        bool mousePressed();
1254 tsoots 239
        bool groupTransactionStarted();
1263 tsoots 240
        void setGroupTransactionStarted(bool isOn);
2380 cbradney 241
        void setScale(const double newScale);
4593 cbradney 242
        double scale() const { return Scale; }
4072 cbradney 243
 
244
 
4672 cbradney 245
        //void adjustCanvas(FPoint minPos, FPoint maxPos, bool absolute = false);
3 paul 246
 
247
public slots: // Public slots
2199 cbradney 248
        void languageChange();
2380 cbradney 249
        void unitChange();
4651 cbradney 250
        void setRulersShown(bool isShown);
4654 cbradney 251
        void slotUpdateContents();
252
        void slotUpdateContents(const QRect &r);
3274 fschmid 253
  /** Zooms in or out */
168 Franz 254
        void slotDoZoom();
3274 fschmid 255
        void slotZoom100();
256
  /** Zooms in */
238 Franz 257
        void slotZoomIn(int mx=0,int my=0);
4297 cbradney 258
        //void slotZoomIn2(int mx=0,int my=0);
238 Franz 259
        void slotZoomOut(int mx=0,int my=0);
4297 cbradney 260
        //void slotZoomOut2(int mx=0,int my=0);
456 fschmid 261
  /** Redraws everything */
168 Franz 262
        void DrawNew();
263
        void setMenTxt(int Seite);
2937 cbradney 264
        void setLayerMenuText(const QString &);
168 Franz 265
        void GotoPa(int Seite);
3 paul 266
        void GotoLa(int l);
168 Franz 267
        void GotoPage(int Seite);
268
        void ChgUnit(int art);
269
        void SetCPo(int x, int y);
3 paul 270
        void SetCCPo(int x, int y);
2260 cbradney 271
        void editExtendedImageProperties();
456 fschmid 272
        void TogglePic();
273
        void UpdatePic();
4585 cbradney 274
        void RefreshItem(PageItem *currItem);
3942 cbradney 275
        /**
276
         * Adjust an image frame's size to fit the size of the image in it
277
         */
278
        void adjustFrametoImageSize();
456 fschmid 279
        void ToggleBookmark();
280
        void ToggleAnnotation();
281
        void ToggleLock();
1858 cbradney 282
        void ToggleSizeLock();
456 fschmid 283
        void sentToScrap();
284
        void ToBack();
285
        void ToFront();
286
        void LowerItem();
287
        void RaiseItem();
288
        void ToPicFrame();
289
        void ToPolyFrame();
290
        void ToTextFrame();
291
        void ToBezierFrame();
2026 cbradney 292
        void ToPathText();
293
        void FromPathText();
294
        void UniteObj();
295
        void SplitObj();
456 fschmid 296
        void Bezier2Poly();
297
        void ClearItem();
298
        void DeleteItem();
299
        void PasteToPage();
300
        void TextToPath();
301
        void BlinkCurs();
1155 fschmid 302
        void updatePict(QString name);
303
        void removePict(QString name);
2256 cbradney 304
        void changePreview(int id);
4672 cbradney 305
        void adjustCanvas(double width, double height, double dX=0.0, double dY=0.0);
168 Franz 306
 
3 paul 307
private: // Private attributes
456 fschmid 308
        QPopupMenu *pmen3;
2173 fschmid 309
        QPopupMenu *pmenResolution;
168 Franz 310
        bool Ready;
3982 craig 311
        int  oldX;
312
        int  oldY;
1254 tsoots 313
        bool _groupTransactionStarted;
1461 tsoots 314
        bool _isGlobalMode;
2171 fschmid 315
        bool evSpon;
2951 fschmid 316
        bool forceRedraw;
2380 cbradney 317
        double Scale;
1226 tsoots 318
 
3 paul 319
private slots:
168 Franz 320
        void Zval();
3942 cbradney 321
        /**
322
         * Called to update the GUI when the canvas(view) scrollbars are moved
323
         * @param x
324
         * @param y
325
         */
168 Franz 326
        void setRulerPos(int x, int y);
1443 tsoots 327
        void selectionChanged();
1461 tsoots 328
        void setObjectUndoMode();
329
        void setGlobalUndoMode();
168 Franz 330
 
3 paul 331
protected: // Protected methods
2171 fschmid 332
        virtual void viewportPaintEvent ( QPaintEvent * p );
456 fschmid 333
        virtual void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
334
        virtual void leaveEvent(QEvent *);
335
        virtual void contentsDragEnterEvent(QDragEnterEvent *e);
336
        virtual void contentsDragMoveEvent(QDragMoveEvent *e);
337
        virtual void contentsDragLeaveEvent(QDragLeaveEvent *e);
338
        virtual void contentsDropEvent(QDropEvent *e);
339
        virtual void contentsMouseDoubleClickEvent(QMouseEvent *m);
340
        virtual void contentsMouseReleaseEvent(QMouseEvent *m);
341
        virtual void contentsMouseMoveEvent(QMouseEvent *m);
342
        virtual void contentsMousePressEvent(QMouseEvent *m);
3 paul 343
        virtual void contentsWheelEvent ( QWheelEvent *ev );
344
        virtual void setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
345
        virtual void setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
4019 cbradney 346
 
3954 cbradney 347
        void drawLinkFrameLine(ScPainter* painter, FPoint &start, FPoint &end);
4654 cbradney 348
 
349
 
350
        //The width of vertical ruler/height of horizontal ruler, set to 17 in scribusview.cpp
351
        int m_vhRulerHW;
352
 
168 Franz 353
 
3 paul 354
signals:
355
        void changeUN(int);
356
        void changeLA(int);
456 fschmid 357
        void ItemPos(double, double);
358
        void HaveSel(int);
359
        void ItemGeom(double, double);
360
        void DocChanged();
361
        void PolyOpen();
362
        void PStatus(int, uint);
363
        void SetAngle(double);
364
        void SetSizeValue(double);
3934 cbradney 365
        void SetLineArt(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle);
456 fschmid 366
        void SetLocalValues(double, double, double, double);
367
        void ItemFarben(QString, QString, int, int);
368
        void ItemGradient(int);
369
        void ItemTrans(double, double);
370
        void ItemTextAttr(double);
2382 fschmid 371
        void ItemTextUSval(int);
456 fschmid 372
        void ItemTextCols(int, double);
373
        void SetDistValues(double, double, double, double);
374
        void ItemTextAbs(int);
375
        void ItemTextFont(QString);
376
        void ItemTextSize(int);
377
        void ItemTextSca(int);
2230 fschmid 378
        void ItemTextScaV(int);
2234 fschmid 379
        void ItemTextBase(int);
2257 fschmid 380
        void ItemTextOutline(int);
2247 fschmid 381
        void ItemTextShadow(int, int);
2262 fschmid 382
        void ItemTextUnderline(int, int);
2272 fschmid 383
        void ItemTextStrike(int, int);
456 fschmid 384
        void ItemTextFarben(QString, QString, int, int);
385
        void ItemTextStil(int);
3990 cbradney 386
        //void ItemRadius(double);
456 fschmid 387
        void HasTextSel();
388
        void HasNoTextSel();
389
        void MVals(double, double, double, double, double, double, int);
390
        void PaintingDone();
391
        void LoadPic();
392
        void AppendText();
393
        void DoGroup();
1858 cbradney 394
        //void DoUnGroup();
456 fschmid 395
        void CutItem();
396
        void CopyItem();
397
        void Amode(int);
398
        void AddBM(PageItem *);
399
        void DelBM(PageItem *);
400
        void ChBMText(PageItem *);
401
        void ToScrap(QString);
3743 fschmid 402
        void LoadElem(QString, double, double, bool, bool, ScribusDoc *, ScribusView *);
456 fschmid 403
        void LevelChanged(uint);
404
        void RasterPic(bool);
405
        void HavePoint(bool, bool);
406
        void ClipPo(double, double);
407
        void AnnotProps();
408
        void EndNodeEdit();
409
        void Hrule(int);
410
        void Vrule(int);
411
        void EditGuides();
412
        void MousePos(double, double);
1155 fschmid 413
        void callGimp();
1491 fschmid 414
        void AddObj(PageItem *);
415
        void UpdtObj(uint, uint);
2626 cbradney 416
        void signalGuideInformation(int, double);
3 paul 417
};
418
#endif