Warning, file /office/calligra/libs/flake/KoCanvasController.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * 0003 * Copyright (C) 2010 Boudewijn Rempt <boud@kogmbh.com> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "KoCanvasController.h" 0022 #include "KoToolManager.h" 0023 0024 #include <QSize> 0025 #include <QPoint> 0026 0027 class Q_DECL_HIDDEN KoCanvasController::Private 0028 { 0029 public: 0030 Private() 0031 : canvasMode(Centered) 0032 , margin(0) 0033 , preferredCenterFractionX(0.5) 0034 , preferredCenterFractionY(0.5) 0035 , actionCollection(0) 0036 { 0037 } 0038 0039 CanvasMode canvasMode; 0040 int margin; 0041 QSize documentSize; 0042 QPoint documentOffset; 0043 qreal preferredCenterFractionX; 0044 qreal preferredCenterFractionY; 0045 KActionCollection* actionCollection; 0046 }; 0047 0048 KoCanvasController::KoCanvasController(KActionCollection* actionCollection) 0049 : d(new Private()) 0050 { 0051 proxyObject = new KoCanvasControllerProxyObject(this); 0052 d->actionCollection = actionCollection; 0053 } 0054 0055 KoCanvasController::~KoCanvasController() 0056 { 0057 KoToolManager::instance()->removeCanvasController(this); 0058 delete d; 0059 delete proxyObject; 0060 } 0061 0062 void KoCanvasController::setCanvasMode(CanvasMode mode) 0063 { 0064 d->canvasMode = mode; 0065 switch (mode) { 0066 case AlignTop: 0067 d->preferredCenterFractionX = 0; 0068 d->preferredCenterFractionY = 0.5; 0069 break; 0070 case Infinite: 0071 case Centered: 0072 d->preferredCenterFractionX = 0.5; 0073 d->preferredCenterFractionY = 0.5; 0074 break; 0075 case Spreadsheet: 0076 d->preferredCenterFractionX = 0; 0077 d->preferredCenterFractionY = 0; 0078 break; 0079 }; 0080 } 0081 0082 void KoCanvasController::setMargin(int margin) 0083 { 0084 d->margin = margin; 0085 } 0086 0087 int KoCanvasController::margin() const 0088 { 0089 return d->margin; 0090 } 0091 0092 0093 KoCanvasController::CanvasMode KoCanvasController::canvasMode() const 0094 { 0095 return d->canvasMode; 0096 } 0097 0098 KoCanvasBase* KoCanvasController::canvas() const 0099 { 0100 return 0; 0101 } 0102 0103 void KoCanvasController::setDocumentSize(const QSize &sz) 0104 { 0105 d->documentSize = sz; 0106 } 0107 0108 QSize KoCanvasController::documentSize() const 0109 { 0110 return d->documentSize; 0111 } 0112 0113 void KoCanvasController::setPreferredCenterFractionX(qreal x) 0114 { 0115 d->preferredCenterFractionX = x; 0116 } 0117 0118 qreal KoCanvasController::preferredCenterFractionX() const 0119 { 0120 return d->preferredCenterFractionX; 0121 } 0122 0123 void KoCanvasController::setPreferredCenterFractionY(qreal y) 0124 { 0125 d->preferredCenterFractionY = y; 0126 } 0127 0128 qreal KoCanvasController::preferredCenterFractionY() const 0129 { 0130 return d->preferredCenterFractionY; 0131 } 0132 0133 void KoCanvasController::setDocumentOffset(QPoint &offset) 0134 { 0135 d->documentOffset = offset; 0136 } 0137 0138 QPoint KoCanvasController::documentOffset() const 0139 { 0140 return d->documentOffset; 0141 } 0142 0143 0144 0145 0146 KoCanvasControllerProxyObject::KoCanvasControllerProxyObject(KoCanvasController *controller, QObject *parent) 0147 : QObject(parent) 0148 , m_canvasController(controller) 0149 { 0150 } 0151 0152 void KoCanvasControllerProxyObject::updateDocumentSize(const QSize &newSize, bool recalculateCenter) 0153 { 0154 m_canvasController->updateDocumentSize(newSize, recalculateCenter); 0155 } 0156 0157 KActionCollection* KoCanvasController::actionCollection() const 0158 { 0159 return d->actionCollection; 0160 }