File indexing completed on 2024-05-12 15:27:35
0001 /*************************************************************************** 0002 File : WorksheetElement.h 0003 Project : LabPlot 0004 Description : Base class for all Worksheet children. 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2009 Tilman Benkert (thzs@gmx.net) 0007 Copyright : (C) 2012-2015 by Alexander Semke (alexander.semke@web.de) 0008 0009 ***************************************************************************/ 0010 0011 /*************************************************************************** 0012 * * 0013 * This program is free software; you can redistribute it and/or modify * 0014 * it under the terms of the GNU General Public License as published by * 0015 * the Free Software Foundation; either version 2 of the License, or * 0016 * (at your option) any later version. * 0017 * * 0018 * This program is distributed in the hope that it will be useful, * 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0021 * GNU General Public License for more details. * 0022 * * 0023 * You should have received a copy of the GNU General Public License * 0024 * along with this program; if not, write to the Free Software * 0025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0026 * Boston, MA 02110-1301 USA * 0027 * * 0028 ***************************************************************************/ 0029 0030 #ifndef WORKSHEETELEMENT_H 0031 #define WORKSHEETELEMENT_H 0032 0033 #include "backend/core/AbstractAspect.h" 0034 #include <QPainterPath> 0035 0036 class QAction; 0037 class QGraphicsItem; 0038 class QPen; 0039 class KConfig; 0040 0041 class WorksheetElement : public AbstractAspect { 0042 Q_OBJECT 0043 0044 public: 0045 enum class Orientation {Horizontal, Vertical}; 0046 WorksheetElement(const QString&, AspectType); 0047 ~WorksheetElement() override; 0048 0049 enum class WorksheetElementName {NameCartesianPlot = 1}; 0050 0051 enum class HorizontalPosition {Left, Center, Right, Custom}; 0052 enum class VerticalPosition {Top, Center, Bottom, Custom}; 0053 0054 enum class HorizontalAlignment {Left, Center, Right}; 0055 enum class VerticalAlignment {Top, Center, Bottom}; 0056 0057 struct PositionWrapper { 0058 QPointF point; 0059 WorksheetElement::HorizontalPosition horizontalPosition; 0060 WorksheetElement::VerticalPosition verticalPosition; 0061 }; 0062 0063 virtual QGraphicsItem* graphicsItem() const = 0; 0064 virtual void setZValue(qreal); 0065 virtual void setVisible(bool on) = 0; 0066 virtual bool isVisible() const = 0; 0067 virtual bool isFullyVisible() const; 0068 virtual void setPrinting(bool) = 0; 0069 0070 QMenu* createContextMenu() override; 0071 0072 virtual void loadThemeConfig(const KConfig&); 0073 virtual void saveThemeConfig(const KConfig&); 0074 0075 static QPainterPath shapeFromPath(const QPainterPath&, const QPen&); 0076 virtual void handleResize(double horizontalRatio, double verticalRatio, bool pageResize = false) = 0; 0077 0078 public slots: 0079 virtual void retransform() = 0; 0080 0081 private: 0082 QMenu* m_drawingOrderMenu; 0083 QMenu* m_moveBehindMenu; 0084 QMenu* m_moveInFrontOfMenu; 0085 0086 private slots: 0087 void prepareMoveBehindMenu(); 0088 void prepareMoveInFrontOfMenu(); 0089 void execMoveBehind(QAction*); 0090 void execMoveInFrontOf(QAction*); 0091 0092 signals: 0093 friend class AbstractPlotSetHorizontalPaddingCmd; 0094 friend class AbstractPlotSetVerticalPaddingCmd; 0095 friend class AbstractPlotSetRightPaddingCmd; 0096 friend class AbstractPlotSetBottomPaddingCmd; 0097 friend class AbstractPlotSetSymmetricPaddingCmd; 0098 void horizontalPaddingChanged(float); 0099 void verticalPaddingChanged(float); 0100 void rightPaddingChanged(double); 0101 void bottomPaddingChanged(double); 0102 void symmetricPaddingChanged(double); 0103 0104 void hovered(); 0105 void unhovered(); 0106 }; 0107 0108 #endif