~inkscape.dev/inkscape-devlibs/devlibs-gtk3

« back to all changes in this revision

Viewing changes to include/gdkmm-2.4/gdkmm/color.h

  • Committer: JazzyNico
  • Date: 2013-01-21 10:11:05 UTC
  • Revision ID: nicoduf@yahoo.fr-20130121101105-i8d8slkq9ng4olx8
Adding gtk2 libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
// Generated by gtkmmproc -- DO NOT MODIFY!
 
3
#ifndef _GDKMM_COLOR_H
 
4
#define _GDKMM_COLOR_H
 
5
 
 
6
#include <gdkmmconfig.h>
 
7
 
 
8
 
 
9
#include <glibmm.h>
 
10
 
 
11
/* $Id: color.hg,v 1.5 2005/11/29 16:38:10 murrayc Exp $ */
 
12
 
 
13
/* Copyright (C) 1998-2002 The gtkmm Development Team
 
14
 *
 
15
 * This library is free software; you can redistribute it and/or
 
16
 * modify it under the terms of the GNU Lesser General Public
 
17
 * License as published by the Free Software Foundation; either
 
18
 * version 2.1 of the License, or (at your option) any later version.
 
19
 *
 
20
 * This library is distributed in the hope that it will be useful,
 
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
23
 * Lesser General Public License for more details.
 
24
 *
 
25
 * You should have received a copy of the GNU Lesser General Public
 
26
 * License along with this library; if not, write to the Free
 
27
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
28
 */
 
29
 
 
30
// This is for including the config header before any code (such as
 
31
// the #ifndef GDKMM_DISABLE_DEPRECATED in deprecated classes) is generated:
 
32
 
 
33
 
 
34
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
35
extern "C" { typedef struct _GdkColor GdkColor; }
 
36
#endif
 
37
 
 
38
namespace Gdk
 
39
{
 
40
 
 
41
class Colormap;
 
42
 
 
43
/** Gdk::Color is used to describe an allocated or unallocated color.
 
44
 * It contains the following data:
 
45
 *   pixel: For allocated colors, the value used to draw this color on the screen.
 
46
 *   red: The red component of the color. This is a value between 0 and 65535, with 65535 indicating full intensitiy.
 
47
 *   green: The green component of the color.
 
48
 *   blue: The blue component of the color.
 
49
 */
 
50
class Color
 
51
{
 
52
  public:
 
53
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
54
  typedef Color CppObjectType;
 
55
  typedef GdkColor BaseObjectType;
 
56
 
 
57
  static GType get_type() G_GNUC_CONST;
 
58
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
59
 
 
60
 
 
61
  explicit Color(GdkColor* gobject, bool make_a_copy = true);
 
62
 
 
63
  Color(const Color& other);
 
64
  Color& operator=(const Color& other);
 
65
 
 
66
  ~Color();
 
67
 
 
68
  void swap(Color& other);
 
69
 
 
70
  ///Provides access to the underlying C instance.
 
71
  GdkColor*       gobj()       { return gobject_; }
 
72
 
 
73
  ///Provides access to the underlying C instance.
 
74
  const GdkColor* gobj() const { return gobject_; }
 
75
 
 
76
  ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
 
77
  GdkColor* gobj_copy() const;
 
78
 
 
79
protected:
 
80
  GdkColor* gobject_;
 
81
 
 
82
private:
 
83
 
 
84
public:
 
85
 
 
86
  
 
87
  /** Instantiate a new Gdk::Color.
 
88
   * You should then use the set methods and call Gdk::Colormap::alloc_color().
 
89
   */
 
90
  Color();
 
91
 
 
92
  /** Instantiate a new Gdk::Color.
 
93
   * The color is not allocated - you must call Gdk::Colormap::alloc_color() yourself.
 
94
   * The text string can be in any of the forms accepted by XParseColor; these include names for a color from rgb.txt,
 
95
   * such as DarkSlateGray, or a hex specification such as 305050.
 
96
   * @param value the string specifying the color..
 
97
   */
 
98
  explicit Color(const Glib::ustring& value);
 
99
 
 
100
  /** Set a grey color, by using the same value for all color components.
 
101
   * @param value The value to be used for the red, green, and blue components.
 
102
   */
 
103
  void set_grey(gushort value);
 
104
  void set_grey_p(double g);
 
105
 
 
106
  /** Set the color, by specifying red, green, and blue color component values.
 
107
   * @param red_ The red component of the color.
 
108
   * @param green_ The green component of the color.
 
109
   * @param blue_ The blue component of the color.
 
110
   */
 
111
  void set_rgb(gushort red_, gushort green_, gushort blue_);
 
112
 
 
113
  /** Set the color, by specifying red, green, and blue color component values, as percentages.
 
114
   * @param red_ The red component of the color, as a percentage.
 
115
   * @param green_ The green component of the color, as a percentage.
 
116
   * @param blue_ The blue component of the color, as a percentage.
 
117
   */
 
118
  void set_rgb_p(double red_, double green_, double blue_);
 
119
 
 
120
  void set_hsv(double h, double s, double v);
 
121
  void set_hsl(double h, double s, double l);
 
122
 
 
123
  /** Parses a textual specification of a color and fills in the red, green, and blue values.
 
124
  * The color is not allocated - you must call Gdk::Colormap::alloc_color() yourself.
 
125
  * The text string can be in any of the forms accepted by XParseColor; these include names for a color from rgb.txt,
 
126
  * such as DarkSlateGray, or a hex specification such as 305050.
 
127
  *
 
128
  * @param value the string specifying the color.
 
129
  * @result true if the parsing succeeded.
 
130
  */
 
131
  bool set(const Glib::ustring& value);
 
132
 
 
133
  #ifndef GDKMM_DISABLE_DEPRECATED
 
134
 
 
135
  /**
 
136
   * @deprecated See set().
 
137
   */
 
138
  bool parse(const Glib::ustring& spec);
 
139
  #endif // GDKMM_DISABLE_DEPRECATED
 
140
 
 
141
 
 
142
  /** Get the red component of the color.
 
143
   * @result The red component of the color.
 
144
   */
 
145
  gushort get_red() const;
 
146
 
 
147
  /** Get the green component of the color.
 
148
   * @result The green component of the color.
 
149
   */
 
150
  gushort get_green() const;
 
151
 
 
152
  /** Get the blue component of the color.
 
153
   * @result The blue component of the color.
 
154
   */
 
155
  gushort get_blue() const;
 
156
 
 
157
  /** Set the red component of the color.
 
158
   * @param value The red component of the color.
 
159
   */
 
160
  void set_red(gushort value);
 
161
 
 
162
  /** Set the green component of the color.
 
163
   * @param value The green component of the color.
 
164
   */
 
165
  void set_green(gushort value);
 
166
 
 
167
  /** Set the blue component of the color.
 
168
   * @param value The blue component of the color.
 
169
   */
 
170
  void set_blue(gushort value);
 
171
 
 
172
#ifndef GDKMM_DISABLE_DEPRECATED
 
173
 
 
174
  /** This will fill in the pixel field with the best matching pixel from a color cube.
 
175
   * The color is then ready to be used for drawing, e.g. you can call Gdk::GC::set_foreground() which expects pixel to be initialized.
 
176
   * Call this after setting the red, green, and blue fields.
 
177
   *
 
178
   * In many cases, you can avoid this whole issue by calling Gdk::GC::set_rgb_fg_color() or Gdk::GC::set_rgb_bg_color(),
 
179
   * which do not expect pixels to be initialized in advance. If you use those methods, there's no need for this method().
 
180
   *
 
181
   * @param map The colormap for the graphics context and drawable you're using to draw. If you're drawing to a Gtk::Widget, call Gtk::Widget::get_colormap().
 
182
   *
 
183
   * @deprecated Cairo handles colors automatically.
 
184
   */
 
185
  void rgb_find_color(const Glib::RefPtr<Gdk::Colormap>& map);
 
186
#endif // GDKMM_DISABLE_DEPRECATED
 
187
 
 
188
 
 
189
  /** Get the pixel value, for allocated colors.
 
190
   * @result For allocated colors, the value used to draw this color on the screen.
 
191
   */
 
192
  guint get_pixel() const;
 
193
 
 
194
  /** Get the red component of the color, as a percentage.
 
195
   * @result The red component of the color, as a percentage.
 
196
   */
 
197
  double get_red_p() const;
 
198
 
 
199
  /** Get the green component of the color, as a percentage.
 
200
   * @result The green component of the color, as a percentage.
 
201
   */
 
202
  double get_green_p() const;
 
203
 
 
204
  /** Get the blue component of the color, as a percentage.
 
205
   * @result The blue component of the color, as a percentage.
 
206
   */
 
207
  double get_blue_p() const;
 
208
 
 
209
  /** Get a textual specification of color in the hexadecimal form #rrrrggggbbbb,
 
210
   * where r, g and b are hex digits representing the red, green and blue components respectively.
 
211
   *
 
212
   * @result The string representation.
 
213
   *
 
214
   * @newin{2,14}
 
215
   */
 
216
  Glib::ustring to_string() const;
 
217
 
 
218
 
 
219
};
 
220
 
 
221
 
 
222
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
223
/* These traits are for arrays of GdkColor structs -- not pointer arrays.
 
224
 */
 
225
struct ColorTraits
 
226
{
 
227
  typedef Gdk::Color  CppType;
 
228
  typedef GdkColor    CType;
 
229
  typedef GdkColor    CTypeNonConst;
 
230
 
 
231
  static CType   to_c_type      (const CppType& obj);
 
232
  static CType   to_c_type      (const CType&   obj);
 
233
  static CppType to_cpp_type    (const CType&   obj);
 
234
  static void    release_c_type (const CType&);
 
235
};
 
236
#endif //DOXYGEN_SHOULD_SKIP_THIS
 
237
 
 
238
typedef Glib::ArrayHandle<Color,ColorTraits> ArrayHandle_Color;
 
239
 
 
240
} // namespace Gdk
 
241
 
 
242
 
 
243
namespace Gdk
 
244
{
 
245
 
 
246
/** @relates Gdk::Color
 
247
 * @param lhs The left-hand side
 
248
 * @param rhs The right-hand side
 
249
 * @result The result
 
250
 */
 
251
bool operator==(const Color& lhs, const Color& rhs);
 
252
 
 
253
/** @relates Gdk::Color
 
254
 * @param lhs The left-hand side
 
255
 * @param rhs The right-hand side
 
256
 * @result The result
 
257
 */
 
258
bool operator!=(const Color& lhs, const Color& rhs);
 
259
 
 
260
 
 
261
} // namespace Gdk
 
262
 
 
263
 
 
264
namespace Gdk
 
265
{
 
266
 
 
267
/** @relates Gdk::Color
 
268
 * @param lhs The left-hand side
 
269
 * @param rhs The right-hand side
 
270
 */
 
271
inline void swap(Color& lhs, Color& rhs)
 
272
  { lhs.swap(rhs); }
 
273
 
 
274
} // namespace Gdk
 
275
 
 
276
namespace Glib
 
277
{
 
278
 
 
279
/** A Glib::wrap() method for this object.
 
280
 * 
 
281
 * @param object The C instance.
 
282
 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
 
283
 * @result A C++ instance that wraps this C instance.
 
284
 *
 
285
 * @relates Gdk::Color
 
286
 */
 
287
Gdk::Color wrap(GdkColor* object, bool take_copy = false);
 
288
 
 
289
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
290
template <>
 
291
class Value<Gdk::Color> : public Glib::Value_Boxed<Gdk::Color>
 
292
{};
 
293
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
294
 
 
295
} // namespace Glib
 
296
 
 
297
 
 
298
#endif /* _GDKMM_COLOR_H */
 
299