1 | /* |
2 | SPDX-FileCopyrightText: 2008 Aurélien Gâteau <agateau@kde.org> |
3 | SPDX-FileCopyrightText: 2009 Sebastian Trueg <trueg@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.1-or-later |
6 | */ |
7 | |
8 | #ifndef _K_PIXMAPSEQUENCE_H_ |
9 | #define _K_PIXMAPSEQUENCE_H_ |
10 | |
11 | #include <QSharedDataPointer> |
12 | #include <QSize> |
13 | |
14 | #include <kwidgetsaddons_export.h> |
15 | |
16 | class QPixmap; |
17 | |
18 | /*! |
19 | * \class KPixmapSequence |
20 | * \inmodule KWidgetsAddons |
21 | * |
22 | * \brief Loads and gives access to the frames of a typical multi-row pixmap |
23 | * as often used for spinners. |
24 | * |
25 | * KPixmapSequence is implicitly shared. Copying is fast. |
26 | * |
27 | * \since 4.4 |
28 | */ |
29 | class KWIDGETSADDONS_EXPORT KPixmapSequence |
30 | { |
31 | public: |
32 | /*! |
33 | * Create an empty sequence |
34 | */ |
35 | KPixmapSequence(); |
36 | |
37 | KPixmapSequence(const KPixmapSequence &other); |
38 | |
39 | /*! |
40 | * Create a sequence from a pixmap. |
41 | * |
42 | * \a pixmap Pixmap to load |
43 | * |
44 | * \a frameSize The size of the frames to load. The width of the file has to be |
45 | * a multiple of the frame width; the same is true for the height. If an invalid |
46 | * size is specified the file is considered to be one column of square frames. |
47 | */ |
48 | explicit KPixmapSequence(const QPixmap &pixmap, const QSize &frameSize = QSize()); |
49 | |
50 | /*! |
51 | * Create a sequence from an icon name. |
52 | * |
53 | * \a fullPath The full path of the icon |
54 | * |
55 | * \a size The icon/frame size |
56 | */ |
57 | KPixmapSequence(const QString &fullPath, int size); |
58 | |
59 | ~KPixmapSequence(); |
60 | |
61 | /*! |
62 | * Create a copy of \a other. The data is implicitly shared. |
63 | */ |
64 | KPixmapSequence &operator=(const KPixmapSequence &other); |
65 | |
66 | /*! |
67 | * Returns \c true if a sequence was loaded successfully. |
68 | * |
69 | * \sa isEmpty() |
70 | */ |
71 | bool isValid() const; |
72 | |
73 | /*! |
74 | * \return \c true if no sequence was loaded successfully. |
75 | * |
76 | * \sa isValid() |
77 | */ |
78 | bool isEmpty() const; |
79 | |
80 | /*! |
81 | * \return The size of an individual frame in the sequence. |
82 | */ |
83 | QSize frameSize() const; |
84 | |
85 | /*! |
86 | * The number of frames in this sequence. |
87 | */ |
88 | int frameCount() const; |
89 | |
90 | /*! |
91 | * Retrieve the frame at \a index. |
92 | * |
93 | * \a index The index of the frame in question starting at 0. |
94 | */ |
95 | QPixmap frameAt(int index) const; |
96 | |
97 | private: |
98 | QSharedDataPointer<class KPixmapSequencePrivate> d; |
99 | }; |
100 | |
101 | #endif |
102 | |