/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#ifndef GRADIENTPREVIEW_H
#define GRADIENTPREVIEW_H

#include "canvaswidget.h"

class Gradient;
class KCanvasItem;
/**
Previews a given gradient
 
@author Hans Oischinger
*/
class GradientPreview : public CanvasWidget
{
  Q_OBJECT
public:
  GradientPreview(QWidget *parent = 0, const char *name = 0);
  ~GradientPreview();

  /**
   * Set the gradient to preview (operates on a deep copy from then)
   */
  void setGradient( Gradient& );

  /**
   * Set the gradient to preview
   * Unlike setGradient( Gradient& ) this method operates on a reference
   * Don't ever mix the two methods!
   * @see setGradient( Gradient& )
   */
  void setGradientRef( Gradient* );

  /**
   * Specify the orientation of the preview
   * @def horizontal
   */
  void setOrientation( Qt::Orientation orientation );

  /**
   * Sets the gradient fill style on the canvasitem
   */
  void updatePreview();

protected:
  void resizeEvent(QResizeEvent *event);

  /**
   * Creates a new canvasitem (and removes the old one if exists)
   */
  void initCanvasItem();


private:
  Gradient* m_gradient;
  KCanvasItem *m_canvasItem;
  Qt::Orientation m_orientation;
};

#endif
