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 */ 7 /*************************************************************************** 8 hruler.h - description 9 ------------------- 10 begin : Tue Apr 10 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 HRULER_H 25 #define HRULER_H 26 27 #include <QWidget> 28 29 #include "scribusapi.h" 30 #include "styles/paragraphstyle.h" 31 32 class PageItem; 33 34 class QPaintEvent; 35 class QMouseEvent; 36 class PrefsManager; 37 class RulerGesture; 38 class ScribusView; 39 class ScribusDoc; 40 class ScribusMainWindow; 41 42 /** \brief Horizontal ruler 43 \author Franz Schmid 44 */ 45 46 47 enum ruler_code 48 { 49 rc_none = 0, 50 rc_leftFrameDist = 1, 51 rc_rightFrameDist = 2, 52 rc_indentFirst = 3, 53 rc_leftMargin = 4, 54 rc_tab = 5, 55 rc_rightMargin = 6 56 }; 57 58 class SCRIBUS_API Hruler : public QWidget 59 { 60 Q_OBJECT 61 62 public: 63 Hruler(ScribusView *pa, ScribusDoc *doc); ~Hruler()64 ~Hruler() {} 65 66 double ruleSpacing(); 67 void setItem(PageItem * item); textMode(bool state)68 void textMode(bool state) { m_textEditMode = state; } 69 double textBase() const; // left text edge in canvas coord 70 double textWidth() const; 71 double textPosToCanvas(double x) const; 72 int textPosToLocal(double x) const; 73 double localToTextPos(int x) const; 74 void shift(double pos); // using canvas coord 75 void shiftRel(double dist); // using canvas coord offset()76 double offset() const { return m_offset; } 77 78 private: 79 int findRulerHandle(QPoint mp, double grabRadius); 80 81 virtual void paintEvent(QPaintEvent *e); 82 virtual void mousePressEvent(QMouseEvent *m); 83 virtual void mouseReleaseEvent(QMouseEvent *); 84 virtual void mouseMoveEvent(QMouseEvent *m); 85 virtual void enterEvent(QEvent *m); 86 virtual void leaveEvent(QEvent *m); 87 88 void drawMarks(QPainter& p); 89 void drawTextMarks(double pos, double endPos, QPainter& p); 90 void drawMarker(QPainter& p); 91 void drawNumber(const QString& num, int startx, int starty, QPainter & p); 92 void updateTabList(); 93 94 PageItem* m_currItem {nullptr}; 95 QList<ParagraphStyle::TabRecord> m_tabValues; 96 ScribusDoc *m_doc {nullptr}; 97 ScribusView *m_view {nullptr}; 98 bool m_drawMark {false}; 99 bool m_mousePressed {false}; 100 bool m_reverse {false}; 101 bool m_textEditMode {false}; 102 double m_colGap {0.0}; 103 double m_cor {0.0}; 104 double m_distLeft {0.0}; 105 double m_distRight {0.0}; 106 double m_firstIndent {0.0}; 107 double m_itemEndPos {0.0}; 108 double m_itemPos {0.0}; 109 double m_itemScale {1.0}; 110 double m_iter {0.0}; 111 double m_iter2 {0.0}; 112 double m_leftMargin {0.0}; 113 double m_lineCorr {0.0}; 114 double m_offset {0.0}; 115 double m_rightMargin {0.0}; 116 double m_scaling {0.0}; 117 int m_cols {0}; 118 int m_currCol {1}; 119 int m_currTab {0}; 120 int m_mouseX {0}; 121 int m_oldMark {0}; 122 int m_rulerCode {rc_none}; 123 int m_whereToDraw {0}; 124 125 public slots: // Public slots 126 /** \brief draw mark 127 \param where where to draw */ 128 void draw(int where); 129 void unitChange(); 130 131 signals: 132 void DocChanged(bool); 133 void MarkerMoved(double base, double xp); 134 135 private: 136 RulerGesture* rulerGesture; 137 }; 138 139 #endif 140