/* Copyright (C) 2022 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(gtkmmconfig.h)

#include <gdkmm/rgba.h>
#include <gtkmm/colordialog.h>
#include <gtkmm/widget.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)

namespace Gtk
{

/** A wrapper around a Gtk::ColorDialog.
 *
 * Allows to open a color dialog to change the color.
 *
 * It is a suitable widget for selecting a color in a preference dialog.
 *
 * @ingroup Widgets
 * @newin{4,10}
 */
class GTKMM_API ColorDialogButton : public Widget
{
  _CLASS_GTKOBJECT(ColorDialogButton, GtkColorDialogButton, GTK_COLOR_DIALOG_BUTTON, Gtk::Widget, GtkWidget, , , GTKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GtkColorDialogButton is a final type
  _STRUCT_NOT_HIDDEN

public:
  _WRAP_METHOD_DOCS_ONLY(gtk_color_dialog_button_new, voidreturn)
  _WRAP_CTOR(ColorDialogButton(const Glib::RefPtr<ColorDialog>& dialog = {}), gtk_color_dialog_button_new)

  _WRAP_METHOD(Glib::RefPtr<ColorDialog> get_dialog(), gtk_color_dialog_button_get_dialog, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const ColorDialog> get_dialog() const, gtk_color_dialog_button_get_dialog, refreturn, constversion)
  _WRAP_METHOD(void set_dialog(const Glib::RefPtr<ColorDialog>& dialog), gtk_color_dialog_button_set_dialog)

#m4 _CONVERSION(`const GdkRGBA*',`Gdk::RGBA',`Glib::wrap(const_cast<GdkRGBA*>($3), true)')
  _WRAP_METHOD(Gdk::RGBA get_rgba() const, gtk_color_dialog_button_get_rgba)
  _WRAP_METHOD(void set_rgba(const Gdk::RGBA& color), gtk_color_dialog_button_set_rgba)

  _WRAP_PROPERTY("dialog", Glib::RefPtr<ColorDialog>)
  _WRAP_PROPERTY("rgba", Gdk::RGBA)

  // no_default_handler because the wrapped C signal has no default handler.
  _WRAP_SIGNAL(void activate(), "activate", no_default_handler, newin "4,18")};

} // namespace Gtk
