00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SCRIBUSVIEW_H
00025 #define SCRIBUSVIEW_H
00026
00027 #include "styleoptions.h"
00028
00029 #include <vector>
00030
00031 #include <QScrollArea>
00032 #include <QLineEdit>
00033 #include <QScrollBar>
00034 #if OPTION_USE_QTOOLBUTTON
00035 #include <QToolButton>
00036 #else
00037 #include <QPushButton>
00038 #endif
00039 #include <QMap>
00040 #include <QMenu>
00041 #include <QLabel>
00042 #include <QComboBox>
00043 #include <QProgressDialog>
00044 #include <QSpinBox>
00045 #include <QCursor>
00046 #include <QDragLeaveEvent>
00047 #include <QDragEnterEvent>
00048 #include <QDragMoveEvent>
00049 #include <QDropEvent>
00050 #include <QMouseEvent>
00051 #include <QPaintEvent>
00052 #include <QPoint>
00053 #include <QRect>
00054 #include <QRectF>
00055 #include <QTime>
00056 #include <QWheelEvent>
00057 #include <QRubberBand>
00058 #include <QList>
00059
00060 class QEvent;
00061
00062
00063 #include "observable.h"
00064 #include "scribusapi.h"
00065 #include "scribusdoc.h"
00066 #include "scrspinbox.h"
00067
00068 class Canvas;
00069 class CanvasMode;
00070 class CanvasGesture;
00071 class Hruler;
00072 class Vruler;
00073 class Page;
00074 class RulerMover;
00075 class PageSelector;
00076 class ScribusWin;
00077 class ScribusMainWindow;
00078 class UndoManager;
00079 class UndoTransaction;
00080
00081
00082
00087 class SCRIBUS_API ScribusView : public QScrollArea, public Observer<QRectF>
00088 {
00089 Q_OBJECT
00090
00091 public:
00092 ScribusView(QWidget* win=0, ScribusMainWindow* mw=0, ScribusDoc* doc=0);
00093 ~ScribusView();
00094
00095 friend class LegacyMode;
00096 friend class CanvasMode_NodeEdit;
00097
00098 void requestMode(int appMode);
00099 void startGesture(CanvasGesture*);
00100 void stopGesture();
00101
00103 ScrSpinBox* zoomSpinBox;
00104 PageSelector* pageSelector;
00105 RulerMover *rulerMover;
00106 Hruler *horizRuler;
00107 Vruler *vertRuler;
00108 #if OPTION_USE_QTOOLBUTTON
00109 QToolButton *zoomDefaultToolbarButton;
00110 QToolButton *zoomOutToolbarButton;
00111 QToolButton *zoomInToolbarButton;
00112 QToolButton *cmsToolbarButton;
00113 QToolButton *previewToolbarButton;
00114 #else
00115 QPushButton *zoomDefaultToolbarButton;
00116 QPushButton *zoomOutToolbarButton;
00117 QPushButton *zoomInToolbarButton;
00118 QToolButton *cmsToolbarButton;
00119 QPushButton *previewToolbarButton;
00120 #endif
00121 QComboBox *layerMenu;
00122 QComboBox *unitSwitcher;
00123 QComboBox *visualMenu;
00125 ScribusDoc * const Doc;
00126 Canvas * const m_canvas;
00127 CanvasMode* m_canvasMode;
00128 QMap<int,CanvasMode*> modeInstances;
00129 ApplicationPrefs * const Prefs;
00130 UndoManager * const undoManager;
00131 double OldScale;
00132 double dragX,dragY,dragW,dragH;
00133 double oldW;
00134 int RotMode;
00135 int DrHY;
00136 int DrVX;
00137 bool HaveSelRect;
00138
00139 bool DraggedGroup;
00140 bool DraggedGroupFirst;
00141 bool MidButt;
00142 bool updateOn;
00143 bool FirstPoly;
00144 bool Magnify;
00145 bool storedFramesShown;
00146 bool storedShowControls;
00147 int redrawMode;
00148 int redrawCount;
00149 PageItem *redrawItem;
00150 QRubberBand *redrawMarker;
00151 FPoint RCenter;
00152 void updatesOn(bool on);
00153
00154
00155 Page* addPage(int nr, bool mov = true);
00156
00157 void reformPages(bool moveObjects = true);
00158 void updateLayerMenu();
00159 void showMasterPage(int nr);
00160 void hideMasterPage();
00161 QImage PageToPixmap(int Nr, int maxGr, bool drawFrame = true);
00162 QImage MPageToPixmap(QString name, int maxGr, bool drawFrame = true);
00163 void RecalcPicturesRes();
00164 void rulerMove(QMouseEvent *m);
00169 void setNewRulerOrigin(QMouseEvent *m);
00170
00171
00172
00173
00174
00175
00176
00177 void getDragRectScreen(double *x, double *y, double *w, double *h);
00178 void getGroupRectScreen(double *x, double *y, double *w, double *h);
00179
00180
00181
00182 bool PointOnLine(QPoint Start, QPoint Ende, QRect MArea);
00183 void TransformPoly(int mode, int rot = 1, double scaling = 1.0);
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 bool slotSetCurs(int x, int y);
00198 void HandleCurs(PageItem *currItem, QRect mpo);
00199
00200 bool GetItem(PageItem **b, int nr = -1);
00201 void Deselect(bool prop = true);
00202 void SelectItemNr(uint nr, bool draw = true, bool single = false);
00203 void SelectItem(PageItem *pi, bool draw = true, bool single = false);
00204
00205
00206
00207
00208 void SetFrameRect();
00209 void SetFrameRounded();
00210 void SetFrameOval();
00211 void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false, bool noResize = true);
00212
00213 void rememberOldZoomLocation(int mx=0, int my=0);
00214 bool groupTransactionStarted() { return m_groupTransactions > 0; }
00215
00216 void startGroupTransaction(const QString &actionName = "",
00217 const QString &description = "",
00218 QPixmap *actionPixmap = 0,
00219 Selection* customSelection = 0);
00220 void endGroupTransaction();
00221 void cancelGroupTransaction();
00222 void setScale(const double newScale);
00223 double scale() const;
00224
00225 virtual void changed(QRectF re);
00226
00227 void updateCanvas(QRectF box = QRectF());
00228 void updateCanvas(double x, double y, double width, double height) { updateCanvas(QRectF(x,y,width,height)); }
00229 void setCanvasOrigin(double x, double y);
00230 void setCanvasCenter(double x, double y);
00231 void scrollCanvasBy(double deltaX, double deltaY);
00232 FPoint canvasOrigin() const;
00233 QRectF visibleCanvas() const;
00234
00235 private:
00236
00237 void updateContents(QRect box = QRect());
00238 void updateContents(int x, int y, int w, int h);
00239 void repaintContents(QRect box);
00240 void resizeContents(int w, int h);
00241 QPoint contentsToViewport(QPoint p);
00242 QPoint viewportToContents(QPoint p);
00243 public:
00244 int contentsX();
00245 int contentsY();
00246 int contentsWidth();
00247 int contentsHeight();
00248 void setContentsPos(int x, int y);
00249 int visibleWidth() { return viewport()->size().width(); } ;
00250 int visibleHeight() { return viewport()->size().height(); } ;
00251 void stopAllDrags();
00252 void scrollBy(int x, int y);
00253
00254 public slots:
00255 void languageChange();
00256 void toggleCMS();
00257 void switchPreviewVisual(int vis);
00258 void togglePreview();
00259 void unitChange();
00260 void setRulersShown(bool isShown);
00261 void slotUpdateContents();
00262 void slotUpdateContents(const QRect &r);
00264 void slotDoZoom();
00265 void slotZoom100();
00267 void slotZoomIn(int mx=0,int my=0);
00268 void slotZoomOut(int mx=0,int my=0);
00270 void DrawNew();
00271 void setMenTxt(int Seite);
00272 void setLayerMenuText(const QString &);
00273 void GotoPa(int Seite);
00274 void GotoLa(int l);
00275 void GotoPage(int Seite);
00276 void ChgUnit(int art);
00277 void SetCPo(double x, double y);
00278 void SetCCPo(double x, double y);
00279 void editExtendedImageProperties();
00280
00281 void RefreshGradient(PageItem *currItem, double dx = 8, double dy = 8);
00285
00286 void ToggleBookmark();
00287 void ToggleAnnotation();
00288
00289 void ToBack();
00290 void ToFront();
00291 void LowerItem();
00292 void RaiseItem();
00293 void ToPicFrame();
00294 void ToPolyFrame();
00295 void ToTextFrame();
00296 void ToBezierFrame();
00297 void ToPathText();
00298 void FromPathText();
00299
00300
00301 void Bezier2Poly();
00302 void PasteToPage();
00303
00304 void TextToPath();
00305 void adjustCanvas(double width, double height, double dX=0.0, double dY=0.0);
00306
00307 private:
00308 int m_previousMode;
00309 QMenu *pmen3;
00310 QMenu *pmenResolution;
00311 QPoint m_pressLocation;
00312 QTime m_moveTimer;
00313 QTimer *m_dragTimer;
00314 bool m_dragTimerFired;
00315 bool Ready;
00316 int oldX;
00317 int oldY;
00318 int m_groupTransactions;
00319 UndoTransaction* m_groupTransaction;
00320 bool _isGlobalMode;
00321
00322
00323 double oldItemX;
00324 double oldItemY;
00325
00326 private slots:
00327 void setZoom();
00333 void setRulerPos(int x, int y);
00334 void selectionChanged();
00335 void setObjectUndoMode();
00336 void setGlobalUndoMode();
00337 void dragTimerTimeOut();
00338
00339 public:
00340 virtual void wheelEvent ( QWheelEvent *ev );
00341 virtual void changeEvent(QEvent *e);
00342
00343 void keyPressEvent(QKeyEvent *k);
00344 void keyReleaseEvent(QKeyEvent *k);
00345
00346 inline void registerMousePress(QPoint p);
00347 bool mousePressed();
00348 void resetMousePressed();
00349 inline QPoint mousePressLocation();
00350 inline bool moveTimerElapsed();
00351 inline void resetMoveTimer();
00352
00353 inline void startDragTimer();
00354 inline void stopDragTimer();
00355 inline void resetDragTimer();
00356 inline bool dragTimerElapsed();
00357
00358 protected:
00359 virtual void enterEvent(QEvent *);
00360 virtual void leaveEvent(QEvent *);
00361 virtual void resizeEvent ( QResizeEvent * event );
00362 bool eventFilter(QObject *obj, QEvent *event);
00363
00364
00365 virtual void contentsDragEnterEvent(QDragEnterEvent *e);
00366 virtual void contentsDragMoveEvent(QDragMoveEvent *e);
00367 virtual void contentsDragLeaveEvent(QDragLeaveEvent *e);
00368 virtual void contentsDropEvent(QDropEvent *e);
00369 virtual void setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
00370 virtual void setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
00371 void scrollContentsBy(int dx, int dy);
00372
00373
00374 int m_vhRulerHW;
00375 ScribusMainWindow* m_ScMW;
00376
00377 signals:
00378 void changeUN(int);
00379 void changeLA(int);
00380 void ItemPos(double, double);
00381 void HaveSel(int);
00382 void ItemGeom(double, double);
00383 void DocChanged();
00384 void PolyOpen();
00385 void PStatus(int, uint);
00386 void SetAngle(double);
00387 void SetSizeValue(double);
00388 void SetLineArt(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle);
00389 void SetLocalValues(double, double, double, double);
00390
00391
00392
00393
00394 void ItemTextAttr(double);
00395 void ItemTextUSval(double);
00396 void ItemTextCols(int, double);
00397 void SetDistValues(double, double, double, double);
00398 void ItemTextAbs(int);
00399 void ItemTextFont(const QString&);
00400 void ItemTextSize(double);
00401 void ItemTextSca(double);
00402 void ItemTextScaV(double);
00403 void ItemTextBase(double);
00404 void ItemTextOutline(double);
00405 void ItemTextShadow(double, double);
00406 void ItemTextUnderline(double, double);
00407 void ItemTextStrike(double, double);
00408 void ItemTextFarben(QString, QString, double, double);
00409 void ItemTextStil(int);
00410
00411 void HasTextSel();
00412 void HasNoTextSel();
00413 void MVals(double, double, double, double, double, double, int);
00414 void PaintingDone();
00415 void LoadPic();
00416 void StatusPic();
00417 void AppendText();
00418 void DoGroup();
00419
00420 void CutItem();
00421 void CopyItem();
00422 void Amode(int);
00423 void AddBM(PageItem *);
00424 void DelBM(PageItem *);
00425 void ChBMText(PageItem *);
00426 void ToScrap(QString);
00427 void LoadElem(QString, double, double, bool, bool, ScribusDoc *, ScribusView *);
00428 void LevelChanged(uint);
00429 void RasterPic(bool);
00430 void HavePoint(bool, bool);
00431 void ClipPo(double, double);
00432 void AnnotProps();
00433 void EndNodeEdit();
00434 void Hrule(int);
00435 void Vrule(int);
00436
00437 void MousePos(double, double);
00438 void callGimp();
00439 void signalGuideInformation(int, double);
00440 };
00441
00442
00443
00444
00445 inline void ScribusView::registerMousePress(QPoint p)
00446 {
00447 m_pressLocation = p;
00448 m_moveTimer.start();
00449 m_dragTimerFired = false;
00450 }
00451
00452
00453 inline QPoint ScribusView::mousePressLocation()
00454 {
00455 return m_pressLocation;
00456 }
00457
00458
00459 inline bool ScribusView::moveTimerElapsed()
00460 {
00461 return (m_moveTimer.elapsed() > Prefs->moveTimeout);
00462 }
00463
00464
00465 inline void ScribusView::resetMoveTimer()
00466 {
00467 m_moveTimer.start();
00468 }
00469
00470
00471 inline void ScribusView::startDragTimer()
00472 {
00473 m_dragTimerFired = false;
00474 m_dragTimer->setSingleShot(true);
00475 m_dragTimer->start(1000);
00476 }
00477
00478 inline void ScribusView::stopDragTimer()
00479 {
00480 m_dragTimer->stop();
00481 }
00482
00483
00484 inline void ScribusView::resetDragTimer()
00485 {
00486 m_dragTimerFired = false;
00487 }
00488
00489
00490 inline bool ScribusView::dragTimerElapsed()
00491 {
00492 return m_dragTimerFired;
00493 }
00494
00495 #endif