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 Library General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2 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  * Library General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Library 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   
00101   Glib::ustring to_string() const;
00102   
00109   void set_from_hls(guint8 hue, guint8 luminance, guint8 saturation);
00110   
00117   void set_from_hlsx(Fixed hue, Fixed luminance, Fixed saturation);
00118   
00125   void to_hls(guint8& hue, guint8& luminance, guint8& saturation) const;
00126   
00133   void to_hlsx(Fixed& hue, Fixed& luminance, Fixed& saturation) const;
00134   
00139   void set_from_pixel(guint32 pixel);
00140   
00145   guint32 to_pixel() const;
00146 
00147   
00157   Color add(const Color& color) const;
00158   
00159 
00171   Color subtract(const Color& color) const;
00172   
00173 
00174   // the 'darken', 'lighten', and 'shade' functions modify the source color and
00175   // store the result in the color object given by the 'dest' argument.  Usually
00176   // we wrap functions with a 'dest' argument to return a copy by value.
00177   // However, this means that we could never apply 'darken' directly to this
00178   // object (as we could in C by doing something like clutter_color_darken(&foo,
00179   // &foo)).  So I think it makes more sense in the C++ wrappers to darken
00180   // 'this' by default and if the user wants to darken a different color, they
00181   // can aways create the copy first and then call darken on it
00182   // (e.g. Color c2 = c1; c1.darken();).  I think this is more flexible than the
00183   // alternative.
00184   
00190   void darken();
00191   
00192   
00198   void lighten();
00199   
00200 
00207   void shade(double shade);
00208   
00209   
00220   void shadex(Fixed shade);
00221   
00222 
00223   // provide accessors/mutators to modify the individual members like you could
00224   // do in C by directly modifying the struct members
00225    guint8 get_red() const;
00226     void set_red(const guint8& value);
00227     guint8 get_green() const;
00228     void set_green(const guint8& value);
00229     guint8 get_blue() const;
00230     void set_blue(const guint8& value);
00231     guint8 get_alpha() const;
00232     void set_alpha(const guint8& value);
00233  
00234 
00235 };
00236 
00240 Color operator+(const Color& color1, const Color& color2);
00241 
00245 Color operator-(const Color& color1, const Color& color2);
00246 
00247 } // namespace Gdk
00248 
00249 
00250 namespace Clutter
00251 {
00252 
00258 bool operator==(const Color& lhs, const Color& rhs);
00259 
00265 bool operator!=(const Color& lhs, const Color& rhs);
00266 
00267 
00268 } // namespace Clutter
00269 
00270 
00271 namespace Clutter
00272 {
00273 
00278 inline void swap(Color& lhs, Color& rhs)
00279   { lhs.swap(rhs); }
00280 
00281 } // namespace Clutter
00282 
00283 namespace Glib
00284 {
00285 
00294 Clutter::Color wrap(ClutterColor* object, bool take_copy = false);
00295 
00296 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00297 template <>
00298 class Value<Clutter::Color> : public Glib::Value_Boxed<Clutter::Color>
00299 {};
00300 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00301 
00302 } // namespace Glib
00303 
00304 
00305 #endif /* _CLUTTERMM_COLOR_H */
00306 

Generated on Mon Sep 15 05:40:00 2008 for cluttermm by  doxygen 1.5.6