]> Shamusworld >> Repos - architektonas/blobdiff - src/actions/rs_actionprintpreview.cpp
Major refactoring of actions: Moved implementation from header files
[architektonas] / src / actions / rs_actionprintpreview.cpp
index 22dc058e34ed4903e50476a324636861fb47aa86..e280e57116d2d5ad68b7f9c293b6e33ca1b03da4 100644 (file)
@@ -1,81 +1,66 @@
-/****************************************************************************
-** $Id: rs_actionprintpreview.cpp 1161 2004-12-09 23:10:09Z andrew $
-**
-** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
-**
-** This file is part of the qcadlib Library project.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** Licensees holding valid qcadlib Professional Edition licenses may use
-** this file in accordance with the qcadlib Commercial License
-** Agreement provided with the Software.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.ribbonsoft.com for further details.
-**
-** Contact info@ribbonsoft.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+// rs_actionprintpreview.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/04/2010  Added this text. :-)
+//
 
 #include "rs_actionprintpreview.h"
-//Added by qt3to4:
-#include <QPixmap>
+
+#include "rs_dialogfactory.h"
+#include "drawing.h"
+#include "rs_graphicview.h"
 
 /**
  * Constructor.
  */
-RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer& container,
-        RS_GraphicView& graphicView)
-        :RS_ActionInterface("Print Preview",
-                    container, graphicView) {
-    showOptions();
+RS_ActionPrintPreview::RS_ActionPrintPreview(RS_EntityContainer & container, RS_GraphicView & graphicView):
+       RS_ActionInterface("Print Preview",
+               container, graphicView)
+{
+       showOptions();
 }
 
-
-
-RS_ActionPrintPreview::~RS_ActionPrintPreview() {
+RS_ActionPrintPreview::~RS_ActionPrintPreview()
+{
 }
 
-
-QAction* RS_ActionPrintPreview::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
+/*virtual*/ RS2::ActionType RS_ActionPrintPreview::rtti()
 {
-       QAction * action = new QAction(QIcon(":/res/fileprintpreview.png"), tr("Print Pre&view"), 0);
-//     QAction* action = new QAction(tr("Print Preview"), QPixmap::fromMimeSource("fileprintpreview.png"), tr("Print Pre&view"),
-//                                                     QKeySequence(), NULL);
-       action->setStatusTip(tr("Shows a preview of a print"));
-       return action;
+       return RS2::ActionPrintPreview;
 }
 
-
-void RS_ActionPrintPreview::init(int status) {
-    RS_ActionInterface::init(status);
-    showOptions();
+void RS_ActionPrintPreview::init(int status)
+{
+       RS_ActionInterface::init(status);
+       showOptions();
 }
 
+void RS_ActionPrintPreview::trigger()
+{
+}
 
-
-
-void RS_ActionPrintPreview::trigger() {}
-
-
-
-void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent* e) {
-       switch (getStatus()) {
+void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent * e)
+{
+       switch (getStatus())
+       {
        case Moving:
                v2 = graphicView->toGraph(e->x(), e->y());
-               if (graphic!=NULL) {
+
+               if (graphic != NULL)
+               {
                        Vector pinsbase = graphic->getPaperInsertionBase();
 
                        double scale = graphic->getPaperScale();
 
-                       graphic->setPaperInsertionBase(pinsbase-v2*scale+v1*scale);
+                       graphic->setPaperInsertionBase(pinsbase - v2 * scale + v1 * scale);
                }
                v1 = v2;
                graphicView->redraw();
@@ -86,137 +71,133 @@ void RS_ActionPrintPreview::mouseMoveEvent(QMouseEvent* e) {
        }
 }
 
-
-
-void RS_ActionPrintPreview::mousePressEvent(QMouseEvent* e) {
-    if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
-        switch (getStatus()) {
-        case Neutral:
-            v1 = graphicView->toGraph(e->x(), e->y());
-            setStatus(Moving);
-            break;
-
-        default:
-            break;
-        }
-    }
+void RS_ActionPrintPreview::mousePressEvent(QMouseEvent * e)
+{
+       if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+       {
+               switch (getStatus())
+               {
+               case Neutral:
+                       v1 = graphicView->toGraph(e->x(), e->y());
+                       setStatus(Moving);
+                       break;
+
+               default:
+                       break;
+               }
+       }
 }
 
-
-void RS_ActionPrintPreview::mouseReleaseEvent(QMouseEvent* e) {
-       switch (getStatus()) {
+void RS_ActionPrintPreview::mouseReleaseEvent(QMouseEvent * e)
+{
+       switch (getStatus())
+       {
        case Moving:
                setStatus(Neutral);
                break;
 
-    default:
-        //deleteSnapper();
-        RS_DIALOGFACTORY->requestPreviousMenu();
-#if QT_VERSION>=0x030000
-        e->accept();
+       default:
+               //deleteSnapper();
+               RS_DIALOGFACTORY->requestPreviousMenu();
+#if QT_VERSION >= 0x030000
+               e->accept();
 #endif
-        break;
+               break;
        }
 }
 
-
-
-void RS_ActionPrintPreview::coordinateEvent(RS_CoordinateEvent* ) {}
-
-
-
-void RS_ActionPrintPreview::commandEvent(RS_CommandEvent* ) {}
-
-
-
-QStringList RS_ActionPrintPreview::getAvailableCommands() {
-    QStringList cmd;
-    return cmd;
+void RS_ActionPrintPreview::coordinateEvent(Vector *)
+{
 }
 
-
-void RS_ActionPrintPreview::showOptions() {
-    RS_ActionInterface::showOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, true);
+void RS_ActionPrintPreview::commandEvent(RS_CommandEvent *)
+{
 }
 
-
-
-void RS_ActionPrintPreview::hideOptions() {
-    RS_ActionInterface::hideOptions();
-
-    RS_DIALOGFACTORY->requestOptions(this, false);
+QStringList RS_ActionPrintPreview::getAvailableCommands()
+{
+       QStringList cmd;
+       return cmd;
 }
 
+void RS_ActionPrintPreview::showOptions()
+{
+       RS_ActionInterface::showOptions();
 
-void RS_ActionPrintPreview::updateMouseButtonHints() {}
-
-
-
-void RS_ActionPrintPreview::updateMouseCursor() {
-    graphicView->setMouseCursor(RS2::MovingHandCursor);
+       RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
+void RS_ActionPrintPreview::hideOptions()
+{
+       RS_ActionInterface::hideOptions();
 
+       RS_DIALOGFACTORY->requestOptions(this, false);
+}
 
-void RS_ActionPrintPreview::updateToolBar() {}
-
+void RS_ActionPrintPreview::updateMouseButtonHints()
+{
+}
 
-void RS_ActionPrintPreview::center() {
-    if (graphic!=NULL) {
-        graphic->centerToPage();
-        graphicView->redraw();
-    }
+void RS_ActionPrintPreview::updateMouseCursor()
+{
+       graphicView->setMouseCursor(RS2::MovingHandCursor);
 }
 
+void RS_ActionPrintPreview::updateToolBar()
+{
+}
 
-void RS_ActionPrintPreview::fit() {
-    if (graphic!=NULL) {
-        graphic->fitToPage();
-        graphicView->redraw();
-    }
+void RS_ActionPrintPreview::center()
+{
+       if (graphic != NULL)
+       {
+               graphic->centerToPage();
+               graphicView->redraw();
+       }
 }
 
+void RS_ActionPrintPreview::fit()
+{
+       if (graphic != NULL)
+       {
+               graphic->fitToPage();
+               graphicView->redraw();
+       }
+}
 
-void RS_ActionPrintPreview::setScale(double f) {
-    if (graphic!=NULL) {
+void RS_ActionPrintPreview::setScale(double f)
+{
+       if (graphic != NULL)
+       {
                graphic->setPaperScale(f);
-       graphicView->redraw();
+               graphicView->redraw();
        }
 }
 
-
-
-double RS_ActionPrintPreview::getScale() {
+double RS_ActionPrintPreview::getScale()
+{
        double ret = 1.0;
-    if (graphic!=NULL) {
+
+       if (graphic != NULL)
                ret = graphic->getPaperScale();
-       }
        return ret;
 }
 
-
-
-void RS_ActionPrintPreview::setBlackWhite(bool bw) {
-    if (bw) {
-        graphicView->setDrawingMode(RS2::ModeBW);
-    }
-       else {
-        graphicView->setDrawingMode(RS2::ModeFull);
-       }
+void RS_ActionPrintPreview::setBlackWhite(bool bw)
+{
+       if (bw)
+               graphicView->setDrawingMode(RS2::ModeBW);
+       else
+               graphicView->setDrawingMode(RS2::ModeFull);
        graphicView->redraw();
 }
 
-
-RS2::Unit RS_ActionPrintPreview::getUnit() {
-    if (graphic!=NULL) {
+RS2::Unit RS_ActionPrintPreview::getUnit()
+{
+       if (graphic != NULL)
                return graphic->getUnit();
-       }
-       else {
+       else
                return RS2::None;
-       }
 }
 
-
 // EOF