/***************************************************************************
 *                          Zanoza Modeler v2.x                            *
 *      This is unpublished propietary source code of Zanoza Software.     *
 *      The copyright notice does not evidence any actual or intended      *
 *                    publication of such source code.                     *
 *                                                                         *
 *                   Copyright (c) 2002 Zanoza Software.                   *
 *                                                                         *
 *                        All rights reserved.                             *
 ***************************************************************************
 *--------------------------------------------------------------------------
 * @author:   Oleg M.
 *--------------------------------------------------------------------------
 * @purpose:  ZModeler's native color class. DWORD value 0xAABBGGRR
 *--------------------------------------------------------------------------
 * @histroy: 20.01.2003. Created
 */
#ifndef zcolor_h_included
#define zcolor_h_included

//------------------------------------------------------
//  ZColor - ZModeler's native color
//------------------------------------------------------
class DLL_LINKAGE ZColor
{
public:
  //-------------------------
  // constructors
  ZColor();
  // this constructor can be used to init from both ARGB and COLORREF.
  // If supplied color has an alpha value (&0xFF000000) then it's
  // assumed to be ARGB color. otherwise, COLORREF (BGR)
  ZColor(DWORD dwColor);

  ZColor(int r, int g, int b, int a=0xFF); //cast to unsigned char is used
  ZColor(float r, float g, float b, float a=1.0f);
  ZColor(const ZColor& color);
  ~ZColor() {}

  //-------------------------
  // operators
public:
  operator COLORREF() const;

  ZColor& operator = (const DWORD color); //0xAARRGGBB or 0x00BBGGRR;
  ZColor& operator = (const ZColor& color);
  bool operator != (const ZColor color) const;
  bool operator == (const ZColor color) const;
  bool operator <  (const ZColor color) const;
  const ZColor  operator + (const ZColor color) const;
  const ZColor  operator - (const ZColor color) const;
  const ZColor  operator * (const float f) const;
  const ZColor  operator / (const float f) const;

  //------------------------
  // functions
public:
  inline void color(const DWORD dwARGB) { m_dwColor = dwARGB; } 
  DWORD     getRGBA() const; //0xRRGGBBAA
  inline DWORD getARGB() const { return m_dwColor; }
  DWORD     getBGRA() const; //0xBBGGRRAA
  DWORD     getABGR() const; //0xAABBGGRR
  BYTE      r() const;
  BYTE      g() const;
  BYTE      b() const;
  BYTE      a() const;
  float     rf() const;
  float     gf() const;
  float     bf() const;
  float     af() const;
  void      r(const BYTE r);
  void      g(const BYTE g);
  void      b(const BYTE b);
  void      a(const BYTE a);

  BYTE      getHLS_h() const;
  BYTE      getHLS_l() const;
  BYTE      getHLS_s() const;
  void      fromHLS(BYTE h, BYTE l, BYTE s);
  //returns 0x00SSLLHH
  DWORD     getHLS() const;
  ZColor    transformHLS(int shift_H, int percent_L, int percent_S);

  void      average(const ZColor color);
  void      maximum(const ZColor color);
  void      minimum(const ZColor color);
  void      white();
  void      black();
  void      solid();//max alpha.

  //-------------------------------------------------------
  // Linear interpolation between current color and supplied color.
  // @param const ZColor color             : other color
  // @param int thisPercent = 50           : % of this color in result
  //-------------------------------------------------------
  ZColor    lerp(const ZColor color, int thisPercent = 50);

protected:
  DWORD     m_dwColor; //0xAARRGGBB;
};


#endif //zcolor_h_included

