File indexing completed on 2024-05-05 04:35:17
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2013-2014 Dominik Haumann <dhaumann@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU Library General Public License as published 0007 * by the Free Software Foundation, either version 2 of the License, or 0008 * (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 0013 * GNU 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, see 0017 * <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef TIKZ_UI_CURVE_HANDLE_H 0021 #define TIKZ_UI_CURVE_HANDLE_H 0022 0023 #include "tikzui_export.h" 0024 0025 #include <tikz/core/tikz.h> 0026 0027 #include "TikzItem.h" 0028 0029 namespace tikz { 0030 namespace ui { 0031 class PathItem; 0032 } 0033 } 0034 0035 class QPainter; 0036 class CurveHandlePrivate; 0037 0038 class CurveHandle : public TikzItem 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 /** 0044 * Constructor. 0045 */ 0046 CurveHandle(tikz::ui::PathItem * path = nullptr); 0047 0048 /** 0049 * Destructor 0050 */ 0051 virtual ~CurveHandle(); 0052 0053 /** 0054 * Reimplment to return a proper UserType + 4. 0055 */ 0056 int type() const override; 0057 0058 Q_SIGNALS: 0059 /** 0060 * This signal is emitted whenever the position of this handle 0061 * changed through user interaction. 0062 */ 0063 void positionChanged(const QPointF & pos); 0064 0065 // 0066 // reimplemented from QGraphicsItem 0067 // 0068 public: 0069 /** 0070 * Paint this item. 0071 */ 0072 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; 0073 0074 /** 0075 * Returns the bounding rect of this item. 0076 */ 0077 QRectF boundingRect() const override; 0078 0079 /** 0080 * Returns @p true, if @p point is contained in this handle. 0081 */ 0082 bool contains(const QPointF &point) const override; 0083 0084 // 0085 // protected overrides 0086 // 0087 protected: 0088 void mouseMoveEvent(QGraphicsSceneMouseEvent * event) override; 0089 void mousePressEvent(QGraphicsSceneMouseEvent * event) override; 0090 void mouseReleaseEvent(QGraphicsSceneMouseEvent * event) override; 0091 0092 private: 0093 CurveHandlePrivate * const d; 0094 }; 0095 0096 #endif // TIKZ_UI_CURVE_HANDLE_H 0097 0098 // kate: indent-width 4; replace-tabs on;