/* Copyright (C) 2010 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 <https://www.gnu.org/licenses/>.
 */

_DEFS(gtkmm,gtk)
_CONFIGINCLUDE(gtkmmconfig.h)
_IS_DEPRECATED // The entire file is deprecated.

_PINCLUDE(glibmm/private/object_p.h)
_PINCLUDE(gtk/gtk.h)

#include <gtkmm/styleprovider.h>
#include <gtkmm/border.h>
#include <gtkmm/enums.h>
#include <gdkmm/display.h>
#include <gdkmm/rgba.h>

#include <gtkmm/enums.h>
#include <pangomm/context.h>
#include <pangomm/fontdescription.h>
#include <pangomm/layout.h>
#include <gtkmmconfig.h>

#m4 _PUSH(SECTION_CC_PRE_INCLUDES)
#undef GTK_DISABLE_DEPRECATED
#define GDK_DISABLE_DEPRECATION_WARNINGS 1
#m4 _POP()

namespace Gdk
{
class GTKMM_API Texture;
}

namespace Gtk
{

/** This object stores styling information affecting a widget defined by WidgetPath.
 *
 * In order to construct the final style information, StyleContext
 * queries information from all attached StyleProviders. Style providers
 * can be either attached explicitly to the context through
 * add_provider(), or to the display through
 * add_provider_for_display(). The resulting style is a
 * combination of all providers' information in priority order.
 *
 * For GTK+ widgets, any StyleContext returned by
 * Widget::get_style_context() will already have a WidgetPath, a
 * Gdk::Display and RTL/LTR information set, The style context will be also
 * updated automatically if any of these settings change on the widget.
 *
 * <h2>Transition animations</h2>
 *
 * StyleContext has built-in support for state change transitions.
 * Note that these animations respect the Settings::property_gtk_enable_animations()
 * setting.
 *
 * For simple widgets where state changes affect the whole widget area,
 * calling notify_state_change() with a no region
 * is sufficient to trigger the transition animation. And GTK+ already
 * does that when Widget::set_state() or Widget::set_state_flags()
 * are called.
 *
 * If a widget needs to declare several animatable regions (i.e. not
 * affecting the whole widget area), its Widget::signal_draw() signal handler
 * needs to wrap the render operations for the different regions with
 * calls to push_animatable_region() and
 * pop_animatable_region(). These methods take an
 * identifier for the region which must be unique within the style context.
 * For simple widgets with a fixed set of animatable regions, using an
 * enumeration works well.
 *
 * For complex widgets with an arbitrary number of animatable regions, it
 * is up to the implementation to come up with a way to uniquely identify
 * each animatable region. Using pointers to internal objects is one way
 * to achieve this.
 *
 * The widget also needs to notify the style context about a state change
 * for a given animatable region so the animation is triggered.
 * notify_state_change() can take no region IDs, meaning that the whole widget
 * area will be updated by the animation.
 *
 * @newin{3,0}
 * @deprecated 4.10: The relevant API has been moved to Gtk::Widget and
 *   Gtk::StyleProvider where applicable; otherwise, there is no replacement
 *   for querying the style machinery. Stylable UI elements should use widgets.
 */
class GTKMM_API StyleContext : public Glib::Object
{
  _CLASS_GOBJECT(StyleContext, GtkStyleContext, GTK_STYLE_CONTEXT, Glib::Object, GObject, , , GTKMM_API)
protected:
  _CTOR_DEFAULT()

public:
  _WRAP_ENUM(PrintFlags, GtkStyleContextPrintFlags, decl_prefix GTKMM_API)

  _WRAP_METHOD(static void add_provider_for_display(const Glib::RefPtr<Gdk::Display>& display, const Glib::RefPtr<StyleProvider>& provider, guint priority),
    gtk_style_context_add_provider_for_display, deprecated "Use Gtk::StyleProvider::add_provider_for_display() instead.")
  _WRAP_METHOD(static void remove_provider_for_display(const Glib::RefPtr<Gdk::Display>& display, const Glib::RefPtr<StyleProvider>& provider),
    gtk_style_context_remove_provider_for_display, deprecated "Use Gtk::StyleProvider::remove_provider_for_display() instead.")

  _WRAP_METHOD(void add_provider(const Glib::RefPtr<StyleProvider>& provider, guint priority), gtk_style_context_add_provider)

  _WRAP_METHOD(void remove_provider(const Glib::RefPtr<StyleProvider>& provider), gtk_style_context_remove_provider)

  _WRAP_METHOD(void context_save(), gtk_style_context_save)
  _WRAP_METHOD(void context_restore(), gtk_style_context_restore)

  _WRAP_METHOD(void set_state(StateFlags flags), gtk_style_context_set_state,
    deprecated "You should not use this api.")
  _WRAP_METHOD(StateFlags get_state() const, gtk_style_context_get_state,
    deprecated "Use Gtk::Widget::get_state_flags() instead.")

  _WRAP_METHOD(void set_scale(int scale), gtk_style_context_set_scale,
    deprecated "You should not use this api.")
  _WRAP_METHOD(int get_scale() const, gtk_style_context_get_scale,
    deprecated "Use Gtk::Widget::get_scale_factor() instead.")

  _WRAP_METHOD(void add_class(const Glib::ustring& class_name), gtk_style_context_add_class,
    deprecated "Use Gtk::Widget::add_css_class() instead.")
  _WRAP_METHOD(void remove_class(const Glib::ustring& class_name), gtk_style_context_remove_class,
    deprecated "Use Gtk::Widget::remove_css_class() instead.")
  _WRAP_METHOD(bool has_class(const Glib::ustring& class_name), gtk_style_context_has_class,
    deprecated "Use Gtk::Widget::has_css_class() instead.")

  _WRAP_METHOD(void set_display(const Glib::RefPtr<Gdk::Display>& display), gtk_style_context_set_display,
    deprecated "You should not use this api.")
  _WRAP_METHOD(Glib::RefPtr<Gdk::Display> get_display(), gtk_style_context_get_display, refreturn,
    deprecated "Use Gtk::Widget::get_display() instead.")
  _WRAP_METHOD(Glib::RefPtr<const Gdk::Display> get_display() const, gtk_style_context_get_display, refreturn, constversion,
    deprecated "Use Gtk::Widget::get_display() instead.")

  _WRAP_METHOD(bool lookup_color(const Glib::ustring& color_name, Gdk::RGBA& color), gtk_style_context_lookup_color)

  /** Gets the foreground color for a given state.
   *
   * @newin{3,0}
   * @deprecated Use Gtk::Widget::get_color() instead.
   *
   * @return The foreground color for the given state.
   */
  Gdk::RGBA get_color() const;
  _IGNORE(gtk_style_context_get_color)

  Border get_border() const;
  _IGNORE(gtk_style_context_get_border)

  Border get_padding() const;
  _IGNORE(gtk_style_context_get_padding)

  Border get_margin() const;
  _IGNORE(gtk_style_context_get_margin)

  _WRAP_METHOD(void render_check(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_check)
  _WRAP_METHOD(void render_option(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_option)
  _WRAP_METHOD(void render_arrow(const Cairo::RefPtr<Cairo::Context>& cr, double angle, double x, double y, double size), gtk_render_arrow)
  _WRAP_METHOD(void render_background(const Cairo::RefPtr<Cairo::Context>& cr, double x,  double y, double width, double height), gtk_render_background)
  _WRAP_METHOD(void render_frame(const Cairo::RefPtr<Cairo::Context>& cr, double x,  double y, double width, double height), gtk_render_frame)
  _WRAP_METHOD(void render_expander(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_expander)
  _WRAP_METHOD(void render_focus(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_focus)
  _WRAP_METHOD(void render_layout(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, const Glib::RefPtr<Pango::Layout>& layout), gtk_render_layout)
  _WRAP_METHOD(void render_line(const Cairo::RefPtr<Cairo::Context>& cr, double x0, double y0,  double x1, double y1), gtk_render_line)
  _WRAP_METHOD(void render_handle(const Cairo::RefPtr<Cairo::Context>& cr, double x, double y, double width, double height), gtk_render_handle)
  _WRAP_METHOD(void render_activity(const Cairo::RefPtr<Cairo::Context>& cr,  double x,  double y, double width, double height), gtk_render_activity)
  _WRAP_METHOD(void render_icon(const Cairo::RefPtr<Cairo::Context>& cr, const Glib::RefPtr<Gdk::Texture>& texture, double x, double y), gtk_render_icon)

  _WRAP_METHOD(Glib::ustring to_string(PrintFlags flags) const, gtk_style_context_to_string)

  _WRAP_PROPERTY("display", Glib::RefPtr<Gdk::Display>)
};

} // namespace Gtk
