1 /* This file is part of the KDE project 2 * Copyright (C) 2006 Thomas Zander <zander@kde.org> 3 * Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net> 4 * Copyright (C) 2010 Thorsten Zachmann <zachmann@kde.org> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 */ 21 #ifndef KOFLAKE_H 22 #define KOFLAKE_H 23 24 #include "kritaflake_export.h" 25 26 class QGradient; 27 class QRectF; 28 class QPointF; 29 class QSizeF; 30 31 class KoShape; 32 class QTransform; 33 34 #include <Qt> 35 36 /** 37 * Flake reference 38 */ 39 namespace KoFlake 40 { 41 enum FillVariant { 42 Fill, 43 StrokeFill 44 }; 45 46 enum FillType { 47 None, 48 Solid, 49 Gradient, 50 Pattern, 51 MeshGradient 52 }; 53 54 enum MarkerPosition { 55 StartMarker, 56 MidMarker, 57 EndMarker 58 }; 59 60 /// the selection type for KoSelection::selectedObjects() 61 enum SelectionType { 62 FullSelection, ///< Create a list of all user-shapes in the selection. This excludes KoShapeGroup grouping objects that may be selected. 63 StrippedSelection, ///< Create a stripped list, without children if the container is also in the list. 64 TopLevelSelection ///< Create a list, much like the StrippedSelection, but have the KoShapeGroup instead of all of its children if one is selected. 65 }; 66 67 /// Enum determining which handle is meant, used in KoInteractionTool 68 enum SelectionHandle { 69 TopMiddleHandle, ///< The handle that is at the top - center of a selection 70 TopRightHandle, ///< The handle that is at the top - right of a selection 71 RightMiddleHandle, ///< The handle that is at the right - center of a selection 72 BottomRightHandle, ///< The handle that is at the bottom right of a selection 73 BottomMiddleHandle, ///< The handle that is at the bottom center of a selection 74 BottomLeftHandle, ///< The handle that is at the bottom left of a selection 75 LeftMiddleHandle, ///< The handle that is at the left center of a selection 76 TopLeftHandle, ///< The handle that is at the top left of a selection 77 NoHandle ///< Value to indicate no handle 78 }; 79 80 /** 81 * Used to change the behavior of KoShapeManager::shapeAt() 82 */ 83 enum ShapeSelection { 84 Selected, ///< return the first selected with the highest z-ordering (i.e. on top). 85 Unselected, ///< return the first unselected on top. 86 NextUnselected, ///< return the first unselected directly under a selected shape, or the top most one if nothing is selected. 87 ShapeOnTop ///< return the shape highest z-ordering, regardless of selection. 88 }; 89 90 /** 91 * Used to see which style type is active 92 */ 93 enum StyleType { 94 Background, ///< the background / fill style is active 95 Foreground ///< the foreground / stroke style is active 96 }; 97 98 enum AnchorPosition { 99 TopLeft, 100 Top, 101 TopRight, 102 Left, 103 Center, 104 Right, 105 BottomLeft, 106 Bottom, 107 BottomRight, 108 NoAnchor, 109 NumAnchorPositions 110 }; 111 112 KRITAFLAKE_EXPORT QPointF anchorToPoint(AnchorPosition anchor, const QRectF rect, bool *valid = 0); 113 114 enum CanvasResource { 115 HotPosition = 1410100299 116 }; 117 118 /// clones the given gradient 119 KRITAFLAKE_EXPORT QGradient *cloneGradient(const QGradient *gradient); 120 121 KRITAFLAKE_EXPORT QGradient *mergeGradient(const QGradient *coordsSource, const QGradient *fillSource); 122 123 /** 124 * Convert absolute to relative position 125 * 126 * @param absolute absolute position 127 * @param size for which the relative position needs to be calculated 128 * 129 * @return relative position 130 */ 131 KRITAFLAKE_EXPORT QPointF toRelative(const QPointF &absolute, const QSizeF &size); 132 133 /** 134 * Convert relative size to absolute size 135 * 136 * @param relative relative position 137 * @param size for which the absolute position needs to be calculated 138 * 139 * @return absolute position 140 */ 141 KRITAFLAKE_EXPORT QPointF toAbsolute(const QPointF &relative, const QSizeF &size); 142 143 KRITAFLAKE_EXPORT Qt::Orientation significantScaleOrientation(qreal scaleX, qreal scaleY); 144 145 KRITAFLAKE_EXPORT void scaleShape(KoShape *shape, qreal scaleX, qreal scaleY, 146 const QPointF &absoluteStillPoint, 147 const QTransform &postScalingCoveringTransform); 148 149 KRITAFLAKE_EXPORT void scaleShapeGlobal(KoShape *shape, qreal scaleX, qreal scaleY, 150 const QPointF &absoluteStillPoint); 151 152 153 KRITAFLAKE_EXPORT void resizeShape(KoShape *shape, qreal scaleX, qreal scaleY, 154 const QPointF &absoluteStillPoint, 155 bool useGlobalMode); 156 157 KRITAFLAKE_EXPORT void resizeShapeCommon(KoShape *shape, qreal scaleX, qreal scaleY, 158 const QPointF &absoluteStillPoint, 159 bool useGlobalMode, 160 bool usePostScaling, const QTransform &postScalingCoveringTransform); 161 } 162 163 #endif 164