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

#include <Wt/Ext/AbstractButton>

namespace Wt {
  namespace Ext {

class Panel;

/*! \class Button Wt/Ext/Button Wt/Ext/Button
 *  \brief A button.
 *
 * A button with a label and/or icon, which may be standalone, or be
 * added to a ToolBar (see ToolBar::addButton()) or to a Dialog (see
 * Dialog::addButton()).
 *
 * The API is similar to the WPushButton API, with the following additional
 * features:
 * <ul>
 *   <li>an icon may be specified using AbstractButton::setIcon();</li>
 *   <li>the button may be configured as a toggle button
 *     (see AbstractButton::setCheckable();</li>
 *   <li>the button may be associated with a popup-menu
 *     (see AbstractButton::setMenu();</li>
 * </ul>
 *
 * \image html ExtButton-1.png Standalone button
 * \image html ExtButton-1a.png Standalone button hover effect
 * \image html ExtButton-2.png Button in tool bar
 * \image html ExtButton-3.png Button in tool bar with icon
 * \image html ExtButton-4.png Button in tool bar with icon and menu
 * \image html ExtButton-5.png Button in tool bar hover effect
 * \image html ExtButton-6.png Toggled button in tool bar
 *
 * \ingroup ext
 */
class WT_EXT_API Button : public AbstractButton
{
public:
  /*! \brief Create a push button with empty label.
   */
  Button(WContainerWidget *parent = 0);

  /*! \brief Create a push button with given label.
   */
  Button(const WString& text, WContainerWidget *parent = 0);

  /*! \brief Delete a button
   */
  ~Button();

  /*! \brief Configure as the default button.
   *
   * This only applies for buttons that have been added to a dialog using
   * Dialog::addButton().
   *
   * The default button will be activated when the user presses the
   * Enter (or Return) key in a dialog.
   *
   * The default button may be rendered with more emphasis (?).
   *
   * \sa isDefault()
   */
  void setDefault(bool how);

  /*! \brief Return if is the default button.
   *
   * \sa setDefault(bool)
   */
  bool isDefault() const;

  /*! \brief Alias for the activated() signal.
   *
   * This signal is added for increased API compatibility with WPushButton.
   */
  JSignal<>& clicked() { return activated(); }

private:
  Panel *panel_;

  virtual std::string createJS(DomElement *inContainer);
  virtual std::string checkMethodJS() const;
  virtual std::string checkEventJS() const;
  virtual std::string checkInitialState() const;

  void setPanel(Panel *panel);

  friend class Panel;
};

  }
}

#endif // EXT_BUTTON_H_
