/* Copyright (C) 2023 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 <glibmm/interface.h>
#include <gdkmm/rgba.h>
#include <gdkmm/snapshot.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/interface_p.h)

#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C"
{
typedef struct _GtkSymbolicPaintableInterface GtkSymbolicPaintableInterface;
}
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

namespace Gtk
{

/** An interface that supports symbolic colors in paintables.
 *
 * Gdk::Paintable%s implementing the interface will have the
 * snapshot_symbolic_vfunc() function called and have the colors for drawing
 * symbolic icons passed. At least 5 colors are guaranteed to be passed every time.
 * These 5 colors are the foreground color, and the colors to use for errors,
 * warnings and success information in that order, followed by the system
 * accent color.
 *
 * The system accent color has been added in GTK 4.22.
 * More colors may be added in the future.
 *
 * @newin{4,12}
 */
class GTKMM_API SymbolicPaintable : public Glib::Interface
{
  _CLASS_INTERFACE(SymbolicPaintable, GtkSymbolicPaintable, GTK_SYMBOLIC_PAINTABLE, GtkSymbolicPaintableInterface, , , GTKMM_API)

public:
  /** Snapshots the paintable with the given colors.
   *
   * If less than 4 colors are provided, GTK will pad the vector with
   * default colors.
   *
   * @newin{4,12}
   *
   * @param snapshot A Gdk::Snapshot to snapshot to.
   * @param width Width to snapshot in.
   * @param height Height to snapshot in.
   * @param colors A vector of colors.
   */
  void snapshot_symbolic(const Glib::RefPtr<Gdk::Snapshot>& snapshot,
    double width, double height, const std::vector<Gdk::RGBA>& colors);
  _IGNORE(gtk_symbolic_paintable_snapshot_symbolic)

  /** Snapshots the paintable with the given colors and weight.
   *
   * If less than 5 colors are provided, GTK will pad the array with default colors.
   *
   * @newin{4,22}
   *
   * @param snapshot A `Gdk::Snapshot` to snapshot to.
   * @param width Width to snapshot in.
   * @param height Height to snapshot in.
   * @param colors A vector of colors.
   * @param weight The font weight to use (from 1 to 1000, with default 400).
   */
  void snapshot_with_weight(const Glib::RefPtr<Gdk::Snapshot>& snapshot,
    double width, double height, const std::vector<Gdk::RGBA>& colors, double weight);
  _IGNORE(gtk_symbolic_paintable_snapshot_with_weight)

protected:
#m4begin
dnl // WRAP_VFUNC "snapshot_symbolic"
dnl // C++ prototype: void snapshot_symbolic(const Glib::RefPtr<Gdk::Snapshot>& snapshot,
dnl //   double width, double height, const std::vector<Gdk::RGBA>& colors)
dnl // C prototype: void snapshot_symbolic(GdkSnapshot* snapshot,
dnl //   double width, double height, const GdkRGBA* colors, gsize n_colors)

  _VFUNC_H(snapshot_symbolic_vfunc, void,
    `const Glib::RefPtr<Gdk::Snapshot>& snapshot, double width, double height, const std::vector<Gdk::RGBA>& colors')
  _VFUNC_PH(snapshot_symbolic, void,
    `GtkSymbolicPaintable* self, GdkSnapshot* snapshot, double width, double height, const GdkRGBA* colors, gsize n_colors',,dnl // C prototype
    `self, snapshot, width, height, colors, n_colors')dnl // C argument names
  _VFUNC_CC(snapshot_symbolic_vfunc, snapshot_symbolic, void, void,
    `const Glib::RefPtr<Gdk::Snapshot>& snapshot, double width, double height, const std::vector<Gdk::RGBA>& colors',dnl // C++ arguments
    `Glib::unwrap(snapshot), width, height, Glib::ArrayHandler<Gdk::RGBA,Gdk::RGBATraits>::vector_to_array(colors).data(), colors.size()')dnl // C++ -> C conversion
  _VFUNC_PCC(snapshot_symbolic_vfunc, snapshot_symbolic, void, void,
    `GtkSymbolicPaintable* self, GdkSnapshot* snapshot, double width, double height, const GdkRGBA* colors, gsize n_colors',dnl // C arguments
    `self, snapshot, width, height, colors, n_colors',dnl // C argument names
    `Glib::wrap(snapshot, true), width, height, Glib::ArrayHandler<Gdk::RGBA, Gdk::RGBATraits>::array_to_vector(colors, n_colors, Glib::OWNERSHIP_NONE)',dnl // C -> C++ conversion
    self)
#m4end
// TODO: When we can break ABI, add snapshot_with_weight_vfunc().
};

} // namespace Gtk
