File indexing completed on 2024-05-12 03:50:12

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
0005 //
0006 
0007 
0008 #ifndef MARBLE_GEODATALABELSTYLE_H
0009 #define MARBLE_GEODATALABELSTYLE_H
0010 
0011 #include "GeoDataColorStyle.h"
0012 
0013 #include "geodata_export.h"
0014 
0015 class QFont;
0016 
0017 namespace Marble
0018 {
0019 
0020 class GeoDataLabelStylePrivate;
0021 
0022 /**
0023  * @short specifies how the <b>name</b> of a GeoDataFeature is drawn
0024  *
0025  * A GeoDataLabelStyle specifies how the <b>name</b> of a
0026  * GeoDataFeature is drawn in the viewer. A custom color, color mode
0027  * (both inherited from GeoDataColorStyle, and scale for the label
0028  * (name) can be specified.
0029  */
0030 class GEODATA_EXPORT GeoDataLabelStyle : public GeoDataColorStyle
0031 {
0032   public:
0033     enum Alignment{Corner, Center, Right /*, Left, Below  */};
0034 
0035     /// Construct a new GeoDataLabelStyle
0036     GeoDataLabelStyle();
0037     GeoDataLabelStyle( const GeoDataLabelStyle& other );
0038     /**
0039      * @brief Construct a new GeoDataLabelStyle
0040      * @param  font   the font to use when showing the name
0041      * @param  color  the color to use when showing the name @see GeoDataColorStyle
0042      */
0043     GeoDataLabelStyle( const QFont &font, const QColor &color );
0044 
0045     ~GeoDataLabelStyle() override;
0046     
0047     /**
0048     * @brief assignment operator
0049     */
0050     GeoDataLabelStyle& operator=( const GeoDataLabelStyle& other );
0051 
0052     bool operator==( const GeoDataLabelStyle &other ) const;
0053     bool operator!=( const GeoDataLabelStyle &other ) const;
0054 
0055     /// Provides type information for downcasting a GeoData
0056     const char* nodeType() const override;
0057 
0058     /**
0059      * @brief Set the scale of the label
0060      * @param  scale  the new scale
0061      */
0062     void setScale(float scale);
0063     /**
0064      * @brief Return the current scale of the label
0065      * @return  the current scale
0066      */
0067     float scale() const;
0068     /**
0069      * @brief Set the alignment of the label
0070      * @param alignment the alignment
0071      */
0072     void setAlignment ( GeoDataLabelStyle::Alignment alignment );
0073     /**
0074      * @brief Return the alignment of the label
0075      * @return  the current alignment
0076      */
0077     GeoDataLabelStyle::Alignment alignment() const;
0078     /**
0079      * @brief Set the font of the label
0080      * @param  font  the new font
0081      */
0082     void setFont( const QFont &font );
0083     /**
0084      * @brief Return the current font of the label
0085      * @return  the current font
0086      */
0087     QFont font() const;
0088 
0089     /**
0090      * @brief Return the scaled font of the label
0091      * @return  the scaled font
0092      */
0093     QFont scaledFont() const;
0094 
0095     /**
0096      * @brief Return true if the text of the label should glow, false otherwise
0097      * @see setGlow
0098      */
0099     bool glow() const;
0100 
0101     /**
0102      * @brief Enable or disable a glow effect around the text of the label.
0103      *
0104      * The default is false.
0105      *
0106      * Note that this is not a KML property.
0107      */
0108     void setGlow( bool on );
0109 
0110     /**
0111      * @brief  Serialize the style to a stream.
0112      * @param  stream  the stream
0113      */
0114     void pack( QDataStream& stream ) const override;
0115     /**
0116      * @brief  Unserialize the style from a stream
0117      * @param  stream  the stream
0118      */
0119     void unpack( QDataStream& stream ) override;
0120 
0121   private:
0122     GeoDataLabelStylePrivate * const d;
0123 };
0124 
0125 }
0126 
0127 #endif