]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionprintpreview.cpp
Initial import
[architektonas] / src / actions / rs_actionprintpreview.cpp
1 /****************************************************************************
2 ** $Id: rs_actionprintpreview.cpp 1161 2004-12-09 23:10:09Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the qcadlib Library project.
7 **
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
12 **
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #include "rs_actionprintpreview.h"
28 //Added by qt3to4:
29 #include <QPixmap>
30
31 /**
32  * Constructor.
33  */
34 RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer& container,
35         RS_GraphicView& graphicView)
36         :RS_ActionInterface("Print Preview",
37                     container, graphicView) {
38     showOptions();
39 }
40
41
42
43 RS_ActionPrintPreview::~RS_ActionPrintPreview() {
44 }
45
46
47 QAction* RS_ActionPrintPreview::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
48 {
49         QAction * action = new QAction(QIcon(":/res/fileprintpreview.png"), tr("Print Pre&view"), 0);
50 //      QAction* action = new QAction(tr("Print Preview"), QPixmap::fromMimeSource("fileprintpreview.png"), tr("Print Pre&view"),
51 //                                                      QKeySequence(), NULL);
52         action->setStatusTip(tr("Shows a preview of a print"));
53         return action;
54 }
55
56
57 void RS_ActionPrintPreview::init(int status) {
58     RS_ActionInterface::init(status);
59     showOptions();
60 }
61
62
63
64
65 void RS_ActionPrintPreview::trigger() {}
66
67
68
69 void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent* e) {
70         switch (getStatus()) {
71         case Moving:
72                 v2 = graphicView->toGraph(e->x(), e->y());
73                 if (graphic!=NULL) {
74                         Vector pinsbase = graphic->getPaperInsertionBase();
75
76                         double scale = graphic->getPaperScale();
77
78                         graphic->setPaperInsertionBase(pinsbase-v2*scale+v1*scale);
79                 }
80                 v1 = v2;
81                 graphicView->redraw();
82                 break;
83
84         default:
85                 break;
86         }
87 }
88
89
90
91 void RS_ActionPrintPreview::mousePressEvent(QMouseEvent* e) {
92     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
93         switch (getStatus()) {
94         case Neutral:
95             v1 = graphicView->toGraph(e->x(), e->y());
96             setStatus(Moving);
97             break;
98
99         default:
100             break;
101         }
102     }
103 }
104
105
106 void RS_ActionPrintPreview::mouseReleaseEvent(QMouseEvent* e) {
107         switch (getStatus()) {
108         case Moving:
109                 setStatus(Neutral);
110                 break;
111
112     default:
113         //deleteSnapper();
114         RS_DIALOGFACTORY->requestPreviousMenu();
115 #if QT_VERSION>=0x030000
116         e->accept();
117 #endif
118         break;
119         }
120 }
121
122
123
124 void RS_ActionPrintPreview::coordinateEvent(RS_CoordinateEvent* ) {}
125
126
127
128 void RS_ActionPrintPreview::commandEvent(RS_CommandEvent* ) {}
129
130
131
132 QStringList RS_ActionPrintPreview::getAvailableCommands() {
133     QStringList cmd;
134     return cmd;
135 }
136
137
138 void RS_ActionPrintPreview::showOptions() {
139     RS_ActionInterface::showOptions();
140
141     RS_DIALOGFACTORY->requestOptions(this, true);
142 }
143
144
145
146 void RS_ActionPrintPreview::hideOptions() {
147     RS_ActionInterface::hideOptions();
148
149     RS_DIALOGFACTORY->requestOptions(this, false);
150 }
151
152
153 void RS_ActionPrintPreview::updateMouseButtonHints() {}
154
155
156
157 void RS_ActionPrintPreview::updateMouseCursor() {
158     graphicView->setMouseCursor(RS2::MovingHandCursor);
159 }
160
161
162
163 void RS_ActionPrintPreview::updateToolBar() {}
164
165
166 void RS_ActionPrintPreview::center() {
167     if (graphic!=NULL) {
168         graphic->centerToPage();
169         graphicView->redraw();
170     }
171 }
172
173
174 void RS_ActionPrintPreview::fit() {
175     if (graphic!=NULL) {
176         graphic->fitToPage();
177         graphicView->redraw();
178     }
179 }
180
181
182 void RS_ActionPrintPreview::setScale(double f) {
183     if (graphic!=NULL) {
184                 graphic->setPaperScale(f);
185         graphicView->redraw();
186         }
187 }
188
189
190
191 double RS_ActionPrintPreview::getScale() {
192         double ret = 1.0;
193     if (graphic!=NULL) {
194                 ret = graphic->getPaperScale();
195         }
196         return ret;
197 }
198
199
200
201 void RS_ActionPrintPreview::setBlackWhite(bool bw) {
202     if (bw) {
203         graphicView->setDrawingMode(RS2::ModeBW);
204     }
205         else {
206         graphicView->setDrawingMode(RS2::ModeFull);
207         }
208         graphicView->redraw();
209 }
210
211
212 RS2::Unit RS_ActionPrintPreview::getUnit() {
213     if (graphic!=NULL) {
214                 return graphic->getUnit();
215         }
216         else {
217                 return RS2::None;
218         }
219 }
220
221
222 // EOF