File indexing completed on 2025-01-26 03:34:10

0001 /*
0002     File                 : CartesianPlotLegend.h
0003     Project              : LabPlot
0004     Description          : Legend for the cartesian plot
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2013-2022 Alexander Semke <alexander.semke@web.de>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #ifndef CARTESIANPLOTLEGEND_H
0012 #define CARTESIANPLOTLEGEND_H
0013 
0014 #include "backend/lib/macros.h"
0015 #include "backend/worksheet/WorksheetElement.h"
0016 
0017 class Background;
0018 class CartesianPlotLegendPrivate;
0019 class Line;
0020 class TextLabel;
0021 
0022 #ifdef SDK
0023 #include "labplot_export.h"
0024 class LABPLOT_EXPORT CartesianPlotLegend : public WorksheetElement {
0025 #else
0026 class CartesianPlotLegend : public WorksheetElement {
0027 #endif
0028     Q_OBJECT
0029     Q_ENUMS(HorizontalPosition)
0030     Q_ENUMS(VerticalPosition)
0031 
0032 public:
0033     explicit CartesianPlotLegend(const QString& name);
0034     ~CartesianPlotLegend() override;
0035 
0036     void finalizeAdd() override;
0037     QIcon icon() const override;
0038     void save(QXmlStreamWriter*) const override;
0039     bool load(XmlStreamReader*, bool preview) override;
0040     void loadThemeConfig(const KConfig& config) override;
0041 
0042     TextLabel* title();
0043 
0044     CLASS_D_ACCESSOR_DECL(QFont, labelFont, LabelFont)
0045     CLASS_D_ACCESSOR_DECL(QColor, labelColor, LabelColor)
0046     BASIC_D_ACCESSOR_DECL(bool, labelColumnMajor, LabelColumnMajor)
0047     BASIC_D_ACCESSOR_DECL(qreal, lineSymbolWidth, LineSymbolWidth)
0048 
0049     Background* background() const;
0050 
0051     Line* borderLine() const;
0052     BASIC_D_ACCESSOR_DECL(qreal, borderCornerRadius, BorderCornerRadius)
0053 
0054     BASIC_D_ACCESSOR_DECL(qreal, layoutTopMargin, LayoutTopMargin)
0055     BASIC_D_ACCESSOR_DECL(qreal, layoutBottomMargin, LayoutBottomMargin)
0056     BASIC_D_ACCESSOR_DECL(qreal, layoutLeftMargin, LayoutLeftMargin)
0057     BASIC_D_ACCESSOR_DECL(qreal, layoutRightMargin, LayoutRightMargin)
0058     BASIC_D_ACCESSOR_DECL(qreal, layoutHorizontalSpacing, LayoutHorizontalSpacing)
0059     BASIC_D_ACCESSOR_DECL(qreal, layoutVerticalSpacing, LayoutVerticalSpacing)
0060     BASIC_D_ACCESSOR_DECL(int, layoutColumnCount, LayoutColumnCount)
0061 
0062     void retransform() override;
0063     void setZValue(qreal) override;
0064     void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
0065 
0066     typedef CartesianPlotLegendPrivate Private;
0067 
0068 protected:
0069     CartesianPlotLegend(const QString& name, CartesianPlotLegendPrivate* dd);
0070 
0071 private:
0072     Q_DECLARE_PRIVATE(CartesianPlotLegend)
0073     void init();
0074     void initActions();
0075 
0076 Q_SIGNALS:
0077     void labelFontChanged(QFont&);
0078     void labelColorChanged(QColor&);
0079     void labelColumnMajorChanged(bool);
0080     void lineSymbolWidthChanged(float);
0081     void borderCornerRadiusChanged(float);
0082     void layoutTopMarginChanged(float);
0083     void layoutBottomMarginChanged(float);
0084     void layoutLeftMarginChanged(float);
0085     void layoutRightMarginChanged(float);
0086     void layoutVerticalSpacingChanged(float);
0087     void layoutHorizontalSpacingChanged(float);
0088     void layoutColumnCountChanged(int);
0089 };
0090 
0091 #endif