File indexing completed on 2024-05-05 04:35:18
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_TIKZ_SCENE_H 0021 #define TIKZ_UI_TIKZ_SCENE_H 0022 0023 #include <QGraphicsScene> 0024 0025 #include "tikzui_export.h" 0026 #include "tikzui.h" 0027 0028 namespace tikz { 0029 namespace ui { 0030 0031 class DocumentPrivate; 0032 class TikzScenePrivate; 0033 0034 class TIKZKITUI_EXPORT TikzScene : public QGraphicsScene 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 /** 0040 * Constructor. 0041 */ 0042 TikzScene(DocumentPrivate * document = nullptr); 0043 0044 /** 0045 * Destructor. 0046 */ 0047 virtual ~TikzScene(); 0048 0049 /** 0050 * Returns the associated DocumentPrivate. 0051 */ 0052 DocumentPrivate * document() const; 0053 0054 // 0055 // Edit mode 0056 // 0057 public Q_SLOTS: 0058 /** 0059 * Set the edit mode to @p mode. 0060 */ 0061 void setEditMode(TikzEditMode mode); 0062 0063 public: 0064 /** 0065 * Get the edit mode. 0066 */ 0067 TikzEditMode editMode() const; 0068 0069 Q_SIGNALS: 0070 /** 0071 * This signal is emitted whenever the edit mode changed through setEditMode. 0072 */ 0073 void editModeChanged(TikzEditMode mode) const; 0074 0075 protected: 0076 /** 0077 * Reimplemented to pass mouse press events to tool handler. 0078 */ 0079 void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent) override; 0080 0081 /** 0082 * Reimplemented to pass mouse move events to tool handler. 0083 */ 0084 void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) override; 0085 0086 /** 0087 * Reimplemented to pass mouse release events to tool handler. 0088 */ 0089 void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent) override; 0090 0091 /** 0092 * Reimplemented to pass key press events to tool handler. 0093 */ 0094 void keyPressEvent(QKeyEvent * keyEvent) override; 0095 0096 private Q_SLOTS: 0097 /** 0098 * Updates the scene rect such that the entire contents is visible. 0099 */ 0100 void updateSceneRect(); 0101 0102 private: 0103 TikzScenePrivate * const d; 0104 }; 0105 0106 } 0107 } 0108 0109 #endif // TIKZ_UI_TIKZ_SCENE_H 0110 0111 // kate: indent-width 4; replace-tabs on;