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 #ifndef TABRULER_H 8 #define TABRULER_H 9 10 #include <QEvent> 11 #include <QGridLayout> 12 #include <QHBoxLayout> 13 #include <QLabel> 14 #include <QMouseEvent> 15 #include <QPaintEvent> 16 #include <QVariant> 17 #include <QVBoxLayout> 18 #include <QWidget> 19 20 #include "scribusapi.h" 21 #include "sctextstruct.h" 22 23 class QComboBox; 24 class QPushButton; 25 class QToolButton; 26 class ScrSpinBox; 27 28 class SCRIBUS_API RulerT : public QWidget 29 { 30 Q_OBJECT 31 32 public: 33 RulerT(QWidget* parent, int unit, const QList<ParagraphStyle::TabRecord>& tabs, bool ind, double wid); ~RulerT()34 ~RulerT() {}; 35 36 void setTabs(const QList<ParagraphStyle::TabRecord>& tabs, int unit); 37 void updateTabList(); 38 39 bool mousePressed { false }; 40 QList<ParagraphStyle::TabRecord> tabValues; 41 bool haveInd { false }; 42 int unitIndex { 0 }; 43 int offset { 0 }; 44 int actTab { -1 }; 45 double leftIndent { 0.0 }; 46 double firstLine { 0.0 }; 47 int rulerCode { 0 }; 48 int mouseX { 0 }; 49 int offsetIncrement { 5 }; 50 51 public slots: 52 void resetOffsetInc(); 53 void decreaseOffset(); 54 void increaseOffset(); 55 void changeTab(int t); 56 void changeTabChar(QChar t); 57 void moveTab(double t); 58 void removeActTab(); 59 void moveFirstLine(double t); 60 void moveLeftIndent(double t); 61 62 signals: 63 void tabMoved(double); 64 void typeChanged(int); 65 void fillCharChanged(QChar); 66 void leftIndentMoved(double); 67 void firstLineMoved(double); 68 void noTabs(); 69 void newTab(); 70 void mouseReleased(); 71 void tabSelected(); 72 73 protected: 74 virtual void paintEvent(QPaintEvent *); 75 virtual void mousePressEvent(QMouseEvent *m); 76 virtual void mouseReleaseEvent(QMouseEvent *); 77 virtual void mouseMoveEvent(QMouseEvent *m); 78 virtual void leaveEvent(QEvent*); 79 80 private: 81 double m_iter { 10.0 }; // Result of unitRulerGetIter1FromIndex() for point unit 82 double m_iter2 { 100.0 }; // Result of unitRulerGetIter2FromIndex() for point unit 83 double m_rulerWidth { 0.0 }; 84 }; 85 86 class SCRIBUS_API Tabruler : public QWidget 87 { 88 Q_OBJECT 89 90 public: 91 Tabruler(QWidget* parent, 92 bool haveFirst = true, 93 int unit = 1, 94 const QList<ParagraphStyle::TabRecord>& tabs = QList<ParagraphStyle::TabRecord>(), 95 double wid = -1); ~Tabruler()96 ~Tabruler() {}; 97 98 virtual void setTabs(const QList<ParagraphStyle::TabRecord>& tabs, int unit); 99 100 QList<ParagraphStyle::TabRecord> getTabVals(); 101 double getFirstLine(); 102 double getLeftIndent(); 103 double getRightIndent(); 104 105 public slots: 106 void resetOFfL(); 107 void resetOFfR(); 108 void clearAll(); 109 void clearOne(); 110 void tabAdded(); 111 void lastTabRemoved(); 112 void setTabType(int t); 113 void setType(); 114 void setTabData(double t); 115 void setTab(); 116 void setFirstLineData(double t); 117 void setFirstLine(); 118 void setLeftIndentData(double t); 119 void setLeftIndent(); 120 void setRightIndentData(double t); 121 void setRightIndent(); 122 void setTabFillChar(QChar t); 123 void setFillChar(); 124 void setCustomFillChar(const QString &txt); 125 126 signals: 127 /*! This signal is emitted when something is changed in the tab ruler dialog/widget. 128 4/11/2005 pv */ 129 void tabrulerChanged(); 130 131 /** emitted when tabs are changed */ 132 void tabsChanged(); 133 /** emitted when left indent is changed */ 134 void leftIndentChanged(double); 135 /** emitted when right indent is changed */ 136 void rightIndentChanged(double); 137 /** emitted when first line is changed */ 138 void firstLineChanged(double); 139 void mouseReleased(); 140 141 protected: 142 QVBoxLayout* tabrulerLayout { nullptr }; 143 QHBoxLayout* layout2 { nullptr }; 144 QHBoxLayout* layout1 { nullptr }; 145 QHBoxLayout* indentLayout { nullptr }; 146 QComboBox* typeCombo { nullptr }; 147 QComboBox* tabFillCombo { nullptr }; 148 QLabel* tabFillComboT { nullptr }; 149 RulerT* ruler { nullptr }; 150 QToolButton* rulerScrollL { nullptr }; 151 QToolButton* rulerScrollR { nullptr }; 152 QLabel* positionLabel { nullptr }; 153 QLabel* firstLineLabel { nullptr }; 154 QLabel* leftIndentLabel { nullptr }; 155 QLabel* rightIndentLabel { nullptr }; 156 ScrSpinBox* tabData { nullptr }; 157 ScrSpinBox* firstLineData { nullptr }; 158 ScrSpinBox* leftIndentData { nullptr }; 159 ScrSpinBox* rightIndentData { nullptr }; 160 QToolButton* clearButton { nullptr }; 161 QToolButton* clearOneButton { nullptr }; 162 163 bool m_haveFirst; 164 double m_docUnitRatio; 165 166 void changeEvent(QEvent *e) override; 167 168 protected slots: 169 void iconSetChange(); 170 void languageChange(); 171 void slotMouseReleased(); 172 }; 173 174 #endif // TABRULER_H 175