~ubuntu-branches/ubuntu/vivid/ardour/vivid-proposed

« back to all changes in this revision

Viewing changes to libs/gtkmm2/gdk/gdkmm/color.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Jaromír Mikeš, Felipe Sateler
  • Date: 2014-05-22 14:39:25 UTC
  • mfrom: (29 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20140522143925-vwqfo9287pmkrroe
Tags: 1:2.8.16+git20131003-3
* Team upload

[ Jaromír Mikeš ]
* Add -dbg package

[ Felipe Sateler ]
* Upload to experimental

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