// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2005 Koen Deforche, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WCSSDECORATIONSTYLE_H_
#define WCSSDECORATIONSTYLE_H_

#include <WLength>
#include <WBorder>
#include <WColor>
#include <WFont>
#include <WWidget>

namespace Wt {

class DomElement;
class WWebWidget;

/*! \class WCssDecorationStyle WCssDecorationStyle WCssDecorationStyle
 *  \brief Style class that groups all decorative style aspects of a WWidget
 *         or a style sheet rule.
 *
 * \sa WCssStyleSheet::addRule(const std::string selector, const WCssDecorationStyle& style)
 * \sa WWidget::decorationStyle()
 */
class WT_API WCssDecorationStyle
{
public:
  /*! \brief Cursor style
   */
  enum Cursor { Default,   //!< Arrow,
		Auto,      //!< Unspecified, default
		CrossHair, //!< Crosshair
		Pointer,   //!< Hand
		Move,      //!< Move
		Wait,      //!< Wait symbol
		Text,      //!< Text edit
		Help       //!< Help symbol
  };

  /*! \brief How a background image must be repeated.
   */
  enum Repeat { RepeatXY,  //!< Repeat horizontally and vertically, default
		RepeatX,   //!< Repeat horizontally
		RepeatY,   //!< Repeat vertically
		NoRepeat   //!< Do not repeat
  };

  /*! \brief Text decoration options
   */
  enum TextDecoration { Underline   = 0x1, //!< Underline
			Overline    = 0x2, //!< Overline
			LineThrough = 0x4, //!< LineThrough
			Blink       = 0x8  //!< Blink
  };

  /*! \brief Create a default style
   */
  WCssDecorationStyle();

  /*! \brief Set the cursor style
   */
  void setCursor(Cursor c);

  /*! \brief Get the cursor style
   */
  Cursor cursor() const { return cursor_; }

  /*! \brief Set the background color.
   */
  void setBackgroundColor(WColor color);

  /*! \brief Get the background color.
   */
  WColor backgroundColor() const { return backgroundColor_; }

  /*! \brief Set a background image URL.
   *
   * The image may be placed in a particular location by specifying
   * sides by OR'ing WWidget::Side values together, e.g. (Right | Top).
   */
  void setBackgroundImage(const std::string imageHRef,
			  Repeat repeat = RepeatXY,
			  int sides = 0);

  /*! \brief Get the background image URL.
   */
  const std::string backgroundImage() const { return backgroundImage_; }

  /*! \brief Get the background image repeat.
   */
  Repeat backgroundImageRepeat() const { return backgroundImageRepeat_; }

  /*! \brief Set the foreground color.
   */
  void setForegroundColor(WColor color);

  /*! \brief Get the foreground color.
   */
  WColor foregroundColor() const { return foregroundColor_; }

  /*! \brief Set the border style.
   *  
   * A border may be placed in a particular location by specifying
   * sides by OR'ing WWidget::Side values together, e.g. (Right | Top).
   */
  void setBorder(WBorder border, int sides = WWidget::All);

  /*! \brief Get the border style.
   */
  WBorder border() const { return border_; }

  /*! \brief Change the font.
   */
  void setFont(const WFont& font);

  /*! \brief Get a reference to the font.
   */
  WFont& font() { return font_; }

  /*! \brief Set the text decoration options.
   *
   * You may logically or together any of the options of the
   * TextDecoration enumeration.
   *
   * The default is 0.
   */
  void setTextDecoration(int decoration);

  /*! \brief Get the text decoration options.
   */
  int textDecoration() const { return textDecoration_; }

  std::string cssText();
  void updateDomElement(DomElement& element, bool all);

private:
  WWebWidget      *widget_;
  Cursor           cursor_;
  WBorder          border_;
  WColor           backgroundColor_;
  WColor	   foregroundColor_;
  std::string	   backgroundImage_;
  Repeat	   backgroundImageRepeat_;
  int              backgroundImageLocation_;
  WFont		   font_;
  int              textDecoration_;
  int              borderPosition_;  

  bool		   cursorChanged_;
  bool		   borderChanged_;
  bool		   foregroundColorChanged_;
  bool		   backgroundColorChanged_;
  bool	  	   backgroundImageChanged_;
  bool		   fontChanged_;
  bool             textDecorationChanged_;

  WCssDecorationStyle(WWebWidget *widget);
  friend class WWebWidget;
};

}

#endif // WCSSDECORATIONSTYLE_H_
