1 /****************************************************************************
2 ** $Id: rs_actionprintpreview.cpp 1161 2004-12-09 23:10:09Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
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.
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.
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.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
27 #include "rs_actionprintpreview.h"
34 RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer& container,
35 RS_GraphicView& graphicView)
36 :RS_ActionInterface("Print Preview",
37 container, graphicView) {
43 RS_ActionPrintPreview::~RS_ActionPrintPreview() {
47 QAction* RS_ActionPrintPreview::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
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"));
57 void RS_ActionPrintPreview::init(int status) {
58 RS_ActionInterface::init(status);
65 void RS_ActionPrintPreview::trigger() {}
69 void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent* e) {
70 switch (getStatus()) {
72 v2 = graphicView->toGraph(e->x(), e->y());
74 Vector pinsbase = graphic->getPaperInsertionBase();
76 double scale = graphic->getPaperScale();
78 graphic->setPaperInsertionBase(pinsbase-v2*scale+v1*scale);
81 graphicView->redraw();
91 void RS_ActionPrintPreview::mousePressEvent(QMouseEvent* e) {
92 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
93 switch (getStatus()) {
95 v1 = graphicView->toGraph(e->x(), e->y());
106 void RS_ActionPrintPreview::mouseReleaseEvent(QMouseEvent* e) {
107 switch (getStatus()) {
114 RS_DIALOGFACTORY->requestPreviousMenu();
115 #if QT_VERSION>=0x030000
124 void RS_ActionPrintPreview::coordinateEvent(RS_CoordinateEvent* ) {}
128 void RS_ActionPrintPreview::commandEvent(RS_CommandEvent* ) {}
132 QStringList RS_ActionPrintPreview::getAvailableCommands() {
138 void RS_ActionPrintPreview::showOptions() {
139 RS_ActionInterface::showOptions();
141 RS_DIALOGFACTORY->requestOptions(this, true);
146 void RS_ActionPrintPreview::hideOptions() {
147 RS_ActionInterface::hideOptions();
149 RS_DIALOGFACTORY->requestOptions(this, false);
153 void RS_ActionPrintPreview::updateMouseButtonHints() {}
157 void RS_ActionPrintPreview::updateMouseCursor() {
158 graphicView->setMouseCursor(RS2::MovingHandCursor);
163 void RS_ActionPrintPreview::updateToolBar() {}
166 void RS_ActionPrintPreview::center() {
168 graphic->centerToPage();
169 graphicView->redraw();
174 void RS_ActionPrintPreview::fit() {
176 graphic->fitToPage();
177 graphicView->redraw();
182 void RS_ActionPrintPreview::setScale(double f) {
184 graphic->setPaperScale(f);
185 graphicView->redraw();
191 double RS_ActionPrintPreview::getScale() {
194 ret = graphic->getPaperScale();
201 void RS_ActionPrintPreview::setBlackWhite(bool bw) {
203 graphicView->setDrawingMode(RS2::ModeBW);
206 graphicView->setDrawingMode(RS2::ModeFull);
208 graphicView->redraw();
212 RS2::Unit RS_ActionPrintPreview::getUnit() {
214 return graphic->getUnit();