/* Copyright (C) 2024 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/>.
 */

#include <glibmm/object.h>
#include <glibmm/bytes.h>
#include <gdkmm/enums.h>
#include <cairomm/region.h>

_DEFS(gdkmm,gdk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gdk
{
class GDKMM_API ColorState;
class GDKMM_API Texture;

/** %Gdk::MemoryTextureBuilder is a builder used to construct Gdk::Texture objects
 * from system memory provided via Glib::Bytes.
 *
 * The operation is quite simple: Create a texture builder, set all the necessary
 * properties - keep in mind that property_bytes(), property_stride(),
 * property_width(), and property_height() are mandatory - and then call
 * build() to create the new texture.
 *
 * %Gdk::MemoryTextureBuilder can be used for quick one-shot construction of
 * textures as well as kept around and reused to construct multiple textures.
 *
 * @newin{4,16}
 */
class GDKMM_API MemoryTextureBuilder : public Glib::Object
{
  _CLASS_GOBJECT(MemoryTextureBuilder, GdkMemoryTextureBuilder, GDK_MEMORY_TEXTURE_BUILDER, Glib::Object, GObject, , , GDKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GdkMemoryTextureBuilder is an internal type

protected:
  _CTOR_DEFAULT()

public:
  _WRAP_CREATE()

  // Glib::Bytes and Gdk::ColorState are immutable. No need for non-const get-methods.
  _WRAP_METHOD(Glib::RefPtr<Glib::Bytes> get_bytes() const, gdk_memory_texture_builder_get_bytes, refreturn)
  _WRAP_METHOD(void set_bytes(const Glib::RefPtr<const Glib::Bytes>& context), gdk_memory_texture_builder_set_bytes)

  _WRAP_METHOD(gsize get_stride() const, gdk_memory_texture_builder_get_stride)
  _WRAP_METHOD(void set_stride(gsize stride), gdk_memory_texture_builder_set_stride)

  _WRAP_METHOD(gsize get_stride_for_plane(unsigned int plane) const, gdk_memory_texture_builder_get_stride_for_plane)
  _WRAP_METHOD(void set_stride_for_plane(unsigned int plane, gsize stride), gdk_memory_texture_builder_set_stride_for_plane)

  _WRAP_METHOD(gsize get_offset(unsigned int plane) const, gdk_memory_texture_builder_get_offset)
  _WRAP_METHOD(void set_offset(unsigned int plane, gsize offset), gdk_memory_texture_builder_set_offset)

  _WRAP_METHOD(int get_width() const, gdk_memory_texture_builder_get_width)
  _WRAP_METHOD(void set_width(int width), gdk_memory_texture_builder_set_width)

  _WRAP_METHOD(int get_height() const, gdk_memory_texture_builder_get_height)
  _WRAP_METHOD(void set_height(int height), gdk_memory_texture_builder_set_height)

  _WRAP_METHOD(MemoryFormat get_format() const, gdk_memory_texture_builder_get_format)
  _WRAP_METHOD(void set_format(MemoryFormat format), gdk_memory_texture_builder_set_format)

  _WRAP_METHOD(Glib::RefPtr<ColorState> get_color_state() const, gdk_memory_texture_builder_get_color_state, refreturn)
  _WRAP_METHOD(void set_color_state(const Glib::RefPtr<const ColorState>& color_state), gdk_memory_texture_builder_set_color_state)

  _WRAP_METHOD(Glib::RefPtr<Texture> get_update_texture(), gdk_memory_texture_builder_get_update_texture, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Texture> get_update_texture() const, gdk_memory_texture_builder_get_update_texture, refreturn, constversion)
  _WRAP_METHOD(void set_update_texture(const Glib::RefPtr<Texture>& texture), gdk_memory_texture_builder_set_update_texture)

  _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Region> get_update_region(), gdk_memory_texture_builder_get_update_region, refreturn)
  _WRAP_METHOD(::Cairo::RefPtr<const ::Cairo::Region> get_update_region() const, gdk_memory_texture_builder_get_update_region, refreturn, constversion)
  _WRAP_METHOD(void set_update_region(const ::Cairo::RefPtr< ::Cairo::Region>& region), gdk_memory_texture_builder_set_update_region)

  _WRAP_METHOD(Glib::RefPtr<Texture> build(), gdk_memory_texture_builder_build)

  _WRAP_PROPERTY("bytes", Glib::RefPtr<Glib::Bytes>)
  _WRAP_PROPERTY("color-state", Glib::RefPtr<ColorState>)
  _WRAP_PROPERTY("format", MemoryFormat)
  _WRAP_PROPERTY("height", int)
  _WRAP_PROPERTY("stride", gsize)
  _WRAP_PROPERTY("update-region", ::Cairo::RefPtr< ::Cairo::Region>)
  _WRAP_PROPERTY("update-texture", Glib::RefPtr<Texture>)
  _WRAP_PROPERTY("width", int)

  // There are no signals or public vfuncs.
};

} // namespace Gdk
