File indexing completed on 2024-05-05 03:49:47

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
0004 //
0005 
0006 #ifndef MARBLE_FRAMEGRAPHICSITEM_H
0007 #define MARBLE_FRAMEGRAPHICSITEM_H
0008 
0009 // Marble
0010 #include "marble_export.h"
0011 #include "ScreenGraphicsItem.h"
0012 
0013 #include <Qt> // for Qt::PenStyle
0014 
0015 class QBrush;
0016 class QPainterPath;
0017 
0018 namespace Marble
0019 {
0020 
0021 class FrameGraphicsItemPrivate;
0022 
0023 class MARBLE_EXPORT FrameGraphicsItem : public ScreenGraphicsItem
0024 {
0025  public:
0026     enum FrameType {
0027         NoFrame,
0028         RectFrame,
0029         RoundedRectFrame,
0030         ShadowFrame
0031     };
0032 
0033     explicit FrameGraphicsItem( MarbleGraphicsItem *parent = nullptr );
0034 
0035     ~FrameGraphicsItem() override;
0036 
0037     /**
0038      * Returns the type of the frame.
0039      */
0040     FrameType frame() const;
0041 
0042     /**
0043      * Sets the type of the Frame. Standard is NoFrame.
0044      */
0045     void setFrame( FrameType type );
0046 
0047     /**
0048      * Returns the margin of the item. This is used for all margins with the value 0.0.
0049      * The padding is the space outside the painted space.
0050      */
0051     qreal margin() const;
0052 
0053     /**
0054      * Sets the margin of the item. This is used for all margins with the value 0.0.
0055      */
0056     void setMargin( qreal margin );
0057 
0058     /**
0059      * Returns the top margin of the item.
0060      */
0061     qreal marginTop() const;
0062 
0063     /**
0064      * Set the top margin of the item.
0065      */
0066     void setMarginTop( qreal marginTop );
0067 
0068     /**
0069      * Returns the bottom margin of the item.
0070      */
0071     qreal marginBottom() const;
0072 
0073     /**
0074      * Set the bottom margin of the item.
0075      */
0076     void setMarginBottom( qreal marginBottom );
0077 
0078     /**
0079      * Returns the left margin of the item.
0080      */
0081     qreal marginLeft() const;
0082 
0083     /**
0084      * Set the left margin of the item.
0085      */
0086     void setMarginLeft( qreal marginLeft );
0087 
0088     /**
0089      * Returns the right margin of the item.
0090      */
0091     qreal marginRight() const;
0092 
0093     /**
0094      * Set the right margin of the item.
0095      */
0096     void setMarginRight( qreal marginRight );
0097 
0098     /**
0099      * Returns the border width of the item.
0100      */
0101     qreal borderWidth() const;
0102 
0103     /**
0104      * Set the border width of the item.
0105      */
0106     void setBorderWidth( qreal width );
0107 
0108     /**
0109      * Returns the padding of the item.
0110      * The padding is the empty space inside the border.
0111      */
0112     qreal padding() const;
0113 
0114     /**
0115      * Set the padding of the item.
0116      */
0117     void setPadding( qreal width );
0118 
0119     /**
0120      * Returns the brush of the border.
0121      */
0122     QBrush borderBrush() const;
0123 
0124     /**
0125      * Change the brush of the border.
0126      */
0127     void setBorderBrush( const QBrush &brush );
0128 
0129     /**
0130      * Returns the style of the border.
0131      */
0132     Qt::PenStyle borderStyle () const;
0133 
0134     /**
0135      * Change the style of the border.
0136      */
0137     void setBorderStyle( Qt::PenStyle style );
0138 
0139     /**
0140      * Returns the background brush of the item.
0141      */
0142     QBrush background() const;
0143 
0144     /**
0145      * Changes the background brush of the item.
0146      */
0147     void setBackground( const QBrush &background );
0148 
0149     QRectF paintedRect() const;
0150 
0151     QRectF contentRect() const override;
0152     QSizeF contentSize() const override;
0153 
0154     /**
0155      * Sets the size of the content of the item.
0156      * @p size is the size required for contents.
0157      */
0158     void setContentSize( const QSizeF& size ) override;
0159 
0160  protected:
0161     /**
0162      * Returns the shape of the background.
0163      */
0164     virtual QPainterPath backgroundShape() const;
0165 
0166     /**
0167      * This function won't be reimplemented in most cases.
0168      */
0169     void paint( QPainter *painter ) override;
0170 
0171     /**
0172      * Here the items paint their content.
0173      */
0174     virtual void paintContent( QPainter *painter );
0175 
0176     /**
0177      * Paints the background. This function won't be reimplemented in most cases.
0178      */
0179     virtual void paintBackground( QPainter *painter );
0180 
0181     explicit FrameGraphicsItem(FrameGraphicsItemPrivate *dd);
0182 
0183  private:
0184     Q_DISABLE_COPY( FrameGraphicsItem )
0185     Q_DECLARE_PRIVATE(FrameGraphicsItem)
0186 };
0187 
0188 } // namespace Marble
0189 
0190 #endif