File indexing completed on 2024-04-28 15:32:11

0001 /*
0002     SPDX-FileCopyrightText: 2008 Aurélien Gâteau <agateau@kde.org>
0003     SPDX-FileCopyrightText: 2009 Sebastian Trueg <trueg@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef _K_PIXMAPSEQUENCE_H_
0009 #define _K_PIXMAPSEQUENCE_H_
0010 
0011 #include <QSharedDataPointer>
0012 #include <QSize>
0013 
0014 #include <kwidgetsaddons_export.h>
0015 
0016 class QPixmap;
0017 
0018 /**
0019  * \class KPixmapSequence kpixmapsequence.h KPixmapSequence
0020  *
0021  * \brief Loads and gives access to the frames of a typical multi-row pixmap
0022  * as often used for spinners.
0023  *
0024  * KPixmapSequence is implicitly shared. Copying is fast.
0025  *
0026  * \author Aurélien Gâteau <agateau@kde.org>
0027  * \author Sebastian Trueg <trueg@kde.org>
0028  *
0029  * \since 4.4
0030  */
0031 class KWIDGETSADDONS_EXPORT KPixmapSequence
0032 {
0033 public:
0034     /**
0035      * Create an empty sequence
0036      */
0037     KPixmapSequence();
0038 
0039     /**
0040      * Copy constructor
0041      */
0042     KPixmapSequence(const KPixmapSequence &other);
0043 
0044     /**
0045      * Create a sequence from a pixmap.
0046      *
0047      * \param pixmap Pixmap to load
0048      * \param frameSize The size of the frames to load. The width of the file has to be
0049      * a multiple of the frame width; the same is true for the height. If an invalid
0050      * size is specified the file is considered to be one column of square frames.
0051      */
0052     explicit KPixmapSequence(const QPixmap &pixmap, const QSize &frameSize = QSize());
0053 
0054     /**
0055      * Create a sequence from an icon name.
0056      *
0057      * \param fullPath The full path of the icon
0058      * \param size The icon/frame size
0059      */
0060     KPixmapSequence(const QString &fullPath, int size);
0061 
0062     /**
0063      * Destructor
0064      */
0065     ~KPixmapSequence();
0066 
0067     /**
0068      * Create a copy of \p other. The data is implicitly shared.
0069      */
0070     KPixmapSequence &operator=(const KPixmapSequence &other);
0071 
0072     /**
0073      * \return \p true if a sequence was loaded successfully.
0074      *
0075      * \sa isEmpty
0076      */
0077     bool isValid() const;
0078 
0079     /**
0080      * \return \p true if no sequence was loaded successfully.
0081      *
0082      * \sa isValid
0083      */
0084     bool isEmpty() const;
0085 
0086     /**
0087      * \return The size of an individual frame in the sequence.
0088      */
0089     QSize frameSize() const;
0090 
0091     /**
0092      * The number of frames in this sequence.
0093      */
0094     int frameCount() const;
0095 
0096     /**
0097      * Retrieve the frame at \p index.
0098      *
0099      * \param index The index of the frame in question starting at 0.
0100      */
0101     QPixmap frameAt(int index) const;
0102 
0103 private:
0104     QSharedDataPointer<class KPixmapSequencePrivate> d;
0105 };
0106 
0107 #endif