Warning, file /office/calligra/libs/flake/KoConnectionPoint.h 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) 2011 Jan Hambrecht <jaham@gmx.net>
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 #ifndef KOCONNECTIONPOINT_H
0022 #define KOCONNECTIONPOINT_H
0023 
0024 #include "flake_export.h"
0025 #include <QPointF>
0026 #include <QMap>
0027 
0028 /// Data of a single connection point
0029 struct FLAKE_EXPORT KoConnectionPoint
0030 {
0031     /// Default connection point ids
0032     enum PointId {
0033         TopConnectionPoint = 0,         ///< default connection point on the middle of the top edge
0034         RightConnectionPoint = 1,       ///< default connection point on the middle of the right edge
0035         BottomConnectionPoint = 2,      ///< default connection point on the middle of the bottom edge
0036         LeftConnectionPoint = 3,        ///< default connection point on the middle of the left edge
0037         FirstCustomConnectionPoint = 4  ///< first custom connection point id
0038     };
0039 
0040     /// Escape directions for connections connected to connection points
0041     enum EscapeDirection {
0042         AllDirections,        ///< connection can escape in all directions
0043         HorizontalDirections, ///< connection can escape left and right
0044         VerticalDirections,   ///< connection can escape top and down
0045         LeftDirection,        ///< connection can escape left
0046         RightDirection,       ///< connection can escape right
0047         UpDirection,          ///< connection can escape up
0048         DownDirection         ///< connection can escape down
0049     };
0050 
0051     /// Alignments for connection points for shape resizing
0052     enum Alignment {
0053         AlignNone,         ///< align to nothing
0054         AlignTopLeft,      ///< align to top and left edge
0055         AlignTop,          ///< align to top edge, centered
0056         AlignTopRight,     ///< align to top and right edge
0057         AlignLeft,         ///< align to left edge, centered
0058         AlignCenter,       ///< align to center
0059         AlignRight,        ///< align to right edge, centered
0060         AlignBottomLeft,   ///< align to bottom and left edge
0061         AlignBottom,       ///< align to bottom edge, centered
0062         AlignBottomRight   ///< align to bottom and right edge
0063     };
0064 
0065     /// Default constructor
0066     KoConnectionPoint();
0067 
0068     /// Creates connection point with specified position
0069     KoConnectionPoint(const QPointF &position);
0070 
0071     /// Creates connection point with specified position and escape direction
0072     KoConnectionPoint(const QPointF &position, EscapeDirection escapeDirection);
0073 
0074     /// Creates connection point with specified position, escape direction and alignment
0075     KoConnectionPoint(const QPointF &position, EscapeDirection escapeDirection, Alignment alignment);
0076 
0077     /// Returns default connection point with specified id
0078     static KoConnectionPoint defaultConnectionPoint(KoConnectionPoint::PointId connectionPointId);
0079 
0080     QPointF position; ///< the position of the connection point in shape coordinates
0081     EscapeDirection escapeDirection; ///< the escape direction for connection attached to that connection point
0082     Alignment alignment;      ///< specifies to which edge the connection point is aligned to
0083 };
0084 
0085 /// Connection point container storing connection point data along their id
0086 typedef QMap<int, KoConnectionPoint> KoConnectionPoints;
0087 
0088 #endif // KOCONNECTIONPOINT_H