/
qgscolorscheme.sip
270 lines (206 loc) · 7.97 KB
/
qgscolorscheme.sip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/** List of colors paired with a friendly display name identifying the color*/
typedef QList< QPair< QColor, QString > > QgsNamedColorList;
/** \ingroup core
* \class QgsColorScheme
* \brief Abstract base class for color schemes
*
* A color scheme for display in QgsColorButtonV2. Color schemes return lists
* of colors with an optional associated color name. The colors returned
* can be generated using an optional base color.
* \note Added in version 2.5
*/
class QgsColorScheme
{
%TypeHeaderCode
#include <qgscolorscheme.h>
%End
%ConvertToSubClassCode
if (dynamic_cast<QgsUserColorScheme*>(sipCpp) != NULL)
sipType = sipType_QgsUserColorScheme;
else if (dynamic_cast<QgsRecentColorScheme*>(sipCpp) != NULL)
sipType = sipType_QgsRecentColorScheme;
else if (dynamic_cast<QgsCustomColorScheme*>(sipCpp) != NULL)
sipType = sipType_QgsCustomColorScheme;
else if (dynamic_cast<QgsProjectColorScheme*>(sipCpp) != NULL)
sipType = sipType_QgsProjectColorScheme;
else if (dynamic_cast<QgsGplColorScheme*>(sipCpp) != NULL)
sipType = sipType_QgsGplColorScheme;
else
sipType = sipType_QgsColorScheme;
%End
public:
/** Flags for controlling behaviour of color scheme
*/
enum SchemeFlag
{
ShowInColorDialog, /*!< show scheme in color picker dialog */
ShowInColorButtonMenu, /*!< show scheme in color button drop down menu */
ShowInAllContexts /*!< show scheme in all contexts */
};
typedef QFlags<QgsColorScheme::SchemeFlag> SchemeFlags;
QgsColorScheme();
virtual ~QgsColorScheme();
/** Gets the name for the color scheme
* @returns color scheme name
*/
virtual QString schemeName() const = 0;
/** Returns the current flags for the color scheme.
* @returns current flags
*/
virtual SchemeFlags flags() const;
/** Gets a list of colors from the scheme. The colors can optionally
* be generated using the supplied context and base color.
* @param context string specifiying an optional context for the returned
* colors. For instance, a "recent colors" scheme may filter returned colors
* by context so that colors used only in a "composer" context are returned.
* @param baseColor base color for the scheme's colors. Some color schemes
* may take advantage of this to filter or modify their returned colors
* to colors related to the base color.
* @returns a list of QPairs of color and color name
*/
virtual QgsNamedColorList fetchColors( const QString &context = QString(),
const QColor &baseColor = QColor() ) = 0;
/** Returns whether the color scheme is editable
* @returns true if scheme is editable
* @see setColors
*/
virtual bool isEditable() const;
/** Sets the colors for the scheme. This method is only valid for editable color schemes.
* @param colors list of colors for the scheme
* @param context to set colors for
* @param baseColor base color to set colors for
* @returns true if colors were set successfully
* @see isEditable
*/
virtual bool setColors( const QgsNamedColorList &colors, const QString &context = QString(), const QColor &baseColor = QColor() );
/** Clones a color scheme
* @returns copy of color scheme
*/
virtual QgsColorScheme* clone() const = 0 /Factory/;
}; // class QgsColorScheme
QFlags<QgsColorScheme::SchemeFlag> operator|(QgsColorScheme::SchemeFlag f1, QFlags<QgsColorScheme::SchemeFlag> f2);
/** \ingroup core
* \class QgsGplColorScheme
* \brief A color scheme which stores its colors in a gpl palette file.
* \note Added in version 2.5
*/
class QgsGplColorScheme : QgsColorScheme
{
%TypeHeaderCode
#include <qgscolorscheme.h>
%End
public:
QgsGplColorScheme();
virtual ~QgsGplColorScheme();
virtual QgsNamedColorList fetchColors( const QString &context = QString(),
const QColor &baseColor = QColor() );
virtual bool setColors( const QgsNamedColorList &colors, const QString &context = QString(), const QColor &baseColor = QColor() );
protected:
/** Returns the file path for the associated gpl palette file
* @returns gpl file path
*/
virtual QString gplFilePath() = 0;
};
/** \ingroup core
* \class QgsUserColorScheme
* \brief A color scheme which stores its colors in a gpl palette file within the "palettes"
* subfolder off the user's QGIS settings folder.
* \note Added in version 2.5
*/
class QgsUserColorScheme : QgsGplColorScheme
{
%TypeHeaderCode
#include <qgscolorscheme.h>
%End
public:
/** Constructs a new user color scheme, using a specified gpl palette file
* @param filename filename of gpl palette file stored in the users "palettes" folder
*/
QgsUserColorScheme( const QString &filename );
virtual ~QgsUserColorScheme();
virtual QString schemeName() const;
virtual QgsUserColorScheme* clone() const /Factory/;
virtual bool isEditable() const;
virtual QgsColorScheme::SchemeFlags flags() const;
/** Sets the name for the scheme
* @param name new name
*/
void setName( const QString &name );
/** Erases the associated gpl palette file from the users "palettes" folder
* @returns true if erase was successful
*/
bool erase();
/** Sets whether a this scheme should be shown in color button menus.
* @param show set to true to show in color button menus, or false to hide from menus
* @note added in QGIS 3.0
*/
void setShowSchemeInMenu( bool show );
protected:
virtual QString gplFilePath();
};
/** \ingroup core
* \class QgsRecentColorScheme
* \brief A color scheme which contains the most recently used colors.
* \note Added in version 2.5
*/
class QgsRecentColorScheme : QgsColorScheme
{
%TypeHeaderCode
#include <qgscolorscheme.h>
%End
public:
QgsRecentColorScheme();
virtual ~QgsRecentColorScheme();
virtual QString schemeName() const;
virtual SchemeFlags flags() const;
virtual QgsNamedColorList fetchColors( const QString &context = QString(),
const QColor &baseColor = QColor() );
virtual QgsRecentColorScheme* clone() const /Factory/;
/** Adds a color to the list of recent colors.
* @param color color to add
* @note added in QGIS 2.14
*/
static void addRecentColor( const QColor& color );
};
/** \ingroup core
* \class QgsCustomColorScheme
* \brief A color scheme which contains custom colors set through QGIS app options dialog.
* \note Added in version 2.5
*/
class QgsCustomColorScheme : QgsColorScheme
{
%TypeHeaderCode
#include <qgscolorscheme.h>
%End
public:
QgsCustomColorScheme();
virtual ~QgsCustomColorScheme();
virtual QString schemeName() const;
virtual SchemeFlags flags() const;
virtual QgsNamedColorList fetchColors( const QString &context = QString(),
const QColor &baseColor = QColor() );
virtual bool isEditable() const;
virtual bool setColors( const QgsNamedColorList &colors, const QString &context = QString(), const QColor &baseColor = QColor() );
virtual QgsCustomColorScheme* clone() const /Factory/;
};
/** \ingroup core
* \class QgsProjectColorScheme
* \brief A color scheme which contains project specific colors set through project properties dialog.
* \note Added in version 2.5
*/
class QgsProjectColorScheme : QgsColorScheme
{
%TypeHeaderCode
#include <qgscolorscheme.h>
%End
public:
QgsProjectColorScheme();
virtual ~QgsProjectColorScheme();
virtual QString schemeName() const;
virtual SchemeFlags flags() const;
virtual QgsNamedColorList fetchColors( const QString &context = QString(),
const QColor &baseColor = QColor() );
virtual bool isEditable() const;
virtual bool setColors( const QgsNamedColorList &colors, const QString &context = QString(), const QColor &baseColor = QColor() );
virtual QgsProjectColorScheme* clone() const /Factory/;
};