Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scribusview.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           scribusview.h  -  description
00009                              -------------------
00010     begin                : Fre Apr  6 21:47:55 CEST 2001
00011     copyright            : (C) 2001 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #ifndef SCRIBUSVIEW_H
00025 #define SCRIBUSVIEW_H
00026 
00027 #include "styleoptions.h"
00028 
00029 #include <vector>
00030 // include files for QT
00031 #include <qscrollview.h>
00032 #include <qptrlist.h>
00033 #include <qlineedit.h>
00034 #include <qscrollbar.h>
00035 #if OPTION_USE_QTOOLBUTTON
00036     #include <qtoolbutton.h>
00037 #else
00038     #include <qpushbutton.h>
00039 #endif
00040 #include <qpopupmenu.h>
00041 #include <qlabel.h>
00042 #include <qcombobox.h>
00043 #include <qprogressdialog.h>
00044 #include <qspinbox.h>
00045 #include <qcursor.h>
00046 // application specific includes
00047 #include "scribusapi.h"
00048 #include "scribusdoc.h"
00049 #include "scribusstructs.h"
00050 #include "scpainter.h"
00051 class Page;
00052 #include "mspinbox.h"
00053 //#include "util.h"
00054 class Hruler;
00055 class Vruler;
00056 class UndoManager;
00057 class RulerMover;
00058 class PageSelector;
00059 class ScribusWin;
00060 class ScribusMainWindow;
00061 
00066 class SCRIBUS_API ScribusView : public QScrollView
00067 {
00068        Q_OBJECT
00069 
00070 public:
00071     ScribusView(QWidget* win=0, ScribusMainWindow* mw=0, ScribusDoc* doc=0);
00072     ~ScribusView() {};
00074        MSpinBox* zoomSpinBox; //zoom spinbox at bottom of view
00075        PageSelector* pageSelector; //Page selector at bottom of view
00076        RulerMover *rulerMover; //Widget between the two rulers for dragging the ruler origin
00077        Hruler *horizRuler;
00078        Vruler *vertRuler;
00079 #if OPTION_USE_QTOOLBUTTON
00080        QToolButton *zoomDefaultToolbarButton;
00081        QToolButton *zoomOutToolbarButton;
00082        QToolButton *zoomInToolbarButton;
00083        QToolButton *cmsToolbarButton;
00084        QToolButton *previewToolbarButton;
00085 #else
00086        QPushButton *zoomDefaultToolbarButton;
00087        QPushButton *zoomOutToolbarButton;
00088        QPushButton *zoomInToolbarButton;
00089        QToolButton *cmsToolbarButton;
00090        QPushButton *previewToolbarButton;
00091 #endif
00092        QComboBox *layerMenu; //Menu for layers at bottom of view
00093        QComboBox *unitSwitcher; //Menu for units at bottom of view
00094        QComboBox *visualMenu;
00096        ScribusDoc * const Doc;
00097        ApplicationPrefs * const Prefs;
00098        UndoManager * const undoManager;
00099        double OldScale;
00100        double dragX,dragY,dragW,dragH;
00101        double oldW;
00102        int oldCp;
00103        int Mxp;
00104        int Myp;
00105        int dragConstrainInitPtX;
00106        int dragConstrainInitPtY;
00107        int Dxp;
00108        int Dyp;
00109        int m_SnapCounter;
00116        int frameResizeHandle;
00117        int SeRx;
00118        int SeRy;
00119        int GyM;
00120        int GxM;
00121        int ClRe;
00122        int ClRe2;
00123        int SegP1;
00124        int SegP2;
00125        int RotMode;
00126        int DrHY;
00127        int DrVX;
00128        bool EdPoints;
00129        bool m_MouseButtonPressed;
00130        bool operItemMoving;
00131        bool shiftSelItems;
00132        bool MoveGY;
00133        bool MoveGX;
00134        bool HaveSelRect;
00135        bool operItemResizing;
00136        bool EditContour;
00137        //bool GroupSel;
00138        bool DraggedGroup;
00139        bool DraggedGroupFirst;
00140        bool operItemResizeInEditMode;
00141        bool inItemCreation;
00142        bool MidButt;
00143        bool updateOn;
00144        bool FirstPoly;
00145        bool Magnify;
00146        bool MoveSym;
00147        bool previewMode;
00148        bool viewAsPreview;
00149        bool storedFramesShown;
00150        bool storedShowControls;
00151        int previewVisual;
00152        FPoint RCenter;
00153        FPointArray RecordP;
00154        void DrawMasterItems(ScPainter *painter, Page *page, QRect clip);
00155        void DrawPageItems(ScPainter *painter, QRect clip);
00156        void DrawPageMarks(ScPainter *p, Page* page, QRect clip);
00157        void updatesOn(bool on);
00158        //CB This MUST now be called AFTER a call to doc->addPage or doc->addMasterPage as it
00159        //does NOT create a page anymore.
00160        Page* addPage(int nr, bool mov = true);
00161        QPtrList<PageItem> linkedFramesToShow;
00162        QValueList<int> SelNode;
00163 
00164        
00165        struct oldPageVar
00166        {
00167               uint newPg;
00168               double oldXO;
00169               double oldYO;
00170        };
00171        static const uint moveWithFullOutlinesThreshold = 21;
00172        static const uint moveWithBoxesOnlyThreshold = 41;
00173        void reformPages(bool moveObjects = true);
00174        void updateLayerMenu();
00175        void showMasterPage(int nr);
00176        void hideMasterPage();
00177        QImage PageToPixmap(int Nr, int maxGr, bool drawFrame = true);
00178        QImage MPageToPixmap(QString name, int maxGr, bool drawFrame = true);
00179        void RecalcPicturesRes();
00180        void rulerMove(QMouseEvent *m);
00185        void setNewRulerOrigin(QMouseEvent *m);
00186        void FromHRuler(QMouseEvent *m);
00187        void FromVRuler(QMouseEvent *m);
00188        void SetYGuide(QMouseEvent *m, int oldIndex);
00189        void SetXGuide(QMouseEvent *m, int oldIndex);
00190 //     void getClosestGuides(double xin, double yin, double *xout, double *yout);
00191 //     bool ApplyGuides(double *x, double *y);
00192 //     void SnapToGuides(PageItem *currItem);
00193        void getDragRectScreen(double *x, double *y, double *w, double *h);
00194        void getGroupRectScreen(double *x, double *y, double *w, double *h);
00195        void paintGroupRect(bool norm = true);
00196        void PaintSizeRect(QPainter *p, QRect neu);
00197        void ToView(QPainter *p);
00198        void ToView(QWMatrix& m);
00199 //     bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
00200        void MarkClip(PageItem *currItem, FPointArray cli, bool once = false);
00201        bool PointOnLine(QPoint Start, QPoint Ende, QRect MArea);
00202        void TransformPoly(int mode, int rot = 1, double scaling = 1.0);
00203        void Reset1Control();
00204        void ResetControl();
00205        void MoveClipPoint(PageItem *currItem, FPoint np);
00206 //     bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
00207 //     bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
00208        void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
00209 //     void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
00210 //     bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
00211        void RotateGroup(double win);
00212        void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
00213 //     void RotateItem(double win, int ite);
00214 //     void RotateItem(double win, PageItem *currItem);
00215 //     void AdjustItemSize(PageItem *currItem);
00216        bool slotSetCurs(int x, int y);
00217        void slotDoCurs(bool draw);
00218        void HandleCurs(QPainter *p, PageItem *currItem, QRect mpo);
00219        void HandleSizer(QPainter *p, PageItem *currItem, QRect mpo, QMouseEvent *m);
00220        bool GetItem(PageItem **b, int nr = -1);
00221        void Deselect(bool prop = true);
00222        void SelectItemNr(uint nr, bool draw = true, bool single = false);
00223        void SelectItem(PageItem *pi, bool draw = true, bool single = false);
00224        void selectPage(QMouseEvent *m);
00225        bool SeleItem(QMouseEvent *m);
00226        void SetupDraw(int Nr);
00227        void SetupDrawNoResize(int nr);
00228        void Transform(PageItem *currItem, QPainter *p);
00229        void Transform(PageItem *currItem, QWMatrix& m);
00230        void TransformM(PageItem *currItem, QPainter *p);
00231        void SetFrameRect();
00232        void SetFrameRounded();
00233        void SetFrameOval();
00234        void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false, bool noResize = true);
00235 //     void QueryFarben();
00236        void rememberOldZoomLocation(int mx=0, int my=0);
00237        bool mousePressed();
00238        bool groupTransactionStarted();
00239        void setGroupTransactionStarted(bool isOn);
00240        void setScale(const double newScale);
00241        double scale() const { return Scale; }
00242        void normalizeSelectionRect();
00243        FPoint translateToView(double x, double y);
00244        FPoint translateToView(FPoint in);
00245        FPoint translateToDoc(double x, double y);
00246        FPoint translateToDoc(FPoint in);
00247        FPoint translateFromViewport(double x, double y);
00248        FPoint translateFromViewport(FPoint in);
00249        FPoint translateToViewport(double x, double y);
00250        FPoint translateToViewport(FPoint in);
00251 
00252 public slots: // Public slots
00253        void languageChange();
00254        void toggleCMS();
00255        void switchPreviewVisual(int vis);
00256        void togglePreview();
00257        void unitChange();
00258        void setRulersShown(bool isShown);
00259        void slotUpdateContents();
00260        void slotUpdateContents(const QRect &r);
00262        void slotDoZoom();
00263        void slotZoom100();
00265        void slotZoomIn(int mx=0,int my=0);
00266        void slotZoomOut(int mx=0,int my=0);
00268        void DrawNew();
00269        void setMenTxt(int Seite);
00270        void setLayerMenuText(const QString &);
00271        void GotoPa(int Seite);
00272        void GotoLa(int l);
00273        void GotoPage(int Seite);
00274        void ChgUnit(int art);
00275        void SetCPo(double x, double y);
00276        void SetCCPo(double x, double y);
00277        void editExtendedImageProperties();
00278        void RefreshItem(PageItem *currItem);
00279        void RefreshGradient(PageItem *currItem, double dx = 8, double dy = 8);
00283 //     void adjustFrametoImageSize();
00284        void ToggleBookmark();
00285        void ToggleAnnotation();
00286 //     void sentToScrap();
00287        void ToBack();
00288        void ToFront();
00289        void LowerItem();
00290        void RaiseItem();
00291        void ToPicFrame();
00292        void ToPolyFrame();
00293        void ToTextFrame();
00294        void ToBezierFrame();
00295        void ToPathText();
00296        void FromPathText();
00297 //     void UniteObj();
00298 //     void SplitObj();
00299        void Bezier2Poly();
00300        void PasteToPage();
00301        void PasteRecentToPage(int id);
00302        void TextToPath();
00303        void blinkCursor();
00304        void adjustCanvas(double width, double height, double dX=0.0, double dY=0.0);
00305 
00306 private: // Private attributes
00307        QPopupMenu *pmen3;
00308        QPopupMenu *pmenResolution;
00309        QTime moveTimer;
00310        bool Ready;
00311        int  oldX;
00312        int  oldY;
00313        bool _groupTransactionStarted;
00314        bool _isGlobalMode;
00315        bool evSpon;
00316        bool forceRedraw;
00317        double Scale;
00318 
00319        // for shape/countour line editing undo actions
00320        // store oldClip in mousePressed if in edit shape
00321        // and in mouseRelease send the undo action with the 
00322        // new clip
00323        bool isContourLine;
00324        FPointArray *oldClip;
00325        double oldItemX;
00326        double oldItemY;
00327 
00328 private slots:
00329        void setZoom();
00335        void setRulerPos(int x, int y);
00336        void selectionChanged();
00337        void setObjectUndoMode();
00338        void setGlobalUndoMode();
00339 
00340 protected: // Protected methods
00341        virtual void viewportPaintEvent ( QPaintEvent * p );
00342        virtual void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
00343        virtual void enterEvent(QEvent *);
00344        virtual void leaveEvent(QEvent *);
00345        virtual void contentsDragEnterEvent(QDragEnterEvent *e);
00346        virtual void contentsDragMoveEvent(QDragMoveEvent *e);
00347        virtual void contentsDragLeaveEvent(QDragLeaveEvent *e);
00348        virtual void contentsDropEvent(QDropEvent *e);
00349        virtual void contentsMouseDoubleClickEvent(QMouseEvent *m);
00350        virtual void contentsMouseReleaseEvent(QMouseEvent *m);
00351        virtual void contentsMouseMoveEvent(QMouseEvent *m);
00352        virtual void contentsMousePressEvent(QMouseEvent *m);
00353        virtual void contentsWheelEvent ( QWheelEvent *ev );
00354        virtual void setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
00355        virtual void setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
00356 
00357        void drawLinkFrameLine(ScPainter* painter, FPoint &start, FPoint &end);
00358        inline bool moveTimerElapsed();
00359        
00360        //The width of vertical ruler/height of horizontal ruler, set to 17 in scribusview.cpp
00361        int m_vhRulerHW;
00362        bool m_cursorVisible;
00363        ScribusMainWindow* m_ScMW;
00364 
00365 signals:
00366        void changeUN(int);
00367        void changeLA(int);
00368        void ItemPos(double, double);
00369        void HaveSel(int);
00370        void ItemGeom(double, double);
00371        void DocChanged();
00372        void PolyOpen();
00373        void PStatus(int, uint);
00374        void SetAngle(double);
00375        void SetSizeValue(double);
00376        void SetLineArt(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle);
00377        void SetLocalValues(double, double, double, double);
00378 //     void ItemFarben(QString, QString, int, int);
00379 //     void ItemGradient(int);
00380 //     void ItemTrans(double, double);
00381 //     void ItemBlend(int, int);
00382        void ItemTextAttr(double);
00383        void ItemTextUSval(int);
00384        void ItemTextCols(int, double);
00385        void SetDistValues(double, double, double, double);
00386        void ItemTextAbs(int);
00387        void ItemTextFont(const QString&);
00388        void ItemTextSize(int);
00389        void ItemTextSca(int);
00390        void ItemTextScaV(int);
00391        void ItemTextBase(int);
00392        void ItemTextOutline(int);
00393        void ItemTextShadow(int, int);
00394        void ItemTextUnderline(int, int);
00395        void ItemTextStrike(int, int);
00396        void ItemTextFarben(QString, QString, int, int);
00397        void ItemTextStil(int);
00398        //void ItemRadius(double);
00399        void HasTextSel();
00400        void HasNoTextSel();
00401        void MVals(double, double, double, double, double, double, int);
00402        void PaintingDone();
00403        void LoadPic();
00404        void AppendText();
00405        void DoGroup();
00406        //void DoUnGroup();
00407        void CutItem();
00408        void CopyItem();
00409        void Amode(int);
00410        void AddBM(PageItem *);
00411        void DelBM(PageItem *);
00412        void ChBMText(PageItem *);
00413        void ToScrap(QString);
00414        void LoadElem(QString, double, double, bool, bool, ScribusDoc *, ScribusView *);
00415        void LevelChanged(uint);
00416        void RasterPic(bool);
00417        void HavePoint(bool, bool);
00418        void ClipPo(double, double);
00419        void AnnotProps();
00420        void EndNodeEdit();
00421        void Hrule(int);
00422        void Vrule(int);
00423        //void EditGuides();
00424        void MousePos(double, double);
00425        void callGimp();
00426        void signalGuideInformation(int, double);
00427 };
00428 #endif