color.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _CLUTTERMM_COLOR_H
00004 #define _CLUTTERMM_COLOR_H
00005 
00006 
00007 #include <glibmm.h>
00008 
00009 /* Copyright (C) 2007 The cluttermm Development Team
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Lesser General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2.1 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this library; if not, write to the Free
00023  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  */
00025 
00026 #include <glibmm/ustring.h>
00027 #include <cluttermm/types.h>
00028  
00029 
00030 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00031 extern "C" { typedef struct _ClutterColor ClutterColor; }
00032 #endif
00033 
00034 namespace Clutter
00035 {
00036 
00037 class Color
00038 {
00039   public:
00040 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00041   typedef Color CppObjectType;
00042   typedef ClutterColor BaseObjectType;
00043 
00044   static GType get_type() G_GNUC_CONST;
00045 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00046 
00047 
00048   explicit Color(ClutterColor* gobject, bool make_a_copy = true);
00049 
00050   Color(const Color& other);
00051   Color& operator=(const Color& other);
00052 
00053   ~Color();
00054 
00055   void swap(Color& other);
00056 
00058   ClutterColor*       gobj()       { return gobject_; }
00059 
00061   const ClutterColor* gobj() const { return gobject_; }
00062 
00064   ClutterColor* gobj_copy() const;
00065 
00066 protected:
00067   ClutterColor* gobject_;
00068 
00069 private:
00070 
00071   
00072 public:
00073 
00074 
00075   // TODO: it'd be nice if these constructors allowed you to specify the alpha
00076   // value, but the underlying set_from_*() functions don't accept an alpha
00077   // value so it would have to set the struct member directly.  The struct
00078   // member is a guint8 type, so the Fixed-point version would need conversions
00079   // or have an odd signature that takes a guint8 as the last parameter
00080   
00081   Color();
00084   Color(guint8 red, guint8 green, guint8 blue, guint8 alpha=255);
00085 
00088   explicit Color(guint32 pixel);
00089 
00090   // TODO: this could fail, just return a 'default' color or throw an exception?
00091   explicit Color(const Glib::ustring& color);
00092 
00093   void set_from_rgb(guint8 red, guint8 blue, guint8 green);
00094   void set_from_string(const Glib::ustring& color);
00095   
00096   
00102   Glib::ustring to_string() const;
00103   
00110   void set_from_hls(float hue, float luminance, float saturation);
00111   
00120   void to_hls(float& hue, float& luminance, float& saturation) const;
00121   
00126   void set_from_pixel(guint32 pixel);
00127   
00132   guint32 to_pixel() const;
00133 
00134   
00143   Color add(const Color& color) const;
00144   
00145 
00157   Color subtract(const Color& color) const;
00158   
00159 
00160   // the 'darken', 'lighten', and 'shade' functions modify the source color and
00161   // store the result in the color object given by the 'dest' argument.  Usually
00162   // we wrap functions with a 'dest' argument to return a copy by value.
00163   // However, this means that we could never apply 'darken' directly to this
00164   // object (as we could in C by doing something like clutter_color_darken(&foo,
00165   // &foo)).  So I think it makes more sense in the C++ wrappers to darken
00166   // 'this' by default and if the user wants to darken a different color, they
00167   // can aways create the copy first and then call darken on it
00168   // (e.g. Color c2 = c1; c1.darken();).  I think this is more flexible than the
00169   // alternative.
00170   
00176   void darken();
00177   
00178   
00184   void lighten();
00185   
00186 
00192   void shade(double shade);
00193   
00194 
00195   // provide accessors/mutators to modify the individual members like you could
00196   // do in C by directly modifying the struct members
00197    guint8 get_red() const;
00198     void set_red(const guint8& value);
00199     guint8 get_green() const;
00200     void set_green(const guint8& value);
00201     guint8 get_blue() const;
00202     void set_blue(const guint8& value);
00203     guint8 get_alpha() const;
00204     void set_alpha(const guint8& value);
00205  
00206 
00207 };
00208 
00212 Color operator+(const Color& color1, const Color& color2);
00213 
00217 Color operator-(const Color& color1, const Color& color2);
00218 
00219 } // namespace Clutter
00220 
00221 
00222 namespace Clutter
00223 {
00224 
00230 bool operator==(const Color& lhs, const Color& rhs);
00231 
00237 bool operator!=(const Color& lhs, const Color& rhs);
00238 
00239 
00240 } // namespace Clutter
00241 
00242 
00243 namespace Clutter
00244 {
00245 
00250 inline void swap(Color& lhs, Color& rhs)
00251   { lhs.swap(rhs); }
00252 
00253 } // namespace Clutter
00254 
00255 namespace Glib
00256 {
00257 
00266 Clutter::Color wrap(ClutterColor* object, bool take_copy = false);
00267 
00268 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00269 template <>
00270 class Value<Clutter::Color> : public Glib::Value_Boxed<Clutter::Color>
00271 {};
00272 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00273 
00274 } // namespace Glib
00275 
00276 
00277 #endif /* _CLUTTERMM_COLOR_H */
00278 

Generated on 26 Feb 2010 for cluttermm by  doxygen 1.6.1