Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
3 paul 1
#ifndef GUIDEMANAGER_H
2
#define GUIDEMANAGER_H
3
 
4215 subik 4
#include <qlistview.h>
2969 craig 5
#include "scribusapi.h"
3 paul 6
#include "mspinbox.h"
7
 
4185 subik 8
class QWidget;
9
class QGroupBox;
10
class QPushButton;
11
class QLabel;
12
class QString;
13
class QCheckBox;
14
class QHButtonGroup;
181 Franz 15
 
4185 subik 16
 
4215 subik 17
/*! \brief Inherited QListViewItem provides double number values sorting.
18
Guides lists contains double values in 1st (0) columns. Standard QListViewItem
19
provides string sorting so I have to create some special number related one ;)
20
\author Petr Vanek <petr@yarpen.cz>
21
*/
22
class GuideListItem : public QListViewItem
23
{
24
public:
25
        //! \brief Only 2 columns here...
26
        GuideListItem(QListView *parent, QString c1, QString c2) : QListViewItem(parent, c1, c2){};
27
 
28
        /*! \brief Reimplemented compare method to handle double values.
29
        When is no double in column col parent string compare() is called.
30
        \param i QListViewItem to compare with.
31
        \param col column to sort (0 here)
32
        \param asc ascendent on true.
33
        \retval int -1 for (x lt y), 1 for (x gt y). See Qt docs for more info.
34
        */
35
        int compare(QListViewItem *i, int col, bool asc) const;
36
};
37
 
38
 
3620 subik 39
/*! \brief \brief GuideManager is the dialog for guides managing ;).
2215 subik 40
Its public interface is used in scrubus.cpp
4026 craig 41
ScribusMainWindow::ManageGuides() via refreshDoc().
2215 subik 42
Guides are applied via void Page::addXGuides(QValueList<double>& guides)
43
and void Page::addYGuides(QValueList<double>& guides).
4185 subik 44
 
45
\note Current limitations: Applying the guides on all pages with
46
automatic rows or columns removes old guides. To prevent guides
47
multiplications.
48
 
2215 subik 49
\author Petr Vanek <petr@yarpen.cz>
50
\author Alessandro Rimoldi
51
\author Franz Schmid
52
*/
2969 craig 53
class SCRIBUS_API GuideManager : public QDialog
2143 subik 54
{
3 paul 55
    Q_OBJECT
56
 
57
public:
2164 subik 58
        GuideManager(QWidget* parent);
4198 subik 59
        ~GuideManager();
181 Franz 60
 
2215 subik 61
private:
4185 subik 62
        //! \brief If there is a selection on the current page
63
        bool selected;
64
        //! \brief width of the current page
3620 subik 65
        double locPageWidth;
4185 subik 66
        //! \brief height of the current page
3620 subik 67
        double locPageHeight;
4185 subik 68
        //! \brief top margin of the current page
3620 subik 69
        double locTop;
4185 subik 70
        //! \brief bottom margin of the current page
3620 subik 71
        double locBottom;
4185 subik 72
        //! \brief right margin of the current page
3620 subik 73
        double locRight;
4185 subik 74
        //! \brief left margin of the current page
3620 subik 75
        double locLeft;
4185 subik 76
        //! \brief position of the group of selected objects
2164 subik 77
        double gx, gy, gw, gh;
78
 
4185 subik 79
        //! \brief vertical guides GUI
80
        QGroupBox* verGroup;
81
        QListView* verList;
242 Franz 82
        QLabel* TextLabel1;
4185 subik 83
        MSpinBox* verSpin;
84
        QPushButton* verSet;
85
        QPushButton* verDel;
2143 subik 86
 
4185 subik 87
        //! \brief horizontal guides GUI
88
        QGroupBox* horGroup;
89
        QListView* horList;
242 Franz 90
        QLabel* TextLabel2;
4185 subik 91
        MSpinBox* horSpin;
92
        QPushButton* horSet;
93
        QPushButton* horDel;
2143 subik 94
 
4185 subik 95
        //! \brief auto guides GUI
96
        QSpinBox* colSpin;
97
        QSpinBox* rowSpin;
98
        QHButtonGroup *bGroup;
2143 subik 99
 
4185 subik 100
        //! \brief lock the guides GUI
101
        QCheckBox* lockedCheckBox;
2143 subik 102
 
3620 subik 103
        /*! \brief Set the guides and exit */
2215 subik 104
        QPushButton* okButton;
3620 subik 105
        /*! \brief Exit without setting */
2237 subik 106
        QPushButton* cancelButton;
3620 subik 107
        /*! \brief Set the guides and keep the dialog open */
2237 subik 108
        QPushButton* setButton;
181 Franz 109
 
3620 subik 110
        /*! \brief Guide Gap widgets */
2200 subik 111
        QCheckBox* useRowGap;
112
        QCheckBox* useColGap;
113
 
3816 subik 114
        /*! \brief Apply selected guides on all pages */
115
        QCheckBox* allPages;
116
 
4215 subik 117
        //! \brief a pixmap preview holder
118
        QLabel *previewLabel;
119
 
3620 subik 120
        /*! \brief Gaps between guides.
4185 subik 121
        User can create automatic guides with an optional two gapped instead one guide.
2215 subik 122
        For example: 100mm size - guide - 100mm size will be 95mm size - guide - 10mm gap
123
        - guide - 95mm size (with 10mm gap) */
124
        MSpinBox* rowGap;
125
        MSpinBox* colGap;
3 paul 126
 
3620 subik 127
        /*! \brief Initialise the units. Spin boxes gets pt/mm/etc. extensions here. */
2215 subik 128
        void unitChange();
129
 
4185 subik 130
        //! \brief Document measurements and metrics
1843 cbradney 131
        double docUnitRatio;
4185 subik 132
        int docUnitIndex;
133
        int docUnitDecimals;
134
        //! \brief how much 0.xx
135
        int docUnitPrecision;
136
        //! \brief suffix of the unit [mm, ...]
137
        QString suffix;
181 Franz 138
 
4215 subik 139
        /*! \brief A preview page pixmap holder.
140
        This pixmap is created only once - on the dialog opening.
141
        It doesn't contain any guides on it. Guides are painted in
142
        slotDrawPreview() on a copy of this pixmap. */
143
        QPixmap previewPixmap;
144
 
3816 subik 145
        /*! \brief Refresh the guides in the document while the dialog is still opened.
146
        Or closed (of course). */
147
        void refreshDoc();
148
 
149
        /*! \brief Create actual guides on all pages in document */
150
        void refreshWholeDoc();
151
 
4185 subik 152
        /*! \brief Sets the guides from the common list into the GUI.
153
        \param w a widget to set the values. Horizontal or vertical guides list.
154
        \param guides a list with values. E.g. the real document guide list.
2200 subik 155
        */
4185 subik 156
        void setGuidesFromList(QListView *w, QValueList<double> guides);
2215 subik 157
 
4185 subik 158
        /*! \brief Create a list with guides from GUI list.
159
        \param w a widget with list of guides.
160
        \retval QValueList<double> a list to set as document guides.
2200 subik 161
        */
4185 subik 162
        QValueList<double> getValuesFromList(QListView *w);
2200 subik 163
 
4185 subik 164
        /*! \brief Recalculate the margins and measurements for the current page.
165
        It's used for automatic guides position. It's called for every
166
        page when is "apply to all pages" switched on */
167
        void resetMarginsForPage();
181 Franz 168
 
4198 subik 169
        /*! \brief Add a value from spin box to the list.
170
        It's called by "add" slots AddHorVal and AddVerVal.
171
        \param list a reference to the QListView to add a value.
172
        \param spin a reference to the spin box to take a value.
173
        \retval bool false on no add (duplicate etc.), true on success.
174
        */
175
        bool addValueToList(QListView *list, MSpinBox *spin);
176
 
4215 subik 177
        /*! \brief Delete all selected values from list.
178
        \param list a pointer to the chosen QListView
179
        \retval bool false on error
180
        */
181
        bool deleteValueFormList(QListView *list);
182
 
183
        /*! \brief Create automatic horizontal guides.
184
        Calculates positions of the guides.
185
        This algorithm is used for guides creating and deleting too.
186
        \retval QValueList<double> a list with guides */
187
        QValueList<double> getAutoRows();
188
 
189
        /*! \brief Create automatic vertical guides.
190
        Calculates positions of the guides.
191
        This algorithm is used for guides creating and deleting too.
192
        \retval QValueList<double> a list with guides */
193
        QValueList<double> getAutoCols();
194
 
195
signals:
196
        /*! \brief Signal is emitt when the preview pixmap should be repainted.
197
        */
198
        void guidesChanged();
199
 
4185 subik 200
protected slots:
201
 
202
        /*! \brief delete horizontal value */
181 Franz 203
        void DelHorVal();
4185 subik 204
        /*! \brief delete vertical value */
181 Franz 205
        void DelVerVal();
206
 
4185 subik 207
        /*! \brief add horizontal value */
181 Franz 208
        void AddHorVal();
4185 subik 209
        /*! \brief add horizontal value */
181 Franz 210
        void AddVerVal();
211
 
4185 subik 212
        /*! \brief change horizontal value by spinbox */
181 Franz 213
        void ChangeHorVal();
4185 subik 214
        /*! \brief change horizontal value by spinbox */
181 Franz 215
        void ChangeVerVal();
2200 subik 216
 
4185 subik 217
        /*! \brief Set the spin box by selected list value.
218
        \param item current (new) item */
219
        void verList_currentChanged(QListViewItem *item);
220
        /*! \brief Set the spin box by selected list value.
221
        \param item current (new) item */
222
        void horList_currentChanged(QListViewItem *item);
223
 
4215 subik 224
        /*! \brief Slot for automatic rows calling
225
        See getAutoRows()
4185 subik 226
        */
2215 subik 227
        void addRows();
4185 subik 228
 
4215 subik 229
        /*! \brief Slot for automatic columns calling
230
        See getAutoCols()
4185 subik 231
        */
2215 subik 232
        void addCols();
233
 
3620 subik 234
        /*! \brief Gap related widget handling (enable/disable)
2200 subik 235
        \param state enable/disable gaps */
236
        void useRowGap_clicked(bool state);
2215 subik 237
 
3620 subik 238
        /*! \brief Gap related widget handling (enable/disable)
2200 subik 239
        \param state enable/disable gaps */
240
        void useColGap_clicked(bool state);
2237 subik 241
 
3620 subik 242
        /*! \brief Commits all chasnges on exit */
2237 subik 243
        void commitChanges();
244
 
3620 subik 245
        /*! \brief Commits all chasnges and keep the dialog open */
2237 subik 246
        void commitEditChanges();
4215 subik 247
 
248
        /*! \brief Sorts the lists and create page-with-guides preview pixmap.
249
        This slot takes pixmap stored in previewPixmap each time
250
        it's called. The guides are painted on the copy of pre-created
251
        pixmap. Common guides are painted with black; currently selected
252
        guide is painded dark red and ticker. */
253
        void slotDrawPreview();
3 paul 254
};
255
 
256
#endif // GUIDEMANAGER_H